From 37e8cb6145f189b805aa58c7d560b1adf51377a7 Mon Sep 17 00:00:00 2001 From: bakkeby Date: Tue, 16 Apr 2024 21:52:13 +0200 Subject: [PATCH] Adding option to keep the original patches.h and config.h files when finalizing --- flexipatch-finalizer.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/flexipatch-finalizer.sh b/flexipatch-finalizer.sh index 39f11a9..fd9809f 100755 --- a/flexipatch-finalizer.sh +++ b/flexipatch-finalizer.sh @@ -44,6 +44,10 @@ while (( $# )); do shift KEEP_GITFILES=1 ;; + -p|--patches) + shift + KEEP_PATCHES=1 + ;; -h|--help) shift fmt=" %-31s%s\n" @@ -59,6 +63,7 @@ while (( $# )); do printf "$fmt" "-h, --help" "display this help section" printf "$fmt" "-k, --keep" "keep temporary files and do not replace the original ones" printf "$fmt" "-g, --git" "keep .git files" + printf "$fmt" "-p, --patches" "keep patches.h and the original config.h file" printf "$fmt" "-e, --echo" "echo commands that will be run rather than running them" printf "$fmt" " --debug" "prints additional debug information to stderr" printf "\nWarning! This script alters and removes files within the source directory." @@ -267,6 +272,11 @@ END { for FILE in $(find $DIRECTORY -name "*.~"); do chmod --reference=${FILE%%.~} ${FILE} if [[ $KEEP_FILES = 0 ]] || [[ $ECHO_COMMANDS = 1 ]]; then + + if [[ $KEEP_PATCHES = 1 ]] && [[ "${FILE}" == "${DIRECTORY}/config.h.~" ]]; then + mv ${DIRECTORY}/config.h ${DIRECTORY}/config.orig.h + fi + if [[ $ECHO_COMMANDS = 1 ]]; then echo "mv ${FILE} ${FILE%%.~}" else @@ -299,6 +309,11 @@ if [[ $KEEP_FILES = 0 ]] || [[ $ECHO_COMMANDS = 1 ]]; then fi for FILE in $FILES_TO_DELETE ${DIRECTORY}/patches.def.h; do + + if [[ $KEEP_PATCHES = 1 ]] && [[ "$FILE" == "${DIRECTORY}/patches.h" ]]; then + continue + fi + if [[ $ECHO_COMMANDS = 1 ]]; then echo "rm $FILE" else