From 12c99571b8e144066a91eedbf60bc17bc631a709 Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Sat, 2 Jan 2021 23:47:44 +0300 Subject: [PATCH] Use a separate binder FS to avoid potential confclits with something else, try to work on kernels of different configuration --- anbox-container-manager.service | 8 +++++--- anbox-load-kernel-modules.sh | 19 +++++++++++++++++++ anbox.spec | 11 +++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100755 anbox-load-kernel-modules.sh diff --git a/anbox-container-manager.service b/anbox-container-manager.service index f5f87ce..dd2e31d 100644 --- a/anbox-container-manager.service +++ b/anbox-container-manager.service @@ -1,17 +1,19 @@ [Unit] Description=Anbox Container Manager Documentation=man:anbox(1) -# TODO: add dependency from lxc After=network.target Wants=network.target ConditionPathExists=/var/lib/anbox/android.img [Service] -ExecStartPre=/sbin/modprobe ashmem_linux -ExecStartPre=/sbin/modprobe binder_linux +# More datailed log of /usr/bin/anbox +Environment=ANBOX_LOG_LEVEL=debug +# Some kernels may have this functionality build it, not as modules +ExecStartPre=/usr/share/anbox/anbox-load-kernel-modules.sh ExecStartPre=/usr/share/anbox/anbox-bridge.sh start ExecStart=/usr/bin/anbox container-manager --daemon --privileged --data-path=/var/lib/anbox ExecStopPost=/usr/share/anbox/anbox-bridge.sh stop +ExecStopPost=umount /var/lib/anbox/binderfs0 [Install] WantedBy=multi-user.target diff --git a/anbox-load-kernel-modules.sh b/anbox-load-kernel-modules.sh new file mode 100755 index 0000000..90ac7c3 --- /dev/null +++ b/anbox-load-kernel-modules.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -xuef + +device=/var/lib/anbox/binderfs0 + +if findmnt "$device" ; then + echo "$device is already mounted, exiting" + exit 0 +fi + +# Some kernels may have these separate modules, +# some may have functionality built in +modprobe binder_linux 2>/dev/null || : +modprobe ashmem_linux 2>/dev/null || : + +mount -t binder binder "$device" + +[ -e /dev/ashmem ] diff --git a/anbox.spec b/anbox.spec index 62181fe..01281ac 100644 --- a/anbox.spec +++ b/anbox.spec @@ -4,18 +4,19 @@ Summary: Android in a box Name: anbox Version: 0.0 -Release: 0.git%{commit_short}.2 +Release: 0.git%{commit_short}.6 License: GPLv3 Group: Emulators Url: https://anbox.io Source0: https://github.com/anbox/anbox/archive/%{commit}.tar.gz?/%{name}-%{commit}.tar.gz -# Additional stuff from Debian +# Additional stuff, based on stuff from Debian package Source10: anbox-container-manager.service Source11: org.anbox.service Source12: anbox.desktop Source13: anbox.1 Source14: README.ROSA +Source15: anbox-load-kernel-modules.sh # Patches from Debian Patch0001: 0001-fix-spelling-errors-in-external-libraries.patch @@ -38,7 +39,6 @@ BuildRequires: cmake(CpuFeatures) BuildRequires: pkgconfig(dri) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(libcap) -# TODO: lxc v2 is very old, update it to v4 BuildRequires: pkgconfig(lxc) # build of tests is disabled in %%prep, but headers are needed BuildRequires: pkgconfig(gmock) @@ -95,6 +95,7 @@ See %{_docdir}/anbox/README.ROSA for more information. %{_mandir}/man1/anbox.1* %{_unitdir}/anbox-container-manager.service %dir /var/lib/anbox +%dir /var/lib/anbox/binderfs0 %post %systemd_post anbox-container-manager.service @@ -124,6 +125,7 @@ cp %{SOURCE14} README.ROSA -DCMAKE_INSTALL_LIBDIR=%{_libdir} \ -DANBOX_VERSION=%{version}-%{release} \ -DANBOX_VERSION_SUFFIX=%{vendor} \ + -DBINDERFS_PATH=/var/lib/anbox/binderfs0 \ -DCMAKE_BUILD_TYPE=Release %make @@ -135,6 +137,7 @@ install -m0644 -D %{SOURCE10} %{buildroot}%{_unitdir}/anbox-container-manager.se install -m0644 -D %{SOURCE11} %{buildroot}%{_datadir}/dbus-1/services/org.anbox.service install -m0644 -D %{SOURCE12} %{buildroot}%{_datadir}/applications/anbox.desktop install -m0644 -D %{SOURCE13} %{buildroot}%{_mandir}/man1/anbox.1 +install -m0755 -D %{SOURCE15} %{buildroot}%{_datadir}/anbox/anbox-load-kernel-modules.sh install -m0755 -D scripts/anbox-bridge.sh %{buildroot}%{_datadir}/anbox/anbox-bridge.sh install -m0755 -D scripts/anbox-shell.sh %{buildroot}%{_datadir}/anbox/anbox-shell.sh mkdir -p %{buildroot}%{_bindir} @@ -142,7 +145,7 @@ mkdir -p %{buildroot}%{_bindir} ln -s %{_datadir}/anbox/anbox-shell.sh anbox-shell ln -s %{_datadir}/anbox/anbox-bridge.sh anbox-bridge ) -mkdir -p %{buildroot}/var/lib/anbox +mkdir -p %{buildroot}/var/lib/anbox/binderfs0 # XXX Is it needed? Added by commit 4b033022eb318, but is not installed. install -m0644 -D src/anbox/dbus/gps.xml %{buildroot}%{_datadir}/dbus-1/interfaces/org.anbox.Gps.xml # The same, do they have to be installed?