File anbox-modules-dkms.spec of Package anbox-modules-dkms

#
# spec file for package anbox-modules-dkms
#
# Copyright (c) 2018 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/
#

Name:           anbox-modules-dkms
Version:        0
Release:        0
Summary:        Anbox kernel modules
License:        GPL-3.0
Group:          System/Kernel
Url:            https://github.com/anbox/anbox
Source0:        anbox-modules-%{version}.tar.gz
BuildArch:      noarch
PreReq:         dkms
PreReq:         kernel-devel
Requires:       dkms
BuildRequires:	systemd
BuildRequires:	udev
Provides:       anbox-kmp = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Kernel modules for Anbox, source package for DKMS.

%prep
%setup -q -n anbox-modules-%{version}

%build
# nothing to build

%install

install -m644 anbox.conf -Dt %{buildroot}%{_prefix}/lib/modules-load.d/
install -m644 99-anbox.rules -Dt %{buildroot}%{_prefix}/lib/udev/rules.d/

# kmods
install -d %{buildroot}/%{_prefix}/src
for d in ashmem binder ; do
    cp -r $d %{buildroot}/%{_prefix}/src/anbox-$d-%{version}-%{release}
done

%post
set -x
if [ -z "$(dkms status -m anbox-ashmem -v %{version}-%{release})" ]; then
    dkms add -m anbox-ashmem -v %{version}-%{release} --rpm_safe_upgrade
fi
dkms build -m anbox-ashmem -v %{version}-%{release}
dkms install -m anbox-ashmem -v %{version}-%{release}
if [ -z "$(dkms status -m anbox-binder -v %{version}-%{release})" ]; then
    dkms add -m anbox-binder -v %{version}-%{release} --rpm_safe_upgrade
fi
dkms build -m anbox-binder -v %{version}-%{release}
dkms install -m anbox-binder -v %{version}-%{release}

%preun
set -x
dkms remove -m anbox-ashmem -v %{version}-%{release} --rpm_safe_upgrade --all ||:
dkms remove -m anbox-binder -v %{version}-%{release} --rpm_safe_upgrade --all ||:

%files
%defattr(-,root,root)
%{_prefix}/src/anbox-ashmem-%{version}-%{release}
%{_prefix}/src/anbox-binder-%{version}-%{release}
%{_prefix}/lib/modules-load.d/anbox.conf
%{_prefix}/lib/udev/rules.d/99-anbox.rules

%changelog
openSUSE Build Service is sponsored by