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.
This commit is contained in:
Vekhir 2023-10-20 14:11:20 +02:00 committed by Allan McRae
parent e9b385a636
commit 31ffbc94ca

View file

@ -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