File rtl8814au.spec of Package rtl8814au

#
# spec file for package rtl8814au
#
# Copyright (c) 2022 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/
#


%define archive_name 8814au
Name:           rtl8814au
Version:        1
Release:        0
Summary:        Linux Driver for USB WiFi Adapters that are based on the RTL8814AU Chipset
License:        GPL-2.0-only
URL:            https://github.com/morrownr/8814au
Source0:        _service
Source1:        %{name}-preamble
BuildRequires:  %{kernel_module_package_buildreqs}
BuildRequires:  bc
BuildRequires:  kernel-macros
BuildRequires:  module-init-tools
BuildRequires:  pesign-obs-integration
%{?!kernel_module_directory:%define kernel_module_directory /lib/modules}

%description
Kernel driver for Realtek 8814au wifi cards

The sources were obtained from https://github.com/morrownr/8814au, which adapts the official driver
released by Realtek to build on recent kernels.

%package KMP
Summary:        Kernel driver for Realtek rtl8814au wifi cards
Group:          System/Kernel

%description KMP
Kernel driver for Realtek 8814au wifi cards

The sources were obtained from https://github.com/morrownr/8814au, which adapts the official driver
released by Realtek to build on recent kernels.

%kernel_module_package -p %{name}-preamble

%prep
%setup -q -n %{_sourcedir}/%{archive_name}-%{version} -T -D

set -- *
mkdir source
mv "$@" 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

for flavor in %{flavors_to_build} ; do
    rm -rf obj/$flavor
    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_build
    popd
done

%install
%if 0%{?suse_version} > 1600
install -D -m 644 source/LICENSE %{buildroot}%{_licensedir}/%name/LICENSE
install -D -m 644 source/README.md %{buildroot}%{_docdir}/%name/README.md
%endif

export BRP_PESIGN_FILES="*.ko"
export BRP_PESIGN_COMPRESS_MODULE=%{compress_modules}
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}/lib/modules/${kernel_version}-${flavor}/${INSTALL_MOD_DIR}/
    mkdir -p %{buildroot}%{kernel_module_directory}/${kernel_version}-${flavor}/${INSTALL_MOD_DIR}/
    install -p -m 644 8814au.ko %{buildroot}%{kernel_module_directory}/${kernel_version}-${flavor}/${INSTALL_MOD_DIR}/
    popd
done

%files
%license source/LICENSE
%doc source/README.md

%changelog
openSUSE Build Service is sponsored by