Author: dnicholson
Date: 2008-04-21 13:11:44 -0600 (Mon, 21 Apr 2008)
New Revision: 7391
Modified:
trunk/BOOK/postlfs/config/compressdoc.xml
trunk/auxfiles/compressdoc
Log:
compressdoc: Be more robust with directories
Modified: trunk/BOOK/postlfs/config/compressdoc.xml
===================================================================
--- trunk/BOOK/postlfs/config/compressdoc.xml 2008-04-21 19:11:32 UTC (rev
7390)
+++ trunk/BOOK/postlfs/config/compressdoc.xml 2008-04-21 19:11:44 UTC (rev
7391)
@@ -32,7 +32,7 @@
<screen role="root"><?dbfo keep-together="auto"?><userinput>cat >
/usr/sbin/compressdoc << "EOF"
<literal>#!/bin/bash
-# VERSION: 20080421.1112
+# VERSION: 20080421.1121
#
# Compress (with bzip2 or gzip) all man pages in a hierarchy and
# update symlinks - By Marc Heerdink <marc @ koelkast.net>
@@ -62,6 +62,9 @@
# compressdoc when working recursively. This means the same compressdoc
# will be used whether a full path was given or it was resolved from PATH.
#
+# Modified 20080421 by Dan Nicholson to be more robust with directories
+# that don't exist or don't have sufficient permissions.
+#
# TODO:
# - choose a default compress method to be based on the available
# tool : gzip or bzip2;
@@ -315,6 +318,14 @@
exit 1
fi
+# Check that the specified directories actually exist and are readable
+for DIR in $MAN_DIR; do
+ if [ ! -d "$DIR" -o ! -r "$DIR" ]; then
+ echo "Directory '$DIR' does not exist or is not readable"
+ exit 1
+ fi
+done
+
# Fake?
if [ "$FAKE" != "no" ]; then
echo "Actual parameters used:"
@@ -354,6 +365,10 @@
if [ "$BACKUP" = "yes" ]; then
for DIR in $MAN_DIR; do
cd "${DIR}/.."
+ if [ ! -w "`pwd`" ]; then
+ echo "Directory '`pwd`' is not writable"
+ exit 1
+ fi
DIR_NAME=`basename "${DIR}"`
echo "Backing up $DIR..." > $DEST_FD0
[ -f "${DIR_NAME}.tar.old" ] && rm -f "${DIR_NAME}.tar.old"
@@ -368,6 +383,10 @@
# I need to take into account the localized man, so I'm going recursive
for DIR in $MAN_DIR; do
MEM_DIR=`pwd`
+ if [ ! -w "$DIR" ]; then
+ echo "Directory '$DIR' is not writable"
+ exit 1
+ fi
cd "$DIR"
for FILE in *; do
# Fixes the case were the directory is empty
Modified: trunk/auxfiles/compressdoc
===================================================================
--- trunk/auxfiles/compressdoc 2008-04-21 19:11:32 UTC (rev 7390)
+++ trunk/auxfiles/compressdoc 2008-04-21 19:11:44 UTC (rev 7391)
@@ -1,5 +1,5 @@
#!/bin/bash
-# VERSION: 20080421.1112
+# VERSION: 20080421.1121
# $LastChangedBy$
# $Date$
#
@@ -31,6 +31,9 @@
# compressdoc when working recursively. This means the same compressdoc
# will be used whether a full path was given or it was resolved from PATH.
#
+# Modified 20080421 by Dan Nicholson to be more robust with directories
+# that don't exist or don't have sufficient permissions.
+#
# TODO:
# - choose a default compress method to be based on the available
# tool : gzip or bzip2;
@@ -284,6 +287,14 @@
exit 1
fi
+# Check that the specified directories actually exist and are readable
+for DIR in $MAN_DIR; do
+ if [ ! -d "$DIR" -o ! -r "$DIR" ]; then
+ echo "Directory '$DIR' does not exist or is not readable"
+ exit 1
+ fi
+done
+
# Fake?
if [ "$FAKE" != "no" ]; then
echo "Actual parameters used:"
@@ -323,6 +334,10 @@
if [ "$BACKUP" = "yes" ]; then
for DIR in $MAN_DIR; do
cd "${DIR}/.."
+ if [ ! -w "`pwd`" ]; then
+ echo "Directory '`pwd`' is not writable"
+ exit 1
+ fi
DIR_NAME=`basename "${DIR}"`
echo "Backing up $DIR..." > $DEST_FD0
[ -f "${DIR_NAME}.tar.old" ] && rm -f "${DIR_NAME}.tar.old"
@@ -337,6 +352,10 @@
# I need to take into account the localized man, so I'm going recursive
for DIR in $MAN_DIR; do
MEM_DIR=`pwd`
+ if [ ! -w "$DIR" ]; then
+ echo "Directory '$DIR' is not writable"
+ exit 1
+ fi
cd "$DIR"
for FILE in *; do
# Fixes the case were the directory is empty
--
http://linuxfromscratch.org/mailman/listinfo/blfs-book
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page