build/distfiles: clean up subdiretories on manual arguments passed

This eases maintenance when trying to refetch smaller portions of
distfiles without losing the others.
This commit is contained in:
Franco Fichtner 2025-09-01 11:35:59 +02:00
parent c52a19d078
commit 31c3a2bc65
2 changed files with 19 additions and 1 deletions

View file

@ -641,6 +641,16 @@ setup_distfiles()
mkdir -p ${1}${PORTSDIR}
rm -rf ${1}${PORTSDIR}/distfiles
tar -C ${1}${PORTSDIR} -xpf ${DISTFILESET}
# clear all additional sub-directories passed
for DIR in ${@}; do
rm -rf ${1}${PORTSDIR}/distfiles/${DIR}
done
fi
if [ -n "${@}" ]; then
# in cleanup mode signal that we are done
return 1
fi
}

View file

@ -42,7 +42,15 @@ setup_base ${STAGEDIR}
setup_clone ${STAGEDIR} ${PORTSDIR}
setup_clone ${STAGEDIR} ${SRCDIR}
setup_chroot ${STAGEDIR}
setup_distfiles ${STAGEDIR}
if ! setup_distfiles ${STAGEDIR} ${@}; then
echo -n ">>> Recreating distfiles set... "
tar -C ${STAGEDIR}${PORTSDIR} -cf \
${SETSDIR}/distfiles-${PRODUCT_VERSION}.tar distfiles
echo "done"
exit 0
fi
extract_packages ${STAGEDIR} || true