rm of prefile can be done directly in hook

This commit is contained in:
James Barnett 2017-02-14 11:30:18 -06:00
parent 02770cffc6
commit 83e578369d
No known key found for this signature in database
GPG key ID: E4B5E45AA3B8C5C3
2 changed files with 3 additions and 5 deletions

View file

@ -25,4 +25,4 @@ Target = snap-pac
Description = NOTE: You are removing snap-pac. No post transaction snapshots will be taken.
Depends = snap-pac
When = PreTransaction
Exec = /usr/share/libalpm/scripts/snap-pac rem
Exec = /usr/bin/rm -f /tmp/snap-pac-pre_*

View file

@ -54,7 +54,7 @@ source "$SNAPPER_CONFIG_FILE"
[[ $EUID -ne 0 ]] && die "Script must be run as root."
[[ ! -d /var/run/dbus ]] && die "No dbus available. Are you in a chroot environment?"
[[ $# -ne 1 ]] && die "Only one argument should be passed to this script."
[[ $1 != "pre" ]] && [[ $1 != "post" ]] && [[ $1 != "rem" ]] && die "First argument should either be 'pre', 'post', or 'rem'."
[[ $1 != "pre" ]] && [[ $1 != "post" ]] && die "First argument should either be 'pre' or 'post'."
[[ -z "$SNAPPER_CONFIGS" ]] && die "No snapper configurations found, so not taking any snapshots."
declare -r pre_or_post=$1
@ -68,9 +68,6 @@ fi
declare -i x=0
for CONFIG in $SNAPPER_CONFIGS; do
prefile="/tmp/$name-pre_$CONFIG"
[[ "$pre_or_post" == "rem" ]] && rm -f "$prefile" && continue
# Set defaults
PACMAN_PRE_POST="no"
[[ $CONFIG == "root" ]] && PACMAN_PRE_POST="yes"
@ -83,6 +80,7 @@ for CONFIG in $SNAPPER_CONFIGS; do
[[ $PACMAN_PRE_POST == "no" ]] && continue
prefile="/tmp/$name-pre_$CONFIG"
snapper_cmd="snapper --config $CONFIG create --type $pre_or_post --cleanup-algorithm $PACMAN_CLEANUP_ALGORITHM --print-number --description"
x=$((x+1))