Extend snap packaging with further details
This commit is contained in:
parent
1c9ebae83d
commit
117111ce20
8 changed files with 198 additions and 44 deletions
8
scripts/container-manager.sh
Executable file
8
scripts/container-manager.sh
Executable file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Make sure our setup path for the container rootfs
|
||||||
|
# is present as lxc is statically configured for
|
||||||
|
# this path.
|
||||||
|
mkdir -p $SNAP_COMMON/lxc
|
||||||
|
|
||||||
|
exec $SNAP/bin/anbox container-manager
|
||||||
10
scripts/container-shell.sh
Executable file
10
scripts/container-shell.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
$SNAP/bin/lxc-attach \
|
||||||
|
--lxcpath=$SNAP_COMMON/var/lib/anbox/containers \
|
||||||
|
--name default \
|
||||||
|
--clear-env \
|
||||||
|
--set-var PATH=/system/bin:/system/sbin:/system/xbin \
|
||||||
|
--set-var ANDROID_DATA=/data \
|
||||||
|
-- \
|
||||||
|
/system/bin/sh
|
||||||
16
scripts/setup-rootfs.sh
Executable file
16
scripts/setup-rootfs.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# We need to put the rootfs somewhere where we can modify some
|
||||||
|
# parts of the content on first boot (namely file permissions).
|
||||||
|
# Other than that nothing should ever modify the content of the
|
||||||
|
# rootfs.
|
||||||
|
|
||||||
|
ROOTFS_PATH=$SNAP_COMMON/var/lib/anbox/rootfs
|
||||||
|
|
||||||
|
if [ -d $ROOTFS_PATH ] ; then
|
||||||
|
rm -rf $ROOTFS_PATH
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Copying rootfs into $ROOTFS_PATH .."
|
||||||
|
mkdir -p $ROOTFS_PATH
|
||||||
|
tar xf $SNAP/anbox-android-rootfs.tar -C $ROOTFS_PATH/ --strip-components=1
|
||||||
3
scripts/shell.sh
Executable file
3
scripts/shell.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
exec /bin/bash $@
|
||||||
43
scripts/snap-wrapper.sh
Executable file
43
scripts/snap-wrapper.sh
Executable file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ "$SNAP_ARCH" == "amd64" ]; then
|
||||||
|
ARCH="x86_64-linux-gnu"
|
||||||
|
elif [ "$SNAP_ARCH" == "armhf" ]; then
|
||||||
|
ARCH="arm-linux-gnueabihf"
|
||||||
|
else
|
||||||
|
ARCH="$SNAP_ARCH-linux-gnu"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
# Mesa Libs
|
||||||
|
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa:$LD_LIBRARY_PATH
|
||||||
|
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
# XDG Config
|
||||||
|
export XDG_CONFIG_DIRS=$SNAP/etc/xdg:$XDG_CONFIG_DIRS
|
||||||
|
export XDG_CONFIG_DIRS=$SNAP/usr/xdg:$XDG_CONFIG_DIRS
|
||||||
|
# Note: this doesn't seem to work, QML's LocalStorage either ignores
|
||||||
|
# or fails to use $SNAP_USER_DATA if defined here
|
||||||
|
export XDG_DATA_DIRS=$SNAP_USER_DATA:$XDG_DATA_DIRS
|
||||||
|
export XDG_DATA_DIRS=$SNAP/usr/share:$XDG_DATA_DIRS
|
||||||
|
|
||||||
|
# Not good, needed for fontconfig
|
||||||
|
export XDG_DATA_HOME=$SNAP/usr/share
|
||||||
|
|
||||||
|
# Tell libGL where to find the drivers
|
||||||
|
export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/$ARCH/dri
|
||||||
|
|
||||||
|
# ensure the snappy gl libs win
|
||||||
|
export LD_LIBRARY_PATH="$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH"
|
||||||
|
|
||||||
|
cd $SNAP
|
||||||
|
|
||||||
|
if [ "$(id -u)" == "0" ] ; then
|
||||||
|
# Make sure our setup path for the container rootfs
|
||||||
|
# is present as lxc is statically configured for
|
||||||
|
# this path.
|
||||||
|
mkdir -p $SNAP_COMMON/lxc
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec $SNAP/usr/bin/anbox $@
|
||||||
3
scripts/start-container.sh
Executable file
3
scripts/start-container.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
exec $SNAP/bin/lxc-start -P $SNAP_COMMON/var/lib/anbox/containers -n default -F
|
||||||
155
snapcraft.yaml
155
snapcraft.yaml
|
|
@ -8,48 +8,117 @@ description: |
|
||||||
confinement: devmode
|
confinement: devmode
|
||||||
|
|
||||||
apps:
|
apps:
|
||||||
anbox:
|
anbox:
|
||||||
command: usr/bin/anbox
|
command: bin/anbox-wrapper.sh
|
||||||
|
container-manager:
|
||||||
|
command: bin/anbox-wrapper.sh container-manager
|
||||||
|
# daemon: simple
|
||||||
|
setup-rootfs:
|
||||||
|
command: bin/setup-rootfs.sh
|
||||||
|
shell:
|
||||||
|
command: bin/container-shell.sh
|
||||||
|
sh:
|
||||||
|
command: bin/shell.sh
|
||||||
|
start-container:
|
||||||
|
command: bin/start-container.sh
|
||||||
|
|
||||||
parts:
|
parts:
|
||||||
anbox:
|
android-rootfs:
|
||||||
plugin: cmake
|
plugin: dump
|
||||||
source: .
|
source: .
|
||||||
configflags:
|
snap:
|
||||||
# FIXME: Anbox currently has some paths with hard coded prefixes. Once
|
- anbox-android-rootfs.tar
|
||||||
# that is fixed we can avoid using a prefix here.
|
anbox-common:
|
||||||
- -DCMAKE_INSTALL_PREFIX:PATH=/usr
|
plugin: dump
|
||||||
# FIXME: When building in release mode we get a lot of error which cause
|
source: .
|
||||||
# the build to fail.
|
organize:
|
||||||
- -DCMAKE_BUILD_TYPE=debug
|
scripts/snap-wrapper.sh: bin/anbox-wrapper.sh
|
||||||
build-packages:
|
scripts/setup-rootfs.sh: bin/setup-rootfs.sh
|
||||||
- build-essential
|
scripts/container-shell.sh: bin/container-shell.sh
|
||||||
- cmake
|
scripts/shell.sh: bin/shell.sh
|
||||||
- cmake-data
|
scripts/start-container.sh: bin/start-container.sh
|
||||||
- debhelper
|
snap:
|
||||||
- dbus
|
- bin/anbox-wrapper.sh
|
||||||
- google-mock
|
- bin/setup-rootfs.sh
|
||||||
- libboost-dev
|
- bin/container-shell.sh
|
||||||
- libboost-filesystem-dev
|
- bin/shell.sh
|
||||||
- libboost-log-dev
|
- bin/start-container.sh
|
||||||
- libboost-iostreams-dev
|
lxc:
|
||||||
- libboost-program-options-dev
|
source: git://github.com/morphis/lxc
|
||||||
- libboost-system-dev
|
source-branch: snappy-support
|
||||||
- libboost-thread-dev
|
build-packages:
|
||||||
- libcap-dev
|
- libapparmor-dev
|
||||||
- libdbus-1-dev
|
- libcap-dev
|
||||||
- libdbus-cpp-dev
|
- libgnutls28-dev
|
||||||
- libegl1-mesa-dev
|
- libseccomp-dev
|
||||||
- libgles2-mesa-dev
|
- pkg-config
|
||||||
- libglib2.0-dev
|
plugin: autotools
|
||||||
- libgtest-dev
|
configflags:
|
||||||
- libprotobuf-dev
|
- --disable-selinux
|
||||||
- pkg-config
|
- --disable-python
|
||||||
- protobuf-compiler
|
- --disable-lua
|
||||||
stage-packages:
|
- --disable-tests
|
||||||
- lxc1
|
- --disable-examples
|
||||||
snap:
|
- --disable-doc
|
||||||
- usr/bin/anbox
|
- --disable-api-docs
|
||||||
- usr/bin/anbox-container
|
- --disable-bash
|
||||||
- usr/bin/lxc-usernsexec
|
- --disable-cgmanager
|
||||||
- usr/lib/*-linux-*/
|
# FIXME: Enable again once stacked AppArmor support landed
|
||||||
|
- --disable-apparmor
|
||||||
|
- --disable-seccomp
|
||||||
|
- --enable-capabilities
|
||||||
|
- --with-rootfs-path=/var/snap/anbox/common/lxc/
|
||||||
|
snap:
|
||||||
|
- bin/lxc-attach
|
||||||
|
- bin/lxc-ls
|
||||||
|
- bin/lxc-start
|
||||||
|
- bin/lxc-stop
|
||||||
|
- lib/liblxc.so.1
|
||||||
|
- lib/liblxc.so.1.2.0
|
||||||
|
- libexec/lxc/lxc-monitord
|
||||||
|
anbox:
|
||||||
|
plugin: cmake
|
||||||
|
after:
|
||||||
|
- lxc
|
||||||
|
source: .
|
||||||
|
configflags:
|
||||||
|
# FIXME: Anbox currently has some paths with hard coded prefixes. Once
|
||||||
|
# that is fixed we can avoid using a prefix here.
|
||||||
|
- -DCMAKE_INSTALL_PREFIX:PATH=/usr
|
||||||
|
# FIXME: When building in release mode we get a lot of error which cause
|
||||||
|
# the build to fail.
|
||||||
|
- -DCMAKE_BUILD_TYPE=debug
|
||||||
|
build-packages:
|
||||||
|
- build-essential
|
||||||
|
- cmake
|
||||||
|
- cmake-data
|
||||||
|
- debhelper
|
||||||
|
- dbus
|
||||||
|
- google-mock
|
||||||
|
- libboost-dev
|
||||||
|
- libboost-filesystem-dev
|
||||||
|
- libboost-log-dev
|
||||||
|
- libboost-iostreams-dev
|
||||||
|
- libboost-program-options-dev
|
||||||
|
- libboost-system-dev
|
||||||
|
- libboost-thread-dev
|
||||||
|
- libcap-dev
|
||||||
|
- libdbus-1-dev
|
||||||
|
- libdbus-cpp-dev
|
||||||
|
- libegl1-mesa-dev
|
||||||
|
- libgles2-mesa-dev
|
||||||
|
- libglib2.0-dev
|
||||||
|
- libgtest-dev
|
||||||
|
- libprotobuf-dev
|
||||||
|
- libsdl2-dev
|
||||||
|
- pkg-config
|
||||||
|
- protobuf-compiler
|
||||||
|
stage-packages:
|
||||||
|
- libegl1-mesa
|
||||||
|
- libgles2-mesa
|
||||||
|
- libgl1-mesa-glx
|
||||||
|
- libsdl2-2.0-0
|
||||||
|
- libsdl2-gfx-1.0-0
|
||||||
|
snap:
|
||||||
|
- usr/bin/anbox
|
||||||
|
- usr/lib/*-linux-*/
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,11 @@ anbox::cmds::StartContainer::StartContainer()
|
||||||
});
|
});
|
||||||
|
|
||||||
auto rt = Runtime::create();
|
auto rt = Runtime::create();
|
||||||
|
auto container = std::make_shared<container::LxcContainer>();
|
||||||
|
container::Configuration config;
|
||||||
|
|
||||||
rt->start();
|
rt->start();
|
||||||
|
container->start(config);
|
||||||
trap->run();
|
trap->run();
|
||||||
rt->stop();
|
rt->stop();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue