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() remove_pkg()
{ {
local subpkg ver found local subpkg found pkg
[ -z $pkgname ] && msg_error "unexistent package, aborting.\n" [ -z $pkgname ] && msg_error "unexistent package, aborting.\n"
ver=$($XBPS_PKGDB_CMD version $pkgname)
for subpkg in ${subpackages}; do for subpkg in ${subpackages}; do
if [ -d "$XBPS_DESTDIR/${subpkg}-${ver%_*}" ]; then . ${XBPS_SRCPKGDIR}/${sourcepkg}/${subpkg}.template
rm -rf "$XBPS_DESTDIR/${subpkg}-${ver%_*}" 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 found=1
else
msg_warn "'${pkg}' not installed in destdir!\n"
fi fi
# Remove leftover files in $wrksrc. # Remove leftover files in $wrksrc.
if [ -f "${wrksrc}/.xbps_do_install_${subpkg}_done" ]; then if [ -f "${wrksrc}/.xbps_do_install_${subpkg}_done" ]; then
@ -207,8 +211,10 @@ remove_pkg()
fi fi
done done
if [ -d "$XBPS_DESTDIR/${pkgname}-${ver%_*}" ]; then pkg="${pkgname}-${version}"
rm -rf "$XBPS_DESTDIR/${pkgname}-${ver%_*}" if [ -d "$XBPS_DESTDIR/${pkg}" ]; then
msg_normal "'${pkg}': removing files from destdir...\n"
rm -rf "$XBPS_DESTDIR/${pkg}"
found=1 found=1
fi fi
@ -216,6 +222,15 @@ remove_pkg()
[ -f $XBPS_POST_INSTALL_DONE ] && rm -f $XBPS_POST_INSTALL_DONE [ -f $XBPS_POST_INSTALL_DONE ] && rm -f $XBPS_POST_INSTALL_DONE
[ -f $XBPS_INSTALL_DONE ] && rm -f $XBPS_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 $? stow_pkg_handler unstow || return $?
[ -n "$found" ] && return 0 [ -n "$found" ] && return 0

View File

@ -169,10 +169,12 @@ unstow_pkg_real()
fi fi
setup_tmpl $pkgname setup_tmpl $pkgname
pkg="${pkgname}-${version}"
[ -n "$revision" ] && pkg="${pkg}_${revision}"
ver=$($XBPS_PKGDB_CMD version $pkgname) ver=$($XBPS_PKGDB_CMD version $pkgname)
if [ -z "$ver" ]; then if [ -z "$ver" ]; then
msg_warn "$pkgname is not installed.\n" msg_warn "'${pkg}' not installed in masterdir!\n"
return 0 return 0
fi fi
@ -181,8 +183,8 @@ unstow_pkg_real()
# If it's a metapkg, do nothing. # If it's a metapkg, do nothing.
: :
elif [ ! -f ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then elif [ ! -f ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then
msg_warn "$pkgname wasn't installed from source!\n" msg_warn "'${pkg}' wasn't installed from source!\n"
return 0 return 1
elif [ ! -w ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then elif [ ! -w ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then
msg_error "$pkgname cannot be removed (permission denied).\n" msg_error "$pkgname cannot be removed (permission denied).\n"
elif [ -s ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then elif [ -s ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then

View File

@ -458,7 +458,8 @@ remove)
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
fi fi
setup_tmpl ${_pkgname} 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_SHUTILSDIR/chroot.sh
xbps_chroot_handler $target ${_pkgname} xbps_chroot_handler $target ${_pkgname}
else else