@@ -15,50 +15,57 @@ SKIP_DEVICE=$8 # Skip any device-specific stages
1515MIRROR=$9
1616VARIANT=" --variant=minbase"
1717
18- time qemu-debootstrap --arch $ARCH --include=$PACKAGES $VARIANT \
18+ root=sudo
19+
20+ if [ $EUID -ne 0 ]; then echo " The next stage runs as sudo, please enter password if asked." ; fi
21+
22+ # It's easier to just really be root for debootstrap
23+ time $root qemu-debootstrap --arch $ARCH --include=$PACKAGES $VARIANT \
1924 $DISTRO $OUT_TMP $MIRROR
2025
2126# Some reason debootstrap leaves these mounted
22- umount $OUT_TMP /proc/sys/fs/binfmt_misc || true
23- umount $OUT_TMP /proc || true
27+ $root umount $OUT_TMP /proc/sys/fs/binfmt_misc || true
28+ $root umount $OUT_TMP /proc || true
2429
2530# Make bash the default shell
26- chroot $OUT_TMP rm /bin/sh || true
27- chroot $OUT_TMP ln -s /bin/bash /bin/sh || true
28- cp $spath /addons/bashrc $OUT_TMP /.bashrc
29- cp $spath /addons/bashrc.common $OUT_TMP /.bashrc.common
30- cp $spath /addons/bashrc.silent $OUT_TMP /.bashrc.silent
31- cp $spath /addons/get_kvers.sh $OUT_TMP /
31+ $root ln -sf /bin/bash $OUT_TMP /bin/sh || true
32+ $root cp $spath /addons/bashrc $OUT_TMP /.bashrc
33+ $root cp $spath /addons/bashrc.common $OUT_TMP /.bashrc.common
34+ $root cp $spath /addons/bashrc.silent $OUT_TMP /.bashrc.silent
35+ $root cp $spath /addons/get_kvers.sh $OUT_TMP /
3236
3337for f in $EXTRA_FILES ; do
3438 if [ $f == " none" ]; then continue ; fi
35- cp $f $OUT_TMP /
39+ $root cp $f $OUT_TMP /
3640done
3741
3842# Cleanup
39- rm -rf $OUT_TMP /lib/udev/*
40- rm -rf $OUT_TMP /var/lib/apt/lists/*
41- rm -rf $OUT_TMP /var/cache/apt/archives/* deb
42- rm -rf $OUT_TMP /usr/share/locale/*
43- rm -rf $OUT_TMP /usr/lib/share/locale/*
44- rm -rf $OUT_TMP /usr/share/doc/*
45- rm -rf $OUT_TMP /usr/lib/share/doc/*
46- rm -rf $OUT_TMP /usr/share/ieee-data/*
47- rm -rf $OUT_TMP /usr/lib/share/ieee-data/*
48- rm -rf $OUT_TMP /usr/share/man/*
49- rm -rf $OUT_TMP /usr/lib/share/man/*
43+ $root rm -rf $OUT_TMP /lib/udev/*
44+ $root rm -rf $OUT_TMP /var/lib/apt/lists/*
45+ $root rm -rf $OUT_TMP /var/cache/apt/archives/* deb
46+ $root rm -rf $OUT_TMP /usr/share/locale/*
47+ $root rm -rf $OUT_TMP /usr/lib/share/locale/*
48+ $root rm -rf $OUT_TMP /usr/share/doc/*
49+ $root rm -rf $OUT_TMP /usr/lib/share/doc/*
50+ $root rm -rf $OUT_TMP /usr/share/ieee-data/*
51+ $root rm -rf $OUT_TMP /usr/lib/share/ieee-data/*
52+ $root rm -rf $OUT_TMP /usr/share/man/*
53+ $root rm -rf $OUT_TMP /usr/lib/share/man/*
5054
5155# Fix apt-get issue: Android requires _apt user to be in the
5256# AID_INET group which is also android specific.
5357grep -ri _apt:x:100:65534 $OUT_TMP /etc/passwd > /dev/null 2>&1
5458if [ $? -ne 0 ]; then
5559 c_warning " _apt user cannot be added to AID_INET group"
5660else
57- sed -i -e ' s/_apt:x:100:65534/_apt:x:100:3003/' $OUT_TMP /etc/passwd
61+ $root sed -i -e ' s/_apt:x:100:65534/_apt:x:100:3003/' \
62+ $OUT_TMP /etc/passwd
5863fi
5964
6065# Add a default DNS server
61- echo " nameserver 4.2.2.2" > $OUT_TMP /etc/resolv.conf
66+ $root tee -a $OUT_TMP /etc/resolv.conf > /dev/null << EOF
67+ nameserver 4.2.2.2
68+ EOF
6269
6370# Clone BCC if needed
6471if [ $INSTALL_BCC -eq 1 ]; then
@@ -71,12 +78,10 @@ if [ $INSTALL_BCC -eq 1 ]; then
7178 popd
7279fi
7380
74- # Should be really do this?
75- chmod -R 0777 $TDIR /
76-
7781[ $SKIP_DEVICE -eq 0 ] || exit 0
7882
7983c_info " Compressing new filesystem to prepare to push to Android /data/androdeb/"
80- tar -zcf $TDIR /deb.tar.gz -C $TDIR debian
8184
82- chmod 0777 $TDIR /deb.tar.gz
85+ $root tar -zpcf $TDIR /deb.tar.gz -C $TDIR debian
86+
87+ $root chown --reference=$TDIR $TDIR /deb.tar.gz
0 commit comments