blob: 881dcbc0c809f28dafe8b27a2926f9f3a3fcf77e [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 Fernandes9d767b42018-04-05 22:55:24 -070012INSTALL_BCC=$6
Joel Fernandes301e4552018-04-05 22:46:19 -070013
14time qemu-debootstrap --arch $ARCH --include=$(make_csv "$PACKAGES") \
15 $DISTRO $OUT_TMP http://deb.debian.org/debian/
16
17# Some reason debootstrap leaves these mounted
18umount $OUT_TMP/proc/sys/fs/binfmt_misc || true
19umount $OUT_TMP/proc || true
20
21# Make bash the default shell
22chroot $OUT_TMP rm /bin/sh || true
23chroot $OUT_TMP ln -s /bin/bash /bin/sh || true
24cp $spath/addons/bashrc $OUT_TMP/.bashrc
25
26# Cleanup
27rm -rf $OUT_TMP/lib/udev/*
28rm -rf $OUT_TMP/var/lib/apt/lists/*
29rm -rf $OUT_TMP/var/cache/apt/archives/*deb
30rm -rf $OUT_TMP/usr/share/locale/*
31rm -rf $OUT_TMP/usr/lib/share/locale/*
32rm -rf $OUT_TMP/usr/share/doc/*
33rm -rf $OUT_TMP/usr/lib/share/doc/*
34rm -rf $OUT_TMP/usr/share/ieee-data/*
35rm -rf $OUT_TMP/usr/lib/share/ieee-data/*
36rm -rf $OUT_TMP/usr/share/man/*
37rm -rf $OUT_TMP/usr/lib/share/man/*
38
39# Clone BCC if needed
40if [[ ! -z ${INSTALL_BCC+x} ]]; then
41git clone https://github.com/iovisor/bcc.git $TDIR/debian/bcc-master
42cp $spath/bcc/build-bcc.sh $TDIR/debian/bcc-master/; fi
43
44echo "Compressing new filesystem to prepare to push to Android /data/androdeb/"
45tar -zcf $TDIR/deb.tar.gz -C $TDIR debian
46
47chmod -R 0777 $TDIR/
48
49chmod 0777 $TDIR/deb.tar.gz