File degirum.spec of Package degirum

#
# spec file for package degirum
#
# Copyright (c) 2024 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#

Name:           degirum
Version:        0.5.0.3
Release:        0
Summary:        DeGirum kernel drivers
License:        GPL-2.0-only
Group:          System/Kernel
URL:            https://github.com/DeGirum/lincdadrv
Source0:        https://github.com/DeGirum/lincdadrv/archive/refs/tags/%{version}.tar.gz#/lincdadrv-%{version}.tar.gz
Source1:        preamble
Source2:        system-group-degirum.conf
Source3:        60-degirum.rules
Patch0:         lincdadrv_whitespace.diff
Patch1:         lincdadrv_printk.diff
Patch2:         lincdadrv_module.diff
BuildRequires:  %{kernel_module_package_buildreqs}
BuildRequires:  pkgconfig(systemd)
BuildRequires:  systemd-rpm-macros
BuildRequires:  sysuser-shadow
BuildRequires:  sysuser-tools
%kernel_module_package -p %_sourcedir/preamble

%description
This package contains DeGirum kernel drivers.

%package -n system-group-degirum
Summary:        System group 'dg_orca'
License:        MIT
Group:          System/Fhs
%{sysusers_requires}
BuildArch:      noarch

%description -n system-group-degirum
This package provides the system group 'dg_orca'.

%package udev-rules
Summary:        udev rules for DeGirum
License:        MIT
Group:          System/Fhs
Requires:       system-group-degirum
Requires:       systemd
BuildArch:      noarch

%description udev-rules
This package provides udev rules for the DeGirum kernel drivers.

%prep
%autosetup -p1 -n lincdadrv-%{version}
set -- *
mkdir source
mv "$@" source/
mkdir obj

%build
for flavor in %{flavors_to_build}; do
    rm -rf obj/$flavor
    cp -r source obj/$flavor
    make %{?_smp_mflags} -C %{kernel_source $flavor} %{?linux_make_arch} modules M=$PWD/obj/$flavor/src
done

%sysusers_generate_pre %{SOURCE2} degirum system-group-degirum.conf

%install
export INSTALL_MOD_PATH=%{buildroot}
for flavor in %{flavors_to_build}; do
        make -C %{kernel_source $flavor} %{?linux_make_arch} modules_install M=$PWD/obj/$flavor/src
done

mkdir -p %{buildroot}%{_sysusersdir}
install -m 644 %{SOURCE2} %{buildroot}%{_sysusersdir}/system-group-degirum.conf

mkdir -p %{buildroot}%{_prefix}/lib/udev/rules.d/
install -m 644 %{SOURCE3} %{buildroot}%{_prefix}/lib/udev/rules.d/

%pre -n system-group-degirum -f degirum.pre

%post udev-rules
%udev_rules_update

%postun udev-rules
%udev_rules_update

%files udev-rules
%{_prefix}/lib/udev/rules.d/60-degirum.rules

%files -n system-group-degirum
%{_sysusersdir}/system-group-degirum.conf

%changelog
openSUSE Build Service is sponsored by