aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsbodl182
1 files changed, 91 insertions, 91 deletions
diff --git a/sbodl b/sbodl
index a56d938..9f612a8 100755
--- a/sbodl
+++ b/sbodl
@@ -170,15 +170,15 @@ DEFARCHIVE=https://slackware.uk/sbosrcarch
ARCHIVE=${SBODL_ARCHIVE:-$DEFARCHIVE}
if [ -t 1 ]; then
- RED="\033[1;31m"
- GREEN="\033[1;32m"
- YELLOW="\033[1;33m"
- COLOR_OFF="\033[0m"
+ RED="\033[1;31m"
+ GREEN="\033[1;32m"
+ YELLOW="\033[1;33m"
+ COLOR_OFF="\033[0m"
fi
die() {
- echo "$SELF: $*" 2>&1
- exit 1
+ echo "$SELF: $*" 2>&1
+ exit 1
}
CONTDISP="--content-disposition"
@@ -188,51 +188,51 @@ CONTDISP="--content-disposition"
OPTS=$( getopt -n $SELF -o vmhafnu -l help,man,doc,version,archive,force,no-content-disposition,update -- "$@" )
eval set -- "$OPTS"
while true; do
- case "$1" in
- -h|--help|--doc) exec perldoc "$0" ;;
- -m|--man) exec pod2man --stderr -s1 -csbo-maintainer-tools -r$VERSION "$0" ;;
- -v|--version) echo $VERSION ; exit 0 ;;
- -a|--archive) USEARCHIVE="yes" ; shift ; continue ;;
- -f|--force) FORCEDL="yes" ; shift ; continue ;;
- -u|--update) UPDATE="yes" ; shift ; continue ;;
- -n) CONTDISP="--no-content-disposition" ; shift ; continue ;;
- --) shift; break ;;
- esac
+ case "$1" in
+ -h|--help|--doc) exec perldoc "$0" ;;
+ -m|--man) exec pod2man --stderr -s1 -csbo-maintainer-tools -r$VERSION "$0" ;;
+ -v|--version) echo $VERSION ; exit 0 ;;
+ -a|--archive) USEARCHIVE="yes" ; shift ; continue ;;
+ -f|--force) FORCEDL="yes" ; shift ; continue ;;
+ -u|--update) UPDATE="yes" ; shift ; continue ;;
+ -n) CONTDISP="--no-content-disposition" ; shift ; continue ;;
+ --) shift; break ;;
+ esac
done
if [ "$*" != "" ]; then
- echo -e "${YELLOW}Passing extra arguments to wget: ${RED}$@${COLOR_OFF}"
+ echo -e "${YELLOW}Passing extra arguments to wget: ${RED}$@${COLOR_OFF}"
fi
[ -d "$CACHEDIR/" ] || mkdir -p $CACHEDIR || die "Can't create $CACHEDIR"
INFOFILE="./$( basename $( pwd ) ).info"
source "$INFOFILE" \
- || die "No .info file, are you sure this is a SBo directory? Try '$SELF --help'"
+ || die "No .info file, are you sure this is a SBo directory? Try '$SELF --help'"
# This stanza copied from the SBo template for 14.1:
if [ -z "$ARCH" ]; then
- case "$( uname -m )" in
- i?86) ARCH=i586 ;;
- arm*) ARCH=arm ;;
- *) ARCH=$( uname -m ) ;;
- esac
+ case "$( uname -m )" in
+ i?86) ARCH=i586 ;;
+ arm*) ARCH=arm ;;
+ *) ARCH=$( uname -m ) ;;
+ esac
fi
if [ "$ARCH" = "x86_64" ]; then
- DL=${DOWNLOAD_x86_64:-$DOWNLOAD}
- SUM=${MD5SUM_x86_64:-$MD5SUM}
+ DL=${DOWNLOAD_x86_64:-$DOWNLOAD}
+ SUM=${MD5SUM_x86_64:-$MD5SUM}
else
- DL=$DOWNLOAD
- SUM=${MD5SUM}
+ DL=$DOWNLOAD
+ SUM=${MD5SUM}
fi
if [ -z "$DL" ]; then
- die "Bad .info file (no DOWNLOAD= or DOWNLOAD_x86_64=)."
+ die "Bad .info file (no DOWNLOAD= or DOWNLOAD_x86_64=)."
fi
if [ "$DL" = "UNSUPPORTED" ]; then
- die "$PRGNAM is unsupported on $ARCH"
+ die "$PRGNAM is unsupported on $ARCH"
fi
# save passed-in command line args for use with wget
@@ -243,68 +243,68 @@ EXIT=0
set $SUM
for dl in $DL; do
- if [ "$USEARCHIVE" = "yes" ]; then
- file="$( echo "$dl" | sed 's,.*/,,' )"
- a=$( echo $1 | cut -b1 )
- b=$( echo $1 | cut -b2 )
- dl="$ARCHIVE/by-md5/$a/$b/$1/$file"
- fi
-
- EXTRAWGETARGS="$CONTDISP"
- case "$dl" in
- # sourceforge can't use content-disposition, because some of its
- # mirrors add '?viasf=1' to the filename in the header.
- *sourceforge.net/*|*.sf.net/*) EXTRAWGETARGS="--user-agent wget" ;;
- *) ;;
- esac
-
- FILE=$( echo "$dl" | sed 's,.*/,,' )
-
- # ignore (rm) broken symlinks
- [ -L "$FILE" ] && ! [ -e "$FILE" ] && FORCEDL=yes
-
- [ "$FORCEDL" = "yes" ] && rm -f "$FILE"
-
- if [ -f "$FILE" -a ! -L "$FILE" ]; then
- # file exists and is a regular file, cache it
- mv -b "$FILE" "$CACHEDIR"
- ln -s "$CACHEDIR/$FILE" "$FILE"
- elif [ -e "$FILE" ]; then
- # don't do anything
- :
- elif [ "$FORCEDL" != "yes" ] && [ -e "$CACHEDIR/$FILE" ]; then
- ln -s "$CACHEDIR/$FILE" "$FILE"
- else
- wget $EXTRAWGETARGS $WGETARGS "$dl" || die "Download failed, try '$SELF -a'."
- if [ -e "$FILE" ]; then
- # the chown keeps sbrun sudo users from having root-owned
- # files in ~/sbodl-cache.
- chown --reference="$CACHEDIR" "$FILE" &>/dev/null
- mv -b "$FILE" "$CACHEDIR"
- ln -s "$CACHEDIR/$FILE" "$FILE"
- fi
- fi
-
- if [ -e "$FILE" ]; then
- GOTSUM="$( md5sum "$FILE" | cut -d' ' -f1 )"
- if [ "$1" != "$GOTSUM" ]; then
- echo -e "${RED}WARN: md5sum doesn't match${COLOR_OFF}\\n expected: $1\\n got: $GOTSUM"
- case "$FILE" in
- ?.cabal) echo -e "${YELLOW}HINT:${COLOR_OFF} for ?.cabal files: if the md5sum fails, retry with '$SELF -f'." ;;
- *) if [ "$UPDATE" = "yes" ]; then
- echo "Updating .info file with new md5sum"
- sed -i "s,$1,$GOTSUM," $INFOFILE
- fi ;;
- esac
- EXIT=1
- else
- echo -e "${GREEN}md5sum matches OK${COLOR_OFF}: $1"
- fi
- else
- echo -e "${RED}WARN${COLOR_OFF}: can't find downloaded file $FILE, try '$SELF -a'?"
- EXIT=1
- fi
- shift
+ if [ "$USEARCHIVE" = "yes" ]; then
+ file="$( echo "$dl" | sed 's,.*/,,' )"
+ a=$( echo $1 | cut -b1 )
+ b=$( echo $1 | cut -b2 )
+ dl="$ARCHIVE/by-md5/$a/$b/$1/$file"
+ fi
+
+ EXTRAWGETARGS="$CONTDISP"
+ case "$dl" in
+ # sourceforge can't use content-disposition, because some of its
+ # mirrors add '?viasf=1' to the filename in the header.
+ *sourceforge.net/*|*.sf.net/*) EXTRAWGETARGS="--user-agent wget" ;;
+ *) ;;
+ esac
+
+ FILE=$( echo "$dl" | sed 's,.*/,,' )
+
+ # ignore (rm) broken symlinks
+ [ -L "$FILE" ] && ! [ -e "$FILE" ] && FORCEDL=yes
+
+ [ "$FORCEDL" = "yes" ] && rm -f "$FILE"
+
+ if [ -f "$FILE" -a ! -L "$FILE" ]; then
+ # file exists and is a regular file, cache it
+ mv -b "$FILE" "$CACHEDIR"
+ ln -s "$CACHEDIR/$FILE" "$FILE"
+ elif [ -e "$FILE" ]; then
+ # don't do anything
+ :
+ elif [ "$FORCEDL" != "yes" ] && [ -e "$CACHEDIR/$FILE" ]; then
+ ln -s "$CACHEDIR/$FILE" "$FILE"
+ else
+ wget $EXTRAWGETARGS $WGETARGS "$dl" || die "Download failed, try '$SELF -a'."
+ if [ -e "$FILE" ]; then
+ # the chown keeps sbrun sudo users from having root-owned
+ # files in ~/sbodl-cache.
+ chown --reference="$CACHEDIR" "$FILE" &>/dev/null
+ mv -b "$FILE" "$CACHEDIR"
+ ln -s "$CACHEDIR/$FILE" "$FILE"
+ fi
+ fi
+
+ if [ -e "$FILE" ]; then
+ GOTSUM="$( md5sum "$FILE" | cut -d' ' -f1 )"
+ if [ "$1" != "$GOTSUM" ]; then
+ echo -e "${RED}WARN: md5sum doesn't match${COLOR_OFF}\\n expected: $1\\n got: $GOTSUM"
+ case "$FILE" in
+ ?.cabal) echo -e "${YELLOW}HINT:${COLOR_OFF} for ?.cabal files: if the md5sum fails, retry with '$SELF -f'." ;;
+ *) if [ "$UPDATE" = "yes" ]; then
+ echo "Updating .info file with new md5sum"
+ sed -i "s,$1,$GOTSUM," $INFOFILE
+ fi ;;
+ esac
+ EXIT=1
+ else
+ echo -e "${GREEN}md5sum matches OK${COLOR_OFF}: $1"
+ fi
+ else
+ echo -e "${RED}WARN${COLOR_OFF}: can't find downloaded file $FILE, try '$SELF -a'?"
+ EXIT=1
+ fi
+ shift
done
exit $EXIT