From cc8c5dc361b0f38af63150fb53edbe2517268463 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Tue, 23 Nov 2021 22:18:03 +0000 Subject: iurt: Allow generated src.rpm to change name Some packages use macros for Name and those can change based on the distro version. --- NEWS | 2 ++ lib/Iurt/Urpmi.pm | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index d7518b2..ad64f1a 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ - iurt: record the list of generated packages +- iurt: allow generated src.rpm to have a different name, some packages use + macros for Name and those can change based on the distro version. 0.7.16 - iurt: use --target noarch for noarch packages rather than the arch used to diff --git a/lib/Iurt/Urpmi.pm b/lib/Iurt/Urpmi.pm index eea9c38..c905034 100644 --- a/lib/Iurt/Urpmi.pm +++ b/lib/Iurt/Urpmi.pm @@ -5,6 +5,7 @@ use RPM4::Header; use File::Basename; use File::NCopy qw(copy); use MDV::Distribconf::Build; +use MDK::Common qw(cat_); use Iurt::Chroot qw(add_local_user create_temp_chroot); use Iurt::Process qw(perform_command clean_process sudo); use Iurt::Config qw(get_package_prefix); @@ -525,7 +526,20 @@ sub recreate_srpm { # return 0 unless $ret; - my $file = (glob "$chroot_tmp/home/$luser/rpmbuild/SRPMS/$name-*.src.rpm")[0]; + if (!perform_command(qq(chroot $chroot_tmp su $luser -c "rpmspec -q --srpm /home/$luser/rpmbuild/SPECS/$spec > /home/$luser/rpmbuild/SPECS/$spec.srpm_name"), + $run, $config, + use_iurt_root_command => 1, + hash => "identify_$srpm")) { + plog("ERROR: failed to get the name of the generated src.rpm"); + return; + } + my $generated_srpm_name = cat_("$chroot_tmp/home/$luser/rpmbuild/SPECS/$spec.srpm_name"); + $generated_srpm_name =~ s/\s+$//; + if (!$generated_srpm_name) { + plog("ERROR: failed to get the name of the generated src.rpm"); + return; + } + my $file = "$chroot_tmp/home/$luser/rpmbuild/SRPMS/$generated_srpm_name.src.rpm"; my ($new_srpm) = basename($file); my $prefix = get_package_prefix($srpm); my $newfile = "$chroot_tmp/home/$luser/rpmbuild/SRPMS/$prefix$new_srpm"; -- cgit v1.2.1