diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-05-31 10:51:59 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-06-04 21:09:37 +0200 |
commit | f5aee262159f9b4b1eb3f8f9bf4f457afaab30be (patch) | |
tree | 901c370fc6686cac4488bc0f35e2669163839253 /scripts | |
parent | 34414684fb523f910b1ca57734d5c3e617c4daa7 (diff) | |
download | ptxdist-f5aee262159f9b4b1eb3f8f9bf4f457afaab30be.tar.gz ptxdist-f5aee262159f9b4b1eb3f8f9bf4f457afaab30be.tar.xz |
clean: make it more intelligent
Refuse to delete git repositories unless --force is used.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/ptxd_make_clean.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/lib/ptxd_make_clean.sh b/scripts/lib/ptxd_make_clean.sh new file mode 100644 index 000000000..18e332571 --- /dev/null +++ b/scripts/lib/ptxd_make_clean.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Copyright (C) 2019 by Michael Olbrich <m.olbrich@pengutronix.de> +# +# See CREDITS for details about who has contributed to this project. +# +# For further information about the PTXdist project and license conditions +# see the README file. +# + +ptxd_make_clean() { + local directory="${1}" + + if [ -e "${directory}" ]; then + if [ -h "${directory}" ! -d "${directory}" ]; then + rm -f "${directory}" + elif [ -n "${PTXDIST_FORCE}" ]; then + : # always delete with --force + elif [ -d "${directory}/.git" ]; then + ptxd_bailout "Refusing to delete git repository" \ + "$(ptxd_print_path "${directory}")" \ + "Delete anyways with --force." + fi + rm -rf "${directory}" + fi +} +export -f ptxd_make_clean |