Blame SPECS/kmod-redhat-cfg80211.spec

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