From 34331ef6ba79cf444503909cb716ab5bd334d828 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sun, 21 Mar 2021 21:39:59 +0100 Subject: [PATCH] - add small script to cleanup target --- make/buildsystem-helpers.mk | 1 + support/scripts/target-remove.sh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 support/scripts/target-remove.sh diff --git a/make/buildsystem-helpers.mk b/make/buildsystem-helpers.mk index c236df1e..97ea6e4c 100644 --- a/make/buildsystem-helpers.mk +++ b/make/buildsystem-helpers.mk @@ -115,6 +115,7 @@ GET_GIT_ARCHIVE = support/scripts/get-git-archive.sh GET_GIT_SOURCE = support/scripts/get-git-source.sh GET_SVN_SOURCE = support/scripts/get-svn-source.sh UPDATE-RC.D = support/scripts/update-rc.d -r $(TARGET_DIR) +TARGET_RM = support/scripts/target-remove.sh $(TARGET_DIR) $(REMOVE_DIR) # ----------------------------------------------------------------------------- diff --git a/support/scripts/target-remove.sh b/support/scripts/target-remove.sh new file mode 100755 index 00000000..17267732 --- /dev/null +++ b/support/scripts/target-remove.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# move files/dirs from TARGET_DIR to REMOVE_DIR +# +# (C) 2021 vanhofen +# License: WTFPLv2 +# +# parameters: +# * TARGET_DIR (absolute path) +# * REMOVE_DIR (subdir inside TARGET_DIR) +# * file(s) or dir(s) to remove (*must* be located inside TARGET_DIR) + +TARGET_DIR="$1" +REMOVE_DIR=$(echo $2 | sed -e 's/^\///') # remove leading slash +shift 2 + +# exit on error +set -e + +cd ${TARGET_DIR} +for r in $@; do + r=${r//${TARGET_DIR}\//} + mkdir -p $(dirname ${REMOVE_DIR}/${r}) + mv -v ${r} ${REMOVE_DIR}/${r} +done