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@gentoo.org>
This commit is contained in:
Mike Frysinger 2020-05-31 12:43:59 -04:00
parent cfc55d1712
commit 0d1104d04f

View file

@ -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=()