Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Install]
Wants=lxc@android.service

This file was deleted.

11 changes: 0 additions & 11 deletions lib/systemd/system/android-mount.service

This file was deleted.

10 changes: 0 additions & 10 deletions lib/systemd/system/system.mount

This file was deleted.

6 changes: 0 additions & 6 deletions usr/lib/lxc-android/copy-udev-rules

This file was deleted.

39 changes: 0 additions & 39 deletions usr/lib/lxc-android/mount-android

This file was deleted.

4 changes: 4 additions & 0 deletions var/lib/lxc/android/pre-start.d/10-no-adbd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# Disable adbd
rm $LXC_ROOTFS_PATH/sbin/adbd
6 changes: 6 additions & 0 deletions var/lib/lxc/android/pre-start.d/20-no-default-prop-adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/sh

# Avoid changing the the property when running on the emulator
if ! grep -q "qemu=1" /proc/cmdline; then
sed -i '/^persist.sys.usb.config=.*/d' $LXC_ROOTFS_PATH/default.prop || true
fi
7 changes: 7 additions & 0 deletions var/lib/lxc/android/pre-start.d/25-process-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Copies files from /var/lib/lxc/android/overrides, which can be provided (for
# example) by the Android image's overlay, the distribution maintainer, or
# the device vendor, into the rootfs.

cp -a /var/lib/lxc/android/overrides/* $LXC_ROOTFS_PATH || true
41 changes: 13 additions & 28 deletions var/lib/lxc/android/pre-start.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
#!/bin/sh

mount_android_partitions() {
fstab=$1
lxc_rootfs_path=$2
cat ${fstab} | while read line; do
set -- $line
# Skip any unwanted entry
echo $1 | egrep -q "^#" && continue
([ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]) && continue
([ "$3" = "emmc" ] || [ "$3" = "swap" ] || [ "$3" = "mtd" ]) && continue
[ ! -d "$2" ] && continue

mkdir -p ${lxc_rootfs_path}/$2
mount -n -o bind,recurse $2 ${lxc_rootfs_path}/$2
done
}
for mountpoint in /android/*; do
mount_name=`basename $mountpoint`
desired_mount=$LXC_ROOTFS_PATH/$mount_name

# Remove symlinks, for example bullhead has /vendor -> /system/vendor
[ -L $desired_mount ] && rm $desired_mount

[ -d $desired_mount ] || mkdir $desired_mount
mount --bind $mountpoint $desired_mount
done

if [ -f "/tmp/lxc_android_once" ]; then
echo "lxc:android contianer had already been invoked.";
exit -255
fi
touch /tmp/lxc_android_once

INITRD=/system/boot/android-ramdisk.img
rm -Rf $LXC_ROOTFS_PATH
mkdir -p $LXC_ROOTFS_PATH
cd $LXC_ROOTFS_PATH
cat $INITRD | gzip -d | cpio -i

mknod -m 666 $LXC_ROOTFS_PATH/dev/null c 1 3

# Create /dev/pts if missing
Expand All @@ -37,15 +26,11 @@ mkdir -p $LXC_ROOTFS_PATH/dev/pts
mkdir -p /dev/socket $LXC_ROOTFS_PATH/socket
mount -n -o bind,rw /dev/socket $LXC_ROOTFS_PATH/socket

rm $LXC_ROOTFS_PATH/sbin/adbd

rm -Rf $LXC_ROOTFS_PATH/vendor

# Mount the android partitions
mount_android_partitions $LXC_ROOTFS_PATH/fstab* "$LXC_ROOTFS_PATH"

sed -i '/on early-init/a \ mkdir /dev/socket\n\ mount none /socket /dev/socket bind' $LXC_ROOTFS_PATH/init.rc

sed -i "/mount_all /d" $LXC_ROOTFS_PATH/init.*.rc
sed -i "/swapon_all /d" $LXC_ROOTFS_PATH/init.*.rc
sed -i "/on nonencrypted/d" $LXC_ROOTFS_PATH/init.rc

# Config snippet scripts
run-parts /var/lib/lxc/android/pre-start.d || true