From 39dee2be1f7ef8752d0838cdcd7a1079307ebba2 Mon Sep 17 00:00:00 2001 From: Wes Barnett Date: Wed, 15 Aug 2018 20:06:35 -0400 Subject: [PATCH] Remove old module symlinks on pre snapshot Only do this if LINK_MODULES is set to yes. This prevents old symlinks getting in the way of other packages. Fixes #21. --- man8/snap-pac.8 | 6 ++---- scripts/snap-pac | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/man8/snap-pac.8 b/man8/snap-pac.8 index 7a6db5f..0403d6f 100644 --- a/man8/snap-pac.8 +++ b/man8/snap-pac.8 @@ -65,10 +65,8 @@ symlink will be created in the kernel modules directory for the currently running kernel to same directory in the pre snapshot of the "root" configuration. This is so that the kernel modules will still be available for use before a reboot is required. snap-pac will also -delete broken symlinks in the kernel modules directory if this is set -to "yes". (snapper -removes configurations according to the specified cleanup algorithm, -so eventually symlinks to old kernel modules directories will break). +delete all symlinks in the kernel modules directory if this is set +to "yes", in order to clean up the directory. Default is "no". .RE diff --git a/scripts/snap-pac b/scripts/snap-pac index 72df42b..57f50e7 100755 --- a/scripts/snap-pac +++ b/scripts/snap-pac @@ -129,10 +129,12 @@ for CONFIG in $SNAPPER_CONFIGS; do if [[ "$pre_or_post" == "pre" ]]; then x=$($snapper_cmd "$(truncate_description $PRE_DESCRIPTION)") printf "==> %s: $(echo $x | tee "$prefile")\n" "$CONFIG" + if [[ "$LINK_MODULES" == "yes" && "$CONFIG" == "root" ]]; then + find /usr/lib/modules -xtype l -delete + fi elif [[ -f $prefile && "$pre_or_post" == "post" ]]; then if [[ "$LINK_MODULES" == "yes" && "$kernel_updated" == "yes" && "$CONFIG" == "root" ]]; then printf "==> Symlinking old kernel modules...\n" - find /usr/lib/modules -xtype l -delete ln -sv /.snapshots/$(<$prefile)/snapshot/usr/lib/modules/$(uname -r) /usr/lib/modules/ fi x=$($snapper_cmd "$(truncate_description $POST_DESCRIPTION)" --pre-number "$(< "$prefile")")