File rtw88.spec of Package rtw88

#
# spec file for package rtl8812au
#
# 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/
#

%{?!kernel_module_directory:%define kernel_module_directory /lib/modules}

# The following line tells the buildservice to save the project certificate as
# %_sourcedir/_projectcert.crt
#
# needssslcertforbuild

Name:           rtw88
Version:        trunk+git20250315.11d2944
Release:        0
Summary:        A backport of the Realtek Wifi 5 drivers from the wireless-next repo.
License:        GPL-2.0-only
Group:          System/Kernel
URL:            https://github.com/lwfinger/rtw88
ExcludeArch:    s390x
Source0:        %{name}-%{version}.tar.xz
Source1:        %{name}-preamble
Source2:        COPYING
Source3:        GPL-2.0
Source4:        Linux-syscall-note
Source5:        license-rules.rst
Source6:        99-rtw88-denylist.conf
BuildRequires:  %{kernel_module_package_buildreqs}
BuildRequires:  pesign-obs-integration
%kernel_module_package -p %{name}-preamble -c %_sourcedir/_projectcert.crt

%description
A backport of the Realtek Wifi 5 drivers from the wireless-next repo.

The sources were obtained from https://github.com/lwfinger/rtw88.

%package KMP
Summary:        A backport of the Realtek Wifi 5 drivers from the wireless-next repo.
Group:          System/Kernel

%description KMP
A backport of the Realtek Wifi 5 drivers from the wireless-next repo.

The sources were obtained from https://github.com/lwfinger/rtw88.

%prep
%setup -q

set -- *
mkdir source
mv "$@" source/
cp "%{S:2}" source/
mkdir -p source/LICENSES/preferred/
mkdir -p source/LICENSES/exceptions/
mkdir -p source/Documentation/process/
cp "%{S:3}" source/LICENSES/preferred/
cp "%{S:4}" source/LICENSES/exceptions/
cp "%{S:5}" source/Documentation/process/
cp "%{S:6}" source/
mkdir obj

%build
%ifarch %arm
export ARCH=arm
%endif
%ifarch aarch64
export ARCH=arm64
%endif
%ifarch %ppc ppc64 ppc64le
export ARCH=powerpc
%endif
%ifarch riscv64
export ARCH=riscv
%endif
%ifarch i586
export ARCH=i386
%endif

for flavor in %{flavors_to_build} ; do
	cp -a source obj/$flavor
        pushd obj/$flavor
        sed -i -e "s,^KSRC := /lib/modules/\$(KVER)/build$,KSRC := %{_prefix}/src/linux-obj/%{_target_cpu}/$flavor," Makefile
        make -O V=1 %{?_smp_mflags}
        popd
done

%install
export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR=%{kernel_module_package_moddir}
kernel_version=`uname -r | sed -e "s/-[^-]*$//"`

echo ${kernel_version}
for flavor in %{flavors_to_build} ; do
        pushd obj/$flavor
        install -d %{buildroot}%{kernel_module_directory}/${kernel_version}-${flavor}/${INSTALL_MOD_DIR}/
        install -p -m 644 *.ko %{buildroot}%{kernel_module_directory}/${kernel_version}-${flavor}/${INSTALL_MOD_DIR}/
        popd
done

mkdir -p %{buildroot}/etc/modprobe.d/
install -p -m 644 source/99-rtw88-denylist.conf %{buildroot}/etc/modprobe.d/

export BRP_PESIGN_FILES='*.ko'

%files
%license source/COPYING
%license source/LICENSES/preferred/GPL-2.0
%license source/LICENSES/exceptions/Linux-syscall-note
%license source/Documentation/process/license-rules.rst
/etc/modprobe.d/99-rtw88-denylist.conf

%changelog
openSUSE Build Service is sponsored by