From 82ca966d4b004c6e7dd2fc218d38aca1d4cfb2bc Mon Sep 17 00:00:00 2001 From: Darren 'Tadgy' Austin Date: Wed, 7 Sep 2022 15:38:41 +0100 Subject: [PATCH] Add support for keeping an archive of config files removed from packages. Update .gitignore. --- .gitignore | 4 +++- source/cpan-modules/cpan-modules.SlackBuild | 17 +++++++++++++++-- templates/template.SlackBuild | 17 +++++++++++++++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 7488932..c76f90c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -*..swp +*~ +*.save +.*.swp slackware-* slackware64-* slackwarearm-* diff --git a/source/cpan-modules/cpan-modules.SlackBuild b/source/cpan-modules/cpan-modules.SlackBuild index 385a714..cc87c31 100755 --- a/source/cpan-modules/cpan-modules.SlackBuild +++ b/source/cpan-modules/cpan-modules.SlackBuild @@ -1,5 +1,5 @@ #!/bin/bash -# Version: 0.6.3 +# Version: 0.6.4 # Copyright (c) 2005-2022: # Darren 'Tadgy' Austin # Licensed under the terms of the GNU General Public License version 3. @@ -52,6 +52,8 @@ cd "$(cd "${BASH_SOURCE[0]%/*}"; pwd -P)" while (( $# > 0 )); do if [[ "$1" =~ ^-(-)?f(orce)?$ ]]; then BUILD_FORCE=1 + elif [[ "$1" =~ ^-(-)?k(eep-configs)?$ ]]; then + BUILD_KEEPCONFIGS=1 elif [[ "$1" =~ ^-(-)?n(o-cleanup)?$ ]]; then BUILD_CLEANUP=0 elif [[ "$1" =~ ^-(-)?v(ersion)?$ ]]; then @@ -61,7 +63,7 @@ while (( $# > 0 )); do exit 0 else printf "%s: %s: %s\\n" "${0##*/}" "Invalid option" "$1" >&2 - printf "%s: %s %s\\n" "Usage" "${0##*/}" "[[-f|--force]|[-n|--no-cleanup]|[-v|--version]]" >&2 + printf "%s: %s %s\\n" "Usage" "${0##*/}" "[[[-f|--force] [-k|--keep-configs] [-n|--no-cleanup]]|[-v|--version]]" >&2 exit 1 fi shift @@ -91,6 +93,7 @@ unset DIST_OS_VERSION_CODENAME # Build environment. BUILD_WORKDIR="${BUILD_WORKDIR:-/tmp/pkg-build}" BUILD_ROOT="$BUILD_WORKDIR/pkg-$PKG_NAME" +BUILD_CONFIG_ARCHIVE="${BUILD_CONFIG_ARCHIVE:-/tmp/pkg-config-archive}" BUILD_PREFIX="${BUILD_PREFIX:-/opt}" BUILD_ALTCC="${BUILD_ALTCC:-}" BUILD_ALTCXX="${BUILD_ALTCXX:-}" @@ -241,6 +244,16 @@ for ((I = 0; I < ${#BUILD_PERL_MODULES[@]}; I++)); do fi done +# Move the package configuration files into the archive. +[[ -e "$BUILD_ROOT/etc/$PKG_NAME" ]] && { + (( ${BUILD_KEEPCONFIGS:-0} == 0 )) && { + rm -rf "$BUILD_CONFIG_ARCHIVE/$PKG_NAME-$PKG_VERSION" + mkdir -p -m 755 "$BUILD_CONFIG_ARCHIVE/$PKG_NAME-$PKG_VERSION/etc/$PKG_NAME" || \ + die "Failed to create directory: $BUILD_CONFIG_ARCHIVE/$PKG_NAME-$PKG_VERSION/etc/$PKG_NAME" + mv "$BUILD_ROOT/etc/$PKG_NAME"/* "$BUILD_CONFIG_ARCHIVE/$PKG_NAME-$PKG_VERSION/etc/$PKG_NAME" || die "Failed to move configuration files to archive" + } +} + ################################################## # End of the only section that required editing. # ################################################## diff --git a/templates/template.SlackBuild b/templates/template.SlackBuild index 9c89b4d..a414e8f 100755 --- a/templates/template.SlackBuild +++ b/templates/template.SlackBuild @@ -1,5 +1,5 @@ #!/bin/bash -# Version: 0.6.3 +# Version: 0.6.4 # Copyright (c) 2005-2022: # Darren 'Tadgy' Austin # Licensed under the terms of the GNU General Public License version 3. @@ -52,6 +52,8 @@ cd "$(cd "${BASH_SOURCE[0]%/*}"; pwd -P)" while (( $# > 0 )); do if [[ "$1" =~ ^-(-)?f(orce)?$ ]]; then BUILD_FORCE=1 + elif [[ "$1" =~ ^-(-)?k(eep-configs)?$ ]]; then + BUILD_KEEPCONFIGS=1 elif [[ "$1" =~ ^-(-)?n(o-cleanup)?$ ]]; then BUILD_CLEANUP=0 elif [[ "$1" =~ ^-(-)?v(ersion)?$ ]]; then @@ -61,7 +63,7 @@ while (( $# > 0 )); do exit 0 else printf "%s: %s: %s\\n" "${0##*/}" "Invalid option" "$1" >&2 - printf "%s: %s %s\\n" "Usage" "${0##*/}" "[[-f|--force]|[-n|--no-cleanup]|[-v|--version]]" >&2 + printf "%s: %s %s\\n" "Usage" "${0##*/}" "[[[-f|--force] [-k|--keep-configs] [-n|--no-cleanup]]|[-v|--version]]" >&2 exit 1 fi shift @@ -91,6 +93,7 @@ unset DIST_OS_VERSION_CODENAME # Build environment. BUILD_WORKDIR="${BUILD_WORKDIR:-/tmp/pkg-build}" BUILD_ROOT="$BUILD_WORKDIR/pkg-$PKG_NAME" +BUILD_CONFIG_ARCHIVE="${BUILD_CONFIG_ARCHIVE:-/tmp/pkg-config-archive}" BUILD_PREFIX="${BUILD_PREFIX:-/opt}" BUILD_ALTCC="${BUILD_ALTCC:-}" BUILD_ALTCXX="${BUILD_ALTCXX:-}" @@ -224,6 +227,16 @@ for ((I = 0; I < ${#SRC_DIRNAMES[@]}; I++)); do esac done +# Move the package configuration files into the archive. +[[ -e "$BUILD_ROOT/etc/$PKG_NAME" ]] && { + (( ${BUILD_KEEPCONFIGS:-0} == 0 )) && { + rm -rf "$BUILD_CONFIG_ARCHIVE/$PKG_NAME-$PKG_VERSION" + mkdir -p -m 755 "$BUILD_CONFIG_ARCHIVE/$PKG_NAME-$PKG_VERSION/etc/$PKG_NAME" || \ + die "Failed to create directory: $BUILD_CONFIG_ARCHIVE/$PKG_NAME-$PKG_VERSION/etc/$PKG_NAME" + mv "$BUILD_ROOT/etc/$PKG_NAME"/* "$BUILD_CONFIG_ARCHIVE/$PKG_NAME-$PKG_VERSION/etc/$PKG_NAME" || die "Failed to move configuration files to archive" + } +} + ################################################## # End of the only section that required editing. # ##################################################