From 0cd82a6e43eaf1e40f4b6c14e09d117dec3b1e0a Mon Sep 17 00:00:00 2001 From: emmett1 Date: Tue, 29 Aug 2017 21:43:10 +0800 Subject: [PATCH] updated --- functions | 2 +- installpkg | 18 +++++++++--------- removepkg | 38 ++++++++++++++++++++++++++++++-------- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/functions b/functions index 6e62f87..6f55806 100644 --- a/functions +++ b/functions @@ -76,7 +76,7 @@ rmdir_silent() { } rm_silent() { - command rm -d "$@" 2> /dev/null + command rm "$@" 2> /dev/null } nocolor() { diff --git a/installpkg b/installpkg index 6290524..6fbd0dd 100755 --- a/installpkg +++ b/installpkg @@ -13,6 +13,11 @@ installpkg() { msg "Installing ${color_green}$packagename${color_reset}..." + # noextract file into system + for noextr in ${NO_EXTRACT[@]}; do + excludefile+=(--exclude=$noextr) + done + #ignore dependency check if [ ! "$IGNORE_DEP" ]; then msg2 "Checking package dependencies..." @@ -44,11 +49,6 @@ installpkg() { run_preupgrade fi - # noextract file into system - for noextr in ${NO_EXTRACT[@]}; do - excludefile+=(--exclude=$noextr) - done - #installing package into system msg2 "Extracting package..." if [ "$VERBOSE_INSTALL" ]; then @@ -58,7 +58,7 @@ installpkg() { fi if [ $? != 0 ]; then - msg "Failed install ${color_red}$packagename${color_reset}." + msgerr "Failed install ${color_red}$packagename${color_reset}." pushd $ROOT_DIR while IFS=' ' read -r line; do rm_silent "$line" || rmdir_silent --ignore-fail-on-non-empty "$line" @@ -147,7 +147,7 @@ checkpkgconflict() { } -checkconflict() { +checkconflict() { while IFS=' ' read -r line; do pushd $ROOT_DIR @@ -155,7 +155,7 @@ checkconflict() { fileconflict+=(${line}) fi popd - done < <(tar -tf "$PKGNAME" --exclude=.pkginfo --exclude=.pkginstall) + done < <(tar -tf "$PKGNAME" --exclude=.pkginfo --exclude=.pkginstall --exclude=.pkgreadme ${excludefile[@]}) if [ "${#fileconflict[@]}" -gt 0 ]; then msgerr "File conflict found:" @@ -219,7 +219,7 @@ backupconf() { pushd $ROOT_DIR for bkp in ${backup[@]}; do - if [ -e $b ]; then + if [ -e $bkp ]; then msg2 "Backup ${color_purple}$bkp${color_reset}" cp $bkp $BACKUP_DIR DONE_BACKUP=yes diff --git a/removepkg b/removepkg index d59ccd5..b1edcd9 100755 --- a/removepkg +++ b/removepkg @@ -31,16 +31,38 @@ removepkg() { run_preremove fi - msg2 "Deleting files..." + msg2 "Removing files..." while IFS=' ' read -r line; do - pushd $ROOT_DIR - if [ "$VERBOSE_REMOVE" = "yes" ]; then - rm_silent -v "$line" || rmdir_silent --ignore-fail-on-non-empty "$line" - else - rm_silent "$line" || rmdir_silent --ignore-fail-on-non-empty "$line" + pushd $ROOT_DIR + if [ "$VERBOSE_REMOVE" = "yes" ]; then + rm_silent "$line" && echo " Removed: $line" || msgwarn "Failed remove $line" + else + rm_silent "$line" || msgwarn "Failed remove $line" + fi + popd + done < <(tac $INDEX_DIR/$1/.files | grep -v '/$') + + msg2 "Removing dirs..." + while IFS=' ' read -r line; do + NOREMOVE="" + for allinst in $(ls $INDEX_DIR); do + if [ $1 != $allinst ]; then + if [ $(cat $INDEX_DIR/$allinst/.files | grep -w "$line") ]; then + NOREMOVE=yes + break + fi fi - popd - done < <(tac $INDEX_DIR/$1/.files) + done + if [ ! "$NOREMOVE" ]; then + pushd $ROOT_DIR + if [ "$VERBOSE_REMOVE" = "yes" ]; then + rmdir_silent "$line" && echo " Removed: $line" || msgwarn "Failed remove $line" + else + rmdir_silent "$line" || msgwarn "Failed remove $line" + fi + popd + fi + done < <(tac $INDEX_DIR/$1/.files | grep '/$') if [ ! "$NO_POSTREMOVE" ]; then run_postremove