commit:     0d1104d04fefd4ca6f78fc3721be05cabd77eb19
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun May 31 16:43:59 2020 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun May 31 16:43:59 2020 +0000
URL:        https://gitweb.gentoo.org/proj/releng.git/commit/?id=0d1104d0

catalyst-auto: fix preclean logic after snapshot changes

The snapshot generation logic was moved earlier in the build (before
the cleaning logic) which caused the preclean to nuke the freshly
generated cache.  Move all the preclean logic back up before that.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 tools/catalyst-auto | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/tools/catalyst-auto b/tools/catalyst-auto
index a1e1d7f2..34238c01 100755
--- a/tools/catalyst-auto
+++ b/tools/catalyst-auto
@@ -280,6 +280,21 @@ run_catalyst_commands() {
                fi
        fi
 
+       # Nuke any previous tmpdirs to keep them from accumulating.
+       if [[ ${preclean} == 1 ]]; then
+               rm -rf "${TMP_PATH:-/tmp}/catalyst-auto".*
+
+               snapshot_cache=$(catalyst_var snapshot_cache)
+               if [[ -z ${snapshot_cache} ]]; then
+                       echo "error: snapshot_cache not set in config file"
+                       exit 1
+               fi
+               pushd "${BUILD_SRCDIR_BASE}" >/dev/null || exit 1
+               rm -rf --one-file-system \
+                       kerncache packages snapshots tmp "${snapshot_cache}"/*
+               popd >/dev/null
+       fi
+
        if catalyst --help | grep -q "git-treeish"; then
                snapshot_log=$(mktemp --tmpdir="${TMP_PATH:-/tmp}")
                if ! run_cmd "${snapshot_log}" catalyst -c "${CATALYST_CONFIG}" 
-s stable; then
@@ -301,12 +316,6 @@ run_catalyst_commands() {
        DATESTAMP=$(date -u +%Y%m%d)
        TMPDIR=$(mktemp -d --tmpdir="${TMP_PATH:-/tmp}" 
"catalyst-auto.${TIMESTAMP}.XXXXXX")
 
-       # Nuke any previous tmpdirs to keep them from accumulating.
-       if [[ ${preclean} == 1 ]]; then
-               rm -rf "${TMPDIR%.??????}".*
-               mkdir "${TMPDIR}"
-       fi
-
        if [[ ${verbose} -ge 1 ]]; then
                echo "TMPDIR = ${TMPDIR}"
                echo "TIMESTAMP = ${TIMESTAMP}"
@@ -371,18 +380,6 @@ run_catalyst_commands() {
                exit
        fi
 
-       if [[ ${preclean} == 1 ]]; then
-               snapshot_cache=$(catalyst_var snapshot_cache)
-               if [[ -z ${snapshot_cache} ]]; then
-                       echo "error: snapshot_cache not set in config file"
-                       exit 1
-               fi
-               pushd "${BUILD_SRCDIR_BASE}" >/dev/null || exit 1
-               rm -rf --one-file-system \
-                       kerncache packages snapshots tmp "${snapshot_cache}"/*
-               popd >/dev/null
-       fi
-
        build_failure=0
 
        timeprefix=()

Reply via email to