From 579d79ef92c4ef1cbd72c821415bb2ad089df4d3 Mon Sep 17 00:00:00 2001 From: William Douglas Date: Tue, 19 Sep 2023 11:22:00 -0700 Subject: [PATCH] Make clean-pkgs-dir backup things it cleans up If something already exists in backup form, skip it, otherwise move the content to the backup directory. Signed-off-by: William Douglas --- Makefile.toplevel | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile.toplevel b/Makefile.toplevel index 76059dd..f9931fa 100644 --- a/Makefile.toplevel +++ b/Makefile.toplevel @@ -129,8 +129,13 @@ pull: ${PULL_PKGS} #help removes the associated package repos from the ./packages tree clean-pkgs-dir: $(PACKAGES_FILE) @for p in ${PKGS_ORPHANED}; do \ - echo "Removing $$p from packages, it is no longer in common/packages."; \ - rm -rf packages/$$p; \ + mkdir -p packages_old; \ + if [ -d "packages_old/$$p" ]; then \ + echo "packages_old/$$p already exists, not touching it"; \ + else \ + echo "Moving $$p from packages to packages_old, as it is no longer in common/packages."; \ + mv packages/$$p packages_old/$$p; \ + fi; \ done @echo "packages directory cleaned";