Add support for keeping an archive of config files removed from packages. Update .gitignore.

This commit is contained in:
Darren 'Tadgy' Austin 2022-09-07 15:38:41 +01:00
commit 82ca966d4b
3 changed files with 33 additions and 5 deletions

View file

@ -1,5 +1,5 @@
#!/bin/bash
# Version: 0.6.3
# Version: 0.6.4
# Copyright (c) 2005-2022:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# 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. #
##################################################