From d7039996dbeabbc4c5e43ccd64622dad37c2a219 Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Thu, 11 Apr 2019 09:46:06 +0100 Subject: [PATCH 1/3] androdeb: allow buildtar without flashing device It's more convenient to have the buildtar step SKIP_DEVICE to generate the tar then use the --archive option in the second step to do the actual androdeb setup of the device. Also since INSTALL_BCC is now performed when creating the debian image we can always tar the deb.tar.gz without having to copy anything from the device. Also drop creating a zip version of the generated tarred file. Signed-off-by: Qais Yousef --- androdeb | 25 +++++++++---------------- buildstrap | 2 -- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/androdeb b/androdeb index 1859ee1..b1bddb8 100755 --- a/androdeb +++ b/androdeb @@ -60,7 +60,7 @@ case $key in --kernel-headers-targz) KERNELHDRS=$2; shift || true; shift || true; ;; --tempdir) TDIR="$2"; shift || true; shift || true; ;; --build) DOWNLOAD=0; shift || true; ;; - --buildtar) BTAR=1; DOWNLOAD=0; TARDIR="$2"; shift || true; shift || true; ;; + --buildtar) BTAR=1; DOWNLOAD=0; TARDIR="$2"; SKIP_DEVICE=1; shift || true; shift || true; ;; --device|-s) ADB="$ADB -s $2"; shift || true; shift || true; ;; --ssh) REMOTE="ssh"; SSH_URI="$2"; shift || true; shift || true; ;; --sshpass) SSHPASS="sshpass -p$2"; shift || true; shift || true; ;; @@ -324,6 +324,14 @@ sudo $spath/buildstrap $ARCH $DISTRO $TDIR $OUT_TMP \ $ex_files $INSTALL_BCC $SKIP_DEVICE rm $ex_files +# Extract a tar of the built, compiled and installed androdeb env +if [[ ! -z ${TARDIR+x} ]]; then + c_info "Creating tarball" + pushd $TARDIR + mv $TDIR/deb.tar.gz $FNAME_UZ + popd +fi + # If we only wanted to prepare a rootfs and don't have # a device connected, then just echo that and skip cleanup if [ $SKIP_DEVICE -eq 1 ]; then @@ -346,21 +354,6 @@ remote_copy $TDIR/deb.tar.gz /data/androdeb/ remote_copy $spath/addons/* /data/androdeb/ remote_shell /data/androdeb/device-unpack -# Extract a tar of the built, compiled and installed androdeb env -if [[ ! -z ${TARDIR+x} ]]; then - c_info "Creating tarball" - pushd $TARDIR - if [ $INSTALL_BCC -eq 0 ]; then - mv $TDIR/deb.tar.gz $FNAME_UZ - else - remote_shell /data/androdeb/build-debian-tar - remote_pull /data/androdeb/androdeb-fs.tgz $FNAME_UZ - remote_shell rm /data/androdeb/androdeb-fs.tgz; - fi - zip -r $FNAME $FNAME_UZ - popd -fi - do_cleanup all_done_banner diff --git a/buildstrap b/buildstrap index bdbc554..f8171ce 100755 --- a/buildstrap +++ b/buildstrap @@ -69,8 +69,6 @@ fi # Should we really do this? chmod -R 0777 $TDIR/ -[ $SKIP_DEVICE -eq 0 ] || exit 0 - c_info "Compressing new filesystem to prepare to push to Android /data/androdeb/" tar -zcf $TDIR/deb.tar.gz -C $TDIR debian From 23f245215c3b381abcf8c2fff97270d764c85752 Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Thu, 11 Apr 2019 12:37:25 +0100 Subject: [PATCH 2/3] androdeb: don't download headers if DOWNLOAD != 1 When --buildtar is specified the headers are downloaded and used where in reality we don't care about kheaders at this stage. Since DOWNLOAD=0 when --buildtar is specified, used that to control whether kheaders should be downloaded too. Signed-off-by: Qais Yousef --- androdeb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/androdeb b/androdeb index b1bddb8..e957fe9 100755 --- a/androdeb +++ b/androdeb @@ -259,7 +259,7 @@ if [ $DOWNLOAD -eq 1 ]; then TARF=$TDIR_ABS/$FNAME_UZ fi -if [ ! -z "$FULL" ] && [ -z "$KERNELSRC" ] && [ -z "$KERNELHDRS" ] && [ -z "$BI" ]; then +if [ ! -z "$FULL" ] && [ -z "$KERNELSRC" ] && [ -z "$KERNELHDRS" ] && [ -z "$BI" ] && [ $DOWNLOAD -eq 1 ]; then c_info "Kernel headers are needed but none were provided. Downloading pre-built headers" download_headers fi From a05874e061da429df4ae46964df313b2d8bec914 Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Thu, 11 Apr 2019 15:31:05 +0100 Subject: [PATCH 3/3] buildstrap: install trace-cmd and xz-utils I found myself needing to install these two packages regularly. The first to collect traces and teh 2nd to extract /proc/kheaders.tar.xz. So always make them available by default. Signed-off-by: Qais Yousef --- buildstrap | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildstrap b/buildstrap index f8171ce..3b24fa2 100755 --- a/buildstrap +++ b/buildstrap @@ -59,6 +59,9 @@ fi # Add a default DNS server echo "nameserver 4.2.2.2" > $OUT_TMP/etc/resolv.conf +chroot $OUT_TMP apt update || true +chroot $OUT_TMP apt install -y trace-cmd xz-utils || true + # Clone BCC if needed if [ $INSTALL_BCC -eq 1 ]; then git clone https://github.com/iovisor/bcc.git $TDIR/debian/bcc-master