aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-08-27 04:05:44 +0000
committerThierry Vignaud <tv@mageia.org>2012-08-27 04:05:44 +0000
commit47f8dda3bfb5786615f047152102dcde8750bddd (patch)
tree8cdd3de56e3ffff031c9fe12abfa9c7ca5a7e916
parent52dc0a0d04bd2b6d59d3edd5b0935501a62a1c22 (diff)
downloadiurt-47f8dda3bfb5786615f047152102dcde8750bddd.tar
iurt-47f8dda3bfb5786615f047152102dcde8750bddd.tar.gz
iurt-47f8dda3bfb5786615f047152102dcde8750bddd.tar.bz2
iurt-47f8dda3bfb5786615f047152102dcde8750bddd.tar.xz
iurt-47f8dda3bfb5786615f047152102dcde8750bddd.zip
(clean_and_build_chroot) split it out of clean_chroot()
=> one less argument to clean_chroot() (death to warlism where one add parameters to functions to make them change behaviour depending on them...)
-rwxr-xr-xiurt22
-rw-r--r--lib/Iurt/Chroot.pm25
-rw-r--r--lib/Iurt/DKMS.pm4
3 files changed, 23 insertions, 8 deletions
diff --git a/iurt2 b/iurt2
index bdf94e2..e8b5174 100755
--- a/iurt2
+++ b/iurt2
@@ -1076,7 +1076,7 @@ retry:
} while $rebuild;
if (!$run{debug} && !$run{use_old_chroot}) {
- clean_chroot($chroot_tmp, $chroot_ref, \%run, $config, 1);
+ clean_chroot($chroot_tmp, $chroot_ref, \%run, $config);
}
plog("reprocess generated packages queue");
process_queue($config, \%run, \@wrong_rpm);
diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm
index 2fc59c0..488b53e 100644
--- a/lib/Iurt/Chroot.pm
+++ b/lib/Iurt/Chroot.pm
@@ -13,6 +13,7 @@ use urpm;
our @EXPORT = qw(
add_local_user
+ clean_and_build_chroot
clean_chroot
create_build_chroot
create_temp_chroot
@@ -22,18 +23,17 @@ our @EXPORT = qw(
my $sudo = '/usr/bin/sudo';
-=head2 clean_chroot($chroot, $run, $only_clean)
+=head2 clean_chroot($chroot, $run)
Create or clean a chroot
I<$chroot> chroot path
I<$run> is the running environment
-I<%only_clean> only clean the chroot, do not create a new one
Return true.
=cut
sub clean_chroot {
- my ($chroot, $chroot_ref, $run, $config, $o_only_clean) = @_;
+ my ($chroot, $chroot_ref, $run, $config) = @_;
plog('DEBUG', "clean chroot");
if (-d $chroot) {
@@ -51,8 +51,23 @@ sub clean_chroot {
delete_chroot($run, $config, $chroot);
}
+ 0;
+}
+
+
+=head2 clean_and_build_chroot($chroot, $run)
+
+Create or clean a chroot
+I<$chroot> chroot path
+I<$run> is the running environment
+Return true.
- return 1 if $o_only_clean;
+=cut
+
+
+sub clean_and_build_chroot {
+ my ($chroot, $chroot_ref, $run, $config) = @_;
+ clean_chroot($chroot, $chroot_ref, $run, $config) and return 1;
if (!create_build_chroot($chroot, $chroot_ref, $run, $config)) {
plog('ERROR', "Failed to create chroot");
@@ -187,7 +202,7 @@ sub create_temp_chroot {
plog("Install new chroot");
plog('DEBUG', "... in $chroot_tmp");
- clean_chroot($chroot_tmp, $chroot_ref, $run, $config) or return;
+ clean_and_build_chroot($chroot_tmp, $chroot_ref, $run, $config) or return;
$chroot_tmp;
}
diff --git a/lib/Iurt/DKMS.pm b/lib/Iurt/DKMS.pm
index 7554d0d..422f9f1 100644
--- a/lib/Iurt/DKMS.pm
+++ b/lib/Iurt/DKMS.pm
@@ -3,7 +3,7 @@ package Iurt::DKMS;
use strict;
use base qw(Exporter);
use MDV::Distribconf::Build;
-use Iurt::Chroot qw(clean_chroot add_local_user dump_rpmmacros);
+use Iurt::Chroot qw(clean_and_build_chroot add_local_user dump_rpmmacros);
use Iurt::Config qw(get_maint get_prefix dump_cache);
use Iurt::Mail qw(sendmail);
use File::NCopy qw(copy);
@@ -180,7 +180,7 @@ sub dkms_compile {
my $to_compile = $run->{to_compile};
plog("building chroot: $chroot_tmp");
- clean_chroot($chroot_tmp, $chroot_tar, $run, $config);
+ clean_and_build_chroot($chroot_tmp, $chroot_tar, $run, $config);
my %installed;
# initialize urpmi command
$urpmi->urpmi_command($chroot_tmp);