diff --git a/src/usr/sbin/sbopkg b/src/usr/sbin/sbopkg index d390c1d..31682c7 100755 --- a/src/usr/sbin/sbopkg +++ b/src/usr/sbin/sbopkg @@ -3147,51 +3147,45 @@ add_options() { fi } -do_install() { - # This is mostly equivalent to "upgradepkg --reinstall --install-new $@", - # but also checks for renames - - local PKG OLDPKG - local PKG_NAME PKG_VER PKG_ARCH PKG_BUILD PKG_TAG - - for PKG in "$@"; do - 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 -} - install_package() { # Install the package. + # This is mostly equivalent to "upgradepkg --reinstall --install-new $1", + # but also checks for package ownership and renames local INSTDIR=$1 local INSTPKG=$2 - local OWNER=$(stat -c %U $INSTDIR/$INSTPKG) - local GROUP=$(stat -c %G $INSTDIR/$INSTPKG) - local REPLY + local REPLY OLDPKG + # keep the variables we pull up with split_pkg_name() here + local PKG_NAME PKG_VER PKG_ARCH PKG_BUILD PKG_TAG + # ditto the one from get_old_name() + local OLDNAME - if [[ $OWNER != root && $GROUP != root ]]; then + if [[ $(find $INSTDIR/$INSTPKG ! -user root -o ! -group root) ]]; then crunch_fmt "WARNING: The file $INSTPKG is not set with root:root \ - permissions! Do you want to proceed? Here is the \ - output of ls -l:" + permissions! Do you want to proceed? Here is the output of \ + ls -l:" echo ls -l $INSTDIR/$INSTPKG echo - echo "Press (Y)es to proceed or (N)o to abort." - read - case $REPLY in - y* | Y* ) echo "Proceeding..." ;; - n* | N* ) echo "Aborting..."; return 0 ;; - * ) unknown_response; break ;; - esac + while :; do + read -n1 -ep "Press (Y)es to proceed or (N)o to abort: " + case $REPLY in + y* | Y* ) echo "Proceeding..."; break ;; + n* | N* ) echo "Aborting..."; return ;; + * ) unknown_response ;; + esac + done fi - do_install $INSTDIR/$INSTPKG + + split_pkg_name $INSTPKG + 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=$INSTPKG + fi + upgradepkg --reinstall --install-new $OLDPKG%$INSTDIR/$INSTPKG echo "Done upgrading/installing package." }