1
0
mirror of https://github.com/lineageos4microg/docker-lineage-cicd synced 2024-11-09 10:09:56 +01:00

Add do_cleanup function

This commit is contained in:
Pete Fotheringham 2024-09-02 11:39:24 +01:00
parent b76678c67b
commit 8b67dbd91f

@ -45,3 +45,34 @@
# - call `post-build.sh`
# - call `do_cleanup`
# - call `end.sh`
# do_cleanup function
do_cleanup() {
echo ">> [$(date)] Cleaning up" | tee -a "$DEBUG_LOG"
if [ "$BUILD_OVERLAY" = true ]; then
# The Jack server must be stopped manually, as we want to unmount $TMP_DIR/merged
cd "$TMP_DIR"
if [ -f "$TMP_DIR/merged/prebuilts/sdk/tools/jack-admin" ]; then
"$TMP_DIR/merged/prebuilts/sdk/tools/jack-admin kill-server" &> /dev/null || true
fi
lsof | grep "$TMP_DIR/merged" | awk '{ print $2 }' | sort -u | xargs -r kill &> /dev/null || true
while lsof | grep -q "$TMP_DIR"/merged; do
sleep 1
done
umount "$TMP_DIR/merged"
fi
if [ "$CLEAN_AFTER_BUILD" = true ]; then
echo ">> [$(date)] Cleaning source dir for device $codename" | tee -a "$DEBUG_LOG"
if [ "$BUILD_OVERLAY" = true ]; then
cd "$TMP_DIR"
rm -rf ./* || true
else
cd "$source_dir"
(set +eu ; mka "${jobs_arg[@]}" clean) &>> "$DEBUG_LOG"
fi
fi
}