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