Blame SPECS/kmod-redhat-mt7921.spec

06c887
%define kmod_name		mt7921
06c887
%define kmod_vendor		redhat
06c887
%define kmod_rpm_name		kmod-redhat-mt7921
06c887
%define kmod_driver_version	4.18.0_363_dup8.5
06c887
%define kmod_driver_epoch	%{nil}
06c887
%define kmod_rpm_release	2
06c887
%define kmod_kernel_version	4.18.0-348.el8
06c887
%define kmod_kernel_version_min	%{nil}
06c887
%define kmod_kernel_version_dep	%{nil}
06c887
%define kmod_kbuild_dir		drivers/net/wireless/mediatek/mt76
06c887
%define kmod_dependencies       %{nil}
06c887
%define kmod_dist_build_deps	%{nil}
06c887
%define kmod_build_dependencies	%{nil}
06c887
%define kmod_provides           %{nil}
06c887
%define kmod_devel_package	1
06c887
%define kmod_devel_src_paths	%{nil}
06c887
%define kmod_install_path	extra/kmod-redhat-mt7921
06c887
%define kmod_files_package	0
06c887
%define kmod_files_noarch	1
06c887
%define kernel_pkg		kernel
06c887
%define kernel_devel_pkg	kernel-devel
06c887
%define kernel_modules_pkg	kernel-modules
06c887
06c887
%{!?dist: %define dist .el8_5}
06c887
%{!?make_build: %define make_build make}
06c887
06c887
%if "%{kmod_kernel_version_dep}" == ""
06c887
%define kmod_kernel_version_dep %{kmod_kernel_version}
06c887
%endif
06c887
06c887
%if "%{kmod_dist_build_deps}" == ""
06c887
%if (0%{?rhel} > 7) || (0%{?centos} > 7)
06c887
%define kmod_dist_build_deps redhat-rpm-config kernel-abi-whitelists elfutils-libelf-devel kernel-rpm-macros kmod
06c887
%else
06c887
%define kmod_dist_build_deps redhat-rpm-config kernel-abi-whitelists
06c887
%endif
06c887
%endif
06c887
06c887
Source0:	%{kmod_name}-%{kmod_vendor}-%{kmod_driver_version}.tar.bz2
06c887
# Source code patches
06c887
Patch0:	0001-mt76-connac-do-not-schedule-mac_work-if-the-device-i.patch
06c887
Patch1:	0002-mt76-mt7921-continue-to-probe-driver-when-fw-already.patch
06c887
Patch2:	9000-force-enable-mt7921.patch
06c887
Patch3:	9001-add-driver-version.patch
06c887
Patch4:	9002-change-firmware-path.patch
06c887
06c887
%define findpat %( echo "%""P" )
06c887
%define __find_requires /usr/lib/rpm/redhat/find-requires.ksyms
06c887
%define __find_provides /usr/lib/rpm/redhat/find-provides.ksyms %{kmod_name} %{?epoch:%{epoch}:}%{version}-%{release}
06c887
%define sbindir %( if [ -d "/sbin" -a \! -h "/sbin" ]; then echo "/sbin"; else echo %{_sbindir}; fi )
06c887
%define dup_state_dir %{_localstatedir}/lib/rpm-state/kmod-dups
06c887
%define kver_state_dir %{dup_state_dir}/kver
06c887
%define kver_state_file %{kver_state_dir}/%{kmod_kernel_version}.%(arch)
06c887
%define dup_module_list %{dup_state_dir}/rpm-kmod-%{kmod_name}-modules
06c887
06c887
Name:		kmod-redhat-mt7921
06c887
Version:	%{kmod_driver_version}
06c887
Release:	%{kmod_rpm_release}%{?dist}
06c887
%if "%{kmod_driver_epoch}" != ""
06c887
Epoch:		%{kmod_driver_epoch}
06c887
%endif
06c887
Summary:	mt7921 kernel module for Driver Update Program
06c887
Group:		System/Kernel
06c887
License:	GPLv2
06c887
URL:		https://www.kernel.org/
06c887
BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
06c887
BuildRequires:	%kernel_devel_pkg = %kmod_kernel_version
06c887
%if "%{kmod_dist_build_deps}" != ""
06c887
BuildRequires:	%{kmod_dist_build_deps}
06c887
%endif
06c887
ExclusiveArch:	x86_64
06c887
%global kernel_source() /usr/src/kernels/%{kmod_kernel_version}.$(arch)
06c887
06c887
%global _use_internal_dependency_generator 0
06c887
%if "%{?kmod_kernel_version_min}" != ""
06c887
Provides:	%kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu}
06c887
%else
06c887
Provides:	%kernel_modules_pkg = %{kmod_kernel_version_dep}.%{_target_cpu}
06c887
%endif
06c887
Provides:	kmod-%{kmod_name} = %{?epoch:%{epoch}:}%{version}-%{release}
06c887
Requires(post):	%{sbindir}/weak-modules
06c887
Requires(postun):	%{sbindir}/weak-modules
06c887
Requires:	kernel >= 4.18.0-348.el8
06c887
06c887
Requires:	kernel < 4.18.0-349.el8
06c887
%if 1
06c887
Requires: firmware(%{kmod_name}) = 20211119_105.gitf5d51956_dup8.5
06c887
%endif
06c887
%if "%{kmod_build_dependencies}" != ""
06c887
BuildRequires:  %{kmod_build_dependencies}
06c887
%endif
06c887
%if "%{kmod_dependencies}" != ""
06c887
Requires:       %{kmod_dependencies}
06c887
%endif
06c887
%if "%{kmod_provides}" != ""
06c887
Provides:       %{kmod_provides}
06c887
%endif
06c887
# if there are multiple kmods for the same driver from different vendors,
06c887
# they should conflict with each other.
06c887
Conflicts:	kmod-%{kmod_name}
06c887
06c887
%description
06c887
mt7921 kernel module for Driver Update Program
06c887
06c887
%if 1
06c887
06c887
%package -n kmod-redhat-mt7921-firmware
06c887
Version:	20211119_105.gitf5d51956_dup8.5
06c887
Summary:	mt7921 firmware for Driver Update Program
06c887
Provides:	firmware(%{kmod_name}) = 20211119_105.gitf5d51956_dup8.5
06c887
%if "%{kmod_kernel_version_min}" != ""
06c887
Provides:	%kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu}
06c887
%else
06c887
Provides:	%kernel_modules_pkg = %{kmod_kernel_version_dep}.%{_target_cpu}
06c887
%endif
06c887
%description -n  kmod-redhat-mt7921-firmware
06c887
mt7921 firmware for Driver Update Program
06c887
06c887
06c887
%files -n kmod-redhat-mt7921-firmware
06c887
%defattr(644,root,root,755)
06c887
/lib/firmware/mediatek/WIFI_MT7961_patch_mcu_1_2_hdr_dup8.5.bin
06c887
/lib/firmware/mediatek/WIFI_RAM_CODE_MT7961_1_dup8.5.bin
06c887
06c887
06c887
%endif
06c887
06c887
# Development package
06c887
%if 0%{kmod_devel_package}
06c887
%package -n kmod-redhat-mt7921-devel
06c887
Version:	%{kmod_driver_version}
06c887
Requires:	kernel >= 4.18.0-348.el8
06c887
06c887
Requires:	kernel < 4.18.0-349.el8
06c887
Summary:	mt7921 development files for Driver Update Program
06c887
06c887
%description -n  kmod-redhat-mt7921-devel
06c887
mt7921 development files for Driver Update Program
06c887
06c887
06c887
%files -n kmod-redhat-mt7921-devel
06c887
%defattr(644,root,root,755)
06c887
/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/
06c887
%endif
06c887
06c887
# Extra files package
06c887
%if 0%{kmod_files_package}
06c887
%package -n kmod-redhat-mt7921-files
06c887
Version:	%{kmod_driver_version}
06c887
Summary:	mt7921 additional files for Driver Update Program
06c887
%if 0%{kmod_files_noarch}
06c887
BuildArch:	noarch
06c887
%endif
06c887
%if "%{?kmod_kernel_version_min}" != ""
06c887
Provides:	%kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu}
06c887
%else
06c887
Provides:	%kernel_modules_pkg = %{kmod_kernel_version_dep}.%{_target_cpu}
06c887
%endif
06c887
06c887
%description -n  kmod-redhat-mt7921-files
06c887
mt7921 additional files for Driver Update Program
06c887
06c887
06c887
%files -n kmod-redhat-mt7921-files
06c887
%defattr(644,root,root,755)
06c887
/etc/dracut.conf.d/kmod-redhat-mt7921_dup85.conf
06c887
%endif
06c887
06c887
%post
06c887
modules=( $(find /lib/modules/%{kmod_kernel_version}.%(arch)/%{kmod_install_path} | grep '\.ko$') )
06c887
printf '%s\n' "${modules[@]}" | %{sbindir}/weak-modules --add-modules --no-initramfs
06c887
06c887
mkdir -p "%{kver_state_dir}"
06c887
touch "%{kver_state_file}"
06c887
06c887
exit 0
06c887
06c887
%posttrans
06c887
# We have to re-implement part of weak-modules here because it doesn't allow
06c887
# calling initramfs regeneration separately
06c887
if [ -f "%{kver_state_file}" ]; then
06c887
	kver_base="%{kmod_kernel_version_dep}"
06c887
	kvers=$(ls -d "/lib/modules/${kver_base%%.*}"*)
06c887
06c887
	for k_dir in $kvers; do
06c887
		k="${k_dir#/lib/modules/}"
06c887
06c887
		tmp_initramfs="/boot/initramfs-$k.tmp"
06c887
		dst_initramfs="/boot/initramfs-$k.img"
06c887
06c887
		# The same check as in weak-modules: we assume that the kernel present
06c887
		# if the symvers file exists.
06c887
		if [ -e "/boot/symvers-$k.gz" ] || [ -e "$k_dir/symvers.gz" ]; then
06c887
			/usr/bin/dracut -f "$tmp_initramfs" "$k" || exit 1
06c887
			cmp -s "$tmp_initramfs" "$dst_initramfs"
06c887
			if [ "$?" = 1 ]; then
06c887
				mv "$tmp_initramfs" "$dst_initramfs"
06c887
			else
06c887
				rm -f "$tmp_initramfs"
06c887
			fi
06c887
		fi
06c887
	done
06c887
06c887
	rm -f "%{kver_state_file}"
06c887
	rmdir "%{kver_state_dir}" 2> /dev/null
06c887
fi
06c887
06c887
rmdir "%{dup_state_dir}" 2> /dev/null
06c887
06c887
exit 0
06c887
06c887
%preun
06c887
if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then
06c887
	mkdir -p "%{kver_state_dir}"
06c887
	touch "%{kver_state_file}"
06c887
fi
06c887
06c887
mkdir -p "%{dup_state_dir}"
06c887
rpm -ql kmod-redhat-mt7921-%{kmod_driver_version}-%{kmod_rpm_release}%{?dist}.$(arch) | \
06c887
	grep '\.ko$' > "%{dup_module_list}"
06c887
06c887
%postun
06c887
if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then
06c887
	initramfs_opt="--no-initramfs"
06c887
else
06c887
	initramfs_opt=""
06c887
fi
06c887
06c887
modules=( $(cat "%{dup_module_list}") )
06c887
rm -f "%{dup_module_list}"
06c887
printf '%s\n' "${modules[@]}" | %{sbindir}/weak-modules --remove-modules $initramfs_opt
06c887
06c887
rmdir "%{dup_state_dir}" 2> /dev/null
06c887
06c887
exit 0
06c887
06c887
%files
06c887
%defattr(644,root,root,755)
06c887
/lib/modules/%{kmod_kernel_version}.%(arch)
06c887
/etc/depmod.d/%{kmod_name}.conf
06c887
%doc /usr/share/doc/%{kmod_rpm_name}/greylist.txt
06c887
%if !0%{kmod_files_package}
06c887
/etc/dracut.conf.d/kmod-redhat-mt7921_dup85.conf
06c887
%endif
06c887
06c887
%prep
06c887
%setup -n %{kmod_name}-%{kmod_vendor}-%{kmod_driver_version}
06c887
06c887
%patch0 -p1
06c887
%patch1 -p1
06c887
%patch2 -p1
06c887
%patch3 -p1
06c887
%patch4 -p1
06c887
set -- *
06c887
mkdir source
06c887
mv "$@" source/
06c887
mkdir obj
06c887
06c887
%build
06c887
rm -rf obj
06c887
cp -r source obj
06c887
06c887
PWD_PATH="$PWD"
06c887
%if "%{workaround_no_pwd_rel_path}" != "1"
06c887
PWD_PATH=$(realpath --relative-to="%{kernel_source}" . 2>/dev/null || echo "$PWD")
06c887
%endif
06c887
%{make_build} -C %{kernel_source} V=1 M="$PWD_PATH/obj/%{kmod_kbuild_dir}" \
06c887
	NOSTDINC_FLAGS="-I$PWD_PATH/obj/include -I$PWD_PATH/obj/include/uapi %{nil}" \
06c887
	EXTRA_CFLAGS="%{nil}" \
06c887
	%{nil}
06c887
# mark modules executable so that strip-to-file can strip them
06c887
find obj/%{kmod_kbuild_dir} -name "*.ko" -type f -exec chmod u+x '{}' +
06c887
06c887
whitelist="/lib/modules/kabi-current/kabi_whitelist_%{_target_cpu}"
06c887
for modules in $( find obj/%{kmod_kbuild_dir} -name "*.ko" -type f -printf "%{findpat}\n" | sed 's|\.ko$||' | sort -u ) ; do
06c887
	# update depmod.conf
06c887
	module_weak_path=$(echo "$modules" | sed 's/[\/]*[^\/]*$//')
06c887
	if [ -z "$module_weak_path" ]; then
06c887
		module_weak_path=%{name}
06c887
	else
06c887
		module_weak_path=%{name}/$module_weak_path
06c887
	fi
06c887
	echo "override $(echo $modules | sed 's/.*\///')" \
06c887
	     "$(echo "%{kmod_kernel_version_dep}" |
06c887
	        sed 's/\.[^\.]*$//;
06c887
		     s/\([.+?^$\/\\|()\[]\|\]\)/\\\0/g').*" \
06c887
		     "weak-updates/$module_weak_path" >> source/depmod.conf
06c887
06c887
	# update greylist
06c887
	nm -u obj/%{kmod_kbuild_dir}/$modules.ko | sed 's/.*U //' |  sed 's/^\.//' | sort -u | while read -r symbol; do
06c887
		grep -q "^\s*$symbol\$" $whitelist || echo "$symbol" >> source/greylist
06c887
	done
06c887
done
06c887
sort -u source/greylist | uniq > source/greylist.txt
06c887
06c887
%install
06c887
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
06c887
export INSTALL_MOD_DIR=%{kmod_install_path}
06c887
PWD_PATH="$PWD"
06c887
%if "%{workaround_no_pwd_rel_path}" != "1"
06c887
PWD_PATH=$(realpath --relative-to="%{kernel_source}" . 2>/dev/null || echo "$PWD")
06c887
%endif
06c887
make -C %{kernel_source} modules_install \
06c887
	M=$PWD_PATH/obj/%{kmod_kbuild_dir}
06c887
# Cleanup unnecessary kernel-generated module dependency files.
06c887
find $INSTALL_MOD_PATH/lib/modules -iname 'modules.*' -exec rm {} \;
06c887
06c887
install -m 644 -D source/depmod.conf $RPM_BUILD_ROOT/etc/depmod.d/%{kmod_name}.conf
06c887
install -m 644 -D source/greylist.txt $RPM_BUILD_ROOT/usr/share/doc/%{kmod_rpm_name}/greylist.txt
06c887
%if 1
06c887
install -m 644 -D source/firmware/mediatek/WIFI_MT7961_patch_mcu_1_2_hdr_dup8.5.bin $RPM_BUILD_ROOT/lib/firmware/mediatek/WIFI_MT7961_patch_mcu_1_2_hdr_dup8.5.bin
06c887
install -m 644 -D source/firmware/mediatek/WIFI_RAM_CODE_MT7961_1_dup8.5.bin $RPM_BUILD_ROOT/lib/firmware/mediatek/WIFI_RAM_CODE_MT7961_1_dup8.5.bin
06c887
06c887
%endif
06c887
%if 0%{kmod_devel_package}
06c887
install -m 644 -D $PWD/obj/%{kmod_kbuild_dir}/Module.symvers $RPM_BUILD_ROOT/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/build/Module.symvers
06c887
06c887
if [ -n "%{kmod_devel_src_paths}" ]; then
06c887
	for i in %{kmod_devel_src_paths}; do
06c887
		mkdir -p "$RPM_BUILD_ROOT/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/build/$(dirname "$i")"
06c887
		cp -rv "$PWD/source/$i" \
06c887
			"$RPM_BUILD_ROOT/lib/modules/%{kmod_rpm_name}-%{kmod_driver_version}/build/$i"
06c887
	done
06c887
fi
06c887
%endif
06c887
install -m 664 -D source/extra//etc/dracut.conf.d/kmod-redhat-mt7921_dup85.conf $RPM_BUILD_ROOT//etc/dracut.conf.d/kmod-redhat-mt7921_dup85.conf
06c887
06c887
06c887
%clean
06c887
rm -rf $RPM_BUILD_ROOT
06c887
06c887
%changelog
06c887
* Wed Feb 09 2022 Eugene Syromiatnikov <esyr@redhat.com> 4.18.0_363_dup8.5-2
06c887
- Bump release due to "Package build kmod-redhat-mt7921-4.18.0_363_dup8.5-1.el8_5
06c887
  kept gated because not onboarded to gating".
06c887
06c887
* Wed Feb 09 2022 Eugene Syromiatnikov <esyr@redhat.com> 4.18.0_363_dup8.5-1
06c887
- 9dc660bf1362f5a22a908e61004498cf7ec063a8
06c887
- mt7921 kernel module for Driver Update Program
06c887
- Resolves: #bz2051885