Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit fdc5200

Browse files
committed
build-image: Make device skipping more generic
Currently, build-image skips device preparation stages and doesn't even need a device connected, unlike other options. Make it more generic so that in the future other options can also use such functionality. Also results in a cleanup. Signed-off-by: Joel Fernandes <joel@joelfernandes.org>
1 parent c26696d commit fdc5200

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

androdeb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ source $spath/utils/banners
1313
# Set default vars
1414
DISTRO=buster; ARCH=arm64
1515
ADB="adb"
16+
SKIP_DEVICE=0 # Skip device preparation
1617

1718
# Default packages
1819
DEFAULT_PACKAGES+="bash
@@ -60,7 +61,7 @@ case $key in
6061
--tempdir) TDIR="$2"; shift || true; shift || true; ;;
6162
--buildtar) TARDIR="$2"; shift || true; shift || true; ;;
6263
--device|-s) ADB="$ADB -s $2"; shift || true; shift || true; ;;
63-
--build-image) BUILD_IMAGE=$2; shift || true; shift || true; ;;
64+
--build-image) BI=1; BUILD_IMAGEF=$2; SKIP_DEVICE=1; shift || true; shift || true; ;;
6465
--debug) set -x; shift || true; ;;
6566
*) c_error "Unknown option ($1)"; usage; ;;
6667
esac
@@ -111,7 +112,7 @@ fi
111112

112113
if [[ ! -z ${TARDIR+x} ]] && [[ ! -d $TARDIR ]]; then die 7 "Tar dir specified doesn't exist"; fi
113114

114-
if [ -z "$BUILD_IMAGE" ]; then
115+
if [ -z $BI ]; then
115116
do_adb_root "$ADB"
116117

117118
if [ $? -ne 0 ]; then
@@ -123,6 +124,8 @@ if [ -z "$BUILD_IMAGE" ]; then
123124
c_error "packages on your distro, or by installing the Android SDK."
124125
die 3 "Exiting."
125126
fi
127+
else
128+
[ ! -z $BUILD_IMAGEF ] || die 8 "--build-image passed but no image file provided"
126129
fi
127130

128131
if [ ! -z "$REMOVE" ]; then
@@ -267,19 +270,17 @@ c_info "Using temporary directory: $TDIR"
267270

268271
if [[ $EUID -ne 0 ]]; then c_info "The next stage runs as sudo, please enter password if asked."; fi
269272

270-
SKIP_COMPRESS=0; if [ ! -z "$BUILD_IMAGE" ]; then SKIP_COMPRESS=1; fi
271-
272273
ex_files=$(mktemp); echo $EXTRA_FILES > $ex_files
273274

274275
sudo $spath/buildstrap $ARCH $DISTRO $TDIR $OUT_TMP \
275276
"$(make_csv "$PACKAGES")"\
276-
$ex_files $INSTALL_BCC $SKIP_COMPRESS
277+
$ex_files $INSTALL_BCC $SKIP_DEVICE
277278
rm $ex_files
278279

279280
# If we only wanted to prepare a rootfs and don't have
280281
# a device connected, then just echo that and skip cleanup
281-
if [ ! -z "$BUILD_IMAGE" ]; then
282-
c_info "For --build-image, only the image is built."
282+
if [ $SKIP_DEVICE -eq 1 ]; then
283+
c_info "Device preparation is being skipped for the selected options"
283284
c_info "any builds that need to happen on device may be cloned but not built."
284285
sudo $spath/buildimage $OUT_TMP $(dirname $BUILD_IMAGE)/$(basename $BUILD_IMAGE)
285286
sudo chmod a+rw $(dirname $BUILD_IMAGE)/$(basename $BUILD_IMAGE)

buildstrap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ OUT_TMP=$4
1111
PACKAGES=$5
1212
EXTRA_FILES="$(cat $6)"
1313
INSTALL_BCC=$7
14-
SKIP_COMPRESS=$8
14+
SKIP_DEVICE=$8 # Skip any device-specific stages
1515

1616
time qemu-debootstrap --arch $ARCH --include=$PACKAGES \
1717
$DISTRO $OUT_TMP http://deb.debian.org/debian/
@@ -65,7 +65,7 @@ cp $spath/bcc/build-bcc.sh $TDIR/debian/bcc-master/; fi
6565
# Should be really do this?
6666
chmod -R 0777 $TDIR/
6767

68-
if [ $SKIP_COMPRESS -eq 1 ]; then exit 0; fi
68+
if [ $SKIP_DEVICE -eq 1 ]; then exit 0; fi
6969

7070
c_info "Compressing new filesystem to prepare to push to Android /data/androdeb/"
7171
tar -zcf $TDIR/deb.tar.gz -C $TDIR debian

0 commit comments

Comments
 (0)