summaryrefslogtreecommitdiffstats
path: root/compat32-tools
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2013-02-23 17:53:18 +0000
committer Eric Hameleers <alien@slackware.com>2013-02-23 17:53:18 +0000
commitf9c61c829fc55d1194c9ca461a632757b583a324 (patch)
tree0848a153e39230f842bcc8552b1f0efc8aabe6d4 /compat32-tools
parentd9afff713df86b263fb18b802ce4f0c2f82cd5a2 (diff)
downloadmultilib-f9c61c829fc55d1194c9ca461a632757b583a324.tar.gz
multilib-f9c61c829fc55d1194c9ca461a632757b583a324.tar.xz
Refresh files in target directory. Only download and convert what we do not have yet. Delete obsolete versions we already had converted earlier.
Diffstat (limited to 'compat32-tools')
-rwxr-xr-xcompat32-tools/massconvert32.sh85
1 files changed, 72 insertions, 13 deletions
diff --git a/compat32-tools/massconvert32.sh b/compat32-tools/massconvert32.sh
index 8659394..66af5d9 100755
--- a/compat32-tools/massconvert32.sh
+++ b/compat32-tools/massconvert32.sh
@@ -99,6 +99,22 @@ function contains_spaces () {
[ "x$CHOPPED" = "x$1" ] && return 1 || return 0
}
+# A function to get a package's URL in the repository:
+function get_url_pkg () {
+ local BP="$(basename $1)"
+ local PS="$(dirname $1)"
+
+ local DURL="$2"
+
+ for FP in $(lftp -c 'open '${DURL}' ; cls -1 '${PS}/${BP}'-*.t?z') ZALIEN ; do
+ if [ "$(echo "$FP"|rev|cut -d- -f4-|cut -d/ -f1| rev)" = "$BP" ];
+ then
+ break
+ fi
+ done
+ [ "$FP" != "ZALIEN" ] && echo "$DURL/$PS/$FP" || echo ""
+}
+
# A function to download a package:
function download_pkg () {
local IP="$1"
@@ -121,16 +137,16 @@ function get_pkgfullpath () {
local BP="$(basename $1)"
local FP=""
- for FP in $(ls ${IP}-*.t?z) ; do
+ for FP in $(ls ${IP}-*.t?z 2>/dev/null) ZALIEN; do
if [ "$(echo "$FP"|rev|cut -d- -f4-|cut -d/ -f1| rev)" = "$BP" ];
then
- echo "$FP"
- continue
+ break
fi
done
+ [ "$FP" != "ZALIEN" ] && echo "$FP" || echo ""
}
-# A function to cconvert a package,
+# A function to convert a package,
# downloading it first if needed, and taking patches into account:
function conv_pkg () {
local BP="$1"
@@ -142,20 +158,63 @@ function conv_pkg () {
if [ $? -eq 0 ]; then
echo "--- Using Slackware's patch package for $BP"
PKGPATH="../patches/packages/$BP"
- SLACK32URLFIX="$(dirname $SLACK32URL)/patches"
+ [ -n "$SLACK32URL" ] && SLACK32URLFIX="$(dirname $SLACK32URL)/patches"
else
PKGPATH="$SERIES/$BP"
- SLACK32URLFIX="$SLACK32URL"
+ [ -n "$SLACK32URL" ] && SLACK32URLFIX="$SLACK32URL"
fi
- [ -n "$SLACK32URL" ] && download_pkg $SLACK32ROOT/$PKGPATH $SLACK32URLFIX
- FULLPKG=$(get_pkgfullpath $SLACK32ROOT/$PKGPATH)
- if [ -z "$FULLPKG" ]; then
- echo "*** FAIL: package '$BP' was not found!"
- continue
+ if [ -n "$SLACK32URL" ]; then
+ FULLURL=$(get_url_pkg $PKGPATH $SLACK32URLFIX)
+ if [ -n "$FULLURL" ]; then
+ FULLPKG=$SLACK32ROOT/$SERIES/$(basename $FULLURL)
+ else
+ FULLPKG=""
+ fi
+ else
+ FULLPKG=$(get_pkgfullpath $SLACK32ROOT/$PKGPATH)
+ fi
+
+ if [ -z "$FULLPKG" -o ! -f "$FULLPKG" ]; then
+ echo "*** FAIL: package '$BP' was not found in repository!"
+ break
+ else
+ REPOVERSION=$(basename $FULLPKG |rev |cut -d- -f3 |rev)
+ fi
+
+ # Do we have a local converted package already?
+ HAVE_COMPAT32="$(get_pkgfullpath $TARGET64ROOT/${SERIES}-compat32/$BP-compat32)"
+ if [ -n "$HAVE_COMPAT32" ]; then
+ COMPAT32VERSION=$(echo "$HAVE_COMPAT32" |rev|cut -d- -f3|rev)
+ if [ "$COMPAT32VERSION" != "$REPOVERSION" ]; then
+ echo ">>> Deleting old version '$COMPAT32VERSION' of '${BP}-compat32'"
+ FILE_TO_REMOVE=$HAVE_COMPAT32
+ HAVE_COMPAT32=""
+ else
+ echo "--- ${BP}-compat32 version '$COMPAT32VERSION' is already available"
+ fi
+ fi
+
+ # If we do not have the latest -compat32 package, then run the conversion:
+ if [ ! -n "$HAVE_COMPAT32" ]; then
+
+ if [ -n "$SLACK32URL" ]; then
+ # Download the Slackware package before converting it:
+ ( cd $SLACK32ROOT/$SERIES
+ lftp -c "open $(dirname $FULLURL) ; get $(basename $FULLURL)"
+ )
+ fi
+
+ [ "$VERBOSE" = "1" ] && echo "--- $BP"
+ # Convert the Slackware package into a -compat32 version:
+ sh $CONV32 -i $FULLPKG -d $TARGET64ROOT/${SERIES}-compat32
+
+ if [ -n "$FILE_TO_REMOVE" ]; then
+ # This is where we delete an older version of the -compat32 package:
+ rm $FILE_TO_REMOVE
+ FILE_TO_REMOVE=""
+ fi
fi
- [ "$VERBOSE" = "1" ] && echo "--- $BP"
- sh $CONV32 -i $FULLPKG -d $TARGET64ROOT/${SERIES}-compat32
}
# Safety checks in case a URL was provided: