Check tools are available
authorBrett Parker <arch@sommitrealweird.co.uk>
Tue, 15 May 2007 00:32:07 +0000 (00:32 +0000)
committerBrett Parker <arch@sommitrealweird.co.uk>
Tue, 15 May 2007 00:32:07 +0000 (00:32 +0000)
Check tools we use are available.

git-archimport-id: arch@sommitrealweird.co.uk--2005-desktop/bpgallery--mainline--1.1--patch-12

ChangeLog
README
TODO
bpgallery.sh

index 8f4a7cf6f8aa3b751ac7a1e7589906b860c081e8..328dc66e1e40eed74dd800f147ca45c1866d4280 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-05-15 Brett Parker <iDunno@sommitrealweird.co.uk>
+  * Check that the tools we require exist using the builtin hash function
+  * Minorly reformat changelog
+
 2007-05-14 Brett Parker <iDunno@sommitrealweird.co.uk>
   * 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 <arch@sommitrealweird.co.uk>
-
   * Fix caption generation code
   * Released version 1.1.1
 
 2007-05-13 Brett Parker <arch@sommitrealweird.co.uk>
-
   * Fix medium sized page generation code
   * Fix index page generation
   * Released version 1.1.0
 
 2007-05-12 Brett Parker <arch@sommitrealweird.co.uk>
-
   * 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 <arch@sommitrealweird.co.uk>
-
   * Start of 1.1 release development
   * Generate medium sized pages
diff --git a/README b/README
index 0678ce978882b51100af845a3dfdc6eee5615ed3..df7e5843ffff94971984f470c4572116c5fcd362 100644 (file)
--- 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 8f689016f7b7e62c1f55b688df99833bc8d7ea59..2d86dd219ae04c901cefab3d7e97763e67430e61 100644 (file)
--- 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)
index 3350f209d8a4d09f7b67300e7cef71114c35a576..d26821a325a7434b866dd22238bcb0f687215743 100755 (executable)
@@ -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