diff --git a/etc/systemd/system/systemd-udevd.service.d/10_after_android_container.conf b/etc/systemd/system/systemd-udevd.service.d/10_after_android_container.conf new file mode 100644 index 0000000..f16ed18 --- /dev/null +++ b/etc/systemd/system/systemd-udevd.service.d/10_after_android_container.conf @@ -0,0 +1,2 @@ +[Install] +Wants=lxc@android.service diff --git a/etc/systemd/system/systemd-udevd.service.d/10_copy-device-udev-rules.conf b/etc/systemd/system/systemd-udevd.service.d/10_copy-device-udev-rules.conf deleted file mode 100644 index 75ae40a..0000000 --- a/etc/systemd/system/systemd-udevd.service.d/10_copy-device-udev-rules.conf +++ /dev/null @@ -1,5 +0,0 @@ -[Unit] -RequiresMountsFor=/system - -[Service] -ExecStartPre=-/usr/lib/lxc-android/copy-udev-rules diff --git a/lib/systemd/system/android-mount.service b/lib/systemd/system/android-mount.service deleted file mode 100644 index a49898a..0000000 --- a/lib/systemd/system/android-mount.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=mount android parts -After=system.mount systemd-udev-settle.service -Wants=systemd-udev-settle.service - -[Service] -Type=oneshot -ExecStart=/usr/lib/lxc-android/mount-android - -[Install] -RequiredBy=local-fs.target diff --git a/lib/systemd/system/system.mount b/lib/systemd/system/system.mount deleted file mode 100644 index 9930f5f..0000000 --- a/lib/systemd/system/system.mount +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=mount system.img - -[Mount] -What=/data/system.img -Where=/system -Options=ro - -[Install] -RequiredBy=local-fs.target diff --git a/usr/lib/lxc-android/copy-udev-rules b/usr/lib/lxc-android/copy-udev-rules deleted file mode 100755 index 6b06947..0000000 --- a/usr/lib/lxc-android/copy-udev-rules +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# if device have /system partition have udev rules, use it -device=$(grep ^ro.product.device= /system/build.prop |sed -e 's/.*=//') -[ -e /lib/udev/rules.d/70-$device.rules ] || \ - cp /usr/lib/lxc-android/70-$device.rules /lib/udev/rules.d/ diff --git a/usr/lib/lxc-android/mount-android b/usr/lib/lxc-android/mount-android deleted file mode 100755 index c4c152a..0000000 --- a/usr/lib/lxc-android/mount-android +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -INITRD=/system/boot/android-ramdisk.img -rm -Rf /tmp/android/ -mkdir -p /tmp/android/ -cd /tmp/android/ -cat $INITRD | gzip -d | cpio -i - -fstab=/tmp/android/fstab* - -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 - ([ "$2" = "/system" ] || [ "$2" = "/data" ]) && continue - - label=$(echo $1 | awk -F/ '{print $NF}') - [ -z "$label" ] && continue - - # In case fstab provides /dev/mmcblk0p* lines - path="/dev/$label" - for dir in by-partlabel by-name by-label by-path by-uuid by-partuuid by-id; do - if [ -e "/dev/disk/$dir/$label" ]; then - path="/dev/disk/$dir/$label" - break - fi - done - - [ ! -e "$path" ] && continue - - mkdir -p $2 - mount $path $2 -t $3 -o $4 - -done - -# check if vendor is mounted/created? otherwise link it to system -[ -e "/vendor" ] || ln -s /system/vendor /vendor diff --git a/var/lib/lxc/android/pre-start.d/10-no-adbd b/var/lib/lxc/android/pre-start.d/10-no-adbd new file mode 100755 index 0000000..6fab0cb --- /dev/null +++ b/var/lib/lxc/android/pre-start.d/10-no-adbd @@ -0,0 +1,4 @@ +#!/bin/sh + +# Disable adbd +rm $LXC_ROOTFS_PATH/sbin/adbd diff --git a/var/lib/lxc/android/pre-start.d/20-no-default-prop-adb b/var/lib/lxc/android/pre-start.d/20-no-default-prop-adb new file mode 100755 index 0000000..09c591d --- /dev/null +++ b/var/lib/lxc/android/pre-start.d/20-no-default-prop-adb @@ -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 diff --git a/var/lib/lxc/android/pre-start.d/25-process-overrides b/var/lib/lxc/android/pre-start.d/25-process-overrides new file mode 100755 index 0000000..e461ccf --- /dev/null +++ b/var/lib/lxc/android/pre-start.d/25-process-overrides @@ -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 diff --git a/var/lib/lxc/android/pre-start.sh b/var/lib/lxc/android/pre-start.sh index ae6029f..a162c09 100755 --- a/var/lib/lxc/android/pre-start.sh +++ b/var/lib/lxc/android/pre-start.sh @@ -1,20 +1,15 @@ #!/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."; @@ -22,12 +17,6 @@ if [ -f "/tmp/lxc_android_once" ]; then 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 @@ -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 \ No newline at end of file