From 2e3a82c4290f2ae64355ded0ebcbff0fee9e023f Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Tue, 7 Feb 2017 07:51:08 +0100 Subject: [PATCH] Remove kernel module building inside the snap --- scripts/container-manager.sh | 59 ++++++++---------------------------- snapcraft.yaml | 3 -- 2 files changed, 12 insertions(+), 50 deletions(-) diff --git a/scripts/container-manager.sh b/scripts/container-manager.sh index ba708eb..fd7885e 100755 --- a/scripts/container-manager.sh +++ b/scripts/container-manager.sh @@ -16,45 +16,18 @@ if [ ! -e $ANDROID_IMG ]; then exit 1 fi -build_kernel_modules() { - kversion=$1 - - rm -rf $SNAP_COMMON/kernel-* - - $SNAP/bin/classic-create || true - - rm -rf $SNAP_COMMON/classic/build - mkdir -p $SNAP_COMMON/classic/build - cp -rav $SNAP/ashmem $SNAP_COMMON/classic/build/ - cp -rav $SNAP/binder $SNAP_COMMON/classic/build/ - - cat< $SNAP_COMMON/classic/build/run.sh -#!/bin/sh -set -ex -apt update -apt install -y --force-yes linux-headers-$kversion build-essential -cd /build/ashmem -make -cd /build/binder -make -EOF - - chmod +x $SNAP_COMMON/classic/build/run.sh - $SNAP/bin/classic /build/run.sh - - mkdir -p $SNAP_COMMON/kernel-$kversion - cp $SNAP_COMMON/classic/build/ashmem/ashmem_linux.ko \ - $SNAP_COMMON/kernel-$kversion/ - cp $SNAP_COMMON/classic/build/binder/binder_linux.ko \ - $SNAP_COMMON/kernel-$kversion/ -} - load_kernel_modules() { kversion=`uname -r` rmmod ashmem_linux binder_linux || true echo "Loading kernel modules for version $kversion.." - insmod $SNAP_COMMON/kernel-$kversion/binder_linux.ko - insmod $SNAP_COMMON/kernel-$kversion/ashmem_linux.ko + if ! `modprobe binder_linux` ; then + echo "ERROR: Failed to load kernel binder driver" + return + fi + if ! `modprobe ashmem_linux` ; then + echo "ERROR: Failed to load kernel ashmem driver" + return + fi sleep 0.5 chmod 666 /dev/binder chmod 666 /dev/ashmem @@ -81,18 +54,10 @@ start() { # possible. See snapcraft.yaml for further details. $SNAP/bin/anbox-bridge.sh start - # Building and loading the necessary kernel modules is only possible - # on Ubuntu 16.04 (xenial) - if [ -e /var/lib/snapd/hostfs/etc/os-release ]; then - . /var/lib/snapd/hostfs/etc/os-release - if [ $UBUNTU_CODENAME = xenial ]; then - kversion=`uname -r` - if [ ! -e $SNAP_COMMON/kernel-$kversion ]; then - build_kernel_modules $kversion - fi - load_kernel_modules - fi - fi + # This will try to load the kernel modules. If this fails we will + # continue as normal and anbox will fail later on and report a + # visible error message to the user. + load_kernel_modules # Ensure FUSE support for user namespaces is enabled echo Y | sudo tee /sys/module/fuse/parameters/userns_mounts || echo "WARNING: kernel doesn't support fuse in user namespaces" diff --git a/snapcraft.yaml b/snapcraft.yaml index a9f4f7a..76f49d7 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -22,9 +22,6 @@ parts: source: android-images files: android.img: android.img - kernel-modules: - plugin: dump - source: kernel anbox-common: plugin: copy source: .