Init (thanks to Debian package)

This commit is contained in:
Mikhail Novosyolov 2021-01-02 03:32:33 +03:00
commit 3f7fab69ff
12 changed files with 564 additions and 0 deletions

2
.abf.yml Normal file
View file

@ -0,0 +1,2 @@
sources:
anbox-6c10125a7f13908d2cbe56d2d9ab09872755f265.tar.gz: 6ea0aed70943a590a3de66cadeb687b7c1c9d252

View file

@ -0,0 +1,61 @@
From ffb2be18277c85fac6e7450458884e6a1a3ace9c Mon Sep 17 00:00:00 2001
From: Shengjing Zhu <i@zhsj.me>
Date: Fri, 8 Jun 2018 15:10:44 +0800
Subject: [PATCH 1/3] fix spelling errors in external libraries
Signed-off-by: Shengjing Zhu <i@zhsj.me>
---
external/process-cpp-minimal/src/core/posix/fork.cpp | 8 ++++----
external/xdg/xdg.cpp | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/external/process-cpp-minimal/src/core/posix/fork.cpp b/external/process-cpp-minimal/src/core/posix/fork.cpp
index 82a225c..aa405ad 100644
--- a/external/process-cpp-minimal/src/core/posix/fork.cpp
+++ b/external/process-cpp-minimal/src/core/posix/fork.cpp
@@ -97,12 +97,12 @@ ChildProcess fork(const std::function<posix::exit::Status()>& main,
result = main();
} catch(const std::exception& e)
{
- std::cerr << "core::posix::fork(): An unhandled std::exception occured in the child process:" << std::endl
+ std::cerr << "core::posix::fork(): An unhandled std::exception occurred in the child process:" << std::endl
<< " what(): " << e.what() << std::endl;
print_backtrace(std::cerr, " ");
} catch(...)
{
- std::cerr << "core::posix::fork(): An unhandled exception occured in the child process." << std::endl;
+ std::cerr << "core::posix::fork(): An unhandled exception occurred in the child process." << std::endl;
print_backtrace(std::cerr, " ");
}
@@ -154,12 +154,12 @@ ChildProcess vfork(const std::function<posix::exit::Status()>& main,
result = main();
} catch(const std::exception& e)
{
- std::cerr << "core::posix::fork(): An unhandled std::exception occured in the child process:" << std::endl
+ std::cerr << "core::posix::fork(): An unhandled std::exception occurred in the child process:" << std::endl
<< " what(): " << e.what() << std::endl;
print_backtrace(std::cerr, " ");
} catch(...)
{
- std::cerr << "core::posix::fork(): An unhandled exception occured in the child process." << std::endl;
+ std::cerr << "core::posix::fork(): An unhandled exception occurred in the child process." << std::endl;
print_backtrace(std::cerr, " ");
}
diff --git a/external/xdg/xdg.cpp b/external/xdg/xdg.cpp
index d54fdfe..19a69e9 100644
--- a/external/xdg/xdg.cpp
+++ b/external/xdg/xdg.cpp
@@ -30,7 +30,7 @@ fs::path throw_if_not_absolute(const fs::path& p)
if (p.has_root_directory())
return p;
- throw std::runtime_error{"Directores MUST be absolute."};
+ throw std::runtime_error{"Directories MUST be absolute."};
}
namespace env
--
2.30.0

View file

@ -0,0 +1,37 @@
From 6deb16b7166b76c6f8a81455705693b82175b84f Mon Sep 17 00:00:00 2001
From: Shengjing Zhu <i@zhsj.me>
Date: Sun, 8 Jul 2018 18:07:15 +0800
Subject: [PATCH 2/3] exclude external from all target
Signed-off-by: Shengjing Zhu <i@zhsj.me>
---
CMakeLists.txt | 2 +-
external/xdg/CMakeLists.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 713df49..6c44854 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -136,7 +136,7 @@ set(ANBOX_STATEDIR_FULL "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/anbox")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/src/anbox/build/config.h)
-add_subdirectory(external)
+add_subdirectory(external EXCLUDE_FROM_ALL)
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(android)
diff --git a/external/xdg/CMakeLists.txt b/external/xdg/CMakeLists.txt
index 249da48..8ad4f1d 100644
--- a/external/xdg/CMakeLists.txt
+++ b/external/xdg/CMakeLists.txt
@@ -21,4 +21,4 @@ add_executable(xdg_test xdg_test.cpp)
set_property(TARGET xdg_test PROPERTY CXX_STANDARD 11)
target_link_libraries(xdg_test xdg ${Boost_LIBRARIES})
-add_test(xdg_test xdg_test)
+#add_test(xdg_test xdg_test)
--
2.30.0

View file

@ -0,0 +1,27 @@
From 1603781c312934d31a090954eebc92a972d84dd3 Mon Sep 17 00:00:00 2001
From: Shengjing Zhu <i@zhsj.me>
Date: Wed, 11 Jul 2018 00:30:37 +0800
Subject: [PATCH 3/3] pass dpkg buildflags to external android-emugl
Signed-off-by: Shengjing Zhu <i@zhsj.me>
---
external/android-emugl/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/external/android-emugl/CMakeLists.txt b/external/android-emugl/CMakeLists.txt
index 23173b3..f2e1c43 100644
--- a/external/android-emugl/CMakeLists.txt
+++ b/external/android-emugl/CMakeLists.txt
@@ -1,7 +1,7 @@
# Don't treat any warnings as error as we take the source directly from
# upstream and just compile it.
-set(CMAKE_C_FLAGS "-Wall")
-set(CMAKE_CXX_FLAGS "-std=c++11 -Wall")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
# Ensure -fPIC
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
--
2.30.0

View file

@ -0,0 +1,83 @@
From 916ad080828ab9a1939dea0d417eae05c93da849 Mon Sep 17 00:00:00 2001
From: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
Date: Sat, 2 Jan 2021 03:01:09 +0300
Subject: [PATCH] Use system cpu_features and sdbus-cpp
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
index f677aa0..9341a50 100644
--- a/external/CMakeLists.txt
+++ b/external/CMakeLists.txt
@@ -5,13 +5,4 @@ add_subdirectory(backward-cpp)
set(BUILD_TESTING OFF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error")
-add_subdirectory(cpu_features)
-include(ExternalProject)
-ExternalProject_Add(sdbus-cpp
- PREFIX sdbus-cpp
- SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/sdbus-cpp"
- INSTALL_COMMAND ""
- CMAKE_CACHE_ARGS
- -DBUILD_CODE_GEN:BOOL=ON
- -DBUILD_SHARED_LIBS:BOOL=OFF
-)
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 796b881..6c59f48 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -59,7 +59,7 @@ add_library(anbox-protobuf
target_link_libraries(anbox-protobuf
${PROTOBUF_LITE_LIBRARIES})
-set(XML2CPP ${CMAKE_BINARY_DIR}/external/sdbus-cpp/src/sdbus-cpp-build/tools/sdbus-c++-xml2cpp)
+set(XML2CPP /usr/bin/sdbus-c++-xml2cpp)
macro(DBusServer BaseName)
add_custom_command(
diff --git a/src/anbox/cmds/check_features.cpp b/src/anbox/cmds/check_features.cpp
index 1e5c745..8abbe9e 100644
--- a/src/anbox/cmds/check_features.cpp
+++ b/src/anbox/cmds/check_features.cpp
@@ -18,9 +18,9 @@
#include "anbox/cmds/check_features.h"
#include "anbox/utils.h"
-#include "cpu_features_macros.h"
+#include <cpu_features/cpu_features_macros.h>
#if defined(CPU_FEATURES_ARCH_X86)
-#include "cpuinfo_x86.h"
+#include <cpu_features/cpuinfo_x86.h>
#endif
namespace {
diff --git a/src/anbox/cmds/system_info.cpp b/src/anbox/cmds/system_info.cpp
index b999417..691f7aa 100644
--- a/src/anbox/cmds/system_info.cpp
+++ b/src/anbox/cmds/system_info.cpp
@@ -30,9 +30,9 @@
#include "OpenGLESDispatch/EGLDispatch.h"
-#include "cpu_features_macros.h"
+#include <cpu_features/cpu_features_macros.h>
#if defined(CPU_FEATURES_ARCH_X86)
-#include "cpuinfo_x86.h"
+#include <cpu_features/cpuinfo_x86.h>
#endif
namespace fs = boost::filesystem;
diff --git a/src/anbox/dbus/sensors_server.cpp b/src/anbox/dbus/sensors_server.cpp
index 036022b..103c2aa 100644
--- a/src/anbox/dbus/sensors_server.cpp
+++ b/src/anbox/dbus/sensors_server.cpp
@@ -20,7 +20,7 @@
#include "anbox/android/intent.h"
#include "anbox/application/sensor_type.h"
#include "anbox/logger.h"
-#include "sdbus-c++/Error.h"
+#include <sdbus-c++/Error.h>
sdbus::Struct<double, double, double> SensorsServer::Acceleration() {
if (impl_->disabled_sensors & anbox::application::SensorType::AccelerationSensor)

30
0005-Off-Werror.patch Normal file
View file

@ -0,0 +1,30 @@
From 417ae38718424effe2e807533f6a224ba5a08404 Mon Sep 17 00:00:00 2001
From: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
Date: Sat, 2 Jan 2021 03:08:30 +0300
Subject: [PATCH] Off -Werror
There is a lot of old, copy-pastred, not well maintained code here which fails to build.
---
CMakeLists.txt | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6c44854..9452edc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,11 +38,7 @@ endif()
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower)
-if ("${cmake_build_type_lower}" STREQUAL "release" OR "${cmake_build_type_lower}" STREQUAL "relwithdebinfo")
- option(Werror "Treat warnings as errors" ON)
-else()
- option(Werror "Treat warnings as errors" OFF)
-endif()
+option(Werror "Treat warnings as errors" OFF)
if (${Werror})
message(STATUS "Treat warnings as errors")
--
2.30.0

83
README.ROSA Normal file
View file

@ -0,0 +1,83 @@
Anbox for Debian
----------------
* Setup
In order to run Android system inside container, you need two kernel
modules: ashmem_linux and binder_linux.
On ROSA, install dkms-anbox-modules or binary kernel modules for your kernel,
e.g. kernel-modules-anbox-generic-5.10-latest, if they are available.
Run following commands to check if you have the kernel modules:
modinfo binder_linux
modinfo ashmem_linux
You also need to download the Android image to /var/lib/anbox/android.img.
The path is important, since the systemd service metioned below will check it.
The pre-build image can be found at <https://build.anbox.io/android-images>.
Then start the anbox-container-manager.service and the
anbox-session-manager.service, anbox-session-manager.service is a systemd
user service.
Add lxc to autostart and start it right now:
sudo systemctl enable --now lxc
You can run following commands to manually start and enbale (add to autostart) the services:
sudo systemctl enable --now anbox-container-manager.service
systemctl --user enable --now anbox-session-manager.service
If the above commands all succeed, you can start the Android application from
desktop menu now. Or you launch application from command line:
anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
* Debug
You can launch the anbox process manually with ANBOX_LOG_LEVEL=debug
environment.
For example,
env ANBOX_LOG_LEVEL=debug anbox session-manager
env ANBOX_LOG_LEVEL=debug anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
/var/lib/anbox/logs/container.log contains the LXC log.
/var/lib/anbox/logs/console.log contains the console log of Android system,
Android root shell can be gained by running:
sudo anbox-shell
Then you can run `logcat` inside to see the Android logs.
* Applications
The upstream Android image doesn't bring any App Store, but you can use adb to
install applications from the command line:
wget https://f-droid.org/FDroid.apk
adb install FDroid.apk
As shown in the above example, you can download F-Droid apk from its website
and install it with adb.
abd utility is in the package android-tools in ROSA.
* Misc
1. Anbox may not work with Nvidia graphic drivers. If your meet segmentation
fault, please try to uninstall the drivers first.
2. If you see segfault or other errors from Android, you can try to update
Android rootfs image, as it may be fixed by upstream.
3. Some system may lack features to run Anbox, this can be checked with
command: `anbox check-features`.
More documents can be found at <https://docs.anbox.io/>.
-- Shengjing Zhu <zhsj@debian.org> Sun, 27 Oct 2019 23:08:28 +0800
-- Mikhail Novosyolov <m.novosyolov@rosalinux.ru> Sat, 01 Jan 2021 00:31:00 +0300

View file

@ -0,0 +1,17 @@
[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
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
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,9 @@
[Unit]
Description=Anbox Session Manager
Documentation=man:anbox(1)
[Service]
ExecStart=/usr/bin/anbox session-manager
[Install]
WantedBy=default.target

52
anbox.1 Normal file
View file

@ -0,0 +1,52 @@
.TH anbox 1 "Jan 2021"
.SH NAME
anbox - run Android in a box
.SH SYNOPSIS
.B anbox [command options] [arguments...]
.SH COMMANDS
.TP
system-info
Print various information about the system we're running on
.TP
check-features
Check that the host system supports all necessary features
.TP
session-manager
Run the the anbox session manager
.TP
container-manager
Start the container manager service
.TP
launch
Launch an Activity by sending an intent
.TP
help
prints a short help message
.TP
version
print the version of the daemon
.TP
wait-ready
Wait until the Android system has successfully booted
.SH DESCRIPTION
Anbox is a container-based approach to boot a full Android system on a regular GNU/Linux system
like ROSA. In other words: Anbox will let you run Android on your Linux system without the
slowness of virtualization.
.SH EXAMPLES
To launch an Android application from command line:
anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
.SH SEE ALSO
.B /usr/share/doc/anbox/README.ROSA
.SH AUTHOR
This manual page was written by Shengjing Zhu <zhsj@debian.org>,
for the Debian GNU/Linux system (but may be used by others)
and was adapted for ROSA by mikhailnov <m.novosyolov@rosalinux.ru>.

13
anbox.desktop Normal file
View file

@ -0,0 +1,13 @@
[Desktop Entry]
Name=Anbox
GenericName=Anbox Application Manager
GenericName[ru]=Менеджер приложений Anbox
Comment=Android in a box
Comment[ru]=Запуск Android-приложений
Version=1.0
Type=Application
Icon=anbox
Exec=anbox launch --package=org.anbox.appmgr --component=org.anbox.appmgr.AppViewActivity
Terminal=false
Keywords=android;container;
Categories=Utility;

150
anbox.spec Normal file
View file

@ -0,0 +1,150 @@
%define commit 6c10125a7f13908d2cbe56d2d9ab09872755f265
%define commit_short %(echo %{commit} | head -c 6)
Summary: Android in a box
Name: anbox
Version: 0.0
Release: 0.git%{commit_short}.1
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
Source10: anbox-container-manager.service
Source11: anbox-session-manager.service
Source12: anbox.desktop
Source13: anbox.1
Source14: README.ROSA
# Patches from Debian
Patch0001: 0001-fix-spelling-errors-in-external-libraries.patch
Patch0002: 0002-exclude-external-from-all-target.patch
Patch0003: 0003-pass-dpkg-buildflags-to-external-android-emugl.patch
# ROSA patches
Patch0004: 0004-Use-system-cpu_features-and-sdbus-cpp.patch
Patch0005: 0005-Off-Werror.patch
BuildRequires: boost-devel
BuildRequires: cmake
BuildRequires: egl-devel
BuildRequires: glm-devel
BuildRequires: git-core
BuildRequires: protobuf-compiler
BuildRequires: python3
BuildRequires: systemd-units
BuildRequires: /usr/bin/sdbus-c++-xml2cpp
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)
BuildRequires: pkgconfig(properties-cpp)
BuildRequires: pkgconfig(protobuf)
BuildRequires: pkgconfig(sdl2)
BuildRequires: pkgconfig(SDL2_image)
BuildRequires: pkgconfig(sdbus-c++)
BuildRequires: pkgconfig(systemd)
# In Debian it is like this...
#ExclusiveArch: %{x86_64} %{armx} %{arm}
Requires: lxc
Requires: iptables
# adb to install android apps
Recommends: android-tools
# Description is from Debian package by Shengjing Zhu <zhsj@debian.org>
# https://salsa.debian.org/zhsj/anbox
%description
Anbox is a container-based approach to boot a full Android system on a
regular GNU/Linux system.
In other words: Anbox will let you run Android on your Linux system
without the slowness of virtualization.
Anbox uses Linux namespaces (user, pid, uts, net, mount, ipc) to run a
full Android system in a container and provide Android applications on any
GNU/Linux-based platform.
The Android inside the container has no direct access to any hardware. All
hardware access is going through the anbox daemon on the host. It reuses
what Android implemented within the QEMU-based emulator for OpenGL ES
accelerated rendering. The Android system inside the container uses
different pipes to communicate with the host system and sends all hardware
access commands through these.
This package needs Android kernel modules and rootfs image,
download it from https://build.anbox.io/android-images
and put to /var/lib/anbox/android.img.
See %{_docdir}/anbox/README.ROSA for more information.
%files
%doc README.ROSA
%{_bindir}/anbox
%{_bindir}/anbox-shell
%{_bindir}/anbox-bridge
%{_bindir}/anbox-bridge
%{_datadir}/anbox
%{_datadir}/dbus-1/interfaces/org.anbox.ApplicationManager.xml
%{_datadir}/dbus-1/interfaces/org.anbox.Gps.xml
%{_datadir}/dbus-1/interfaces/org.anbox.Sensors.xml
%{_datadir}/pixmaps/anbox.png
%{_datadir}/applications/anbox.desktop
%{_mandir}/man1/anbox.1*
%{_userunitdir}/anbox-session-manager.service
%{_unitdir}/anbox-container-manager.service
%dir /var/lib/anbox
%post
%systemd_post anbox-container-manager.service
%preun
%systemd_preun anbox-container-manager.service
#------------------------------------------------------------------
%prep
%autosetup -p1 -S git_am -n %{name}-%{commit}
# (From AUR) Don't build tests
#truncate -s 0 cmake/FindGMock.cmake
truncate -s 0 tests/CMakeLists.txt
# Use system libraries
rm -fvr external/sdbus-cpp
rm -fvr external/cpu_features
cp %{SOURCE14} README.ROSA
%build
%cmake \
-DENABLE_TOUCH_INPUT=ON \
-DENABLE_WAYLAND=OFF \
-DCMAKE_INSTALL_LIBDIR=%{_libdir} \
-DANBOX_VERSION=%{version}-%{release} \
-DANBOX_VERSION_SUFFIX=%{vendor} \
-DCMAKE_BUILD_TYPE=Release
%make
%install
%makeinstall_std -C build
install -m0644 -D snap/gui/icon.png %{buildroot}%{_datadir}/pixmaps/anbox.png
install -m0644 -D %{SOURCE10} %{buildroot}%{_unitdir}/anbox-container-manager.service
install -m0644 -D %{SOURCE11} %{buildroot}%{_userunitdir}/anbox-session-manager.service
install -m0644 -D %{SOURCE12} %{buildroot}%{_datadir}/applications/anbox.desktop
install -m0644 -D %{SOURCE13} %{buildroot}%{_mandir}/man1/anbox.1
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}
( cd %{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
# 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?
install -m0644 -D src/anbox/dbus/application_manager.xml %{buildroot}%{_datadir}/dbus-1/interfaces/org.anbox.ApplicationManager.xml
install -m0644 -D src/anbox/dbus/sensors.xml %{buildroot}%{_datadir}/dbus-1/interfaces/org.anbox.Sensors.xml