download-aosp.sh: Add --no-extract/-X

Add a flag that prevents the script from extracting the downloaded
archive, allowing the caller to handle it themselves. When this new flag
is not passed, the behavior of the script remains the same.

Bug: 198568262
Test: build/cuttlefish/download-aosp.sh -X <...>
Change-Id: I6853254b241e0711400b1d4e826267fb9610f8da
diff --git a/cuttlefish/download-aosp.sh b/cuttlefish/download-aosp.sh
index 9bbf271..c0f51d4 100755
--- a/cuttlefish/download-aosp.sh
+++ b/cuttlefish/download-aosp.sh
@@ -12,6 +12,7 @@
 	echo "       -a | --arch                      : architecture to download for: x86, x86_64, arm64"
 	echo "       -A | --android                   : download the Android OS images (by default disabled)"
 	echo "       -C | --cuttlefish                : download the Cuttlefish host images (by default disabled)"
+	echo "       -X | --no-extract                : don't extract the downloaded archive (by default extracted)"
 	echo "       -h | --help                      : print this help message"
 }
 
@@ -19,7 +20,7 @@
 	local help=0
 	local params
 
-	if params=$(getopt -o 'a:ACh' -l 'arch:,android,cuttlefish,help' --name "$0" -- "$@"); then
+	if params=$(getopt -o 'a:AChX' -l 'arch:,android,cuttlefish,help,no-extract' --name "$0" -- "$@"); then
 		eval set -- "${params}"
 		while true; do
 			case "$1" in
@@ -55,6 +56,10 @@
 					help=1
 					shift
 					;;
+				-X|--no-extract)
+					EXTRACT=0
+					shift
+					;;
 				--)
 					shift
 					break
@@ -81,6 +86,7 @@
 
 DOWNLOAD_ANDROID=0
 DOWNLOAD_CF=0
+EXTRACT=1
 
 parse_opts $*
 
@@ -94,8 +100,10 @@
 	set -x
 	IMG=aosp_cf_${ARCH}_phone-img-$(echo $RURL | awk -F\/ '{print $6}').zip
 	wget -nv ${RURL%/view/BUILD_INFO}/raw/${IMG}
-	unzip "${IMG}"
-	rm -v "${IMG}"
+	if [ "${EXTRACT}" -eq 1 ]; then
+		unzip "${IMG}"
+		rm -v "${IMG}"
+	fi
 	set +x
 fi
 
@@ -105,7 +113,9 @@
 	echo "#"
 	set -x
 	wget -nv ${RURL%/view/BUILD_INFO}/raw/cvd-host_package.tar.gz
-	tar xzvf cvd-host_package.tar.gz
-	rm -v cvd-host_package.tar.gz
+	if [ "${EXTRACT}" -eq 1 ]; then
+		tar xzvf cvd-host_package.tar.gz
+		rm -v cvd-host_package.tar.gz
+	fi
 	set +x
 fi