This commit is contained in:
emmett1
2017-08-29 21:43:10 +08:00
parent 69277a8d1e
commit 0cd82a6e43
3 changed files with 40 additions and 18 deletions

View File

@@ -76,7 +76,7 @@ rmdir_silent() {
}
rm_silent() {
command rm -d "$@" 2> /dev/null
command rm "$@" 2> /dev/null
}
nocolor() {

View File

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

View File

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