diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2004-08-09 08:00:25 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2004-08-09 08:00:25 +0000 |
commit | dc25d214b33eb747272fc3b7a4640251b471a2ee (patch) | |
tree | e394b4bfec1396627d51eac8c9238a28f501b6ca /mdkupdate | |
parent | 0943af348f240e34cfdad6427e3ab97b1be43a16 (diff) | |
download | mgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.tar mgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.tar.gz mgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.tar.bz2 mgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.tar.xz mgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.zip |
perl_checker cleanups
Diffstat (limited to 'mdkupdate')
-rwxr-xr-x | mdkupdate | 34 |
1 files changed, 16 insertions, 18 deletions
@@ -40,12 +40,12 @@ foreach (qw(online_dif online_update online3_RemoteAction wizard)) { my $rpms_rep = "/root/tmp/"; my $VERSION = "1.0"; my $YEARS = "2002-2004"; -my $security = grep { /^-?-security$/ } @ARGV; -my $update = grep { /^-?-update$/ } @ARGV; +my $security = find { /^-?-security$/ } @ARGV; +my $update = find { /^-?-update$/ } @ARGV; #for compatibilities mkdir_p($confdir) if !-d $confdir; --e '/root/.mdkupdate' and system("mv","/root/.mdkupdate", "$conffile"); +-e '/root/.mdkupdate' and system("mv", "/root/.mdkupdate", $conffile); my ($scheduled, $noscheduled); @@ -66,7 +66,7 @@ usage: my ($opt) = @ARGV; @ARGV == 1 && ($opt eq '--auto' || $opt eq '--security' || $opt eq '--applet') or usage(); --s $conffile or die N("No $conffile file found. Run mdkonline wizard first"); +-s $conffile or die N("No %s file found. Run mdkonline wizard first", $conffile); my %o = getVarsFromSh($conffile); if ($o{LOGIN} && $o{PASS} && $o{LOGIN} !~ /\s+/ && $o{PASS} !~ /\s+/) { @@ -76,7 +76,7 @@ if ($o{LOGIN} && $o{PASS} && $o{LOGIN} !~ /\s+/ && $o{PASS} !~ /\s+/) { my $contents = $resp->content; #print "CONTENTS = $contents \n"; if ($resp->is_success) { - if ($contents =~ /TRUE/) { $u = 10 } elsif ($contents =~ m/(\d+)/) { $u = sprintf("%d", $1) } else { $u = 83 } ; + if ($contents =~ /TRUE/) { $u = 10 } elsif ($contents =~ m/(\d+)/) { $u = sprintf("%d", $1) } else { $u = 83 }; my $action = { 10 => sub { my $c2h = split_contents($contents); @@ -88,8 +88,8 @@ if ($o{LOGIN} && $o{PASS} && $o{LOGIN} !~ /\s+/ && $o{PASS} !~ /\s+/) { #$c2h->{FTP} = 'ftp://ftp.lip6.fr/pub/linux/distributions/mandrake/updates'; add_media($c2h->{FTP}) } - $scheduled = join(',',@{$c2h->{sched}}); - $noscheduled = join(',',@{$c2h->{nosched}}); $noscheduled =~ s/\.rpm//g; + $scheduled = join(',', @{$c2h->{sched}}); + $noscheduled = join(',', @{$c2h->{nosched}}); $noscheduled =~ s/\.rpm//g; #printf "SCHEDULED = $scheduled\nNOSCHEDULED = $noscheduled\n"; if ($opt eq '--applet') { system "MandrakeUpdate", "--no-confirmation", "--media=mdkupdate", "--pkg-sel=$scheduled", "--pkg-nosel=$noscheduled"; @@ -102,11 +102,11 @@ if ($o{LOGIN} && $o{PASS} && $o{LOGIN} !~ /\s+/ && $o{PASS} !~ /\s+/) { #- send configuration and get back key to use... my $r; - ($r, $new{CURRENTKEY}) = send_conf_update($new{LOGIN},$new{PASS},$new{MACHINE}); + ($r, $new{CURRENTKEY}) = send_conf_update($new{LOGIN}, $new{PASS}, $new{MACHINE}); if ($r eq 'TRUE') { delete $new{OLDKEY}; setVarsInSh($conffile, \%new) } } else { #- this can safely be ignored if new configuration is sent. - send_rpm_dif($new{LOGIN},$new{PASS},$new{MACHINE},$new{OLDKEY}); + send_rpm_dif($new{LOGIN}, $new{PASS}, $new{MACHINE}, $new{OLDKEY}); } clean_dir(); }, @@ -136,15 +136,15 @@ sub split_contents { $s = [ split /\n/, $cont ]; $elem->{torf} = $s->[0]; if ($elem->{torf} eq 'TRUE') { - ($elem->{torf},$elem->{NEWKEY},$elem->{OLDKEY},$elem->{FTP}) = splice(@$s,0,4); - ($elem->{sched},$elem->{nosched}) = partition { $_ =~/i586$/ } @$s; + ($elem->{torf}, $elem->{NEWKEY}, $elem->{OLDKEY}, $elem->{FTP}) = splice(@$s, 0, 4); + ($elem->{sched}, $elem->{nosched}) = partition { /i586$/ } @$s; } $elem } sub auto_install_rpms { my ($pkgs) = shift; my @pkg; - push(@pkg, $_ . '.rpm') foreach @{$pkgs}; + push(@pkg, $_ . '.rpm') foreach @$pkgs; update_pkgs(@pkg); } sub update_conf { @@ -163,7 +163,7 @@ sub update_conf { sub add_media { my $mirror = shift; my ($r) = mdkonline::get_release(); - my $fullpath2mir = "ftp://" . "$mirror". "/$r" . "/RPMS" . "/" ; + my $fullpath2mir = "ftp://" . $mirror . "/$r" . "/RPMS" . "/"; eval { system "/usr/sbin/urpmi.removemedia", "mdkupdate"; system "/usr/sbin/urpmi.addmedia", "--update", "mdkupdate", $fullpath2mir, "with", "../base/synthesis.hdlist.cz"; @@ -179,14 +179,14 @@ sub update_pkgs { $@ and die "Problem upgrading with urpmi"; } sub send_conf_update { - my ($login,$password,$boxname) =@_; + my ($login, $password, $boxname) = @_; mdkonline::report_config("$confdir/$login.$password.$boxname.online.log"); my $tag = { submit => 'upload_wizard', wizard => [ "$confdir/$login.$password.$boxname.online.log.bz2.uue" ] }; my ($res, $key) = mdkonline::send_config($url->{wizard}, $tag); ($res, $key) } sub send_rpm_dif { - my ($login,$password,$boxname,$oldkey) =@_; + my ($login, $password, $boxname, $oldkey) = @_; `sdiff -s $confdir/rpm_qa_installed_after $confdir/mdkupdate.rpms > $confdir/$login.$password.$boxname.$oldkey.dif`; -s "$confdir/$login.$password.$boxname.$oldkey.dif" or die N("No diff found"); my $tag = { submit => "upload_dif", dif_file => [ "$confdir/$login.$password.$boxname.$oldkey.dif" ] }; @@ -207,8 +207,6 @@ sub clean_dir() { sub rpm_qa { my ($file) = @_; - open (FILE,"> $file") || die "Couldn't open $file : $!"; - map { chomp; print FILE "$_" } join('', sort `rpm -qa`); - close FILE; + output($file, chomp_(join('', sort(`rpm -qa`)))); } |