File ch341.spec of Package ch341
#
# spec file for package r8168
#
# 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:           ch341
Version:        1.8
Release:        62.0
Summary:        ch341 linux serial driver
License:        GPL-2.0+
Group:          Hardware/Other
Url:            https://github.com/WCHSoftGroup/ch341ser_linux
Source0:        %{name}-%{version}.tar.gz
Source1:        preamble
Source2:        Module.supported
Patch1:         kernel612.patch
%if 0%{?sle_version} == 150500
BuildRequires:  kernel-syms-rt
%endif
%if 0%{?sle_version} == 150400
BuildRequires:  kernel-syms-rt
%endif
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
USB serial driver for USB to UART chip ch340, ch341, etc. ch341 supports multiple working modes, this driver only supports its serial port mode.
In fact the ch341 serial driver has been built-in since the Linux mainline kernel version 2.6.24. The location is: drivers/usb/serial/ch341.c, it's a pity that the built-in driver cannot be kept up to date and cannot support all features of the chip. We suggest our customers to use this driver.
%kernel_module_package -n ch341 -x debug -x trace -c %_sourcedir/_projectcert.crt -p %_sourcedir/preamble
%prep
%setup -q
%patch -P 1 -p1
cp %{S:1} .
cp %{S:2} .
%build
ln -sf $(type -p kmod) modinfo
%{__mkdir} obj
for flavor in %{flavors_to_build}
do
    %{__rm}   -rf obj/$flavor
    %{__cp}   -rp driver obj/$flavor
    %{__make} -C %{kernel_source $flavor} M=$PWD/obj/$flavor modules
    ./modinfo -F alias $(find $PWD/obj/$flavor/ -name '%{name}.ko')
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
%clean
%{__rm} -rf %{buildroot}
%changelog