blob: 5fed520726636141dc3553eaa1916207e53b2c26 [file] [log] [blame]
Joel Fernandes301e4552018-04-05 22:46:19 -07001#!/bin/bash
2
Joel Fernandes9d767b42018-04-05 22:55:24 -07003spath="$(dirname "$(readlink -f "$0")")"
4source $spath/utils/android
5source $spath/utils/banners
6
Joel Fernandes301e4552018-04-05 22:46:19 -07007ARCH=$1
8DISTRO=$2
9TDIR=$3
10OUT_TMP=$4
11PACKAGES=$5
Joel Fernandes (Google)57b3fd22018-05-29 16:27:03 -070012EXTRA_FILES="$(cat $6)"
Joel Fernandes (Google)4b216fd2018-05-29 12:33:27 -070013INSTALL_BCC=$7
14SKIP_COMPRESS=$8
Joel Fernandes301e4552018-04-05 22:46:19 -070015
Joel Fernandes (Google)4f711082018-05-29 16:23:15 -070016time qemu-debootstrap --arch $ARCH --include=$PACKAGES \
Joel Fernandes301e4552018-04-05 22:46:19 -070017 $DISTRO $OUT_TMP http://deb.debian.org/debian/
18
19# Some reason debootstrap leaves these mounted
20umount $OUT_TMP/proc/sys/fs/binfmt_misc || true
21umount $OUT_TMP/proc || true
22
23# Make bash the default shell
24chroot $OUT_TMP rm /bin/sh || true
25chroot $OUT_TMP ln -s /bin/bash /bin/sh || true
26cp $spath/addons/bashrc $OUT_TMP/.bashrc
27
Joel Fernandes (Google)4b216fd2018-05-29 12:33:27 -070028for f in $EXTRA_FILES; do
29 if [ $f == "none" ]; then continue; fi
30 cp $f $OUT_TMP/
31done
32
Joel Fernandes301e4552018-04-05 22:46:19 -070033# Cleanup
34rm -rf $OUT_TMP/lib/udev/*
35rm -rf $OUT_TMP/var/lib/apt/lists/*
36rm -rf $OUT_TMP/var/cache/apt/archives/*deb
37rm -rf $OUT_TMP/usr/share/locale/*
38rm -rf $OUT_TMP/usr/lib/share/locale/*
39rm -rf $OUT_TMP/usr/share/doc/*
40rm -rf $OUT_TMP/usr/lib/share/doc/*
41rm -rf $OUT_TMP/usr/share/ieee-data/*
42rm -rf $OUT_TMP/usr/lib/share/ieee-data/*
43rm -rf $OUT_TMP/usr/share/man/*
44rm -rf $OUT_TMP/usr/lib/share/man/*
45
46# Clone BCC if needed
47if [[ ! -z ${INSTALL_BCC+x} ]]; then
48git clone https://github.com/iovisor/bcc.git $TDIR/debian/bcc-master
49cp $spath/bcc/build-bcc.sh $TDIR/debian/bcc-master/; fi
50
Joel Fernandes (Google)9c3ae932018-05-28 14:34:48 -070051# Should be really do this?
52chmod -R 0777 $TDIR/
53
54if [ $SKIP_COMPRESS -eq 1 ]; then exit 0; fi
55
Joel Fernandes301e4552018-04-05 22:46:19 -070056echo "Compressing new filesystem to prepare to push to Android /data/androdeb/"
57tar -zcf $TDIR/deb.tar.gz -C $TDIR debian
58
Joel Fernandes301e4552018-04-05 22:46:19 -070059chmod 0777 $TDIR/deb.tar.gz