summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcompat32-tools/massconvert32.sh139
1 files changed, 114 insertions, 25 deletions
diff --git a/compat32-tools/massconvert32.sh b/compat32-tools/massconvert32.sh
index 5992e90..c5760d3 100755
--- a/compat32-tools/massconvert32.sh
+++ b/compat32-tools/massconvert32.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# Written 2009 by Eric Hameleers, Eindhoven, NL
+# Written 2009, 2010 Eric Hameleers, Eindhoven, NL
# Convert 32bit slackware packages 'en masse' into compatibility packages
# to be installed on slackware64 - providing the 32bit part of multilib.
@@ -22,44 +22,51 @@ fi
# Should we be verbose?
VERBOSE=${VERBOSE:-1}
+# In case we need temporary storage:
+TMP=${TMP:-/tmp}
+mkdir -p $TMP
+if [ ! -w "$TMP" ]; then
+ echo "Can not write to temporary directory '$TMP'!"
+ exit 3
+fi
+
+# Zero some other variables:
+SLACK32ROOT=""
+SLACK32URL=""
+TARGET64ROOT=""
+
# Helpful instructions in case the user asks for it:
function show_help () {
# Write the help text to output:
cat <<EOF
-Usage: $0 -i 32bit_package_tree [-d output_directory]
+Usage: $0 <-i 32bit_package_tree|-u 32bit_package_url> [-d output_directory]
$(basename $0) converts an essential subset of 32-bit Slackware
packages into 'compatibility' packages for 64-bit Slackware.
-required parameters::
+Required parameter - one of these two::
-i 32bit_package_tree A 32bit Slackware package-tree. It should have
the a,ap,d,..,y directories immediately below.
-optional parameters::
+ -u 32bit_package_url The URL of a http or ftp server containing 32bit
+ Slackware packages. It should have the
+ a,ap,d,..,y directories immediately below.
+Optional parameter::
-d destination_directory create packages in this directory.
By default, the new packages will be created
in your current directory.
-EOF
-}
+Example of a useable Slackware URL:
+ http://slackware.mirrors.tds.net/pub/slackware/slackware-13.0/slackware
-# A function to retrieve the fullname of a package:
-function get_pkgfullpath () {
- local IP="$1"
- for FP in $(ls $IP*.t?z) ; do
- if [ "$(echo $FP|rev|cut -d- -f4-|cut -d/ -f1| rev)" = "$(basename $IP)" ];
- then
- echo $FP
- continue
- fi
- done
+EOF
}
# Parse the commandline parameters:
while [ ! -z "$1" ]; do
case $1 in
-d|--destdir)
- TARGET64ROOT="$(cd $(dirname ${2}); pwd)/$(basename ${2})"
+ TARGET64ROOT="$(cd $(dirname "${2}"); pwd)/$(basename "${2}")"
shift 2
;;
-h|--help)
@@ -67,7 +74,11 @@ while [ ! -z "$1" ]; do
exit 0
;;
-i|--inputdir)
- SLACK32ROOT="$(cd $(dirname ${2}); pwd)/$(basename ${2})"
+ SLACK32ROOT="$(cd $(dirname "${2}"); pwd)/$(basename "${2}")"
+ shift 2
+ ;;
+ -u|--inputurl)
+ SLACK32URL="${2}"
shift 2
;;
-*)
@@ -81,15 +92,77 @@ while [ ! -z "$1" ]; do
esac
done
+# A function to determine if there are spaces in the pathname:
+function contains_spaces () {
+ local CHOPPED=$(echo "$1" | tr -d ' ')
+ [ "x$CHOPPED" = "x$1" ] && return 1 || return 0
+}
+
+# A function to download a package:
+function download_pkg () {
+ local IP="$1"
+ local BP="$(basename $1)"
+ local DP="$(dirname $1)"
+
+ local PS="$(basename $DP)"
+
+ local DURL="$2"
+
+ mkdir -p "$DP"
+ cd "$DP"
+ echo "--- Downloading '$PS/$BP'..."
+ lftp -c 'open '${DURL}' ; mget '${PS}/${BP}'-*.t?z'
+}
+
+# A function to retrieve the fullname of a package:
+function get_pkgfullpath () {
+ local IP="$1"
+ local BP="$(basename $1)"
+ local FP=""
+
+ for FP in $(ls ${IP}-*.t?z) ; do
+ if [ "$(echo "$FP"|rev|cut -d- -f4-|cut -d/ -f1| rev)" = "$BP" ];
+ then
+ echo "$FP"
+ continue
+ fi
+ done
+}
+
+# Safety checks in case a URL was provided:
+if [ -n "$SLACK32URL" ]; then
+ if [ -n "$SLACK32ROOT" ]; then
+ echo "*** Options '-i' and '-u' can not be used together!"
+ exit 1
+ else
+ # Define a 'temporary' root directory where we will download packages:
+ SLACK32ROOT="${TMP}/alienBOB"
+ if ! which lftp 1>/dev/null 2>&1 ; then
+ echo "No lftp binary detected! Need lftp for package downloading!"
+ exit 1
+ fi
+ fi
+fi
+
# The root directory of 32bit Slackware packages
# (should have the a,ap,d,..,y directories immediately below):
-# Let's use a fallback directory in case I am lazy:
-SLACK32ROOT=${SLACK32ROOT:-"~ftp/pub/Linux/Slackware/slackware-current/slackware/"}
+# Let's use a fallback directory in case none was specified:
+SLACK32ROOT="${SLACK32ROOT:-"/home/ftp/pub/Linux/Slackware/slackware-current/slackware"}"
# The output directory for our converted packages; defaults to the current dir.
# Note that {a,ap,d,l,n,x}-compat32 directories will be created below this
# directory if they do not yet exist:
-TARGET64ROOT=${TARGET64ROOT:-"$(pwd)"}
+TARGET64ROOT="${TARGET64ROOT:-"$(pwd)"}"
+
+# Abort if we got directories with spaces in them:
+if contains_spaces "$SLACK32ROOT" ; then
+ echo "Directories with spaces are unsupported: '$SLACK32ROOT'!"
+ exit 1
+fi
+if contains_spaces "$TARGET64ROOT" ; then
+ echo "Directories with spaces are unsupported: '$TARGET64ROOT'!"
+ exit 1
+fi
# Where the scripts are:
SRCDIR=$(cd $(dirname $0); pwd)
@@ -103,10 +176,12 @@ if [ ! -f $CONV32 ]; then
exit 1
fi
-# We can not proceed if there are no packages:
-if [ ! -d $SLACK32ROOT/a -o ! -d $SLACK32ROOT/ap -o ! -d $SLACK32ROOT/d -o ! -d $SLACK32ROOT/l -o ! -d $SLACK32ROOT/n -o ! -d $SLACK32ROOT/x ]; then
- echo "Required package directories a,ap,d,l,n,x below '$SLACK32ROOT' are not found! Aborting..."
- exit 1
+# We can not proceed if there are no packages and we did not get an URL:
+if [ -z "$SLACK32URL" ]; then
+ if [ ! -d $SLACK32ROOT/a -o ! -d $SLACK32ROOT/ap -o ! -d $SLACK32ROOT/d -o ! -d $SLACK32ROOT/l -o ! -d $SLACK32ROOT/n -o ! -d $SLACK32ROOT/x ]; then
+ echo "Required package directories a,ap,d,l,n,x below '$SLACK32ROOT' are not found! Aborting..."
+ exit 1
+ fi
fi
# If a destination_directory was specified, abort now if we can not create it:
@@ -256,6 +331,7 @@ echo "*** Starting the conversion process:"
echo "*** 'A' series:"
for INPKG in $A_COMPAT32 ; do
+ [ -n "$SLACK32URL" ] && download_pkg $SLACK32ROOT/a/$INPKG $SLACK32URL
FULLPKG=$(get_pkgfullpath $SLACK32ROOT/a/$INPKG)
if [ -z "$FULLPKG" ]; then
echo "*** FAIL: package '$INPKG' was not found!"
@@ -267,6 +343,7 @@ done
echo "*** 'AP' series:"
for INPKG in $AP_COMPAT32 ; do
+ [ -n "$SLACK32URL" ] && download_pkg $SLACK32ROOT/ap/$INPKG $SLACK32URL
FULLPKG=$(get_pkgfullpath $SLACK32ROOT/ap/$INPKG)
if [ -z "$FULLPKG" ]; then
echo "*** FAIL: package '$INPKG' was not found!"
@@ -278,6 +355,7 @@ done
echo "*** 'D' series:"
for INPKG in $D_COMPAT32 ; do
+ [ -n "$SLACK32URL" ] && download_pkg $SLACK32ROOT/d/$INPKG $SLACK32URL
FULLPKG=$(get_pkgfullpath $SLACK32ROOT/d/$INPKG)
if [ -z "$FULLPKG" ]; then
echo "*** FAIL: package '$INPKG' was not found!"
@@ -289,6 +367,7 @@ done
echo "*** 'L' series:"
for INPKG in $L_COMPAT32 ; do
+ [ -n "$SLACK32URL" ] && download_pkg $SLACK32ROOT/l/$INPKG $SLACK32URL
FULLPKG=$(get_pkgfullpath $SLACK32ROOT/l/$INPKG)
if [ -z "$FULLPKG" ]; then
echo "*** FAIL: package '$INPKG' was not found!"
@@ -300,6 +379,7 @@ done
echo "*** 'N' series:"
for INPKG in $N_COMPAT32 ; do
+ [ -n "$SLACK32URL" ] && download_pkg $SLACK32ROOT/n/$INPKG $SLACK32URL
FULLPKG=$(get_pkgfullpath $SLACK32ROOT/n/$INPKG)
if [ -z "$FULLPKG" ]; then
echo "*** FAIL: package '$INPKG' was not found!"
@@ -311,6 +391,7 @@ done
echo "*** 'X' series:"
for INPKG in $X_COMPAT32 ; do
+ [ -n "$SLACK32URL" ] && download_pkg $SLACK32ROOT/x/$INPKG $SLACK32URL
FULLPKG=$(get_pkgfullpath $SLACK32ROOT/x/$INPKG)
if [ -z "$FULLPKG" ]; then
echo "*** FAIL: package '$INPKG' was not found!"
@@ -320,5 +401,13 @@ for INPKG in $X_COMPAT32 ; do
sh $CONV32 -i $FULLPKG -d $TARGET64ROOT/x-compat32
done
+# Mention downloaded packages if we used a URL as source:
+if [ -n "$SLACK32URL" ]; then
+ echo "WARNING: packages which were downloaded from '$SLACK32URL'"
+ echo "have been left in directory '$SLACK32ROOT'."
+ echo "It is safe to remove these now."
+ echo ""
+fi
+
echo "*** Conversion done!"
echo "***"