From 5e305a2e0a9b4349300a38ceb39a6c67b6dfd7a4 Mon Sep 17 00:00:00 2001 From: Brett Parker Date: Tue, 15 May 2007 00:32:07 +0000 Subject: [PATCH] Check tools are available Check tools we use are available. git-archimport-id: arch@sommitrealweird.co.uk--2005-desktop/bpgallery--mainline--1.1--patch-12 --- ChangeLog | 8 ++-- README | 21 +++++++++ TODO | 2 - bpgallery.sh | 121 ++++++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 134 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f4a7cf..328dc66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-05-15 Brett Parker + * Check that the tools we require exist using the builtin hash function + * Minorly reformat changelog + 2007-05-14 Brett Parker * Add in pages directory support through PAGESDIRECTORY variable * Up'd version number to be +arch as this is still in development @@ -5,24 +9,20 @@ longer hardcoded 2007-05-14 Brett Parker - * Fix caption generation code * Released version 1.1.1 2007-05-13 Brett Parker - * Fix medium sized page generation code * Fix index page generation * Released version 1.1.0 2007-05-12 Brett Parker - * Exit on failure of being able to write medium sized images * Fix up README to contain the new variables for medium sized images * Change --replace to -I {} so that the xargs commands work in a BSD environment. 2006-05-22 Brett Parker - * Start of 1.1 release development * Generate medium sized pages diff --git a/README b/README index 0678ce9..df7e584 100644 --- a/README +++ b/README @@ -57,6 +57,20 @@ The following environment variables can also be used: INDEXDOCUMENT name of the index page (e.g. index.html) + PAGESDIRECTORY + name of the directory in which to put the pages for fullsized and + mediumsized images. Defaults to the image directory. This is + relative to the images directory, so, for example, + PAGESDIRECTORY=pages would create /path/to/image/files/pages + + MEDIUMDIRECTORY + directory to generate medium sized images in, defaults to medium, + works the same as the PAGESDIRECTORY variable + + ICONSDIRECTORY + directory to generate thumbnails in, defaults to icons, works the + same as MEDIUMDIRECTORY and PAGESDIRECTORY + Example Usage: TITLE="My Funky Gallery" bpgallery.sh /path/to/image/files @@ -65,6 +79,13 @@ Themes Theme support is very rudimentary, basically you create functions for each of the parts of the template, and put them in a file named the same as the theme. The functions that you need to declare are as follows: + + Available in all templates: + ${BASEURL} + Base directory (will generate ../ when making pages in a + subdirectory for getting to the generated stylesheet or to the + index page) + bpgallery_ThemeName_head() what's it for?: This sets up the header for the page, generally diff --git a/TODO b/TODO index 8f68901..2d86dd2 100644 --- a/TODO +++ b/TODO @@ -3,5 +3,3 @@ aspect ratio. * Allow ordering of images rather than the current "sort" based algorithm on filename. -* Make sure that the tools we require are available (i.e. check that we have - xargs, convert, identify etc) diff --git a/bpgallery.sh b/bpgallery.sh index 3350f20..d26821a 100755 --- a/bpgallery.sh +++ b/bpgallery.sh @@ -240,39 +240,140 @@ if [[ -z $TITLE ]]; then fi if [[ -z $CONVERTTOOL ]]; then - CONVERTTOOL=convert + hash convert + if [[ $? != 0 ]]; then + echo "Can't find convert, exiting" + exit 3 + fi + CONVERTTOOL=$(hash -t convert) +else + if [[ ! -x $CONVERTTOOL ]]; then + echo "Can't find convert at location $CONVERTTOOL, exiting" + exit 3 + fi fi if [[ -z $FINDCOMMAND ]]; then - FINDCOMMAND=find + hash find + if [[ $? != 0 ]]; then + echo "Can't find find, exiting" + exit 3 + fi + FINDCOMMAND=$(hash -t find) +else + if [[ ! -x $FINDCOMMAND ]]; then + echo "Can't find find at $FINDCOMMAND, exiting" + exit 3 + fi fi if [[ -z $XARGSCOMMAND ]]; then - XARGSCOMMAND=xargs + hash xargs + if [[ $? != 0 ]]; then + echo "Can't find xargs, exiting" + exit 3 + fi + XARGSCOMMAND=$(hash -t xargs) +else + if [[ ! -x $XARGSCOMMAND ]]; then + echo "Can't find xargs at $XARGSCOMMAND, exiting" + exit 3 + fi fi if [[ -z $ECHOCOMMAND ]]; then ECHOCOMMAND=echo +else + if [[ ! -x $ECHOCOMMAND ]]; then + echo "Can't find echo at $ECHOCOMMAND, exiting" + exit 3 + fi fi if [[ -z $SORTCOMMAND ]]; then - SORTCOMMAND=sort + hash sort + if [[ $? != 0 ]]; then + echo "Can't find sort, exiting" + exit 3 + fi + SORTCOMMAND=$(hash -t sort) +else + if [[ ! -x $SORTCOMMAND ]]; then + echo "Can't find sort, exiting" + exit 3 + fi fi if [[ -z $IDENTIFYCOMMAND ]]; then - IDENTIFYCOMMAND=identify + hash identify + if [[ $? != 0 ]]; then + echo "Can't find indentify, exiting" + exit 3 + fi + IDENTIFYCOMMAND=$(hash -t identify) +else + if [[ ! -x $IDENTIFYCOMMAND ]]; then + echo "Can't find identify at $IDENTIFYCOMMAND, exiting" + exit 3 + fi fi if [[ -z $HEADCOMMAND ]]; then - HEADCOMMAND=head + hash head + if [[ $? != 0 ]]; then + echo "Can't find head, exiting" + exit 3 + fi + HEADCOMMAND=$(hash -t head) +else + if [[ ! -x $HEADCOMMAND ]]; then + echo "Can't find head at $HEADCOMMAND, exiting" + exit 3 + fi fi if [[ -z $GREPCOMMAND ]]; then - GREPCOMMAND=grep + hash grep + if [[ $? != 0 ]]; then + echo "Can't find grep, exiting" + exit 3 + fi + GREPCOMMAND=$(hash -t grep) +else + if [[ ! -x $GREPCOMMAND ]]; then + echo "Can't find grep at $GREPCOMMAND, exiting" + exit 3 + fi fi if [[ -z $SEDCOMMAND ]]; then - SEDCOMMAND=sed + hash sed + if [[ $? != 0 ]]; then + echo "Can't find sed, exiting" + exit 3 + fi + SEDCOMMAND=$(hash -t sed) +else + if [[ ! -x $SEDCOMMAND ]]; then + echo "Can't find sed at $SEDCOMMAND, exiting" + exit 3 + fi +fi + +if [[ -z $WCCOMMAND ]]; then + hash wc + if [[ $? != 0 ]]; then + echo "Can't find wc, exiting" + exit 3 + fi + WCCOMMAND=$(hash -t wc) + WCCOMMAND="$WCCOMMAND -l" +else + if [[ ! -x $WCCOMMAND ]]; then + echo "Can't find wc at $WCCOMMAND, exiting" + exit 3 + fi + WCCOMMAND="$WCCOMMAND -l" fi if [[ -z $WIDTH ]]; then @@ -283,10 +384,6 @@ if [[ -z $IMAGEEXTENSIONS ]]; then IMAGEEXTENSIONS="jpeg jpg gif png"; fi -if [[ -z $WCCOMMAND ]]; then - WCCOMMAND="wc -l" -fi - if [[ -z $CAPTIONHEIGHT ]]; then CAPTIONHEIGHT=75 fi -- 2.30.2