xbps-src: make -D remove only remove files in pkg's destdir.

This commit is contained in:
Juan RP 2011-07-06 11:27:57 +02:00
parent 08c2049d9f
commit 341432f1fb
3 changed files with 29 additions and 11 deletions

View File

@ -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

View File

@ -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

View File

@ -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