Allow re-using extracted content
Usage:
export TMPDIR=/some/dir/$device
export SKIP_CLEANUP=true
Change-Id: I41b992708ca5fc7bc377b22a418f5fd1395cd08a
diff --git a/extract_utils.sh b/extract_utils.sh
index e91ad5a..6297411 100644
--- a/extract_utils.sh
+++ b/extract_utils.sh
@@ -19,7 +19,8 @@
ARCHES=
FULLY_DEODEXED=-1
-TMPDIR=$(mktemp -d)
+SKIP_CLEANUP=${SKIP_CLEANUP:-0}
+TMPDIR=${TMPDIR:-$(mktemp -d)}
HOST="$(uname | tr '[:upper:]' '[:lower:]')"
#
@@ -28,7 +29,11 @@
# kill our tmpfiles with fire on exit
#
function cleanup() {
- rm -rf "${TMPDIR:?}"
+ if [ "$SKIP_CLEANUP" == "true" ] || [ "$SKIP_CLEANUP" == "1" ]; then
+ echo "Skipping cleanup of $TMPDIR"
+ else
+ rm -rf "${TMPDIR:?}"
+ fi
}
trap cleanup 0