From 17a0eb83d851331bad1e2c1185d1751910197846 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Mon, 2 Aug 2004 00:03:20 +0000 Subject: Make perl_checker a bit more happy --- URPM/Build.pm | 41 +++++++++++++++++++++++------------------ URPM/Query.pm | 15 +++++++-------- URPM/Resolve.pm | 8 ++++---- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/URPM/Build.pm b/URPM/Build.pm index f8a6932..b40b005 100644 --- a/URPM/Build.pm +++ b/URPM/Build.pm @@ -27,16 +27,17 @@ sub parse_rpms_build_headers { while (defined (my $file = readdir $dirh)) { my ($fullname, $filename) = $file =~ /(.+?-[^:\-]+-[^:\-]+\.[^:\-\.]+)(?::(\S+))?$/ or next; my @stat = stat "$dir/$file"; - $cache{$filename || $fullname} = { file => $file, - size => $stat[7], - time => $stat[9], - }; + $cache{$filename || $fullname} = { + file => $file, + size => $stat[7], + 'time' => $stat[9], + }; } closedir $dirh; } foreach (@{$options{rpms}}) { - my ($key) = m{([^/]*)\.rpm$} or next; #- get rpm filename. + my ($key) = /([^\/]*)\.rpm$/ or next; #- get rpm filename. my ($id, $filename); if ($cache{$key} && $cache{$key}{time} > 0 && $cache{$key}{time} >= (stat $_)[9]) { @@ -139,9 +140,9 @@ sub parse_rpms { rpms => $rpms, %options, callback => sub { - my ($urpm, $id) = @_; - $start = $id if($start > $id || ! defined($start)); - $end = $id if($end < $id || ! defined($end)); + my (undef, $id) = @_; + $start = $id if $start > $id || ! defined($start); + $end = $id if $end < $id || ! defined($end); } ) ? ($start, $end) : (); } @@ -177,10 +178,11 @@ sub fuzzy_parse { #- callback : callback to relocate reference to package id. sub compute_deps { my ($urpm, %options) = @_; - my %propagated_weight = ( basesystem => 10000, - msec => 20000, - filesystem => 50000, - ); + my %propagated_weight = ( + basesystem => 10000, + msec => 20000, + filesystem => 50000, + ); my ($locales_weight, $step_weight, $fixed_weight) = (-5000, 10000, $propagated_weight{basesystem}); #- avoid recomputing already present infos, take care not to modify @@ -213,9 +215,11 @@ sub compute_deps { while (my $req = shift @requires) { $req =~ /^basesystem/ and next; #- never need to requires basesystem directly as always required! what a speed up! - my $treq = ($req =~ /^\d+$/ && [ $req ] || - $urpm->{provides}{$req} && [ keys %{$urpm->{provides}{$req}} ] || - [ ($req !~ /NOTFOUND_/ && "NOTFOUND_") . $req ]); + my $treq = ( + $req =~ /^\d+$/ ? [ $req ] + : $urpm->{provides}{$req} ? [ keys %{$urpm->{provides}{$req}} ] + : [ ($req !~ /NOTFOUND_/ ? "NOTFOUND_" : "") . $req ] + ); if (@$treq > 1) { #- this is a choice, no closure need to be done here. push @required_packages, $treq; @@ -302,7 +306,7 @@ sub compute_deps { exists $prereqs{$b}{$a} && ! exists $prereqs{$a}{$b} ? 1 : $ordered{$b} <=> $ordered{$a} or do { my ($na, $nb) = map { $urpm->{depslist}[$_]->name } ($a, $b); - my ($sa, $sb) = map { /^lib(.*)/ and $1 } ($na, $nb); + my ($sa, $sb) = map { /^lib(.*)/ ? $1 : '' } ($na, $nb); $sa && $sb ? $sa cmp $sb : $sa ? -1 : $sb ? 1 : $na cmp $nb; } } ($start .. $end)} = ($start .. $end); @@ -397,7 +401,7 @@ sub build_hdlist { -d $dir or die "no directory $dir\n"; @idlist = @{$options{idlist} || []} > 0 ? @{$options{idlist}} : - ($options{start} || 0 .. $options{end} || $#{$urpm->{depslist}}); + (($options{start} || 0) .. ($options{end} || $#{$urpm->{depslist}})); @idlist or return; #- compression ratio are not very high, sample for cooker @@ -414,7 +418,8 @@ sub build_hdlist { open my $fh, "| " . ($ENV{LD_LOADER} || '') . " packdrake -b${ratio}ds '$options{hdlist}' '$dir' $split"; foreach my $pkg (@{$urpm->{depslist}}[@idlist]) { my $filename = $pkg->fullname; - "$filename.rpm" ne $pkg->filename && $pkg->filename =~ m{([^/]*)\.rpm$} and $filename .= ":$1"; + "$filename.rpm" ne $pkg->filename && $pkg->filename =~ /([^\/]*)\.rpm$/ + and $filename .= ":$1"; -s "$dir/$filename" or die "bad header $dir/$filename\n"; print $fh "$filename\n"; } diff --git a/URPM/Query.pm b/URPM/Query.pm index e207f1d..5b62f11 100644 --- a/URPM/Query.pm +++ b/URPM/Query.pm @@ -12,13 +12,13 @@ use strict; # Return an array of ID tag sub tag2id { - my @l = @_; - my %taglist = URPM::list_rpm_tag(); - map { $taglist{uc($_)} || undef } @l; + my @l = @_; + my %taglist = URPM::list_rpm_tag(); + map { $taglist{uc($_)} || undef } @l; } sub query_pkg { - my ($urpm, $pkg, $query) = @_; + my (undef, $pkg, $query) = @_; my @tags = map { [ $pkg->get_tag(tag2id($_)) ] } $query =~ m/\%\{([^{}]*)\}*/g; @@ -29,12 +29,11 @@ sub query_pkg { my ($max, @res) = 0; foreach (@tags) { $max < $#{$_} and $max = $#{$_} }; - + foreach my $i (0 .. $max) { - push(@res, sprintf($query, map { ${$_}[ $#{$_} < $i ? $#{$_} : $i ] } @tags)); + push(@res, sprintf($query, map { ${$_}[ $#{$_} < $i ? $#{$_} : $i ] } @tags)); } - @res + @res } - 1; diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm index 616206c..b222aca 100644 --- a/URPM/Resolve.pm +++ b/URPM/Resolve.pm @@ -444,7 +444,7 @@ sub resolve_requested { exists $dep->{from} ? (from => $dep->{from}) : @{[]}, exists $dep->{requested} ? (requested => $dep->{requested}) : @{[]}, } - } grep { ref } $options{callback_choices}->($urpm, $db, $state, \@chosen); + } grep { ref $_ } $options{callback_choices}->($urpm, $db, $state, \@chosen); next; #- always redo according to choices. } @@ -908,8 +908,8 @@ sub compute_flags { my @regex; #- unless a regular expression is given, search in provides - for my $name (@$val) { - if ($name =~ m{^/(.*)/$}) { + foreach my $name (@$val) { + if ($name =~ m,^/(.*)/$,) { push @regex, $1; } else { foreach (keys %{$urpm->{provides}{$name} || {}}) { @@ -1169,7 +1169,7 @@ sub build_transaction_set { #- compatiblity method which are going to be removed. sub resolve_closure_ask_remove { - my ($urpm, $db, $state, $pkg, $from, $why, $avoided) = @_; + my ($urpm, $db, $state, $pkg, $from, $why) = @_; print STDERR "calling obsoleted method URPM::resolve_closure_ask_remove\n"; -- cgit v1.2.1