Use a separate binder FS to avoid potential confclits with something else, try to work on kernels of different configuration

This commit is contained in:
Mikhail Novosyolov 2021-01-02 23:47:44 +03:00
parent 0810d99547
commit 12c99571b8
3 changed files with 31 additions and 7 deletions

View file

@ -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

19
anbox-load-kernel-modules.sh Executable file
View file

@ -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 ]

View file

@ -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?