From 1a3de3d9cddc23c4040fd6cc804da397bc11c311 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 2 Dec 2009 18:48:02 +0000 Subject: perl_checker cleanups --- iurt2 | 23 ++++++++++++----------- lib/Iurt/Chroot.pm | 25 ++++++++++++------------- lib/Iurt/DKMS.pm | 5 ++--- ulri | 7 ++++--- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/iurt2 b/iurt2 index 08ee704..b547109 100755 --- a/iurt2 +++ b/iurt2 @@ -211,10 +211,10 @@ $run{todo} = []; sub { ($run{no_compile}) = 1 }, "Setting the no compilation flag" ], [ "p", "packager", 1, "", "Use a specific packager", - sub { ($run{packager}) = @_ }, 'Setting packager tag'], + sub { ($run{packager}) = @_ }, 'Setting packager tag' ], [ "", "build-user", 1, "", "Use this username to build package", - sub { ($run{user}) = @_ }, 'Setting build username'], + sub { ($run{user}) = @_ }, 'Setting build username' ], [ "r", "rebuild", -2, " ... ", "Rebuild the packages, e.g. $program_name -r cooker x86_64 /home/foo/rpm/SRPMS/foo-2.3-12mdv2007.0.src.rpm", sub { @@ -230,7 +230,7 @@ $run{todo} = []; } ($srpm, $path) = fileparse(rel2abs($_)); - ($srpm =~ /\.src\.rpm$/) || die "FATAL: $_ doesn't look like an SRPM"; + ($srpm =~ /\.src\.rpm$/) or die "FATAL: $_ doesn't look like an SRPM"; if (check_arch($_, $run{my_arch})) { plog('DEBUG', "force build for $2 (from $1)"); @@ -332,7 +332,7 @@ $run{todo} = []; sub { my ($tmp, @media) = @_; $tmp->[0]{media} = \@media; - 1 + 1; }, "Limiting rebuild to the kernel in the given media regexp" ], ], @@ -342,7 +342,7 @@ $run{todo} = []; my ($opt, $media) = @_; $opt->{repository} = $media; $run{additional_media} = $opt; - 1 + 1; }, "Activating additional medias" ], ############################### @@ -396,11 +396,11 @@ if (-f $configfile) { if ($run{repository}) { plog('DEBUG', "overriding configuration repository by the one given in the command line"); - $config->{repository} = $run{repository} + $config->{repository} = $run{repository}; } if (!$config->{repository}) { - die "FATAL $program_name: no repository have been defined (use --repository to specify one on the command line" + die "FATAL $program_name: no repository have been defined (use --repository to specify one on the command line"; } my $urpmi = Iurt::Urpmi->new(run => \%run, config => $config, urpmi_options => "-v --no-verify-rpm --nolock --auto --ignoresize $config->{urpmi_options}"); @@ -1060,7 +1060,7 @@ retry: $urpmi->add_to_local_media($chroot_tmp, $srpm, $luser); } else { # drop packages and logs if we only want failure logs - if($run{delete_on_success}) { + if ($run{delete_on_success}) { system("rm -rf $local_spool/log/$srpm/"); } else { plog('OK', "build successful, copying packages to $local_spool."); @@ -1084,7 +1084,7 @@ retry: my (undef, $srpm) = @{$run{todo}[$i]}; if (!$run{done}{$srpm}) { $rebuild = $urpmi->order_packages($union_id, \%provides, $luser); - last + last; } } if ($prev_done == $done) { @@ -1139,7 +1139,7 @@ if ($run{unionfs} && !$run{use_old_chroot}) { } unlink "$run{pidfile_home}/$run{pidfile}" if $run{pidfile}; -exit; +exit(); # @@ -1177,7 +1177,7 @@ sub check_needed { if ($version) { $ent->{$name}{version} = $version; } - my $v ||= $version; + my $v = $version; if ($package) { plog("ERROR: $srpm needs package $package which requires missing $name $v to be compiled."); } else { @@ -1345,6 +1345,7 @@ sub check_media { if (open my $syn, "zcat $synthesis_file |") { my @prov; my $nb; + local $_; while (<$syn>) { if (/^\@provides@(.*)/) { foreach my $p (split '@', $1) { diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm index ab8df70..82df2b0 100644 --- a/lib/Iurt/Chroot.pm +++ b/lib/Iurt/Chroot.pm @@ -50,13 +50,13 @@ sub clean_chroot { system("$sudo umount $chroot/var/cache/icecream &> /dev/null"); } if (-d "$chroot/urpmi_medias/") { - system ("$sudo umount $chroot/urpmi_medias"); + system("$sudo umount $chroot/urpmi_medias"); } # Do not run rm if there is something still mounted there - open (my $FP, "/proc/mounts") or die $!; + open(my $FP, "/proc/mounts") or die $!; my @list = grep { /$chroot/ } <$FP>; - close ($FP); + close($FP); if ($#list >= 0) { # Still referenced return 1; @@ -84,39 +84,38 @@ sub clean_chroot { # 20071106 Second try? if (!-d "$chroot/proc" || !-d "$chroot/home/builder") { - create_build_chroot($chroot, $chroot_tar, $run, $config) + create_build_chroot($chroot, $chroot_tar, $run, $config); } if (!dump_rpmmacros($run, $config, "$chroot/home/builder/.rpmmacros")) { - plog ('ERROR', "Failed to dump macros"); + plog('ERROR', "Failed to dump macros"); return; } if (system("$sudo mount none -t proc $chroot/proc")) { - plog ('ERROR', "Failed to mount proc"); + plog('ERROR', "Failed to mount proc"); return; } if (system("$sudo mount none -t devpts $chroot/dev/pts")) { - plog ('ERROR', "Failed to mount dev/pts"); + plog('ERROR', "Failed to mount dev/pts"); return; } if ($run->{icecream}) { system("$sudo mkdir -p $chroot/var/cache/icecream"); if (system("$sudo mount -o bind /var/cache/icecream $chroot/var/cache/icecream")) { - plog ('ERROR', "Failed to mount var/cache/icecream"); + plog('ERROR', "Failed to mount var/cache/icecream"); return; } } if ($run->{additional_media} && $run->{additional_media}{repository}) { my $rep = $run->{additional_media}{repository}; - if (!($rep =~ m/^(http:|ftp:)/)) { + if ($rep !~ m/^(http:|ftp:)/) { my $mount_point = "$chroot/urpmi_medias"; - my $bind; my $url = $rep; $url =~ s!^file://!!; system("$sudo mkdir -p $mount_point"); if (system("$sudo mount -o bind,ro $url $mount_point")) { - plog ('ERROR', "Failed to mount $url on $mount_point"); + plog('ERROR', "Failed to mount $url on $mount_point"); return; } } @@ -135,7 +134,7 @@ Return true. =cut sub update_chroot { - my ($chroot, $chroot_tar, $run, $config, $o_only_clean, $o_only_tar) = @_; + my ($_chroot, $_chroot_tar, $_run, $_config, $_only_clean, $_only_tar) = @_; plog('DEBUG', "update chroot"); @@ -577,7 +576,7 @@ sub build_chroot { system("$sudo umount $tmp_chroot/var/cache/icecream &> /dev/null"); } if (-d "$tmp_chroot/urpmi_medias/") { - system ("$sudo umount $tmp_chroot/urpmi_medias"); + system("$sudo umount $tmp_chroot/urpmi_medias"); } return !system($sudo, 'tar', 'czf', $chroot_tar, '-C', $tmp_chroot, '.'); } diff --git a/lib/Iurt/DKMS.pm b/lib/Iurt/DKMS.pm index c18cd51..201e883 100644 --- a/lib/Iurt/DKMS.pm +++ b/lib/Iurt/DKMS.pm @@ -93,7 +93,6 @@ sub search_dkms { my $hdr = RPM4::Header->new("$path/$rpm"); my $files = $hdr->queryformat('[%{FILENAMES}\n]'); if ($version =~ /(.*)source-(.*)/ || $version =~ /(.*)devel-(.*)/) { - my $source = "$1$2"; my ($sourcedir) = $files =~ m,^/usr/src/([^/ ]+)$,m; plog('NOTIFY', "kernel source $version (sourcedir $sourcedir)"); $kernel_source{$version} = $sourcedir; @@ -198,8 +197,8 @@ sub dkms_compile { my $dkms_spool = "$local_spool/dkms/"; -d $dkms_spool or mkdir $dkms_spool; - for (my $i; $i < @{$run->{dkms_todo}}; $i++) { - my ($name, $version, $_modulesourcedir, $realname, $realversion, $file, $kernel, $modulesdir, $source, $sourcedir, $media) = @{$run->{dkms_todo}[$i]}; + foreach my $dkms_todo (@{$run->{dkms_todo}}) { + my ($name, $version, $_modulesourcedir, $realname, $realversion, $file, $kernel, $modulesdir, $source, $sourcedir, $media) = @$dkms_todo; $done++; $media = $run->{dkms}{umedia} if $run->{dkms}{umedia}; diff --git a/ulri b/ulri index 8c06126..d654e7a 100755 --- a/ulri +++ b/ulri @@ -494,6 +494,7 @@ foreach my $prefix (keys %pkg_tree) { $text .= "\nFailure details available in $fpath/log\n"; $text .= "Reason:\n"; open my $FP, "$fail_dir/$prefix/log/status.log"; + local $_; while (<$FP>) { $text .= $_; } @@ -503,7 +504,7 @@ foreach my $prefix (keys %pkg_tree) { opendir my $DP1, "$fail_dir/$prefix/log/"; foreach my $f1 (readdir $DP1) { - if (not -d "$fail_dir/$prefix/log/$f1" or $f1 =~ m/^\./) { + if (! -d "$fail_dir/$prefix/log/$f1" or $f1 =~ m/^\./) { next; } @@ -514,7 +515,7 @@ foreach my $prefix (keys %pkg_tree) { } $text .= "$fpath/log/$f1/$f2\n"; } - closedir DP2; + closedir $DP2; } closedir $DP1; @@ -551,7 +552,7 @@ foreach my $prefix (sort keys %pkg_tree) { if ($user) { $user = get_author_email($user) || $config->{packager}; } else { - $user = $config->{packager} + $user = $config->{packager}; } $user =~ s/([<>])/\\$1/g; -- cgit v1.2.1