xbps-src: make unstow work even if build template is missing.

This commit is contained in:
Juan RP 2011-10-26 09:05:10 +02:00
parent 9f65b80448
commit c2b0d7a307
3 changed files with 11 additions and 19 deletions

View file

@ -218,11 +218,11 @@ remove_pkg()
set_tmpl_common_vars set_tmpl_common_vars
pkg="${subpkg}-${version}" pkg="${subpkg}-${version}"
if [ -d "$XBPS_DESTDIR/${pkg}" ]; then if [ -d "$XBPS_DESTDIR/${pkg}" ]; then
msg_normal "'${pkg}': removing files from destdir...\n" msg_normal "${pkgver}: removing files from destdir...\n"
rm -rf "$XBPS_DESTDIR/${pkg}" rm -rf "$XBPS_DESTDIR/${pkg}"
found=1 found=1
else else
msg_warn "'${pkg}' not installed in destdir!\n" msg_warn "${pkgver}: 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
@ -233,7 +233,7 @@ remove_pkg()
pkg="${pkgname}-${version}" pkg="${pkgname}-${version}"
if [ -d "$XBPS_DESTDIR/${pkg}" ]; then if [ -d "$XBPS_DESTDIR/${pkg}" ]; then
msg_normal "'${pkg}': removing files from destdir...\n" msg_normal "${pkgver}: removing files from destdir...\n"
rm -rf "$XBPS_DESTDIR/${pkg}" rm -rf "$XBPS_DESTDIR/${pkg}"
found=1 found=1
fi fi
@ -246,8 +246,7 @@ remove_pkg()
if [ -n "$found" ]; then if [ -n "$found" ]; then
return 0 return 0
else else
msg_warn "'${pkg}' not installed in destdir!\n" msg_warn "${pkgver}: not installed in destdir!\n"
return 1
fi fi
fi fi

View file

@ -168,26 +168,22 @@ unstow_pkg_real()
msg_error "cannot unstow $pkgname! (permission denied)\n" msg_error "cannot unstow $pkgname! (permission denied)\n"
fi fi
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 "'${pkg}' not installed in masterdir!\n" msg_warn "'${pkgname}' not installed in masterdir!\n"
return 0 return 0
fi fi
cd $XBPS_PKGMETADIR/$pkgname || exit 1
if [ "$build_style" = "meta-template" ]; then if [ "$build_style" = "meta-template" ]; then
# 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 "'${pkg}' wasn't installed from source!\n" msg_warn "${pkgname}-${ver}: wasn't installed from source!\n"
return 1 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}-${ver}: cannot be removed (permission denied).\n"
elif [ -s ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then elif [ -s ${XBPS_PKGMETADIR}/${pkgname}/flist ]; then
msg_normal "${pkgname}-${ver}: removing files from masterdir...\n"
run_func pre_remove run_func pre_remove
# Remove installed files. # Remove installed files.
for f in $(cat ${XBPS_PKGMETADIR}/${pkgname}/flist); do for f in $(cat ${XBPS_PKGMETADIR}/${pkgname}/flist); do
@ -196,11 +192,7 @@ unstow_pkg_real()
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Removing file: $f" echo "Removing file: $f"
fi fi
fi elif [ -d $XBPS_MASTERDIR/$f ]; then
done
for f in $(cat ${XBPS_PKGMETADIR}/${pkgname}/flist); do
if [ -d $XBPS_MASTERDIR/$f ]; then
rmdir $XBPS_MASTERDIR/$f >/dev/null 2>&1 rmdir $XBPS_MASTERDIR/$f >/dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Removing directory: $f" echo "Removing directory: $f"

View file

@ -497,8 +497,9 @@ unstow)
if [ -z "${_pkgname}" ]; then if [ -z "${_pkgname}" ]; then
[ ! -r ./template ] && msg_error "missing build template in $(pwd).\n" [ ! -r ./template ] && msg_error "missing build template in $(pwd).\n"
_pkgname=$(basename_cwd) _pkgname=$(basename_cwd)
else
pkgname=${_pkgname}
fi fi
setup_tmpl ${_pkgname}
stow_pkg_handler unstow stow_pkg_handler unstow
;; ;;
*) *)