This repository was archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 106
Add Ubuntu Base support, minimal python, python-scapy workaround #3
Open
adelva1984
wants to merge
3
commits into
joelagnel:master
Choose a base branch
from
adelva1984:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,12 +11,13 @@ source $spath/utils/support | |
| source $spath/utils/banners | ||
|
|
||
| # Set default vars | ||
| DISTRO=buster; ARCH=arm64 | ||
| DISTRO=buster; ARCH=arm64; MIRROR=http://deb.debian.org/debian/ | ||
| ADB="adb" | ||
| FULL=0 # Default to a minimal install | ||
| DOWNLOAD=1 # Default to downloading from web | ||
| SKIP_DEVICE=0 # Skip device preparation | ||
| INSTALL_BCC=0 # Decide if BCC is to be installed | ||
| FOREIGN=0 # Use debootstrap --foreign mode | ||
|
|
||
| # Default packages | ||
| PACKAGES="" | ||
|
|
@@ -51,6 +52,8 @@ case $key in | |
| prepare) PREPARE=1; shift || true; ;; | ||
| --full) FULL=1; config_full_build; shift || true; ;; | ||
| --arch) ARCH=$2; shift || true; shift || true; ;; | ||
| --distro) DISTRO="$2"; shift || true; shift || true; ;; | ||
| --foreign) FOREIGN=1; shift || true; ;; | ||
| --archive) TARF=$2; shift || true; shift || true; ;; | ||
| --bcc) source $spath/packages/bcc; shift || true; ;; | ||
| --kernelsrc) KERNELSRC="$2"; shift || true; shift || true; ;; | ||
|
|
@@ -80,6 +83,24 @@ if [ ! -z $BTAR ] && [ -z $TARDIR ]; then | |
| TARDIR=$spath | ||
| fi | ||
|
|
||
| case $ARCH in | ||
| i386) ;; | ||
| amd64) ;; | ||
| arm64) ;; | ||
| armhf) ;; | ||
| *) echo "Unsupported arch ($ARCH)"; ;; | ||
| esac | ||
|
|
||
| case $DISTRO in | ||
| buster) ;; | ||
| bionic) | ||
| if [ "$ARCH" == "i386" -o "$ARCH" == "amd64" ]; then | ||
| MIRROR=http://archive.ubuntu.com/ubuntu/ | ||
| else | ||
| MIRROR=http://ports.ubuntu.com/; fi ;; | ||
| *) echo "Unusupported distro ($DISTRO)"; ;; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you change to "Warning: Untested distro ($DISTRO)" ? |
||
| esac | ||
|
|
||
| if [ ! -z "$GIT_PULL" ]; then | ||
| c_info "Updating androdeb by git pull" | ||
| cd $spath | ||
|
|
@@ -279,13 +300,10 @@ fi | |
| PACKAGES+="$DEFAULT_PACKAGES" | ||
| c_info "Using temporary directory: $TDIR" | ||
|
|
||
| if [[ $EUID -ne 0 ]]; then c_info "The next stage runs as sudo, please enter password if asked."; fi | ||
|
|
||
| ex_files=$(mktemp); echo $EXTRA_FILES > $ex_files | ||
|
|
||
| sudo $spath/buildstrap $ARCH $DISTRO $TDIR $OUT_TMP \ | ||
| "$(make_csv "$PACKAGES")"\ | ||
| $ex_files $INSTALL_BCC $SKIP_DEVICE | ||
| $spath/buildstrap $ARCH $DISTRO $TDIR $OUT_TMP "$PACKAGES" \ | ||
| $ex_files $INSTALL_BCC $SKIP_DEVICE $MIRROR $FOREIGN | ||
| rm $ex_files | ||
|
|
||
| # If we only wanted to prepare a rootfs and don't have | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,56 +8,70 @@ ARCH=$1 | |
| DISTRO=$2 | ||
| TDIR=$3 | ||
| OUT_TMP=$4 | ||
| PACKAGES=$5 | ||
| PACKAGES="$(make_csv "$5")" | ||
| EXTRA_FILES="$(cat $6)" | ||
| INSTALL_BCC=$7 | ||
| SKIP_DEVICE=$8 # Skip any device-specific stages | ||
| MIRROR=$9 | ||
| shift | ||
| FOREIGN=$9 | ||
| VARIANT="--variant=minbase" | ||
|
|
||
| time qemu-debootstrap --arch $ARCH --include=$PACKAGES $VARIANT \ | ||
| $DISTRO $OUT_TMP http://deb.debian.org/debian/ | ||
| if [ $FOREIGN -eq 1 ]; then | ||
| debootstrap="debootstrap --foreign" | ||
| root=fakeroot | ||
| else | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since these if/else blocks are so huge, I suggest split them into 2 different functions. Maybe |
||
| if [ $EUID -ne 0 ]; then echo "The next stage runs as sudo, please enter password if asked."; fi | ||
| debootstrap=qemu-debootstrap | ||
| root=sudo | ||
| fi | ||
|
|
||
| time $root $debootstrap --arch $ARCH --include=$PACKAGES $VARIANT \ | ||
| $DISTRO $OUT_TMP $MIRROR | ||
|
|
||
| # Some reason debootstrap leaves these mounted | ||
| umount $OUT_TMP/proc/sys/fs/binfmt_misc || true | ||
| umount $OUT_TMP/proc || true | ||
| $root umount $OUT_TMP/proc/sys/fs/binfmt_misc || true | ||
| $root umount $OUT_TMP/proc || true | ||
|
|
||
| # Make bash the default shell | ||
| chroot $OUT_TMP rm /bin/sh || true | ||
| chroot $OUT_TMP ln -s /bin/bash /bin/sh || true | ||
| cp $spath/addons/bashrc $OUT_TMP/.bashrc | ||
| cp $spath/addons/bashrc.common $OUT_TMP/.bashrc.common | ||
| cp $spath/addons/bashrc.silent $OUT_TMP/.bashrc.silent | ||
| cp $spath/addons/get_kvers.sh $OUT_TMP/ | ||
| $root ln -sf /bin/bash $OUT_TMP/bin/sh || true | ||
| $root cp $spath/addons/bashrc $OUT_TMP/.bashrc | ||
| $root cp $spath/addons/bashrc.common $OUT_TMP/.bashrc.common | ||
| $root cp $spath/addons/bashrc.silent $OUT_TMP/.bashrc.silent | ||
| $root cp $spath/addons/get_kvers.sh $OUT_TMP/ | ||
|
|
||
| for f in $EXTRA_FILES; do | ||
| if [ $f == "none" ]; then continue; fi | ||
| cp $f $OUT_TMP/ | ||
| $root cp $f $OUT_TMP/ | ||
| done | ||
|
|
||
| # Cleanup | ||
| rm -rf $OUT_TMP/lib/udev/* | ||
| rm -rf $OUT_TMP/var/lib/apt/lists/* | ||
| rm -rf $OUT_TMP/var/cache/apt/archives/*deb | ||
| rm -rf $OUT_TMP/usr/share/locale/* | ||
| rm -rf $OUT_TMP/usr/lib/share/locale/* | ||
| rm -rf $OUT_TMP/usr/share/doc/* | ||
| rm -rf $OUT_TMP/usr/lib/share/doc/* | ||
| rm -rf $OUT_TMP/usr/share/ieee-data/* | ||
| rm -rf $OUT_TMP/usr/lib/share/ieee-data/* | ||
| rm -rf $OUT_TMP/usr/share/man/* | ||
| rm -rf $OUT_TMP/usr/lib/share/man/* | ||
| $root rm -rf $OUT_TMP/lib/udev/* | ||
| $root rm -rf $OUT_TMP/var/lib/apt/lists/* | ||
| $root rm -rf $OUT_TMP/var/cache/apt/archives/*deb | ||
| $root rm -rf $OUT_TMP/usr/share/locale/* | ||
| $root rm -rf $OUT_TMP/usr/lib/share/locale/* | ||
| $root rm -rf $OUT_TMP/usr/share/doc/* | ||
| $root rm -rf $OUT_TMP/usr/lib/share/doc/* | ||
| $root rm -rf $OUT_TMP/usr/share/ieee-data/* | ||
| $root rm -rf $OUT_TMP/usr/lib/share/ieee-data/* | ||
| $root rm -rf $OUT_TMP/usr/share/man/* | ||
| $root rm -rf $OUT_TMP/usr/lib/share/man/* | ||
|
|
||
| # Fix apt-get issue: Android requires _apt user to be in the | ||
| # AID_INET group which is also android specific. | ||
| grep -ri _apt:x:100:65534 $OUT_TMP/etc/passwd > /dev/null 2>&1 | ||
| if [ $? -ne 0 ]; then | ||
| c_warning "_apt user cannot be added to AID_INET group" | ||
| else | ||
| sed -i -e 's/_apt:x:100:65534/_apt:x:100:3003/' $OUT_TMP/etc/passwd | ||
| $root sed -i -e 's/_apt:x:100:65534/_apt:x:100:3003/' \ | ||
| $OUT_TMP/etc/passwd | ||
| fi | ||
|
|
||
| # Add a default DNS server | ||
| echo "nameserver 4.2.2.2" > $OUT_TMP/etc/resolv.conf | ||
| $root tee $OUT_TMP/etc/resolv.conf >/dev/null <<EOF | ||
| nameserver 4.2.2.2 | ||
| EOF | ||
|
|
||
| # Clone BCC if needed | ||
| if [ $INSTALL_BCC -eq 1 ]; then | ||
|
|
@@ -70,12 +84,10 @@ if [ $INSTALL_BCC -eq 1 ]; then | |
| popd | ||
| fi | ||
|
|
||
| # Should be 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 | ||
|
|
||
| chmod 0777 $TDIR/deb.tar.gz | ||
| $root tar -zpcf $TDIR/deb.tar.gz -C $TDIR debian | ||
|
|
||
| $root chown --reference=$TDIR $TDIR/deb.tar.gz | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change to "Warning: untested arch ($ARCH)" ?