build/debian: Add `-w` to keep temp workdir for debugging
When the build script fails to generate an image, it is useful to have the workdir for reproducing issues and for debugging purposes.
In this CL, we add a `-w` option to both containerized and native build scripts to keep the temp workdir.
Bug: None
Test: ./build_in_container.sh -a x86_64 -w
Change-Id: Ifed39cd3eed7cc1b624b23e1b7e3d865b66346c5
diff --git a/build/debian/build.sh b/build/debian/build.sh
index cf229aa..bd918dd 100755
--- a/build/debian/build.sh
+++ b/build/debian/build.sh
@@ -12,6 +12,7 @@
echo "-h Print usage and this help message and exit."
echo "-a ARCH Architecture of the image [default is aarch64]"
echo "-r Release mode build"
+ echo "-w Save temp work directory (for debugging)"
}
check_sudo() {
@@ -22,7 +23,7 @@
}
parse_options() {
- while getopts "hra:" option; do
+ while getopts "a:hrw" option; do
case ${option} in
h)
show_help
@@ -40,6 +41,9 @@
r)
mode=release
;;
+ w)
+ save_workdir=1
+ ;;
*)
echo "Invalid option: $OPTARG"
exit
@@ -213,7 +217,7 @@
}
clean_up() {
- rm -rf "${workdir}"
+ [ "$save_workdir" -eq 0 ] || rm -rf "${workdir}"
}
set -e
@@ -229,6 +233,7 @@
arch=aarch64
debian_arch=arm64
mode=debug
+save_workdir=0
parse_options "$@"
check_sudo