Blame SPECS/kmod-redhat-oracleasm.spec

36072f
%define kmod_name		oracleasm
36072f
%define kmod_vendor		redhat
36072f
%define kmod_rpm_name		kmod-redhat-oracleasm
36072f
%define kmod_driver_version	2.0.8
36072f
%define kmod_driver_epoch	8
df46ae
%define kmod_rpm_release	15.1
df46ae
%define kmod_kernel_version	4.18.0-425.3.1.el8
df46ae
%define kmod_kernel_version_min	4.18.0-425.el8
36072f
%define kmod_kernel_version_dep	4.18.0
36072f
%define kmod_kbuild_dir		drivers/block/oracleasm
df46ae
%define kmod_install_path_ga	updates/kmod-redhat-oracleasm
36072f
%define kmod_install_path	extra/kmod-redhat-oracleasm
36072f
%define kernel_pkg		kernel
36072f
%define kernel_devel_pkg	kernel-devel
36072f
%define kernel_modules_pkg	kernel-modules
36072f
df46ae
%define kmod_rpm_name_ga	%{kmod_rpm_name}-kernel_4_18_0_425_3_1
36072f
df46ae
%define kmod_rpm_name_z		%{kmod_rpm_name}-kernel_4_18_0_425_10_1
df46ae
%define kmod_kernel_version_z	4.18.0-425.10.1.el8_7
df46ae
df46ae
%define kmod_list	%{kmod_rpm_name_ga}:%{kmod_kernel_version}:%{kmod_install_path_ga}: %{kmod_rpm_name_z}:%{kmod_kernel_version_z}:%{kmod_install_path}:%{SOURCE1}
df46ae
df46ae
%{!?dist: %define dist .el8_7}
df46ae
%{!?make_build: %define make_build make}
6a892d
36072f
36072f
Source0:	%{kmod_name}-%{kmod_vendor}-%{kmod_driver_version}.tar.bz2
36072f
# Source code patches
36072f
Patch0:	0000-Makefile-config-opts.patch
6a892d
#Patch1:	0001-oracleasm-driver-replace-fs_context-with-mount_pseud.patch
36072f
Patch2:	0002-oracleasm-driver-make-bio_for_each_segment_all-worki.patch
36072f
Patch3:	0003-oracleasm-copy-rhel8-s-bio_map_user_iov.patch
022011
Patch4:	0004-update-bdi-writeback-acct_dirty-flags.patch
36072f
df46ae
Source1: kernel-devel-%{kmod_kernel_version_z}.x86_64.rpm
df46ae
df46ae
Source9000: find-requires.ksyms
df46ae
36072f
%define findpat %( echo "%""P" )
df46ae
# We bundle our own slightly modified version of find-requires.ksyms in order
df46ae
# to get kernel() Requires: for the kmod versions build against bundled
df46ae
# kernel-devel packages to be generated properly.
df46ae
%define __find_requires "%{SOURCE9000}"
36072f
%define __find_provides /usr/lib/rpm/redhat/find-provides.ksyms %{kmod_name} %{?epoch:%{epoch}:}%{version}-%{release}
36072f
%define sbindir %( if [ -d "/sbin" -a \! -h "/sbin" ]; then echo "/sbin"; else echo %{_sbindir}; fi )
36072f
%define dup_state_dir %{_localstatedir}/lib/rpm-state/kmod-dups
36072f
%define kver_state_dir %{dup_state_dir}/kver
36072f
%define kver_state_file %{kver_state_dir}/%{kmod_kernel_version}.%(arch)
36072f
%define dup_module_list %{dup_state_dir}/rpm-kmod-%{kmod_name}-modules
36072f
36072f
Name:		kmod-redhat-oracleasm
36072f
Version:	%{kmod_driver_version}
36072f
Release:	%{kmod_rpm_release}%{?dist}
36072f
%if "%{kmod_driver_epoch}" != ""
36072f
Epoch:		%{kmod_driver_epoch}
36072f
%endif
36072f
Summary:	oracleasm kernel module
36072f
Group:		System/Kernel
36072f
License:	GPLv2
36072f
URL:		https://github.com/oracle/linux-uek/tree/uek6/master/drivers/block/oracleasm
36072f
BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
6a892d
BuildRequires:	%kernel_devel_pkg = %kmod_kernel_version
6a892d
BuildRequires:	redhat-rpm-config kernel-abi-whitelists elfutils-libelf-devel kernel-rpm-macros kmod
df46ae
# For unpacking bundled kernel-devel packages
df46ae
BuildRequires:	rpm cpio
36072f
ExclusiveArch:	x86_64
36072f
36072f
%global _use_internal_dependency_generator 0
36072f
Provides:	%kernel_modules_pkg >= %{kmod_kernel_version_min}.%{_target_cpu}
36072f
Provides:	kmod-%{kmod_name} = %{?epoch:%{epoch}:}%{version}-%{release}
6a892d
Provides:	%{kmod_name} = %{?epoch:%{epoch}:}%{version}-%{release}
6a892d
Provides:	%{kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
6a892d
Requires(post):	%{sbindir}/weak-modules
6a892d
Requires(postun):	%{sbindir}/weak-modules
36072f
# if there are multiple kmods for the same driver from different vendors,
36072f
# they should conflict with each other.
36072f
Conflicts:	kmod-%{kmod_name}
7f47f2
Obsoletes:	%{name}-kernel_4_18_0_240
7f47f2
Obsoletes:	%{name}-kernel_4_18_0_240_14_1
36072f
df46ae
# Set Requires: based on kernel version(s) installed
df46ae
# "with" is important here: otherwise, ">=" and "<" parts maybe satisfied
df46ae
# by different versions that are installed simultaneously (for example,
df46ae
# 4.18.0-9999 and 4.18.0-80, respectively).
df46ae
Requires:	(%{kmod_rpm_name_ga} if (kernel >= %{kmod_kernel_version} with kernel < %{kmod_kernel_version_z}))
df46ae
Requires:	(%{kmod_rpm_name_z} if kernel >= %{kmod_kernel_version_z})
df46ae
36072f
%description
36072f
oracleasm kernel module
36072f
df46ae
%package -n %{kmod_rpm_name_ga}
df46ae
Summary:	oracleasm kernel module for kernel version %{kmod_kernel_version}..%{kmod_kernel_version_z}
df46ae
Provides:	%kernel_modules_pkg >= %{kmod_kernel_version_z}.%{_target_cpu}
df46ae
BuildRequires:	%kernel_devel_pkg = %kmod_kernel_version
df46ae
Requires:	%{kmod_rpm_name} = %{?epoch:%{epoch}:}%{version}-%{release}
df46ae
Requires(post):	%{sbindir}/weak-modules
df46ae
Requires(postun):	%{sbindir}/weak-modules
df46ae
Requires:	kernel >= %{kmod_kernel_version}
df46ae
df46ae
%description -n  %{kmod_rpm_name_ga}
df46ae
oracleasm kernel module for kernel version %{kmod_kernel_version_z} and higher.
df46ae
df46ae
%package -n %{kmod_rpm_name_z}
df46ae
Summary:	oracleasm kernel module for kernel version %{kmod_kernel_version_z} and higher
df46ae
Provides:	%kernel_modules_pkg >= %{kmod_kernel_version_z}.%{_target_cpu}
df46ae
## We can't have nice things (such as multiple kernel package versions in a brew
df46ae
## buildroot despite its parallel installability, even), so we bundle it
df46ae
## in Source1.
df46ae
#BuildRequires:	%%kernel_devel_pkg = %%kmod_kernel_version_z
df46ae
Requires:	%{kmod_rpm_name} = %{?epoch:%{epoch}:}%{version}-%{release}
df46ae
Requires(post):	%{sbindir}/weak-modules
df46ae
Requires(postun):	%{sbindir}/weak-modules
df46ae
Requires:	kernel >= %{kmod_kernel_version_z}
df46ae
df46ae
%description -n  %{kmod_rpm_name_z}
df46ae
oracleasm kernel module for kernel version %{kmod_kernel_version_z} and higher.
df46ae
df46ae
# Usage: kmod_scripts RPMNAME KVER
df46ae
%define kmod_scripts() %{expand: \
df46ae
%files -n %1 \
df46ae
	%defattr(644,root,root,755) \
df46ae
	/lib/modules/%2.%(arch) \
df46ae
	%doc /usr/share/doc/%{kmod_rpm_name}/greylist.txt.%2 \
df46ae
	\
df46ae
%post -n %1 \
df46ae
	kver="%2" \
df46ae
	modules=( $( { [ -e "/lib/modules/${kver}.%(arch)/%{kmod_install_path}" ] && find "/lib/modules/${kver}.%(arch)/%{kmod_install_path}"; } | grep '\.ko$' ) ) \
df46ae
	printf '%s\\n' "${modules[@]}" | %{sbindir}/weak-modules --add-modules --no-initramfs \
df46ae
	\
df46ae
	mkdir -p "%{kver_state_dir}" \
df46ae
	touch "%{kver_state_dir}/${kver}.%(arch)" \
df46ae
	\
df46ae
	exit 0 \
df46ae
	\
df46ae
%posttrans -n %1 \
df46ae
	# We have to re-implement part of weak-modules here because it doesn't allow \
df46ae
	# calling initramfs regeneration separately \
df46ae
	kver="%2" \
df46ae
	kver_state_file="%{kver_state_dir}/${kver}.%(arch)" \
df46ae
	if [ -f "${kver_state_file}" ]; then \
df46ae
		kver_base="%{kmod_kernel_version_dep}" \
df46ae
		kvers=$(ls -d "/lib/modules/${kver_base%%.*}"*) \
df46ae
		\
df46ae
		for k_dir in $kvers; do \
df46ae
			k="${k_dir#/lib/modules/}" \
df46ae
			\
df46ae
			tmp_initramfs="/boot/initramfs-$k.tmp" \
df46ae
			dst_initramfs="/boot/initramfs-$k.img" \
df46ae
			\
df46ae
			# The same check as in weak-modules: we assume that the kernel present \
df46ae
			# if the symvers file exists. \
df46ae
			if [ -e "/boot/symvers-$k.gz" ] || [ -e "$k_dir/symvers.gz" ]; then \
df46ae
				# Additional depmod call as weak-modules \
df46ae
				# seems to ignore the depmod configuration \
df46ae
				/usr/sbin/depmod "$k" \
df46ae
				/usr/bin/dracut -f "$tmp_initramfs" "$k" || exit 1 \
df46ae
				cmp -s "$tmp_initramfs" "$dst_initramfs" \
df46ae
				if [ "$?" = 1 ]; then \
df46ae
					mv "$tmp_initramfs" "$dst_initramfs" \
df46ae
				else \
df46ae
					rm -f "$tmp_initramfs" \
df46ae
				fi \
df46ae
			fi \
df46ae
		done \
df46ae
		\
df46ae
		rm -f "%{kver_state_dir}/${kver}.%(arch)" \
df46ae
		rmdir "%{kver_state_dir}" 2> /dev/null \
df46ae
	fi \
df46ae
	\
df46ae
	rmdir "%{dup_state_dir}" 2> /dev/null \
df46ae
	\
df46ae
	exit 0 \
df46ae
	\
df46ae
	\
df46ae
%preun -n "%1" \
df46ae
	if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then \
df46ae
		kver="%2" \
df46ae
		mkdir -p "%{kver_state_dir}" \
df46ae
		touch "%{kver_state_dir}/${kver}.%(arch)" \
df46ae
	fi \
df46ae
	\
df46ae
	mkdir -p "%{dup_state_dir}" \
df46ae
	rpm -ql "%1-%{kmod_driver_version}-%{kmod_rpm_release}%{?dist}.%(arch)" | \\\
df46ae
		grep '\\.ko$' > "%{dup_module_list}" \
df46ae
	\
df46ae
	exit 0 \
df46ae
	\
df46ae
	\
df46ae
%postun -n %1 \
df46ae
	if rpm -q --filetriggers kmod 2> /dev/null| grep -q "Trigger for weak-modules call on kmod removal"; then \
df46ae
		initramfs_opt="--no-initramfs" \
df46ae
	else \
df46ae
		initramfs_opt="" \
df46ae
	fi \
df46ae
	\
df46ae
	modules=( $(cat "%{dup_module_list}") ) \
df46ae
	rm -f "%{dup_module_list}" \
df46ae
	printf '%s\\n' "${modules[@]}" | %{sbindir}/weak-modules --remove-modules $initramfs_opt \
df46ae
	\
df46ae
	rmdir "%{dup_state_dir}" 2> /dev/null \
df46ae
	\
df46ae
	exit 0 \
df46ae
}
df46ae
df46ae
%kmod_scripts %{kmod_rpm_name_ga} %{kmod_kernel_version}
df46ae
%kmod_scripts %{kmod_rpm_name_z} %{kmod_kernel_version_z}
6a892d
36072f
36072f
%files
6a892d
%doc /usr/share/doc/%{kmod_rpm_name}/greylist.txt
df46ae
/etc/depmod.d/%{kmod_name}.conf
36072f
36072f
36072f
%prep
df46ae
# A hack for having directory name under builddir equivalent to RPM name
df46ae
%setup -c
df46ae
mv %{kmod_name}-%{kmod_vendor}-%{kmod_driver_version}/* .
36072f
36072f
%patch0 -p1
6a892d
#%patch1 -p1
36072f
%patch2 -p1
36072f
%patch3 -p1
022011
%patch4 -p1
36072f
set -- *
36072f
mkdir source
36072f
mv "$@" source/
df46ae
df46ae
# Unpacking bundled kernel-devel packages
df46ae
for name_kver in %{kmod_list}; do
df46ae
	src="${name_kver##*:}"
df46ae
	[ -n "$src" ] || continue
df46ae
	rpm2cpio "${src}" | cpio -idm
df46ae
done
36072f
36072f
%build
36072f
df46ae
for name_kver in %{kmod_list}; do
df46ae
	kver="${name_kver#*:}"
df46ae
	kver="${kver%%%%:*}"
df46ae
	src="${name_kver##*:}"
df46ae
df46ae
	rm -rf obj.${kver}
df46ae
	cp -r source obj.${kver}
df46ae
	echo > source/greylist
df46ae
df46ae
	kernel_source="${src:+.}/usr/src/kernels/${kver}.%(arch)"
df46ae
	kernel_source="$(realpath "${kernel_source}")"
df46ae
	PWD_PATH=$(realpath --relative-to="${kernel_source}" . 2>/dev/null || echo "$PWD")
df46ae
	%{make_build} -C ${kernel_source} V=1 M="$PWD_PATH/obj.${kver}/%{kmod_kbuild_dir}" \
df46ae
		NOSTDINC_FLAGS="-I$PWD_PATH/obj.${kver}/include -I$PWD_PATH/obj.${kver}/include/uapi %{nil}" \
df46ae
		EXTRA_CFLAGS="%{nil}" \
df46ae
		%{nil}
df46ae
	# mark modules executable so that strip-to-file can strip them
df46ae
	find obj.${kver}/%{kmod_kbuild_dir} -name "*.ko" -type f -exec chmod u+x '{}' +
df46ae
df46ae
	whitelist="/lib/modules/kabi-current/kabi_whitelist_%{_target_cpu}"
df46ae
	for modules in $( find obj.${kver}/%{kmod_kbuild_dir} -name "*.ko" -type f -printf "%{findpat}\n" | sed 's|\.ko$||' | sort -u ) ; do
df46ae
		## update depmod.conf
df46ae
		#module_weak_path=$(echo "$modules" | sed 's/[\/]*[^\/]*$//')
df46ae
		#if [ -z "$module_weak_path" ]; then
df46ae
		#	module_weak_path=%{name}
df46ae
		#else
df46ae
		#	module_weak_path=%{name}/$module_weak_path
df46ae
		#fi
df46ae
		#echo "override $(echo $modules | sed 's/.*\///')" \
df46ae
		#     "$(echo "%{kmod_kernel_version_dep}" |
df46ae
		#        sed 's/\.[^\.]*$//;
df46ae
		#	     s/\([.+?^$\/\\|()\[]\|\]\)/\\\0/g').*" \
df46ae
		#	     "weak-updates/$module_weak_path" >> source/depmod.conf
df46ae
df46ae
		# update greylist
df46ae
		nm -u obj.${kver}/%{kmod_kbuild_dir}/$modules.ko | sed 's/.*U //' |  sed 's/^\.//' | sort -u | while read -r symbol; do
df46ae
			grep -q "^\s*$symbol\$" $whitelist || echo "$symbol" >> source/greylist
df46ae
		done
36072f
	done
df46ae
	sort -u source/greylist | uniq > source/greylist.txt.${kver}
df46ae
df46ae
	[ "x${kver}" != "x%{kmod_kernel_version}" ] || cp source/greylist.txt.${kver} source/greylist.txt
36072f
done
df46ae
df46ae
# Custom depmod conf to avoid touching the GA kernel
df46ae
echo "override oracleasm 4\.18\.0-425\.[1-9][0-9][0-9]* weak-updates/kmod-redhat-oracleasm" > source/depmod.conf
36072f
36072f
%install
36072f
export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
df46ae
df46ae
for name_kver in %{kmod_list}; do
df46ae
	rpm_name="${name_kver%%%%:*}"
df46ae
	kver="${name_kver#*:}"
df46ae
	install_path="${kver#*:}"
df46ae
	install_path="${install_path%%:*}"
df46ae
	kver="${kver%%%%:*}"
df46ae
	src="${name_kver##*:}"
df46ae
df46ae
	export INSTALL_MOD_DIR=${install_path}
df46ae
df46ae
	kernel_source="${src:+.}/usr/src/kernels/${kver}.%(arch)"
df46ae
	kernel_source="$(realpath "${kernel_source}")"
df46ae
	PWD_PATH=$(realpath --relative-to="${kernel_source}" . 2>/dev/null || echo "$PWD")
df46ae
	make -C "${kernel_source}" V=1 modules_install \
df46ae
		M=$PWD_PATH/obj.${kver}/%{kmod_kbuild_dir}
df46ae
df46ae
	install -m 644 -D source/greylist.txt.${kver} $RPM_BUILD_ROOT/usr/share/doc/%{kmod_rpm_name}/greylist.txt.${kver}
df46ae
done
df46ae
36072f
# Cleanup unnecessary kernel-generated module dependency files.
36072f
find $INSTALL_MOD_PATH/lib/modules -iname 'modules.*' -exec rm {} \;
36072f
36072f
install -m 644 -D source/depmod.conf $RPM_BUILD_ROOT/etc/depmod.d/%{kmod_name}.conf
36072f
install -m 644 -D source/greylist.txt $RPM_BUILD_ROOT/usr/share/doc/%{kmod_rpm_name}/greylist.txt
36072f
36072f
36072f
%clean
36072f
rm -rf $RPM_BUILD_ROOT
36072f
36072f
%changelog
df46ae
* Wed Jan 04 2023 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-15.1
df46ae
- Build against kernel-4.18.0-425.10.1.el8_7 in addition to GA kernel
df46ae
  (#2155759).
df46ae
7f47f2
* Mon Aug 29 2022 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-15
7f47f2
- Rebuild against kernel-4.18.0-423.el8 (#2117753).
7f47f2
7f47f2
* Mon Jul 18 2022 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-14
7f47f2
- Add Obsoletes: tag for old kernel-specific sub-packages (#1974732).
7f47f2
7f47f2
* Mon Feb 21 2022 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-13
022011
- Update bdi->capabilities assignment due to change in the value semantics
7f47f2
  (#2060479).
022011
222421
* Tue Jul 13 2021 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-12
222421
- Rebuild against kernel-4.18.0-321.el8.
222421
6a892d
* Thu Feb 11 2021 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-11
6a892d
- Rebuild against kernel-4.18.0-286.el8.
6a892d
6a892d
* Mon Feb 08 2021 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-10
6a892d
- Rebuild against kernel-4.18.0-282.el8 (#1924967).
6a892d
6a892d
* Sun Jan 17 2021 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-9
6a892d
- Rebuild against kernel-4.18.0-275.el8.
6a892d
6a892d
* Mon Jan 04 2021 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-8
6a892d
- Check for symvers.gz presence in /lib/modules/KVER in addition to boot
6a892d
  (#1912195).
6a892d
6a892d
* Tue Dec 29 2020 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-7
6a892d
- Rebuild against kernel-4.18.0-268.el8.
6a892d
6a892d
* Wed Dec 23 2020 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-6
6a892d
- Rebuild against kernel-4.18.0-256.el8.
6a892d
6a892d
* Fri Nov 27 2020 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-5
6a892d
- Rebuild against kernel-4.18.0-254.el8.
6a892d
6a892d
* Sat Nov 21 2020 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-4
6a892d
- Rebuild against kernel-4.18.0-252.el8.
07d977
6a892d
* Fri Oct 30 2020 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-3
6a892d
- Add "Provides: oracleasm" and "Provides: oracleasm-kmod".
6a892d
- Dropping "0001-oracleasm-driver-replace-fs_context-with-mount_pseud.patch".
07d977
6a892d
* Thu Oct 22 2020 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-2
6a892d
- Revision bump due to brew NVR conflict.
07d977
6a892d
* Mon Oct 19 2020 Eugene Syromiatnikov <esyr@redhat.com> 2.0.8-1
36072f
- 19e841b848491d1e14dcd0063d8d681ed1190255
36072f
- oracleasm kernel module
6a892d
- Resolves: #1827015