aboutsummaryrefslogtreecommitdiffstats
path: root/iurt2
diff options
context:
space:
mode:
Diffstat (limited to 'iurt2')
-rwxr-xr-xiurt2307
1 files changed, 152 insertions, 155 deletions
diff --git a/iurt2 b/iurt2
index b9a31ed..35dc7fa 100755
--- a/iurt2
+++ b/iurt2
@@ -58,13 +58,13 @@ my $arg = @ARGV;
my (@params, %run);
$run{program_name} = $program_name;
-$run{todo} = [ ];
+$run{todo} = [];
@params = (
# [ "one letter option", "long name option", "number of args (-X means ´at least X´)", "help text", "function to call", "log info"]
#
# no_rsync, config_help and copy_srpm kept for compatibility reasons
#
- [ "", "$program_name", 0, "[--cache] [--chrooted-urpmi <media prefix>] [--concurrent-run] [--config foo value] [--warn] [--verbose integer]
+ [ "", $program_name, 0, "[--cache] [--chrooted-urpmi <media prefix>] [--concurrent-run] [--config foo value] [--warn] [--verbose integer]
[--copy-srpm] [--debug] [--distro] [--no-rsync] [--clean user1 user2 user3] [--clean-all] [--shell] [--stop {p|c|i|l|b|a|s}]
[--use-system-distrib] [--dir] [--help foo?] [--log filename] [--group] [--unionfs]
[--upload [--markrelease] [--source]] [--dir] [--help foo?] [--log filename] [--unionfs] [--status] [--ignore-failure]
@@ -83,7 +83,7 @@ $run{todo} = [ ];
my ($tmp, @arg) = @_;
$tmp->[0] ||= {};
push @$tmp, @arg;
- 1
+ 1;
}, "Setting auto mode arguments"],
["k", "kmedia", 1, "<kernel media regexp>",
"Media Regexp to limit the kernel search to",
@@ -116,8 +116,8 @@ $run{todo} = [ ];
my ($tmp, @arg) = @_;
$tmp->[0] ||= {};
push @$tmp, @arg;
- 1
- }, "Setting chrooted-urpmi options"],
+ 1;
+ }, "Setting chrooted-urpmi options" ],
["m", "media", -1, "<media1> <media2> ... <median>",
"Media to add instead of --distrib",
sub { my ($tmp, @media) = @_; $tmp->[0]{media} = \@media; 1 }, "Limiting rebuild to the kernel in the given media regexp"],
@@ -163,7 +163,7 @@ $run{todo} = [ ];
$run{log} = pop @_;
open $run{LOG}, ">$run{log}" or die "unable to open $run{log}\n";
print *{$run{LOG}}, "command line: @ARGV\n";
- 1
+ 1;
}, "Log file" ],
[ "m", "media", -1, "<media 1> <media 2> ... <media 3>",
"Media to rebuild",
@@ -196,19 +196,19 @@ $run{todo} = [ ];
if (check_arch($_, $run{my_arch})) {
plog('DEBUG', "force build for $2 (from $1)");
- push @{$run{todo}}, [ $path, $srpm, 1 ]
+ push @{$run{todo}}, [ $path, $srpm, 1 ];
} else {
plog("ERROR: $_ could not be build on $run{my_arch}, ignored.");
}
}
- 1
+ 1;
}, "Activating rebuild mode" ],
[ "", "upload", [
["", "upload", 0, "[options]",
"Upload the rebuild packages",
sub { my ($tmp) = @_;
$tmp->[0] ||= {};
- 1
+ 1;
}, "Setting upload options"],
[ "m", "markrelease", 0, "",
"Mark SVN directory when uploading the packages",
@@ -233,7 +233,7 @@ $run{todo} = [ ];
sub { $run{verbose} = $_[0]; 1 }, "Setting verbose level" ],
[ "w", "warn", 0, "",
"Warn maintainer of the packages about problem in the rebuild",
- sub { $run{warn} = 1 ; 1 }, "Setting warn flag to warn maintainers" ],
+ sub { $run{warn} = 1; 1 }, "Setting warn flag to warn maintainers" ],
[ "", "shell", 0, "",
"Dump to a shell into the newly created chroot with sudo on rpm, urpmi, urpme and urpmi.addmedia",
sub {
@@ -243,13 +243,13 @@ $run{todo} = [ ];
"Perform rpm -b<rpm step> (p c i l b a s) instead of rpm -ba and then open a shell in the chroot",
sub {
($run{stop}) = @_;
- 1
+ 1;
}, "Setting rpm build option" ],
[ "", "status", 1, "<mail>",
"Send a status mail to the provided mail address",
sub {
($run{status_mail}) = @_;
- 1
+ 1;
}, "Setting status mail option" ],
);
@@ -263,8 +263,8 @@ plog_init($program_name, $LOG, 7, 1); # CM: hardcoded for now, will fix ASAP
my $todo = parseCommandLine($program_name, \@ARGV, \@params);
@ARGV and usage($program_name, \@params, "@ARGV, too many arguments");
foreach my $t (@$todo) {
- plog('DEBUG', "$t->[2]");
- &{$t->[0]}(@{$t->[1]}) or plog('ERR', "$t->[2]");
+ plog('DEBUG', $t->[2]);
+ &{$t->[0]}(@{$t->[1]}) or plog('ERR', $t->[2]);
}
$run{distro_tag} = $run{distro};
@@ -281,13 +281,13 @@ if (-f $configfile) {
$config = do $configfile
or die "FATAL $program_name: syntax error in $configfile";
} else {
- $config = {}
+ $config = {};
}
my $urpmi = Iurt::Urpmi->new(run => \%run, config => $config, urpmi_options => "-v --no-verify-rpm --nolock --auto --ignoresize");
$run{urpmi} = $urpmi;
if (!$run{chrooted_urpmi} && $run{group}) {
- die "FATAL $program_name: option --chrooted-urpmi is mandatory if --group is selected"
+ die "FATAL $program_name: option --chrooted-urpmi is mandatory if --group is selected";
}
my %config_usage = (
@@ -306,7 +306,7 @@ my %config_usage = (
desc => 'Name of the media holding basesystem packages',
default => sub {
my ($config, $run) = @_;
- "$config->{repository}/$run->{distro}/$run->{my_arch}/"
+ "$config->{repository}/$run->{distro}/$run->{my_arch}/";
}
},
basesystem_media => {
@@ -418,9 +418,9 @@ my %config_usage = (
);
config_usage() if $run{config_usage};
-$run{my_arch} or usage($program_name, \@params, "no architecture given (media $run{media}, run{my_arch} $run{my_arch}, todo @{$run{todo}})");
+$run{my_arch} or usage($program_name, \@params, "no architecture given (media $run{media}, run{my_arch} $run{my_arch}, todo", join(', ', @{$run{todo}}));
if (!$arch_comp{$real_arch}{$run{my_arch}}) {
- die "FATAL $program_name: could not compile $run{my_arch} binaries on a $real_arch"
+ die "FATAL $program_name: could not compile $run{my_arch} binaries on a $real_arch";
}
config_init(\%config_usage, $config, \%run);
@@ -428,21 +428,21 @@ $config->{upload} .= $run{distro};
$config->{upload} =~ s/community//g;
if ($run{distro} ne 'cooker') {
if ($run{media} ne 'main') {
- $config->{upload} .= "/$run{media}"
+ $config->{upload} .= "/$run{media}";
}
} elsif ($run{media} eq 'contrib') {
$config->{upload} =~ s/cooker/contrib/g;
}
my $lock = $run{media};
-my $local;
+my $local; # FIXME: (tv) variable $local assigned, but not read
if (!$lock && $run{chroot}) {
$lock = 'chroot';
- $local = 1
+ $local = 1;
}
if (!$lock && $run{dkms}) {
$lock = 'dkms';
- $local = 0
+ $local = 0;
}
$run{lock} = $lock;
@@ -454,22 +454,22 @@ $run{cachefile} = $cachefile;
if (!$run{debug} && $run{media} || $run{chroot}) {
$run{pidfile_home} = "$config->{cache_home}/";
$run{pidfile} = "iurt.$run{distro_tag}.$run{my_arch}.$lock";
- check_pid(\%run)
+ check_pid(\%run);
}
$config->{local_upload} ||= $config->{local_home};
my $local_spool;
if ($config->{local_spool}) {
- $local_spool = $config->{local_spool}
+ $local_spool = $config->{local_spool};
} else {
- $local_spool = "$config->{local_upload}/iurt/$run{distro_tag}/$run{my_arch}/$run{media}/"
+ $local_spool = "$config->{local_upload}/iurt/$run{distro_tag}/$run{my_arch}/$run{media}/";
}
plog('INFO', "local spool: $local_spool");
if (!-d "$local_spool/log") {
plog('DEBUG', "creating local spool $local_spool");
mkpath("$local_spool/log")
- or die "FATAL: could not create local spool dir $local_spool ($!)"
+ or die "FATAL: could not create local spool dir $local_spool ($!)";
}
$run{local_spool} = $local_spool;
@@ -489,7 +489,7 @@ if (-f $cachefile && $run{use_cache}) {
(my $date) = $file =~ /iurt\.$run{distro_tag}\.$run{my_arch}\.$run{media}\.cache\.tmp\.(\d{8})/ or next;
if ($date > $to_load && -s "$config->{cache_home}/$file" > $config->{cache_min_size}) {
$to_load = $date;
- $cachefile = "$config->{cache_home}/$file"
+ $cachefile = "$config->{cache_home}/$file";
}
}
@@ -497,7 +497,7 @@ if (-f $cachefile && $run{use_cache}) {
$cache = do $cachefile
or plog('ERR', "FATAL: could not load cache $cachefile ($!)");
}
- $clear_cache = 0 if $cache
+ $clear_cache = 0 if $cache;
}
if ($clear_cache) {
@@ -509,7 +509,7 @@ if ($clear_cache) {
run => 1,
needed => {},
no_unionfs => {}
- }
+ };
}
$run{cache} = $cache;
@@ -523,7 +523,7 @@ $to_compile += search_packages(1, $cache, \%provides, \%run, \%maint,
my $dkms;
if ($run{dkms}) {
$dkms = Iurt::DKMS->new(run => \%run, config => $config);
- $to_compile += $dkms->search_dkms()
+ $to_compile += $dkms->search_dkms;
}
$run{to_compile} = $to_compile;
@@ -535,9 +535,9 @@ my ($fulldate, $daydate) = get_date();
if ($run{use_cache}) {
$run{run} = $cache->{run};
$run{run} ||= 1;
- $cache->{run} = $run{run} + 1
+ $cache->{run} = $run{run} + 1;
} else {
- $run{run} = "0.$fulldate"
+ $run{run} = "0.$fulldate";
}
$run{daydate} = $daydate;
plog('DEBUG', "using $run{run} as chroot extension");
@@ -550,7 +550,7 @@ my $luser = $run{user} || 'builder';
check_sudo_access()
or die "FATAL: you need to have sudo access to run $program_name";
-my $debug_tag = '_debug' if $run{debug};
+my $debug_tag = $run{debug} && '_debug';
$run{debug_tag} = $debug_tag;
if ($run{unionfs}) {
plog(1, "adding unionfs module");
@@ -559,11 +559,11 @@ if ($run{unionfs}) {
$run{unionfs_dir} = "$config->{local_home}/iurt_unionfs$debug_tag/";
remove_chroot(\%run, $run{unionfs_dir}, \&clean_all_unionfs);
$run{unionfs_dir} = "$run{unionfs_dir}/$run{user}/";
- -d $run{unionfs_dir} or mkdir $run{unionfs_dir}
+ -d $run{unionfs_dir} or mkdir $run{unionfs_dir};
}
}
-my (%done, $wait_limit, $done);
+my (%done, $done);
$run{done} = \%done;
my $home = $config->{local_home};
my $union_id = 1;
@@ -572,14 +572,14 @@ my $chroot_name = "chroot_$run{distro_tag}$debug_tag";
my $chroot_tmp = "$config->{local_home}/chroot_tmp";
if (!-d $chroot_tmp) {
- mkdir $chroot_tmp
+ mkdir $chroot_tmp;
} else {
remove_chroot(\%run, $chroot_tmp, \&clean_all_chroot_tmp, $chroot_name);
}
$chroot_tmp = "$config->{local_home}/chroot_tmp/$run{user}";
if (!-d $chroot_tmp) {
- mkdir $chroot_tmp
+ mkdir $chroot_tmp;
}
$chroot_tmp = "$config->{local_home}/chroot_tmp/$run{user}/$chroot_name.$run{run}";
$run{chroot_tmp} = $chroot_tmp;
@@ -589,15 +589,15 @@ $run{chroot_path} = $chroot;
my $chroot_tar = "$chroot.$run{my_arch}.tar.gz";
$run{chroot_tar} = $chroot_tar;
if ($run{chroot} || !-d "$chroot/dev") {
- check_build_chroot($chroot, $chroot_tar, \%run, $config) or die "FATAL $program_name: could not prepare initial chroot"
+ check_build_chroot($chroot, $chroot_tar, \%run, $config) or die "FATAL $program_name: could not prepare initial chroot";
}
# now exit if there is nothing to do and it was just a cleaning pass
if ($run{no_compile} || !@{$run{todo}} && !$run{debug} && !$run{shell} && !$run{rebuild}) {
- send_status_mail(\%run, $config, $cache) if ($run{status_mail});
+ send_status_mail(\%run, $config, $cache) if $run{status_mail};
plog("no package to compile :(");
unlink "$run{pidfile_home}/$run{pidfile}" if $run{pidfile};
- exit
+ exit();
}
plog('DEBUG', "running with pid $$");
@@ -605,7 +605,7 @@ $run{prefix} = get_prefix($luser);
my $df = df $home;
if ($df->{per} >= 99) {
- die "FATAL: not enough space on the filesystem, only $df->{bavail} KB on $home, full at $df->{per}%"
+ die "FATAL: not enough space on the filesystem, only $df->{bavail} KB on $home, full at $df->{per}%";
}
if ($run{shell}) {
@@ -618,20 +618,20 @@ if ($run{shell}) {
#$urpmi->set_command($chroot_tmp);
$urpmi->urpmi_command($chroot_tmp, $luser);
- $urpmi->install_packages('chroot', $chroot_tmp, $local_spool,\%pack_provide, 'configure', "[ADMIN] installation of urpmi and sudo failed in the chroot $run{my_arch}", { check => 1, maintainer => $config->{admin} }, 'urpmi', 'sudo') or die "FATAL $program_name: could not add urpmi and sudo in the chroot";
+ $urpmi->install_packages('chroot', $chroot_tmp, $local_spool, \%pack_provide, 'configure', "[ADMIN] installation of urpmi and sudo failed in the chroot $run{my_arch}", { check => 1, maintainer => $config->{admin} }, 'urpmi', 'sudo') or die "FATAL $program_name: could not add urpmi and sudo in the chroot";
add_sudoers(\%run, $chroot_tmp, $luser);
if ($run{shell}) {
plog('NOTIFY', "dumping to a chrooted shell into $chroot_tmp");
- exec "$sudo chroot $chroot_tmp /bin/su $luser -c \"PS1='[\[\033[01;33m\]iurt $run{distro} \[\033[00m\]\u@\h \W]\$ ' bash\"";
- die "FATAL $program_name: could not exec chroot to $chroot_tmp ($!)"
+ exec $sudo, 'chroot', $chroot_tmp, '/bin/su', $luser, '-c', "PS1='[\[\033[01;33m\]iurt $run{distro} \[\033[00m\]\u@\h \W]\$ ' bash";
+ die "FATAL $program_name: could not exec chroot to $chroot_tmp ($!)";
}
}
# perform some cleaning before running to have some more space, rsync to the server too in case previous iurt crashed
if ($config->{rsync_to} && !$run{no_rsync}) {
# remove some old and very big log files not to saturate the server
- system(qq|find $local_spool/log/ -name "*.log" \\( -size +$config->{log_size_limit} -or -mtime +$config->{log_size_date} \\) -exec rm -f {} \\;|);
- system("rsync --delete -alHPe 'ssh -xc arcfour' $local_spool/log/ $config->{rsync_to}/$run{distro_tag}/$run{my_arch}/$run{media}/log/");
+ system(qq(find $local_spool/log/ -name "*.log" \\( -size +$config->{log_size_limit} -or -mtime +$config->{log_size_date} \\) -exec rm -f {} \\;));
+ system('rsync', '--delete', '-alHPe', 'ssh -xc arcfour', "$local_spool/log/", "$config->{rsync_to}/$run{distro_tag}/$run{my_arch}/$run{media}/log/");
}
if ($run{dkms} && $run{dkms_todo}) {
@@ -640,16 +640,17 @@ if ($run{dkms} && $run{dkms_todo}) {
# The next loop should be moved in a module someday
-my $s = sub {
+# FIXME: (tv) kill this dead code or use it!!
+my $_s = sub {
if ($run{main}) {
plog("dumping cache...");
dump_cache_par(\%run);
$Data::Dumper::Indent = 0;
$Data::Dumper::Terse = 1;
plog("Running environment:\n", Data::Dumper->Dump([\%run]), "\n");
- plog("Configuration:\n", Data::Dumper->Dump([$config]),"\n");
+ plog("Configuration:\n", Data::Dumper->Dump([$config]), "\n");
}
- exit
+ exit();
};
#$SIG{TERM} = $s;
#$SIG{INT} = $s;
@@ -671,7 +672,7 @@ if ($run{group}) {
do {
$rebuild = 0;
- foreach (my $i ; $i < @{$run{todo}}; $i++) {
+ for (my $i; $i < @{$run{todo}}; $i++) {
my ($dir, $srpm, $status) = @{$run{todo}[$i]};
# CM: Set argv[0] (in the C sense) to something we can easily spot and
@@ -682,7 +683,7 @@ do {
$done{$srpm} and next;
$done{$srpm} = 1;
check_version($srpm, \%srpm_version) or next;
- if ($run{debug}) { $run{debug}++ == 2 and exit }
+ if ($run{debug}) { $run{debug}++ == 2 and exit() }
$done++;
plog('NOTIFY', "Build package $srpm [$done/$to_compile]");
# FIXME unfortunately urpmi stalls quite often
@@ -694,18 +695,18 @@ do {
# $cache->{failure}{$srpm} = 1;
# dump_cache(\%run);
retry:
- $urpmi->clean_urpmi_process($chroot_tmp);
+ $urpmi->clean_urpmi_process;
my ($u_id, $chroot_tmp) = create_temp_chroot(\%run, $config,
$cache, $union_id, $chroot_tmp, $chroot_tar, $srpm) or next;
$union_id = $u_id;
$urpmi->urpmi_command($chroot_tmp, $luser);
- my ($srpm_name) = $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or next;
+ $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or next;
my ($maintainer, $cc);
if (!$run{warn}) {
($maintainer) = get_maint(\%run, $srpm);
- $cc = "$maint{$srpm}";#, maintainers\@mandriva.com";
+ $cc = $maint{$srpm};#, maintainers\@mandriva.com";
chomp $maintainer;
if (!$maintainer || $maintainer eq 'NOT_FOUND') {
$maintainer = $cc;
@@ -753,7 +754,7 @@ retry:
# CM: Hack to allow resolution of localhost inside the chroot (for
# e.g. libneon). This will be properly done elsewhere later
#
- system("$sudo sh -c \"echo 127.0.0.1 localhost > $chroot_tmp/etc/hosts\"");
+ system(qq($sudo sh -c "echo 127.0.0.1 localhost > $chroot_tmp/etc/hosts"));
# try to workarround the rpm -qa db4 error(2) from dbcursor->c_get:
# No such file or directory
@@ -770,9 +771,9 @@ retry:
if ($run{stop}) {
$urpmi->install_packages('chroot', $chroot_tmp, $local_spool, \%pack_provide, 'configure', "[ADMIN] installation of urpmi and sudo failed in the chroot $run{my_arch}", { check => 1, maintainer => $config->{admin} }, 'urpmi', 'sudo');
add_sudoers(\%run, $chroot_tmp, $luser);
- $command = "rpm -b$run{stop} /home/$luser/rpm/SPECS/$spec"
+ $command = "rpm -b$run{stop} /home/$luser/rpm/SPECS/$spec";
}
- if (!perform_command(qq{TMP=/home/$luser/tmp/ $sudo chroot $chroot_tmp /bin/su $luser -c "$command"},
+ if (!perform_command(qq(TMP=/home/$luser/tmp/ $sudo chroot $chroot_tmp /bin/su $luser -c "$command"),
\%run, $config, $cache,
mail => $maintainer,
error => "[REBUILD] $srpm from $run{distro_tag} does not build correctly on $run{my_arch}",
@@ -788,18 +789,18 @@ retry:
if ($run{stop}) {
plog("dumping to a chrooted shell into $chroot_tmp (pid $$)");
# exec does not work because it seems stdin and out are shared between children
- system("$sudo chroot $chroot_tmp /bin/su $luser -c \"PS1='[\[\033[01;33m\]iurt $run{distro} \[\033[00m\]\u@\h \W]\$ ' bash\"");
- exit
+ system($sudo, 'chroot', $chroot_tmp, '/bin/su', $luser, '-c', "PS1='[\[\033[01;33m\]iurt $run{distro} \[\033[00m\]\u@\h \W]\$ ' bash");
+ exit();
}
plog('DEBUG', "calling callback for $opt->{hash}");
if ($run{unionfs_tmp} && $output =~ /no space left on device/i) {
plog('ERROR', "ERROR: running out of space to compile $srpm in unionfs mode, will recompile it in normal mode");
$cache->{no_unionfs}{$srpm} = 1;
- return 1
+ return 1;
} elsif ($run{unionfs_tmp} && $output =~ m,$home,) {
plog('ERROR', "ERROR: seems like building $srpm needs to access /proc/self/exe, which is broken with unionfs, will try to recompile it in non unionfs mode");
$cache->{no_unionfs}{$srpm} = 1;
- return 1
+ return 1;
} elsif ($output =~ /bin\/ld: cannot find -l(\S*)|configure.*error.* (?:-l([^\s]+)|([^\s]+) includes)/) {
my $missing = $1;
my @rpm = find_provides(\%run, \%pack_provide, $missing);
@@ -819,9 +820,9 @@ retry:
$opt->{error} = "[MISSING_BUILD_REQUIRES_TAG] $missing-devel, needed to build $srpm, is not in buildrequires";
}
$cache->{buildrequires}{$srpm}{$missing} = \@rpm;
- return
+ return;
}
- 1
+ 1;
},
freq => 1)) {
@@ -843,21 +844,20 @@ retry:
if (!glob "$chroot_tmp/home/$luser/rpm/RPMS/*/*.rpm") {
if ($run{unionfs_tmp} && $cache->{no_unionfs}{$srpm}) {
- goto retry
+ goto retry;
}
$cache->{failure}{$srpm} = 1;
$run{status}{$srpm} = 'build_failure';
# 20060615
dump_cache_par(\%run);
dump_status($local_spool, \%run);
- next
+ next;
}
}
# do some cleaning if the compilation is successful
delete $cache->{needed}{$srpm} if defined $cache->{needed}{$srpm};
delete $cache->{buildrequires}{$srpm} if defined $cache->{buildrequires}{$srpm};
- my $path_rpm = $run{chrooted_urpmi} ? "/home/$luser/rpm/RPMS/" : "$chroot_tmp/home/$luser/rpm/RPMS/";
# FIXME It seems the glob is not correctly expanded any more, so listing the directory content to do so
opendir my $binfh, "$chroot_tmp/home/$luser/rpm/RPMS/";
my @packages;
@@ -876,14 +876,13 @@ retry:
my $successfile = "$local_spool/log/$srpm/binary_test_$srpm-1.log";
open my $f, ">$successfile";
print $f "$srpm build ok";
- close $f
}
$run{status}{$srpm} = 'ok';
delete $cache->{failure}{$srpm} if defined $cache->{failure}{$srpm};
if ($run{debug}) {
plog("debug mode, skip other packages");
- exit
+ exit();
} elsif ($run{group}) {
$rebuild = 1;
plog("group mode, keep packages for local media");
@@ -900,22 +899,22 @@ retry:
system("cp $chroot_tmp/home/$luser/rpm/SRPMS/$srpm $local_spool &>/dev/null") and plog("ERROR: could not copy $srpm from $chroot_tmp/home/$luser/rpm/SRPMS/ to $local_spool ($!)");
}
- process_queue($config, \%run, \@wrong_rpm, 1)
+ process_queue($config, \%run, \@wrong_rpm, 1);
}
# dymp_cache each time so that concurrent process can get updated
dump_cache_par(\%run) if $run{concurrent_run};
}
if ($run{group} && $rebuild) {
- $urpmi->order_packages($union_id, $luser)
+ $urpmi->order_packages($union_id, $luser);
}
-} while ($rebuild);
+} while $rebuild;
-my ($unionfs_dir) = $run{unionfs_dir} =~ /(.*)\/[^\/]+\/?/;
+my ($unionfs_dir) = $run{unionfs_dir} =~ m!(.*)/[^/]+/?!;
if (!$run{debug}) {
if ($run{unionfs}) {
clean_unionfs("$unionfs_dir/$run{user}", \%run, $run{run}, $union_id);
} else {
- clean_chroot($chroot_tmp, $chroot_tar, \%run, $config, 1)
+ clean_chroot($chroot_tmp, $chroot_tar, \%run, $config, 1);
}
}
plog("reprocess generated packages queue");
@@ -926,25 +925,24 @@ dump_cache_par(\%run);
plog('FAIL', "ERROR: RPM with a wrong SRPM name") if @wrong_rpm;
if (@wrong_rpm && open my $file, ">$local_spool/log/wrong_srpm_names.log") {
foreach (@wrong_rpm) {
- print $file "$_->[1] -> $_->[0] (", $cache->{rpm_srpm}{$_->[1]},")\n";
+ print $file "$_->[1] -> $_->[0] (", $cache->{rpm_srpm}{$_->[1]}, ")\n";
}
- close $file
}
dump_status($local_spool, \%run);
-send_status_mail(\%run, $config, $cache) if ($run{status_mail});
+send_status_mail(\%run, $config, $cache) if $run{status_mail};
if ($config->{rsync_to} && !$run{no_rsync}) {
# remove some old and very big log files not to saturate the server
- system(qq|find $local_spool/log/ -name "*.log" \\( -size +$config->{log_size_limit} -or -mtime +$config->{log_size_date} \\) -exec rm -f {} \\;|);
- system("rsync --delete -alHPe 'ssh -xc arcfour' $local_spool/log/ $config->{rsync_to}/$run{distro_tag}/$run{my_arch}/$run{media}/log/");
+ system(qq(find $local_spool/log/ -name "*.log" \\( -size +$config->{log_size_limit} -or -mtime +$config->{log_size_date} \\) -exec rm -f {} \\;));
+ system('rsync', '--delete', '-alHPe', 'ssh -xc arcfour', "$local_spool/log/", "$config->{rsync_to}/$run{distro_tag}/$run{my_arch}/$run{media}/log/");
}
# one last try to clean
plog('DEBUG', "clean remaining unionfs");
if ($run{unionfs}) {
- remove_chroot(\%run, $unionfs_dir, \&clean_all_unionfs)
+ remove_chroot(\%run, $unionfs_dir, \&clean_all_unionfs);
}
unlink "$run{pidfile_home}/$run{pidfile}" if $run{pidfile};
@@ -969,18 +967,18 @@ sub check_needed {
$cache->{needed}{$srpm}{$missing} = {
version => $version,
maint => $maint
- }
+ };
}
- $ent = $cache->{needed}{$srpm}
+ $ent = $cache->{needed}{$srpm};
}
foreach my $name (keys %$ent) {
- my ($package, $version, $maint) = @{$ent->{$name}}{'package', 'version','maint'};
+ my ($package, $version, $maint) = @{$ent->{$name}}{'package', 'version', 'maint'};
# if packages does not exist anymore, it may have been rebuild, then try to recompute the build dependencies
last if $package && !$provides->{$package};
- my ($p_version) = $provides->{$name};
+ my $p_version = $provides->{$name};
if ($p_version) {
next if $version == $p_version;
- next if URPM::ranges_overlap($version, $p_version)
+ next if URPM::ranges_overlap($version, $p_version);
}
$ok = 0;
if ($version) {
@@ -994,10 +992,10 @@ sub check_needed {
}
# try to recompile it once in a while
last if $cache->{warning}{"install_deps_$srpm"}{$maint}++ % 72;
- return 1
+ return 1;
}
delete $cache->{needed}{$srpm} if $ok;
- $ok
+ $ok;
}
sub process_queue {
@@ -1009,23 +1007,23 @@ sub process_queue {
foreach my $rpm (readdir $rpmdir) {
my ($rarch, $srpm) = $urpmi->update_srpm($dir, $rpm, $wrong_rpm);
$rarch or next;
- plog("$rpm");
+ plog($rpm);
next if !$run->{upload};
# recheck if the package has not been uploaded in the meantime
my $rpms_dir = "$config->{repository}/$run->{distro}/$run->{my_arch}/media/$run->{media}/";
if (! -f "$rpms_dir/$rpm") {
- my $err = system('/usr/bin/scp',"$dir/$rpm", $config->{upload} . "/$config->{extra_subdir}/RPMS/");
+ my $err = system('/usr/bin/scp', "$dir/$rpm", $config->{upload} . "/$config->{extra_subdir}/RPMS/");
# try to keep the opportunity to prevent disk full
- if ($err){
+ if ($err) {
plog("ERROR: process_queue: cannot copy $dir/$rpm to ", $config->{upload}, "/$config->{extra_subdir}/RPMS/ ($!)");
- next
+ next;
}
}
if ($run->{upload_source}) {
}
unlink "$dir/$rpm";
- $cache->{queue}{$srpm} = 1
+ $cache->{queue}{$srpm} = 1;
}
closedir $rpmdir;
}
@@ -1033,11 +1031,11 @@ sub process_queue {
sub check_version {
my ($srpm, $srpm_version) = @_;
my ($srpm_name) = $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm/;
- if (URPM::ranges_overlap("= $srpm",">= $srpm_version->{$srpm_name}")) {
+ if (URPM::ranges_overlap("= $srpm", ">= $srpm_version->{$srpm_name}")) {
$srpm_version->{$srpm_name} = $srpm;
- return 1
+ return 1;
}
- 0
+ 0;
}
sub check_pid {
@@ -1072,11 +1070,11 @@ sub check_pid {
my $pid = <$test_PID>;
my (@stat) = stat $pf;
my $time = $stat[9];
- my $diff = time - $time;
+ my $diff = time()-$time;
my $msg = "$program_name: an other iurt is running for $run->{my_arch} on $pid_host, pid $pid, since $diff seconds";
if ($diff < 36000) {
plog("$msg\n");
- exit
+ exit();
} else {
plog("$msg, ignoring it");
}
@@ -1092,27 +1090,27 @@ sub check_pid {
close $test_PID;
if (!$pid) {
plog("ERROR: invalid pidfile ($pid), should be <pid>");
- unlink $pidfile
+ unlink $pidfile;
}
if ($pid && getpgrp $pid != -1) {
my $time = $stat[9];
my $state = `ps h -o state $pid`;
chomp $state;
- if ($time < time - 36000 || $state eq 'Z') {
+ if ($time < time()-36000 || $state eq 'Z') {
plog("an other iurt pid $pid is running for a very long time or is zombie, killing it");
my $i;
while ($i < 5 && getpgrp $pid != -1) {
kill_for_good($pid);
$i++;
- sleep 1
+ sleep 1;
}
} else {
- plog("an other iurt is running for $run->{my_arch}, pid $pid, since ",time - $time," seconds");
- exit
+ plog("an other iurt is running for $run->{my_arch}, pid $pid, since ", time()-$time, " seconds");
+ exit();
}
} else {
plog("a previous iurt for $run->{my_arch} seems dead, cleaning.");
- unlink $pidfile
+ unlink $pidfile;
}
}
plog("setting $pidfile pid lock");
@@ -1122,10 +1120,10 @@ sub check_pid {
if ($lock_ok) {
File::lockf::ulock($lock);
} else {
- unlink "$lockfile.2"
+ unlink "$lockfile.2";
}
close $lock;
- unlink $lockfile
+ unlink $lockfile;
}
sub check_media {
@@ -1141,7 +1139,7 @@ sub check_media {
$rarch or next;
$cache->{queue}{$srpm} = 1;
$run{status}{$srpm} = 'ok';
- check_version($srpm, $srpm_version)
+ check_version($srpm, $srpm_version);
}
closedir $rpmdir;
}
@@ -1159,21 +1157,21 @@ sub check_media {
foreach my $p (split '@', $1) {
if ($p =~ /([^[]+)(?:\[(.*)\])?/g) {
push @prov, $1;
- $provides->{$1} = $2 || 1
+ $provides->{$1} = $2 || 1;
}
}
} elsif (/\@info\@([^@]+)@/) {
$nb++;
my $p = $1;
- my ($name) = $p =~ /(.*)-[^-]+-[^-]+\..*$/;
+ my ($name) = $p =~ /(.*)-[^-]+-[^-]+\./;
$provides->{$p} = 1;
foreach (@prov) {
- $pack_provide->{$_} = $name
+ $pack_provide->{$_} = $name;
}
- @prov = ()
+ @prov = ();
}
}
- $nb < $config->{minimum_package_number} and die "FATAL $program_name: synthesis files seems corrupted, only $nb packages found."
+ $nb < $config->{minimum_package_number} and die "FATAL $program_name: synthesis files seems corrupted, only $nb packages found.";
} else {
die "FATAL $program_name: Could not open $synthesis_file\n";
}
@@ -1183,14 +1181,14 @@ sub check_media {
#"
my $nb;
foreach my $subdir (@{$config->{all_media}{$run->{media}}}) {
- $nb += search_packages(0, $cache, $provides, $run, $maint, $srpm_version, "$config->{repository}/$run->{distro}/SRPMS/$run->{media}/$subdir/")
+ $nb += search_packages(0, $cache, $provides, $run, $maint, $srpm_version, "$config->{repository}/$run->{distro}/SRPMS/$run->{media}/$subdir/");
}
- $nb
+ $nb;
}
sub search_packages {
- my ($clean, $cache, $provides, $run, $maint, $srpm_version, @dir) = @_;
- my ($to_compile, %rep, %done_rpm);
+ my ($clean, $cache, $provides, $run, $_maint, $srpm_version, @dir) = @_;
+ my ($to_compile, %rep);
plog("iurt search_package: @dir");
foreach my $dir (@dir) {
plog("checking SRPMS dir $dir");
@@ -1200,7 +1198,7 @@ sub search_packages {
if ($srpm =~ /^\@\d+:(.*)/) {
link "$dir/$srpm", "$dir/$1";
# unlink "$dir/$srpm";
- $srpm = $1
+ $srpm = $1;
}
$srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or next;
$run->{status}{$srpm} ||= 0;
@@ -1209,7 +1207,7 @@ sub search_packages {
if (check_version($srpm, $srpm_version)) {
if (!$run->{ignore_failure} && defined $cache->{failure}{$srpm}) {
$run->{status}{$srpm} = 'build_failure';
- next
+ next;
}
my $check_needed = check_needed($srpm, $cache, $provides);
$run->{status}{$srpm} = 'missing_buildrequires' if !$check_needed;
@@ -1217,7 +1215,7 @@ sub search_packages {
if (!$cache->{queue}{$srpm} && $check_needed) {
if (!check_arch("$dir/$srpm", $run{my_arch})) {
$run->{status}{$srpm} = 'not_on_this_arch';
- next
+ next;
}
my $hdr = RPM4::Header->new("$dir/$srpm");
my $changelog = $hdr->queryformat("%{CHANGELOGNAME}");
@@ -1225,40 +1223,40 @@ sub search_packages {
$maint{$srpm} = $mail;
print "$program_name: will try to compile $srpm\n";
$to_compile++;
- push @{$run->{todo}}, [ $dir , $srpm, 1 ]
+ push @{$run->{todo}}, [ $dir , $srpm, 1 ];
}
- foreach my $arch (@{$config->{supported_arch}}) {
- $ok &&= $cache->{queue}{$srpm}
+ foreach my $arch (@{$config->{supported_arch}}) { #FIXME: (tv) this loop looks suspiciously broken
+ $ok &&= $cache->{queue}{$srpm};
}
}
if ($clean && ($rep{$srpm} || $ok)) {
print "$program_name: cleaning $dir/$srpm\n";
unlink "$dir/build/$srpm";
- unlink "$dir/$srpm"
+ unlink "$dir/$srpm";
}
- $rep{$srpm} = 1
+ $rep{$srpm} = 1;
}
- closedir $rpmdir
+ closedir $rpmdir;
}
- $to_compile
+ $to_compile;
}
sub add_sudoers {
- my ($run, $chroot, $user) = @_;
+ my ($_run, $chroot, $user) = @_;
my $file = "$chroot/etc/sudoers";
my $f;
- if (!open $f, qq{| $sudo sh -c "cat > $file"}) {
+ if (!open $f, qq(| $sudo sh -c "cat > $file")) {
plog("ERROR: could not open $file ($!)");
- return 0
+ return 0;
}
- print $f qq{Cmnd_Alias RPM=/bin/rpm,/usr/sbin/urpmi,/usr/sbin/urpme,/usr/sbin/urpmi.addmedia,/usr/sbin/urpmi.update,/usr/sbin/urpmi.removemedia
+ print $f qq(Cmnd_Alias RPM=/bin/rpm,/usr/sbin/urpmi,/usr/sbin/urpme,/usr/sbin/urpmi.addmedia,/usr/sbin/urpmi.update,/usr/sbin/urpmi.removemedia
root ALL=(ALL) ALL
$user ALL=(ALL) NOPASSWD:RPM
-};
+);
close $f;
plog("adding sudo for /bin/rpm, /usr/sbin/urpmi and /usr/sbin/urpme");
-f $file or return 0;
- 1
+ 1;
}
sub dump_status {
@@ -1267,14 +1265,13 @@ sub dump_status {
if (open my $file, ">$local_spool/log/status.${media}log") {
foreach my $srpm (sort keys %{$run->{status}}) {
print $file "$srpm: ";
- if ($run{status}->{$srpm}) {
- print $file $run->{status}{$srpm}
+ if ($run{status}{$srpm}) {
+ print $file $run->{status}{$srpm};
} else {
- print $file "unknown"
+ print $file "unknown";
}
- print $file "\n"
+ print $file "\n";
}
- close $file
}
}
@@ -1297,21 +1294,21 @@ sub send_status_mail {
my $maint = $h->{maint} || 'Other';
my $package = $h->{package};
if ($package) {
- push @{$output{missing}{$maint}{$package}{$missing}{$h->{version}}}, $rpm
+ push @{$output{missing}{$maint}{$package}{$missing}{$h->{version}}}, $rpm;
} else {
- $output{missing}{$maint}{$rpm}{$missing}{$h->{version}} = 1
+ $output{missing}{$maint}{$rpm}{$missing}{$h->{version}} = 1;
}
}
} elsif ($run->{status}{$rpm} eq 'build_failure') {
my ($maint) = get_maint($run, $rpm);
if ($cache->{buildrequires}{$rpm}) {
- push @{$output{buildrequires}{$maint}}, $rpm
+ push @{$output{buildrequires}{$maint}}, $rpm;
} else {
- push @{$output{build}{$maint}}, $rpm
+ push @{$output{build}{$maint}}, $rpm;
}
} elsif (!$run->{status}{$rpm}) {
# need to find something more usefull to do at that point
- next
+ next;
}
}
@@ -1322,15 +1319,15 @@ sub send_status_mail {
foreach my $missing (keys %{$cache->{buildrequires}{$pack}}) {
my $rpms = $cache->{buildrequires}{$pack}{$missing};
if (@$rpms) {
- $text .= " $pack should have a buildrequires on @$rpms (for $missing-devel)\n"
+ $text .= " $pack should have a buildrequires on @$rpms (for $missing-devel)\n";
} else {
- $text .= " $pack should have a buildrequires for $missing-devel\n"
+ $text .= " $pack should have a buildrequires for $missing-devel\n";
}
}
}
}
- my $text = "*** Missing dependencies ***\n";
+ $text = "*** Missing dependencies ***\n";
foreach my $maint (keys %{$output{missing}}) {
$text .= "\n$maint\n";
foreach my $pack (keys %{$output{missing}{$maint}}) {
@@ -1338,10 +1335,10 @@ sub send_status_mail {
my $h = $output{missing}{$maint}{$pack}{$missing};
foreach my $version (keys %$h) {
if (ref $h->{$version}) {
- $text .= " $pack should be recompile because\n $missing ". ($version ? "$version " : ''). "is not provided anymore\n";
- $text .= " to compile ". join("\n ", @{$h->{$version}}). "\n"
+ $text .= " $pack should be recompile because\n $missing " . ($version ? "$version " : '') . "is not provided anymore\n";
+ $text .= " to compile " . join("\n ", @{$h->{$version}}) . "\n";
} else {
- $text .= " $pack needs $missing ". ($version ? "$version " : ''). "\n";
+ $text .= " $pack needs $missing " . ($version ? "$version " : '') . "\n";
}
}
}
@@ -1351,31 +1348,31 @@ sub send_status_mail {
foreach my $maint (keys %{$output{build}}) {
$text .= "\n$maint\n";
foreach my $rpm (@{$output{build}{$maint}}) {
- $text .= " $rpm (see $config->{log_url}/$run{distro_tag}/$run{my_arch}/$run->{media}/log/$rpm/)\n"
+ $text .= " $rpm (see $config->{log_url}/$run{distro_tag}/$run{my_arch}/$run->{media}/log/$rpm/)\n";
}
}
print "$text\n";
- sendmail($run->{status_mail}, '' , "Iurt report for $run->{my_arch}/$run->{media}", "$text", "Iurt the rebuild bot <$config->{admin}>", 0)
+ sendmail($run->{status_mail}, '' , "Iurt report for $run->{my_arch}/$run->{media}", $text, "Iurt the rebuild bot <$config->{admin}>", 0);
}
sub find_provides {
- my ($run, $pack_provide, $p) = @_;
+ my ($_run, $pack_provide, $p) = @_;
my @rpm;
foreach my $provides (keys %{pack_provide}) {
if ($provides =~ /$p/ && $provides =~ /devel/) {
push @rpm, $pack_provide->{$provides};
}
}
- @rpm
+ @rpm;
}
-sub check_sudo_access {
+sub check_sudo_access() {
open my $right, "$sudo -l |";
return 1 if ! $<;
local $_;
- while(<$right>) {
- /\(ALL\)\s+NOPASSWD:\s+ALL/ and return 1
+ while (<$right>) {
+ /\(ALL\)\s+NOPASSWD:\s+ALL/ and return 1;
}
- 0
+ 0;
}