pkgmeek: fixed the invocation of pkgadd by non-root user

This commit is contained in:
John McQuah 2022-06-01 20:05:15 -04:00
parent fc0ec86cec
commit 8401b2aa25
1 changed files with 6 additions and 7 deletions

View File

@ -198,14 +198,13 @@ find . -maxdepth 1 -mindepth 1 -type l -delete
# Install if requested
# First find out how the effective user will invoke pkgadd
[ $UID = 0 ] || PKGMK_SU="sudo ";
[ -z "$PKGMK_SU" ] || [ -x $(command -v "$PKGMK_SU") ] || PKGMK_SU="/usr/bin/doas ";
[ -x $(command -v "$PKGMK_SU") ] || PKGMK_SU="su -c";
[ $UID = 0 ] || PKGMK_SU="sudo";
[ -z "$PKGMK_SU" ] || [ -x "$(command -v $PKGMK_SU)" ] || PKGMK_SU="/usr/bin/doas";
[ -x "$(command -v $PKGMK_SU)" ] || PKGMK_SU="su -c";
[ -z "$PKGMK_INSTALL_COMMAND" ] || \
$PKGMK_SU $PKGMK_INSTALL_COMMAND "$package" || \
{ error "Unable to install $package using pkgadd.";
exit "$E_INSTALL"; }
[ -z "$PKGMK_INSTALL_COMMAND" ] || { $PKGMK_SU $PKGMK_INSTALL_COMMAND "$pkg_dir$package" \
&& info "$(basename $PKGMK_INSTALL_COMMAND) $package succeeded."; } || \
{ error "Unable to install $package using pkgadd."; exit "$E_INSTALL"; }
# Clean up, part 2
[ "$PKGMK_KEEP_WORK" = "yes" ] || [ "$pkg_dir" = "$(pwd)/" ] || rm -f "$package"