X Strike Force SVN commit: rev 508 - trunk/debian
Author: branden
Date: 2003-09-12 07:42:37 -0500 (Fri, 12 Sep 2003)
New Revision: 508
Modified:
trunk/debian/shell-lib.sh
Log:
debian/shell-lib.sh: check_symlinks_and_warn(),check_symlinks_and_bomb():
stylistic and cosmetic updates
Modified: trunk/debian/shell-lib.sh
===================================================================
--- trunk/debian/shell-lib.sh 2003-09-12 12:40:56 UTC (rev 507)
+++ trunk/debian/shell-lib.sh 2003-09-12 12:42:37 UTC (rev 508)
@@ -195,66 +195,85 @@
fi
check_symlinks_and_warn () {
- # for each argument, checks for symlink sanity, and warns if they aren't sane
- # should be called from preinst scripts only
- if [ -n "$*" ]; then
- for SYMLINK in $*; do
- if [ -L $SYMLINK ]; then
- if [ "$(maplink $SYMLINK)" != "$(readlink $SYMLINK)" ]; then
- message "Warning: $SYMLINK symbolic link points to the wrong" \
- "place. Removing."
- rm $SYMLINK
- fi
- elif [ -e $SYMLINK ]; then
- ERRMSG="ERROR: $SYMLINK exists and is not a symbolic link. "
- ERRMSG="${ERRMSG}This package cannot be installed until this"
- if [ -f $SYMLINK ]; then
- ERRMSG="$ERRMSG file"
- elif [ -d $SYMLINK ]; then
- ERRMSG="$ERRMSG directory"
- else
- ERRMSG="$ERRMSG thing"
- fi
- ERRMSG="$ERRMSG is removed."
- message "$ERRMSG"
- errormsg "Aborting installation of $THIS_PACKAGE package."
+ # syntax: check_symlinks_and_warn symlink ...
+ #
+ # For each argument, check for symlink sanity, and warn if it isn't sane.
+ #
+ # Call this function from a preinst script in the event $1 is "upgrade" or
+ # "install".
+
+ local errmsg symlink
+
+ # validate arguments
+ if [ $# -lt 1 ]; then
+ usage_errormsg "check_symlinks_and_warn() called with wrong number of" \
+ "arguments; expected at least 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ while [ -n "$1" ]; do
+ if [ -L "$symlink" ]; then
+ if [ "$(maplink "$symlink")" != "$(readlink "$symlink")" ]; then
+ debugmsg "$symlink symbolic link points to wrong location" \
+ "$(readlink "$symlink"); removing"
+ rm "$symlink"
fi
- done
- else
- internal_errormsg "Argh. Some chucklehead called" \
- "check_symlinks_and_warn() with no arguments."
- fi;
+ elif [ -e "$symlink" ]; then
+ errmsg="$symlink exists and is not a symbolic link. This package cannot"
+ errmsg="be installed until this"
+ if [ -f "$symlink" ]; then
+ errmsg="$errmsg file"
+ elif [ -d "$symlink" ]; then
+ errmsg="$errmsg directory"
+ else
+ errmsg="$errmsg thing"
+ fi
+ errmsg="$errmsg is removed."
+ message "$errmsg"
+ errormsg "Aborting installation of $THIS_PACKAGE package."
+ fi
+ shift
+ done
}
check_symlinks_and_bomb () {
- # for each argument, checks for symlink sanity, and bombs if they aren't sane
- # should be called from postinst scripts only
- if [ -n "$*" ]; then
- for SYMLINK in $*; do
- PROBLEM=
- if [ -L $SYMLINK ]; then
- if [ "$(maplink $SYMLINK)" != "$(readlink $SYMLINK)" ]; then
- PROBLEM=yes
- internal_errormsg "ERROR: $SYMLINK symbolic link points to the " \
- "wrong place."
- fi
- elif [ -e $SYMLINK ]; then
- PROBLEM=yes
- internal_errormsg "ERROR: $SYMLINK is not a symbolic link."
- else
- PROBLEM=yes
- internal_errormsg "ERROR: $SYMLINK symbolic link does not exist."
+ # syntax: check_symlinks_and_bomb symlink ...
+ #
+ # For each argument, check for symlink sanity, and bomb if it isn't sane.
+ #
+ # Call this function from a postinst script.
+
+ local problem symlink
+
+ # validate arguments
+ if [ $# -lt 1 ]; then
+ usage_errormsg "check_symlinks_and_bomb() called with wrong number of" \
+ "arguments; expected at least 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ while [ -n "$1" ]; do
+ problem=
+ if [ -L "$symlink" ]; then
+ if [ "$(maplink "$symlink")" != "$(readlink "$symlink")" ]; then
+ problem=yes
+ errormsg "$symlink symbolic link points to wrong location" \
+ "$(readlink "$symlink")"
fi
- if [ -n "$PROBLEM" ]; then
- analyze_path $SYMLINK $(readlink $SYMLINK)
- find_culprits $SYMLINK
- exit $SHELL_LIB_THROWN_ERROR
- fi
- done
- else
- internal_errormsg "Argh. Some chucklehead called" \
- "check_symlinks_and_bomb() with no arguments."
- fi;
+ elif [ -e "$symlink" ]; then
+ problem=yes
+ errormsg "$symlink is not a symbolic link"
+ else
+ problem=yes
+ errormsg "$symlink symbolic link does not exist"
+ fi
+ if [ -n "$problem" ]; then
+ analyze_path "$symlink" "$(readlink "$symlink")"
+ find_culprits "$symlink"
+ exit $SHELL_LIB_THROWN_ERROR
+ fi
+ shift
+ done
}
font_update () {
Reply to: