Modify do_install() in stable and trunk to correctly invoke upgradepkg to avoid

a fairly rare but serious case of removing the wrong package; thanks to NaCl
for the bug report.
This commit is contained in:
slakmagik 2009-06-14 17:58:45 +00:00
parent eb1cea4375
commit 8b87240383
2 changed files with 13 additions and 8 deletions

View File

@ -106,3 +106,6 @@ enhancements:
and instead make all queue formats "$APP" only. This simplifies some code and instead make all queue formats "$APP" only. This simplifies some code
and results in a small speed increase. and results in a small speed increase.
* Exit edit_build_queue menu with 'ESC'; thanks to Nille for the bug report. * Exit edit_build_queue menu with 'ESC'; thanks to Nille for the bug report.
* Modify do_install() to correctly invoke upgradepkg to avoid a fairly rare
but serious case of removing the wrong package; thanks to NaCl for the
bug report.

View File

@ -2701,16 +2701,18 @@ do_install() {
# This is mostly equivalent to "upgradepkg --reinstall --install-new $@", # This is mostly equivalent to "upgradepkg --reinstall --install-new $@",
# but also checks for renames # but also checks for renames
local PKG PKGNAME local PKG OLDPKG
local OLDPKG local PKG_NAME PKG_VER PKG_ARCH PKG_BUILD PKG_TAG
for PKG in "$@"; do for PKG in "$@"; do
# Strip the path from $PKG split_pkg_name $PKG
PKGNAME=${PKG##*/} get_old_name OLDNAME "$PKG_NAME"
# Remove version, arch, build and tag # we grep ls's output rather than have ls return a glob so 'foo'
PKGNAME=$(sed 's/-[^-]*-[^-]*-[^-]*$//' <<< "$PKGNAME") # doesn't match 'foo-bar'
if ! OLDPKG=$(ls /var/log/packages/ |
get_old_name OLDPKG "$PKGNAME" grep -m1 "$OLDNAME-[^-]*-[^-]*-[^-]*$REPO_TAG$"); then
OLDPKG=$PKG
fi
upgradepkg --reinstall --install-new $OLDPKG%"$PKG" upgradepkg --reinstall --install-new $OLDPKG%"$PKG"
done done
} }