diff --git a/ChangeLog-current.txt b/ChangeLog-current.txt index 18061d5..5461306 100644 --- a/ChangeLog-current.txt +++ b/ChangeLog-current.txt @@ -106,3 +106,6 @@ enhancements: and instead make all queue formats "$APP" only. This simplifies some code and results in a small speed increase. * 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. diff --git a/src/usr/sbin/sbopkg b/src/usr/sbin/sbopkg index a40f2d7..1eeed15 100755 --- a/src/usr/sbin/sbopkg +++ b/src/usr/sbin/sbopkg @@ -2701,16 +2701,18 @@ do_install() { # This is mostly equivalent to "upgradepkg --reinstall --install-new $@", # but also checks for renames - local PKG PKGNAME - local OLDPKG + local PKG OLDPKG + local PKG_NAME PKG_VER PKG_ARCH PKG_BUILD PKG_TAG for PKG in "$@"; do - # Strip the path from $PKG - PKGNAME=${PKG##*/} - # Remove version, arch, build and tag - PKGNAME=$(sed 's/-[^-]*-[^-]*-[^-]*$//' <<< "$PKGNAME") - - get_old_name OLDPKG "$PKGNAME" + split_pkg_name $PKG + get_old_name OLDNAME "$PKG_NAME" + # we grep ls's output rather than have ls return a glob so 'foo' + # doesn't match 'foo-bar' + if ! OLDPKG=$(ls /var/log/packages/ | + grep -m1 "$OLDNAME-[^-]*-[^-]*-[^-]*$REPO_TAG$"); then + OLDPKG=$PKG + fi upgradepkg --reinstall --install-new $OLDPKG%"$PKG" done }