Use disk images instead of a rootfs tarball
This commit is contained in:
parent
0c4668d029
commit
6860338c4b
3 changed files with 39 additions and 39 deletions
|
|
@ -23,34 +23,6 @@ function prepare_filesystem() {
|
|||
chown system:system /dev/$f
|
||||
chmod 0666 /dev/$f
|
||||
done
|
||||
|
||||
if [ ! -e /.anbox_setup_done ] ; then
|
||||
echo "Fixing up all permissions ..."
|
||||
|
||||
# Fixup permissions of the android binaries in /system
|
||||
while read line
|
||||
do
|
||||
file=`echo $line | cut -d' ' -f 1`
|
||||
user=`echo $line | cut -d' ' -f 2`
|
||||
group=`echo $line | cut -d' ' -f 3`
|
||||
mode=`echo $line | cut -d' ' -f 4`
|
||||
# Avoid changing symlinks
|
||||
if [ ! -h /$file ] ; then
|
||||
chmod $mode /$file
|
||||
chown -h $user:$group /$file
|
||||
fi
|
||||
done < "/filesystem_config.txt"
|
||||
|
||||
# Additional ones not listed in the config generated from the build
|
||||
for f in qemu_pipe qemu_trace goldfish_pipe ; do
|
||||
[ ! -e /dev/$f ] && continue
|
||||
chown system:system /dev/$f
|
||||
chmod 0666 /dev/$f
|
||||
done
|
||||
|
||||
echo "Setup done!"
|
||||
echo $VERSION > /.anbox_setup_done
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_filesystem &
|
||||
|
|
|
|||
|
|
@ -5,18 +5,42 @@
|
|||
# Other than that nothing should ever modify the content of the
|
||||
# rootfs.
|
||||
|
||||
ROOTFS_PATH=$SNAP_COMMON/var/lib/anbox/rootfs
|
||||
ROOTFS_VERSION=1
|
||||
DATA_PATH=$SNAP_COMMON/var/lib/anbox
|
||||
ROOTFS_PATH=$DATA_PATH/rootfs
|
||||
RAMDISK_PATH=$DATA_PATH/ramdisk
|
||||
INITRD=$SNAP/ramdisk.img
|
||||
SYSTEM_IMG=$SNAP/system.img
|
||||
ANDROID_DATA_PATH=$DATA_PATH/android-data
|
||||
|
||||
if [ ! -e $ROOTFS_PATH ] || [ "$ROOTFS_VERSION" != "$(cat $ROOTFS_PATH/.version)" ] ; then
|
||||
rm -rf $ROOTFS_PATH
|
||||
echo "Copying rootfs into $ROOTFS_PATH .."
|
||||
mkdir -p $ROOTFS_PATH
|
||||
tar xf $SNAP/android-rootfs.tar -C $ROOTFS_PATH/ --strip-components=1
|
||||
chown -R root:root $ROOTFS_PATH
|
||||
echo $ROOTFS_VERSION > $ROOTFS_PATH/.version
|
||||
if [ ! -e $INITRD ]; then
|
||||
echo "ERROR: boot ramdisk does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e $SYSTEM_IMG ]; then
|
||||
echo "ERROR: system image does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract ramdisk content instead of trying to bind mount the
|
||||
# cpio image file to allow modifications.
|
||||
rm -Rf $RAMDISK_PATH
|
||||
mkdir -p $RAMDISK_PATH
|
||||
cd $RAMDISK_PATH
|
||||
cat $INITRD | gzip -d | cpio -i
|
||||
|
||||
# FIXME those things should be fixed in the build process
|
||||
chmod +x $RAMDISK_PATH/anbox-init.sh
|
||||
|
||||
# Setup the read-only rootfs
|
||||
mkdir -p $ROOTFS_PATH
|
||||
mount -o bind,ro $RAMDISK_PATH $ROOTFS_PATH
|
||||
mount -o loop,ro $SYSTEM_IMG $ROOTFS_PATH/system
|
||||
|
||||
# ... but we keep /data in the read/write space
|
||||
mkdir -p $ANDROID_DATA_PATH
|
||||
mount -o bind $ANDROID_DATA_PATH $ROOTFS_PATH/data
|
||||
|
||||
# Make sure our setup path for the container rootfs
|
||||
# is present as lxc is statically configured for
|
||||
# this path.
|
||||
|
|
@ -31,3 +55,6 @@ pid=$!
|
|||
waitpid $pid
|
||||
|
||||
$SNAP/bin/anbox-bridge.sh stop
|
||||
|
||||
umount $ROOTFS_PATH/system
|
||||
umount $ROOTFS_PATH/data
|
||||
|
|
|
|||
|
|
@ -22,11 +22,12 @@ apps:
|
|||
# daemon: oneshot
|
||||
|
||||
parts:
|
||||
android-rootfs:
|
||||
android:
|
||||
plugin: copy
|
||||
source: .
|
||||
files:
|
||||
android-rootfs.tar: android-rootfs.tar
|
||||
system.img: system.img
|
||||
ramdisk.img: ramdisk.img
|
||||
anbox-common:
|
||||
plugin: copy
|
||||
source: .
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue