File anbox.spec of Package anbox
#
# spec file for package anbox
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%if %{undefined _userunitdir}
%define _userunitdir %{_prefix}/lib/systemd/user
%endif
# debug for fedora disabled until bug 304121 is resolved
# https://bugzilla.redhat.com/show_bug.cgi?id=304121
%if 0%{?fedora} < 27
%global debug_package %{nil}
%endif
Name: anbox
Version: 0.0.1
Release: 0
Summary: Android In a Box
License: GPL-3.0
Group: System/Emulators
Url: https://github.com/anbox/anbox
Source0: %{name}-%{version}.tar.gz
Source1: anbox-container-manager.service
Source2: anbox-session-manager.service
Source3: anbox-bridge.service
Source4: anbox.preset
Source6: anbox.desktop
Patch: link-backward-to-libdw.patch
%if %{defined suse_version} && 0%{?suse_version} < 1330
BuildRequires: gcc5-c++
#seems better than owning udev rules dir
BuildRequires: udev
%else
BuildRequires: gcc-c++ >= 5.2
%endif
BuildRequires: cmake
# endian library available since 1.58
%if %{defined suse_version} && 0%{?suse_version} > 1330
BuildRequires: libboost_filesystem-devel >= 1.58
BuildRequires: libboost_log-devel >= 1.58
BuildRequires: libboost_serialization-devel >= 1.58
BuildRequires: libboost_system-devel >= 1.58
BuildRequires: libboost_thread-devel >= 1.58
BuildRequires: libboost_program_options-devel >= 1.58
BuildRequires: libboost_iostreams-devel >= 1.58
BuildRequires: libboost_test-devel >= 1.58
BuildRequires: libboost_atomic-devel >= 1.58
%else
BuildRequires: boost-devel >= 1.58
%endif
%if %{defined fedora}
BuildRequires: gtest-devel
BuildRequires: gmock-devel
%endif
%if %{defined suse_version}
BuildRequires: googletest-devel
BuildRequires: googlemock-devel
%endif
BuildRequires: libcap-devel
BuildRequires: glm-devel
BuildRequires: pkgconfig(properties-cpp)
#BuildRequires: pkgconfig(dbus-cpp)
BuildRequires: pkgconfig(gl)
BuildRequires: pkgconfig(egl)
BuildRequires: pkgconfig(glesv2)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(protobuf)
BuildRequires: pkgconfig(protobuf-lite)
BuildRequires: pkgconfig(sdl2)
BuildRequires: pkgconfig(SDL2_image)
BuildRequires: pkgconfig(dbus-c++-1)
BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(lxc)
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(libdw)
BuildRequires: libdwarf-devel
BuildRequires: binutils-devel
BuildRequires: python
BuildRequires: git
#TODO: get minimum kmod version from git log
%if %{defined suse_version}
Requires: anbox-kmp
%endif
%if %{defined fedora}
Requires: anbox-modules-dkms
%endif
Requires: lxc
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Anbox is container based approach to boot a full Android system on a regular GNU Linux system like Ubuntu.
%if %{defined suse_version}
%debug_package
%endif
%prep
%setup -q
%patch -p1
truncate -s 0 tests/CMakeLists.txt
truncate -s 0 cmake/FindGMock.cmake
%build
%if %{defined suse_version} && 0%{?suse_version} < 1330
export CC=%{_bindir}/gcc-5
export CXX=%{_bindir}/g++-5
%endif
%if %{defined fedora}
mkdir build
pushd build
%cmake .. -DCMAKE_CXX_FLAGS="%{optflags} -Wno-error=implicit-fallthrough"
%make_build
popd
%else
%cmake -DCMAKE_CXX_FLAGS="%{optflags} -Wno-error=implicit-fallthrough"
make %{?_smp_mflags}
%endif
%install
%if %{defined fedora}
pushd build
%make_install
popd
%else
%cmake_install
%endif
install -Dm644 %{SOURCE1} %{buildroot}/%{_unitdir}/anbox-container-manager.service
install -Dm644 %{SOURCE2} %{buildroot}/%{_userunitdir}/anbox-session-manager.service
sed 's|__LIBEXECDIR__|%{_libexecdir}|g' -i %{SOURCE3}
install -Dm644 %{SOURCE3} %{buildroot}/%{_unitdir}/anbox-bridge.service
install -Dm644 %{SOURCE4} %{buildroot}/%{_presetdir}/99-anbox.preset
install -Dm644 %{SOURCE6} %{buildroot}/%{_datadir}/applications/anbox.desktop
install -Dm644 snap/gui/icon.png %{buildroot}/%{_datadir}/pixmaps/anbox.png
install -Dm 755 scripts/anbox-bridge.sh %{buildroot}%{_libexecdir}/anbox/anbox-bridge.sh
mkdir -p %{buildroot}/%{_sharedstatedir}/anbox
%check
ctest -V %{?_smp_mflags}
%files
%defattr(-,root,root)
%license COPYING.GPL
%doc README.md AUTHORS docs/architecture.png docs/build-android.md docs/runtime-setup.md
%{_bindir}/anbox
%{_bindir}/list_cpu_features
%dir %{_libexecdir}/anbox
%{_libexecdir}/anbox/anbox-bridge.sh
%{_unitdir}/anbox-container-manager.service
%{_unitdir}/anbox-bridge.service
%{_presetdir}/99-anbox.preset
%{_userunitdir}/anbox-session-manager.service
%{_datadir}/applications/anbox.desktop
%{_datadir}/pixmaps/anbox.png
%{_datadir}/anbox
%dir %{_sharedstatedir}/anbox
%{_libdir}/libcpu_features.so
%exclude %{_includedir}/backward.hpp
%exclude %{_prefix}/lib/backward/BackwardConfig.cmake
%exclude %{_includedir}/cpu_features
%exclude %{_libdir}/cmake/CpuFeatures
%post
%systemd_post anbox-container-manager.service
%systemd_post anbox-bridge.service
%if %{defined systemd_user_post}
%systemd_user_post anbox-session-manager.service
%endif
%udev_rules_update
%preun
%systemd_preun anbox-container-manager.service
%systemd_preun anbox-bridge.service
%if %{defined systemd_user_preun}
%systemd_user_preun anbox-session-manager.service
%endif
%postun
%systemd_postun anbox-container-manager.service
%systemd_postun anbox-bridge.service
%if %{defined systemd_user_postun}
%systemd_user_postun anbox-session-manager.service
%endif
%udev_rules_update
%changelog