[sbopkg-users] renames bugs - sbopkg 0.27.0
Mauro Giachero
mauro.giachero at gmail.com
Wed Mar 11 16:04:41 UTC 2009
The attached patch (on top of r498) fixes the problem here.
Unless any problems arises, I'd like to commit it this week. I'll also think
about applying a slightly less intrusive patch (not touching info_item and
the updates code, at least -- suggestions are welcome) to -stable.
--
Mauro Giachero
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sbopkg.org/pipermail/sbopkg-users/attachments/20090311/f0950cac/attachment.htm>
-------------- next part --------------
From 0c90aa542dea1440593c23c364409c28d7785c01 Mon Sep 17 00:00:00 2001
From: Mauro Giachero <mauro.giachero at gmail.com>
Date: Mon, 9 Mar 2009 10:59:53 +0100
Subject: [PATCH] Refactor the renames code and fix upgrading renamed packages.
This patch refactors the renames code putting the old/new
name retrieval in two generic helpers.
Also fix the upgrading of renamed packages by providing
the old package name to upgradepkg.
Signed-off-by: Mauro Giachero <mauro.giachero at gmail.com>
---
src/usr/sbin/sbopkg | 77 +++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 65 insertions(+), 12 deletions(-)
diff --git a/src/usr/sbin/sbopkg b/src/usr/sbin/sbopkg
index 4e57126..9836fca 100755
--- a/src/usr/sbin/sbopkg
+++ b/src/usr/sbin/sbopkg
@@ -390,6 +390,47 @@ function progressbar_interrupted () {
[[ "$KEY" = "$ESC" ]]
}
+get_new_name () {
+ # Return the new package name, as for sbopkg-renames.
+ # If there isn't any new name, return the old name.
+ # $1 = the variable where to put the new name
+ # $2 = the old name
+ local NEWNAMEVAR="$1"
+ local OLDNAME="$2"
+ local TMP
+
+ TMP=$(grep "^$OLDNAME=" $SBOPKG_RENAMES)
+ if [[ -z "$TMP" ]]; then
+ # No rename occoured
+ TMP=$OLDNAME
+ else
+ # The package got renamed
+ TMP=$(cut -d= -f2 <<<"$TMP")
+ fi
+ eval $NEWNAMEVAR=$TMP
+}
+
+get_old_name () {
+ # Return the old package name, as for sbopkg-renames.
+ # If there isn't any old name, return the new name.
+ # $1 = the variable where to put the old name
+ # $2 = the new name
+ local OLDNAMEVAR="$1"
+ local NEWNAME="$2"
+ local TMP
+
+ # Manage package renames
+ TMP=$(grep "=$NEWNAME\$" $SBOPKG_RENAMES)
+ if [[ -z "$TMP" ]]; then
+ # No rename occoured
+ TMP=$NEWNAME
+ else
+ # The package got renamed
+ TMP=$(cut -d= -f1 <<<"$TMP")
+ fi
+ eval $OLDNAMEVAR=$TMP
+}
+
check_for_updates () {
# This checks for updates to installed SBo packages. Thanks to Mauro
# Giachero for this much-improved update code and related functions!
@@ -443,14 +484,7 @@ check_for_updates () {
# End pkgtool code
# Manage package renames
- NAME=$(grep "^$OLDNAME=" $SBOPKG_RENAMES)
- if [ -z $NAME ]; then
- # No rename occoured
- NAME=$OLDNAME
- else
- # The package got renamed
- NAME=$(echo $NAME |cut -d= -f2)
- fi
+ get_new_name NAME $OLDNAME
# Find the current SlackBuild
NEWSB=$(find $LOCALREPO/$SLACKVER -name "$NAME.SlackBuild")
@@ -727,8 +761,7 @@ info_item () {
APP="$(cat $TMP/sbopkg_item_selection)"
# We need to check and see if the APP has ever been renamed.
- RAPP=$(grep -w $APP $SBOPKG_RENAMES | cut -d"=" -f1)
- if [ "$RAPP" == "" ]; then RAPP=$APP ; fi
+ get_old_name RAPP $APP
CATEGORY="$(cat $TMP/sbopkg_category_selection)"
SHORTPATH=$LOCALREPO/$SLACKVER/$CATEGORY/$APP
@@ -2055,6 +2088,26 @@ add_options () {
fi
}
+do_install () {
+ # This is mostly equivalent to "upgradepkg --reinstall --install-new $@", but
+ # also checks for renames
+ local PKG PKGNAME
+ local OLDPKG
+
+ for PKG in $@; do
+ # Strip the path from $PKG
+ PKGNAME=${PKG##*/}
+ # Remove version, arch, build and tag
+ PKGNAME=$(rev <<<"$PKGNAME" | cut -d- -f4- |rev)
+
+ get_old_name OLDPKG $PKGNAME
+ if [[ -z $(ls /var/log/packages |grep -x "$OLDPKG-[^-]*-[^-]*-[^-]*") ]]; then
+ OLDPKG=$PKGNAME
+ fi
+ upgradepkg --reinstall --install-new $OLDPKG%$PKG
+ done
+}
+
install_package () {
# Install the package.
INSTPKG=$1
@@ -2081,9 +2134,9 @@ install_package () {
esac
fi
if [ "$INSTALLPKGS" = "1" ]; then
- upgradepkg --reinstall --install-new $OUTPUT/*
+ do_install $OUTPUT/*
else
- upgradepkg --reinstall --install-new $OUTPUT/$INSTPKG
+ do_install $OUTPUT/$INSTPKG
echo "Done upgrading/installing package."
fi
}
--
1.6.1.3
More information about the sbopkg-users
mailing list