Initial work
This commit is contained in:
commit
3222551702
374 changed files with 40290 additions and 0 deletions
2
scripts/iptables-wrapper
Executable file
2
scripts/iptables-wrapper
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
#!/system/bin/sh
|
||||
echo "Dummy iptables wrapper"
|
||||
60
scripts/launch-abox.sh
Executable file
60
scripts/launch-abox.sh
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
set -x
|
||||
|
||||
basepath=/home/phablet/android-box
|
||||
rootfs=$basepath/rootfs
|
||||
rootfs_overrides=$basepath/overrides
|
||||
ramdisk=$basepath/ramdisk.img
|
||||
systemdisk=$basepath/system.img
|
||||
init_cmd="/init"
|
||||
|
||||
if [ "$1" = "shell" ] ; then
|
||||
init_cmd=/system/bin/sh
|
||||
fi
|
||||
|
||||
if [ -d $rootfs ] ; then
|
||||
sudo umount --recursive $rootfs || true
|
||||
rm -rf $rootfs
|
||||
fi
|
||||
|
||||
mkdir -p $rootfs
|
||||
sudo mount -t tmpfs none $rootfs
|
||||
(cd $rootfs ; cat $ramdisk | gzip -d | cpio -i)
|
||||
|
||||
mkdir -p $rootfs/dev/pts
|
||||
sudo mount -o ro,loop $systemdisk $rootfs/system
|
||||
|
||||
if [ -d "$rootfs_overrides" ] ; then
|
||||
for f in `ls $rootfs_overrides` ; do
|
||||
if [ "$f" = "system" ] ; then
|
||||
for f2 in `find $rootfs_overrides/system -type f` ; do
|
||||
real_path=`echo $f2 | sed -e s:$rootfs_overrides::g`
|
||||
sudo mount -o bind $f2 $rootfs/$real_path
|
||||
done
|
||||
else
|
||||
cp $rootfs_overrides/$f $rootfs
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
/home/phablet/bwrap \
|
||||
--ro-bind $rootfs / \
|
||||
--bind /home/phablet/android-box/iptables-wrapper /system/bin/iptables \
|
||||
--bind /home/phablet/android-box/iptables-wrapper /system/bin/ip6tables \
|
||||
--dev /dev \
|
||||
--proc /proc \
|
||||
--tmpfs /data \
|
||||
--unshare-user \
|
||||
--unshare-ipc \
|
||||
--unshare-pid \
|
||||
--unshare-net \
|
||||
--unshare-uts \
|
||||
--uid 0 \
|
||||
--gid 0 \
|
||||
--setenv PATH /system/bin:/system/sbin:/system/xbin \
|
||||
--chdir / \
|
||||
$init_cmd
|
||||
|
||||
sudo umount --recursive $rootfs
|
||||
rm -rf $rootfs
|
||||
156
scripts/setup-partial-armhf-chroot.sh
Executable file
156
scripts/setup-partial-armhf-chroot.sh
Executable file
|
|
@ -0,0 +1,156 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# TODO: Rename this file without "armhf" when it's safe to do so.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
name=${0}
|
||||
|
||||
usage() {
|
||||
echo "Usage: ${name} [options] mychroot-dir"
|
||||
echo "options:"
|
||||
echo " -a arch Select architecture, i.e. armhf, arm64, ppc... Default is armhf"
|
||||
echo " -d dist Select distribution, i.e. vivid, wily. Default is vivid"
|
||||
echo " -r rep Select an additional repository for bootstrap. Default is none"
|
||||
echo
|
||||
echo "please supply at least a directory to create partial chroot in. (eg, ./setup-partial-armhf-chroot.sh mychroot-dir)"
|
||||
}
|
||||
|
||||
# Default to vivid as we don't seem to have any working wily devices right now.
|
||||
# Also Jenkins expects this script to default to vivid (TODO: update CI?)
|
||||
arch=armhf
|
||||
dist=vivid
|
||||
sourceid=0
|
||||
repositories=
|
||||
sources=
|
||||
|
||||
while getopts a:d:r:h opt; do
|
||||
case $opt in
|
||||
a)
|
||||
arch=$OPTARG
|
||||
;;
|
||||
d)
|
||||
dist=$OPTARG
|
||||
;;
|
||||
r)
|
||||
repositories="$repositories $OPTARG"
|
||||
((++sourceid))
|
||||
sources="$sources source$sourceid"
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [ -z ${1} ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
directory=${1}
|
||||
echo "creating phablet-compatible $arch partial chroot for anbox compilation in directory ${directory}"
|
||||
|
||||
if [ ! -d ${directory} ]; then
|
||||
mkdir -p ${directory}
|
||||
fi
|
||||
|
||||
DEBCONTROL=$(pwd)/../debian/control
|
||||
|
||||
pushd ${directory} > /dev/null
|
||||
|
||||
# Empty dpkg status file, so that ALL dependencies are listed with dpkg-checkbuilddeps
|
||||
echo "" > status
|
||||
|
||||
# Manual error code checking is needed for dpkg-checkbuilddeps
|
||||
set +e
|
||||
|
||||
# Parse dependencies from debian/control
|
||||
# dpkg-checkbuilddeps returns non-zero when dependencies are not met and the list is sent to stderr
|
||||
builddeps=$(dpkg-checkbuilddeps -a ${arch} --admindir=. ${DEBCONTROL} 2>&1 )
|
||||
if [ $? -eq 0 ] ; then
|
||||
exit 0
|
||||
fi
|
||||
echo "${builddeps}"
|
||||
|
||||
# now turn exit on error option
|
||||
set -e
|
||||
|
||||
# Sanitize dependencies list for submission to multistrap
|
||||
# build-essential is not needed as we are cross-compiling
|
||||
builddeps=$(echo ${builddeps} | sed -e 's/dpkg-checkbuilddeps://g' \
|
||||
-e 's/error://g' \
|
||||
-e 's/Unmet build dependencies://g' \
|
||||
-e 's/build-essential:native//g')
|
||||
builddeps=$(echo ${builddeps} | sed 's/([^)]*)//g')
|
||||
builddeps=$(echo ${builddeps} | sed -e 's/abi-compliance-checker//g')
|
||||
builddeps=$(echo ${builddeps} | sed -e 's/multistrap//g')
|
||||
|
||||
case ${arch} in
|
||||
amd64 | i386 )
|
||||
source_url=http://archive.ubuntu.com/ubuntu
|
||||
;;
|
||||
* )
|
||||
source_url=http://ports.ubuntu.com/ubuntu-ports
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "[General]
|
||||
arch=${arch}
|
||||
directory=${directory}
|
||||
unpack=false
|
||||
noauth=true
|
||||
bootstrap=Ubuntu ${sources}
|
||||
|
||||
[Ubuntu]
|
||||
packages=${builddeps}
|
||||
source=${source_url}
|
||||
suite=${dist}
|
||||
components=main universe
|
||||
" > mstrap.conf
|
||||
|
||||
sourceid=0
|
||||
for x in ${repositories};
|
||||
do
|
||||
((++sourceid))
|
||||
echo "[source${sourceid}]
|
||||
source=${x}
|
||||
suite=${dist}
|
||||
" >> mstrap.conf
|
||||
done
|
||||
|
||||
multistrap -f mstrap.conf
|
||||
|
||||
rm -f var/cache/apt/archives/lock
|
||||
|
||||
# Remove libc libraries that confuse the cross-compiler
|
||||
rm -f var/cache/apt/archives/libc-dev*.deb
|
||||
rm -f var/cache/apt/archives/libc6*.deb
|
||||
|
||||
for deb in var/cache/apt/archives/* ; do
|
||||
if [ ! -d ${deb} ] ; then
|
||||
echo "unpacking: ${deb}"
|
||||
dpkg -x ${deb} .
|
||||
fi
|
||||
done
|
||||
|
||||
# Fix up symlinks which asssumed the usual root path
|
||||
for broken_symlink in $(find . -name \*.so -type l -xtype l) ; do
|
||||
ln -sf $(pwd)$(readlink ${broken_symlink}) ${broken_symlink}
|
||||
done
|
||||
|
||||
popd > /dev/null
|
||||
Loading…
Add table
Add a link
Reference in a new issue