Blame SPECS/kmod-redhat-mac80211.spec

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