diff options
author | Pascal Terjan <pterjan@mageia.org> | 2023-01-20 19:45:49 +0000 |
---|---|---|
committer | Pascal Terjan <pterjan@mageia.org> | 2023-01-20 19:45:49 +0000 |
commit | 6877e5fc2846c54c6739ecbdd779d7e6092154fb (patch) | |
tree | 897d79af8bb6fac2ca30eb2f70a7f34d48ad546d /lib | |
parent | a04fa2d3f724847222525407b31f22404ec0012e (diff) | |
download | iurt-6877e5fc2846c54c6739ecbdd779d7e6092154fb.tar iurt-6877e5fc2846c54c6739ecbdd779d7e6092154fb.tar.gz iurt-6877e5fc2846c54c6739ecbdd779d7e6092154fb.tar.bz2 iurt-6877e5fc2846c54c6739ecbdd779d7e6092154fb.tar.xz iurt-6877e5fc2846c54c6739ecbdd779d7e6092154fb.zip |
iurt: Cleanup some duplicated code
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Iurt/Urpmi.pm | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/Iurt/Urpmi.pm b/lib/Iurt/Urpmi.pm index 2343ee8..62156e3 100644 --- a/lib/Iurt/Urpmi.pm +++ b/lib/Iurt/Urpmi.pm @@ -445,6 +445,18 @@ sub install_packages { $ok; } +sub get_srpm_name { + my ($run, $config, $chroot_tmp, $srpm, $luser, $spec) = @_; + if (!perform_command(qq(chroot $chroot_tmp su $luser -c "rpmspec -q --qf %{NVR}.src.rpm --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; + } + return cat_("$chroot_tmp/home/$luser/rpmbuild/SPECS/$spec.srpm_name"); +} + # return ("exit_code", srpm, spec) sub recreate_srpm { my ($_self, $run, $config, $chroot_tmp, $dir, $srpm, $luser, $b_retry) = @_; @@ -526,14 +538,7 @@ sub recreate_srpm { # return 0 unless $ret; - if (!perform_command(qq(chroot $chroot_tmp su $luser -c "rpmspec -q --qf %{NVR}.src.rpm --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 $new_srpm = cat_("$chroot_tmp/home/$luser/rpmbuild/SPECS/$spec.srpm_name"); + my $new_srpm = get_srpm_name($run, $config, $chroot_tmp, $srpm, $luser, $spec); if (!$new_srpm) { plog("ERROR: failed to get the name of the generated src.rpm"); return; @@ -553,7 +558,6 @@ sub recreate_srpm { ($ret, "$prefix$new_srpm", $spec); } -# return ("exit_code", srpm, spec) sub install_dynamic_buildrequires { my ($self, $run, $config, $chroot_tmp, $luser, $spec, $srpm) = @_; my $program_name = $run->{program_name}; @@ -566,14 +570,7 @@ sub install_dynamic_buildrequires { return 1; } - if (!perform_command(qq(chroot $chroot_tmp su $luser -c "rpmspec -q --qf %{NVR}.src.rpm --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 $new_srpm = cat_("$chroot_tmp/home/$luser/rpmbuild/SPECS/$spec.srpm_name"); + my $new_srpm = get_srpm_name($run, $config, $chroot_tmp, $srpm, $luser, $spec); if (!$new_srpm) { plog("ERROR: failed to get the name of the generated src.rpm"); return; |