From 31ffbc94cad9c0cb33c1c7786cb891e3896be4e6 Mon Sep 17 00:00:00 2001 From: Vekhir Date: Fri, 20 Oct 2023 14:11:20 +0200 Subject: [PATCH] Delete entire $srcdir upon clean build Currently, the file glob used to clean the $srcdir misses dotfiles. This commit instead removes the directory entirely and recreates it. Since the directory has to exist prior to deletion, the creation commands are duplicated. Perhaps they could be moved to a function later on. The directory cannot be removed while inside it, so the directory change is moved down the line. One important insight here is that almost all functions after it are actually independent of $pwd, allowing the optimization of just not changing directory. They do however depend on the existence of $srcdir, so it has to be recreated. The only exception to this is `extract_sources` which depends on $pwd being $srcdir. An alternative proposal wanted to extend the file matching for deletion, but it was deemed impractical. --- scripts/makepkg.sh.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 31cdf0d5..0b83bc53 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1334,10 +1334,9 @@ else fi fi -# get back to our src directory so we can begin with sources +# ensure existence of our src directory so we can begin with sources mkdir -p "$srcdir" chmod a-s "$srcdir" -cd_safe "$srcdir" if (( !REPKG )); then if (( NOEXTRACT && ! VERIFYSOURCE )); then @@ -1349,9 +1348,12 @@ if (( !REPKG )); then if (( CLEANBUILD )); then msg "$(gettext "Removing existing %s directory...")" "\$srcdir/" - rm -rf "$srcdir"/* + rm -rf "$srcdir" + mkdir -p "$srcdir" + chmod a-s "$srcdir" fi + cd_safe "$srcdir" extract_sources if (( PREPAREFUNC )); then run_prepare