diff --git a/xbps-src/shutils/pkgtarget_funcs.sh.in b/xbps-src/shutils/pkgtarget_funcs.sh.in index 7bff68b0c7c..4050acb970c 100644 --- a/xbps-src/shutils/pkgtarget_funcs.sh.in +++ b/xbps-src/shutils/pkgtarget_funcs.sh.in @@ -189,16 +189,20 @@ list_pkg_files() # remove_pkg() { - local subpkg ver found + local subpkg found pkg [ -z $pkgname ] && msg_error "unexistent package, aborting.\n" - ver=$($XBPS_PKGDB_CMD version $pkgname) - for subpkg in ${subpackages}; do - if [ -d "$XBPS_DESTDIR/${subpkg}-${ver%_*}" ]; then - rm -rf "$XBPS_DESTDIR/${subpkg}-${ver%_*}" + . ${XBPS_SRCPKGDIR}/${sourcepkg}/${subpkg}.template + set_tmpl_common_vars + pkg="${subpkg}-${version}" + if [ -d "$XBPS_DESTDIR/${pkg}" ]; then + msg_normal "'${pkg}': removing files from destdir...\n" + rm -rf "$XBPS_DESTDIR/${pkg}" found=1 + else + msg_warn "'${pkg}' not installed in destdir!\n" fi # Remove leftover files in $wrksrc. if [ -f "${wrksrc}/.xbps_do_install_${subpkg}_done" ]; then @@ -207,8 +211,10 @@ remove_pkg() fi done - if [ -d "$XBPS_DESTDIR/${pkgname}-${ver%_*}" ]; then - rm -rf "$XBPS_DESTDIR/${pkgname}-${ver%_*}" + pkg="${pkgname}-${version}" + if [ -d "$XBPS_DESTDIR/${pkg}" ]; then + msg_normal "'${pkg}': removing files from destdir...\n" + rm -rf "$XBPS_DESTDIR/${pkg}" found=1 fi @@ -216,6 +222,15 @@ remove_pkg() [ -f $XBPS_POST_INSTALL_DONE ] && rm -f $XBPS_POST_INSTALL_DONE [ -f $XBPS_INSTALL_DONE ] && rm -f $XBPS_INSTALL_DONE + if [ -n "$DESTDIR_ONLY_INSTALL" ]; then + if [ -n "$found" ]; then + return 0 + else + msg_warn "'${pkg}' not installed in destdir!\n" + return 1 + fi + fi + stow_pkg_handler unstow || return $? [ -n "$found" ] && return 0 diff --git a/xbps-src/shutils/stow_funcs.sh b/xbps-src/shutils/stow_funcs.sh index 73473d21327..c3f73d15b00 100644 --- a/xbps-src/shutils/stow_funcs.sh +++ b/xbps-src/shutils/stow_funcs.sh @@ -169,10 +169,12 @@ unstow_pkg_real() fi setup_tmpl $pkgname + pkg="${pkgname}-${version}" + [ -n "$revision" ] && pkg="${pkg}_${revision}" ver=$($XBPS_PKGDB_CMD version $pkgname) if [ -z "$ver" ]; then - msg_warn "$pkgname is not installed.\n" + msg_warn "'${pkg}' not installed in masterdir!\n" return 0 fi @@ -181,8 +183,8 @@ unstow_pkg_real() # If it's a metapkg, do nothing. : elif [ ! -f ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then - msg_warn "$pkgname wasn't installed from source!\n" - return 0 + msg_warn "'${pkg}' wasn't installed from source!\n" + return 1 elif [ ! -w ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then msg_error "$pkgname cannot be removed (permission denied).\n" elif [ -s ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then diff --git a/xbps-src/xbps-src.sh.in b/xbps-src/xbps-src.sh.in index d1f7b83c1a3..6c059cad6d2 100644 --- a/xbps-src/xbps-src.sh.in +++ b/xbps-src/xbps-src.sh.in @@ -458,7 +458,8 @@ remove) _pkgname=$(basename_cwd) fi setup_tmpl ${_pkgname} - if [ -z "$IN_CHROOT" -a -z "$bootstrap" ]; then + if [ -z "$IN_CHROOT" -a -z "$bootstrap" \ + -a -z "$BOOTSTRAP_PKG_REBUILD" ]; then . $XBPS_SHUTILSDIR/chroot.sh xbps_chroot_handler $target ${_pkgname} else