spec: Clean up handling of dracut files

Currently the dracut modules are first prepared in a temporary directory
before they are moved to modules.d. All the preparation work can be done
by a single call to 'install' per file. Thus get rid off the indirection
and install the dracut modules directly to modules.d.

While at it merge the three macros to remove the prefix into one.

Signed-off-by: Philipp Rudo <prudo@redhat.com>
Reviewed-by: Pingfan Liu <piliu@redhat.com>
This commit is contained in:
Philipp Rudo 2023-09-06 10:49:45 +02:00 committed by Coiby Xu
parent 755ba199a7
commit 8e0b3598c1

View File

@ -228,39 +228,28 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/
install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/ install -m 644 makedumpfile-%{mkdf_ver}/eppic_scripts/* $RPM_BUILD_ROOT/usr/share/makedumpfile/eppic_scripts/
%endif %endif
%define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g') %define dracutdir %{_prefix}/lib/dracut/modules.d
%define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g') %define remove_prefix() %(echo -n %2|sed 's/.*%1-//g')
%define remove_dracut_fadump_prefix() %(echo -n %1|sed 's/.*dracut-fadump-//g')
# deal with dracut modules # deal with dracut modules
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase mkdir -p -m755 $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase
cp %{SOURCE100} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}} install -m 755 %{SOURCE100} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE100}}
cp %{SOURCE101} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} install -m 755 %{SOURCE101} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE101}}
cp %{SOURCE102} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE102}} install -m 644 %{SOURCE102} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE102}}
cp %{SOURCE104} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE104}} install -m 644 %{SOURCE104} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE104}}
cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE106}} install -m 644 %{SOURCE106} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE106}}
cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}} install -m 644 %{SOURCE107} $RPM_BUILD_ROOT/%{dracutdir}/99kdumpbase/%{remove_prefix dracut %{SOURCE107}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}} mkdir -p -m755 $RPM_BUILD_ROOT/%{dracutdir}/99earlykdump
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump install -m 755 %{SOURCE108} $RPM_BUILD_ROOT/%{dracutdir}/99earlykdump/%{remove_prefix dracut %{SOURCE108}}
cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}} install -m 755 %{SOURCE109} $RPM_BUILD_ROOT/%{dracutdir}/99earlykdump/%{remove_prefix dracut-early-kdump %{SOURCE109}}
cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
%ifarch ppc64 ppc64le %ifarch ppc64 ppc64le
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit mkdir -p -m755 $RPM_BUILD_ROOT/%{dracutdir}/99zz-fadumpinit
cp %{SOURCE200} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}} install -m 755 %{SOURCE200} $RPM_BUILD_ROOT/%{dracutdir}/99zz-fadumpinit/%{remove_prefix dracut-fadump %{SOURCE200}}
cp %{SOURCE201} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}} install -m 755 %{SOURCE201} $RPM_BUILD_ROOT/%{dracutdir}/99zz-fadumpinit/%{remove_prefix dracut-fadump %{SOURCE201}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE200}}
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99zz-fadumpinit/%{remove_dracut_fadump_prefix %{SOURCE201}}
%endif %endif
%define dracutlibdir %{_prefix}/lib/dracut
#and move the custom dracut modules to the dracut directory
mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
%post %post
# Initial installation # Initial installation
%systemd_post kdump.service %systemd_post kdump.service
@ -363,7 +352,7 @@ fi
%config %{_udevrulesdir} %config %{_udevrulesdir}
%{_udevrulesdir}/../kdump-udev-throttler %{_udevrulesdir}/../kdump-udev-throttler
%endif %endif
%{dracutlibdir}/modules.d/* %{dracutdir}/*
%dir %{_localstatedir}/crash %dir %{_localstatedir}/crash
%dir %{_sysconfdir}/kdump %dir %{_sysconfdir}/kdump
%dir %{_sysconfdir}/kdump/pre.d %dir %{_sysconfdir}/kdump/pre.d