This commit is contained in:
emmett1
2017-12-08 16:04:01 +08:00
parent 330f3a00c8
commit 00a6cea8a8
6 changed files with 145 additions and 69 deletions

View File

@@ -1,8 +1,8 @@
#!/bin/bash
. /usr/share/scratchpkg/functions || exit 1
export LC_ALL=C
. /usr/share/scratchpkg/functions || exit 1
spkglock() {
@@ -179,24 +179,6 @@ saferemove() {
}
check_directory() {
for dir in $INDEX_DIR $BACKUP_DIR $REJECTED_DIR; do
if [ ! -d $dir ]; then
msg "Directory ${color_yellow}$1${color_reset} not exist."
DIR_ERROR=yes
elif [ ! -w $dir ]; then
msg "Directory ${color_yellow}$1${color_reset} not writable."
DIR_ERROR=yes
elif [ ! -x $dir ] || [ ! -r $1 ]; then
msg "Directory ${color_yellow}$1${color_reset} not readable."
DIR_ERROR=yes
fi
done
[ "$DIR_ERROR" ] && exit 1
}
runremovehooks() {
if [ "${#runthishook[@]}" -gt 0 ]; then
@@ -277,28 +259,33 @@ main() {
nocolor
fi
### CHECK FOR ROOT ACCESS ###
needroot "Removing package"
### CHECK DIRECTORY ###
checkdirexist "$INDEX_DIR" "$BACKUP_DIR" "$REJECTED_DIR"
checkdirwrite "$INDEX_DIR" "$BACKUP_DIR" "$REJECTED_DIR"
checkdirread "$INDEX_DIR" "$BACKUP_DIR" "$REJECTED_DIR"
### PACKAGE NAME ###
if [ -z $RMNAME ]; then
msgerr "Please state package name for remove."
exit 1
fi
check_directory
### CHECK FOR LOCK FILE ###
if [ -f /tmp/spkg.lock ]; then
msgerr "Cant install/remove package simultaneously."
msgerr "remove ${color_yellow}/tmp/spkg.lock${color_reset} if no install/remove package process running."
exit 1
fi
### CHECK PACKAGE IN DATABASE ###
if [ ! -d $INDEX_DIR/$RMNAME ]; then
msg "Package ${color_red}$RMNAME${color_reset} not installed."
exit 1
fi
### CHECK FOR LOCK FILE ###
if [ -f /tmp/spkg.lock ]; then
msgerr "Cant install/remove package simultaneously."
msgerr "remove ${color_yellow}/tmp/spkg.lock${color_reset} if no install/remove package process running."
exit 1
fi
### GET NAME, VERSION, RELEASE FROM INSTALLED PACKAGE DATABASE ###
getoldname $RMNAME