File r8152.spec of Package r8152

#
# spec file for package r8152
#
# Copyright (c) 2024 SUSE LINUX Products 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/
#
# norootforbuild
# needssslcertforbuild

Name:           r8152
Version:        2.20.1
Release:        1.1
Summary:        Driver for Realtek 2.5GB USB Network Controllers
License:        GPL-2.0+
Group:          Hardware/Other
Url:            https://www.realtek.com/en/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-usb-3-0-software
Source0:        %{name}-%{version}.tar.bz2
Source1:        preamble
Source2:        Module.supported

Patch1:         newID.patch
Patch2:			kernel6.4.10.patch
Patch3:			kernel68.patch
Patch4:			kernel616.patch

BuildRequires:  %kernel_module_package_buildreqs
%if 0%{?sle_version} > 150600
BuildRequires:  suse-module-tools-scriptlets
%endif
BuildRequires:  pesign-obs-integration
BuildRequires:  bc
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
ExclusiveArch:  %ix86 x86_64


%description
Driver for following Realtek 2.5GB USB-Network Controllers: 

RTL8152B
RTL8153 / RTL8153B
RTL8154 / RTL8154B
RTL8156 / RTL8156B(S)(G) 

%package udev-rules
Summary:        udev-rule File for r8152
Group:          System/Kernel
Requires:       %{name}-kmp = %{version}

%description udev-rules
Contains an the udev-rule File for r8152

%kernel_module_package -n r8152 -x debug -x trace -c %_sourcedir/_projectcert.crt -p %_sourcedir/preamble

%prep
%setup -q

%patch -P 1 -p1
%patch -P 2 -p1
%patch -P 3 -p1
%patch -P 4 -p1

cp %{S:1} .
cp %{S:2} .

set -- *
mkdir source
mv "$@" source/
mkdir obj


%build
export EXTRA_CFLAGS='-DVERSION=\"%{version}\"'
for flavor in %flavors_to_build; do
	rm -rf obj/$flavor
	cp -r source obj/$flavor
	make %{?_smp_mflags} -C /usr/src/linux-obj/%_target_cpu/$flavor modules \
	     M=$PWD/obj/$flavor
done

%install
export INSTALL_MOD_PATH=%{buildroot}
export INSTALL_MOD_DIR=updates
export BRP_PESIGN_FILES='*.ko'
export BRP_PESIGN_COMPRESS_MODULE="xz"

for flavor in %flavors_to_build; do
	make -C /usr/src/linux-obj/%_target_cpu/$flavor modules_install \
		M=$PWD/obj/$flavor
done

%{__mkdir_p} %{buildroot}%{_prefix}/lib/udev/rules.d
mv source/50-usb-realtek-net.rules %{buildroot}%{_prefix}/lib/udev/rules.d/50-usb-realtek-net.rules


%clean
%{__rm} -rf %{buildroot}

%files udev-rules
%defattr(-,root,root)
%{_prefix}/lib/udev/rules.d/50-usb-realtek-net.rules

%changelog
openSUSE Build Service is sponsored by