diff --git a/README.md b/README.md index 0b7fa66..6eafd97 100644 --- a/README.md +++ b/README.md @@ -100,12 +100,19 @@ Installing the `nano` package as normal: (1/1) checking for file conflicts [######################################] 100% (1/1) checking available disk space [######################################] 100% :: Running pre-transaction hooks... - (1/1) snapper pre snapshot + (1/1) Performing snapper pre snapshots... + home N/A + root 1033 ✓ :: Processing package changes... (1/1) installing nano [######################################] 100% :: Running post-transaction hooks... - (1/2) snapper post snapshot - (2/2) generate GRUB configuration file + (1/1) Performing snapper post snapshots... + home N/A + root 1034 ✓ + +The snapper snapshot number is given for each snapper configuration that is +used (tip: this is also logged in pacman's log). "N/A" means that configuration +is not set up for snap-pac (see above). And here are the snapshots: @@ -176,6 +183,14 @@ removed before the post snapshot could be taken. When you initially install *snap-pac* the post hook is run, but the pre hook never was, so this message will show up then as well. +**I see an "N/A" next to one of my snapper configurations in the hook's output** + +snap-pac lists all snapper configurations it finds and tells you which ones it +took a snapshot of. "N/A" means the configuration is not set up for snap-pac, so +no snapshot was taken. + +See [configuration](#configuration). + ## License snap-pac diff --git a/hooks/00_snapper-pre.hook b/hooks/00_snapper-pre.hook index e436d7d..9c42914 100644 --- a/hooks/00_snapper-pre.hook +++ b/hooks/00_snapper-pre.hook @@ -24,7 +24,7 @@ Type = Package Target = * [Action] -Description = Performing snapper pre snapshot... +Description = Performing snapper pre snapshots... Depends = snap-pac When = PreTransaction Exec = /usr/share/libalpm/scripts/snap-pac pre diff --git a/hooks/zz_snapper-post.hook b/hooks/zz_snapper-post.hook index 4af6859..731858c 100644 --- a/hooks/zz_snapper-post.hook +++ b/hooks/zz_snapper-post.hook @@ -24,7 +24,7 @@ Type = Package Target = * [Action] -Description = Performing snapper post snapshot... +Description = Performing snapper post snapshots... Depends = snap-pac When = PostTransaction Exec = /usr/share/libalpm/scripts/snap-pac post diff --git a/scripts/snap-pac b/scripts/snap-pac index d6dbf63..ef61498 100755 --- a/scripts/snap-pac +++ b/scripts/snap-pac @@ -66,20 +66,32 @@ for CONFIG in $SNAPPER_CONFIGS; do # shellcheck source=/dev/null source /etc/snapper/configs/"$CONFIG" - [[ $PACMAN_PRE_POST != "yes" ]] && continue + echo -n " $CONFIG " - prefile="/tmp/snap-pac-pre_$CONFIG" - snapper_cmd="snapper --config $CONFIG create --type $pre_or_post --cleanup-algorithm $PACMAN_CLEANUP_ALGORITHM" + if [[ $PACMAN_PRE_POST == "yes" ]]; then - x=$((x+1)) + prefile="/tmp/snap-pac-pre_$CONFIG" + snapper_cmd="snapper --config $CONFIG create --type $pre_or_post --cleanup-algorithm $PACMAN_CLEANUP_ALGORITHM" + + x=$((x+1)) + + if [[ "$pre_or_post" == "pre" ]]; then + $snapper_cmd --description "$PACMAN_PRE_DESCRIPTION" --print-number > "$prefile" + echo -n "$(< "$prefile") " + elif [[ -f $prefile ]]; then + postnum=$($snapper_cmd --description "$PACMAN_POST_DESCRIPTION" --print-number --pre-number "$(< "$prefile")") + echo -n "$postnum " + rm "$prefile" + else + echo "WARNING: $prefile does not exist, so no post snapshot will be taken. If you are initially installing snap-pac, this is normal." + fi + + echo "✓" - if [[ "$pre_or_post" == "pre" ]]; then - $snapper_cmd --description "$PACMAN_PRE_DESCRIPTION" --print-number > "$prefile" - elif [[ -f $prefile ]]; then - $snapper_cmd --description "$PACMAN_POST_DESCRIPTION" --pre-number "$(< "$prefile")" - rm "$prefile" else - echo "WARNING: $prefile does not exist, so no post snapshot will be taken. If you are initially installing snap-pac, this is normal." + + echo "N/A" + fi done