summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2004-08-09 08:00:25 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2004-08-09 08:00:25 +0000
commitdc25d214b33eb747272fc3b7a4640251b471a2ee (patch)
treee394b4bfec1396627d51eac8c9238a28f501b6ca
parent0943af348f240e34cfdad6427e3ab97b1be43a16 (diff)
downloadmgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.tar
mgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.tar.gz
mgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.tar.bz2
mgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.tar.xz
mgaonline-dc25d214b33eb747272fc3b7a4640251b471a2ee.zip
perl_checker cleanups
-rwxr-xr-xmdkonline63
-rw-r--r--mdkonline.pm24
-rwxr-xr-xmdkupdate34
3 files changed, 59 insertions, 62 deletions
diff --git a/mdkonline b/mdkonline
index 1e52fe82..7d885293 100755
--- a/mdkonline
+++ b/mdkonline
@@ -43,7 +43,7 @@ my $conffile = "$confdir/mdkupdate";
add_icon_path("/usr/share/drakfirsttime/pixmaps/");
-my $in = 'interactive'->vnew('su', 'default');
+require_root_capability();
my $VERSION = '1.0';
my ($create_account, $auto_update) = (0, 1);
@@ -51,18 +51,18 @@ my ($o, $p);
#for compatibilities
mkdir_p($confdir) if !-d $confdir;
-mdkonline::mv_files("/root/.mdkupdate", "$conffile");
+mdkonline::mv_files("/root/.mdkupdate", $conffile);
$o->{mw} = ugtk2->new("MandrakeOnline" . " " . $VERSION, center => 1);
gtkset_size_request($o->{mw}{window}, 580, 470);
$o->{mw}{rwindow}->set_position('center');
-$o->{mw}{window}->signal_connect( "delete_event", sub { Gtk2->main_quit} );
+$o->{mw}{window}->signal_connect("delete_event", sub { Gtk2->main_quit });
$o->{nb} = Gtk2::Notebook->new;
$o->{nb}->set_show_tabs(0); $o->{nb}->set_show_border(0);
$o->{bottomHbox} = Gtk2::HBox->new;
my %stage = (
- 0 => sub { if ($o->{account_cb}->get_active) { subs_online() } else { $o->{nb}->next_page} },
- 1 => sub { $o->{nb}->next_page(); set_entry_with_conf() },
+ 0 => sub { if ($o->{account_cb}->get_active) { subs_online() } else { $o->{nb}->next_page } },
+ 1 => sub { $o->{nb}->next_page; set_entry_with_conf() },
2 => sub { check_passwd() },
3 => sub { log::l("[mdkonline] Sending configuration to remote server"); send_conf_online() },
4 => sub { log::l("[mdkonline] Writing local configuration dir"); set_conf() }
@@ -79,14 +79,14 @@ $o->{actions} = {
},
Prev => sub {
$p = $o->{nb}->get_current_page;
- $o->{nb}->prev_page();
+ $o->{nb}->prev_page;
$p <= 1 and init(0)
}
};
foreach my $l (['Next', 'gtk-go-forward', 'stock'], ['SkipWiz', N("Skip Wizard")], ['Prev', 'gtk-go-back', 'stock']) {
$o->{$l->[0]} = $l->[2] ? Gtk2::Button->new_from_stock($l->[1]) : Gtk2::Button->new(" " . $l->[1] . " ");
$l->[2] ? $o->{bottomHbox}->pack_end($o->{$l->[0]}, 0, 0, 1) : $o->{bottomHbox}->pack_start($o->{$l->[0]}, 0, 0, 1);
- $o->{$l->[0]}->signal_connect( clicked => sub { $o->{actions}{$l->[0]}->() });
+ $o->{$l->[0]}->signal_connect(clicked => sub { $o->{actions}{$l->[0]}->() });
}
gtkadd($o->{mw}{window},
gtkpack_(Gtk2::VBox->new(0, 2),
@@ -101,14 +101,14 @@ gtkappend_page($o->{nb},
0, Gtk2::Label->new(N("At this step You are supposed to have an account on MandrakeOnline.\nThis assistant will help you to upload your configuration\n(packages, hardware configuration) to a centralized database in\norder to keep you informed about security updates and useful upgrades.\n")),
1, gtkadd(gtkset_border_width(Gtk2::Frame->new(N("Create a MandrakeOnline Account")), 5),
gtkpack_(gtkset_border_width(Gtk2::VBox->new(0, 5), 5),
- 0, gtksignal_connect(gtkset_active($o->{account_cb} = Gtk2::CheckButton->new(N("I don't have a MandrakeOnline account and I want to ") . N("Subscribe")), $create_account), clicked => sub { $create_account =! $create_account; $o->{vbox_account}->set_sensitive($create_account) }),
+ 0, gtksignal_connect(gtkset_active($o->{account_cb} = Gtk2::CheckButton->new(N("I don't have a MandrakeOnline account and I want to ") . N("Subscribe")), $create_account), clicked => sub { $create_account = !$create_account; $o->{vbox_account}->set_sensitive($create_account) }),
1, gtkpack_($o->{vbox_account} = Gtk2::VBox->new(0, 3),
1, create_packtable({ homogeneous => 1, col_spacings => 10, row_spacings => 10, mcc => 1 },
[],
- [ N("Login:"), $o->{clogin} = Gtk2::Entry->new() ],
+ [ N("Login:"), $o->{clogin} = Gtk2::Entry->new ],
[ N("Password:"), $o->{cpasswd} = entry_hidepass() ],
[ N("Confirm Password:"), $o->{cconfirm} = entry_hidepass() ],
- [ N("Mail contact:"), $o->{cmail} = Gtk2::Entry->new() ]
+ [ N("Mail contact:"), $o->{cmail} = Gtk2::Entry->new ]
))
)
))
@@ -125,9 +125,9 @@ gtkappend_page($o->{nb},
0, Gtk2::WrappedLabel->new("\n\n" . N("Enter your MandrakeOnline login, password and machine name:")),
1, create_packtable({ homogeneous => 1, col_spacings => 10, row_spacings => 10, mcc => 1 },
[],
- [ N("Login:"), $o->{login} = Gtk2::Entry->new(), "" ],
+ [ N("Login:"), $o->{login} = Gtk2::Entry->new, "" ],
[ N("Password:"), $o->{passwd} = entry_hidepass(), "" ],
- [ N("Machine name:"), $o->{machine} = Gtk2::Entry->new() ],
+ [ N("Machine name:"), $o->{machine} = Gtk2::Entry->new ],
))
);
gtkappend_page($o->{nb},
@@ -163,7 +163,7 @@ $o->{mw}{rwindow}->show_all;
Gtk2->main;
ugtk2->exit(0);
-sub subs_online {
+sub subs_online() {
my $explink = 'http://www.mandrakeexpert.com/online3_CreateAccount.php';
my $login = $o->{clogin}->get_text; my $despwd = $o->{cpasswd}->get_text; my $despwdcfm = $o->{cconfirm}->get_text;
my $cmail = $o->{cmail}->get_text;
@@ -174,26 +174,26 @@ sub subs_online {
my $url = $explink . '?desuserid=' . $login . '&despwd=' . $despwd . '&user_email=' . $cmail;
#print "LOGIN = $login\nPASSWD = $despwd\nMAIL= $cmail\nURL=$url\n";
my $ret = mdkonline::subscribe_online($url);
- if ($ret eq 'OK') { $o->{nb}->next_page } else { raiseError($o->{mw}->{window}, $ret) };
+ if ($ret eq 'OK') { $o->{nb}->next_page } else { raiseError($o->{mw}{window}, $ret) };
}
}
sub check_errors {
my ($login, $despwd, $despwdcfm, $cmail) = @_;
- $login or raiseError($o->{mw}->{window},N("Error"), N("Please provide a login"));
+ $login or raiseError($o->{mw}{window}, N("Error"), N("Please provide a login"));
if (!$::error && $despwd ne $despwdcfm) {
- raiseError($o->{mw}->{window},N("Error"), N("The passwords do not match\n Please try again\n"))
- } elsif (!$::error and check_valid_email($cmail) != 1) {
- raiseError($o->{mw}->{window},N("Error"), N("Not a valid mail address!\n"))
+ raiseError($o->{mw}{window}, N("Error"), N("The passwords do not match\n Please try again\n"))
+ } elsif (!$::error && check_valid_email($cmail) != 1) {
+ raiseError($o->{mw}{window}, N("Error"), N("Not a valid mail address!\n"))
}
}
-sub set_entry_with_conf {
+sub set_entry_with_conf() {
my $wideconf = '/etc/sysconfig/mdkonline';
my %t = getVarsFromSh($wideconf);
- my $host = chomp_(`hostname`) ; $host =~ /(\w+)(.*)/;
- $t{MACHINE} ||= $1;
+ my $host = chomp_(`hostname`);
+ $t{MACHINE} ||= $1 if $host =~ /(\w+)(.*)/;
foreach (qw(login machine)) { $o->{$_}->get_text or $o->{$_}->set_text($t{uc($_)}) }
}
-sub send_conf_online {
+sub send_conf_online() {
my ($login, $passwd, $boxname) = get_names();
my $w = wait_msg(N("Reading configuration\n"));
my $link = 'https://www.mandrakeonline.net/wizard.php';
@@ -207,7 +207,7 @@ sub send_conf_online {
$o->{currentkey} = $key;
$o->{nb}->next_page; $o->{Next}->set_label(N("Finish")); $o->{Prev}->hide
} else {
- raiseError($o->{mw}->{window}, N("Connection problem"), N("Problem occurs when uploading files, please try again"));
+ raiseError($o->{mw}{window}, N("Connection problem"), N("Problem occurs when uploading files, please try again"));
}
}
sub set_conf() {
@@ -244,15 +244,16 @@ sub main_quit() {
# remove local files
my ($login, $passwd, $boxname) = get_names();
if ($login && $passwd && $boxname) {
- -f "$confdir/$login.$passwd.$boxname.online.log.bz2.uue" && unlink ("$confdir/$login.$passwd.$boxname.online.log.bz2.uue");
- -f "$confdir/$login.$passwd.$boxname.online.log.bz2" && unlink ("$confdir/$login.$passwd.$boxname.online.log.bz2");
+ -f "$confdir/$login.$passwd.$boxname.online.log.bz2.uue" and unlink("$confdir/$login.$passwd.$boxname.online.log.bz2.uue");
+ -f "$confdir/$login.$passwd.$boxname.online.log.bz2" and unlink("$confdir/$login.$passwd.$boxname.online.log.bz2");
}
# quit
print N("Quitting Wizard\n");
Gtk2->main_quit;
}
sub is_alphanum {
- my $is_num = sub { $_[0] =~ /^[[:alnum:]]+$/ ? 1 : 0 }
+ my ($x) = @_;
+ my $_is_num = sub { $x =~ /^[[:alnum:]]+$/ ? 1 : 0 }
}
sub check_passwd() {
my $link = 'http://www.mandrakeexpert.com/firsttimewizard/validusercheck.php';
@@ -262,16 +263,16 @@ sub check_passwd() {
if ($login && $passwd && $boxname && $login !~ /\s+/ && $passwd !~ /\s+/) {
# NEW METHOD (http)
# first, MD5ify the password
- my $w = wait_msg(("Connecting ...\n"));
+ my $w = wait_msg("Connecting ...\n");
$link .= '?u=' . $login . '&p=' . $passwd;
my $response = mdkonline::get_from_URL($link);
remove_wait_msg($w);
# Check the outcome of the response
if ($response->is_success) {
- $result = ($response->content =~ /TRUE/) ? 0 : -1;
+ $result = $response->content =~ /TRUE/ ? 0 : -1;
} else {
# pb with the connection ? stay on page 2
- raiseError($o->{mw}->{window}, N("Connection problem"), N("MandrakeOnline could not be contacted, please try again at a later time"));
+ raiseError($o->{mw}{window}, N("Connection problem"), N("MandrakeOnline could not be contacted, please try again at a later time"));
return;
}
} else {
@@ -280,10 +281,10 @@ sub check_passwd() {
# if correct, go to page 4
if (! $result) {
- $o->{nb}->next_page();
+ $o->{nb}->next_page;
} else {
# if incorrect, clear passwd and stay on page 2
- raiseError($o->{mw}->{window}, N("Wrong password"), N("Your login or password was wrong.\n Either you'll have to type it again, or you'll need to create an account on MandrakeOnline.\n In the latter case, go back to the first step to connect to MandrakeOnline.\n Be aware that you must also provide a Machine name \n (only alphabetical characters are admitted)"));
+ raiseError($o->{mw}{window}, N("Wrong password"), N("Your login or password was wrong.\n Either you'll have to type it again, or you'll need to create an account on MandrakeOnline.\n In the latter case, go back to the first step to connect to MandrakeOnline.\n Be aware that you must also provide a Machine name \n (only alphabetical characters are admitted)"));
$o->{passwd}->set_text("");
}
}
diff --git a/mdkonline.pm b/mdkonline.pm
index 2be4c45b..66f999da 100644
--- a/mdkonline.pm
+++ b/mdkonline.pm
@@ -20,7 +20,7 @@ sub get_release() {
sub get_from_URL {
my ($link, $agent_name) = @_;
my $ua = LWP::UserAgent->new;
- $ua->agent("$agent_name" . $ua->agent);
+ $ua->agent($agent_name . $ua->agent);
$ua->env_proxy;
my $request = HTTP::Request->new(GET => $link);
my $response = $ua->request($request);
@@ -54,25 +54,23 @@ sub header { "
* $_[0]
********************************************************************************";
}
-open (my $FILE,"> $file") || die "Couldn't open $file : $!";
-map { chomp; print $FILE "$_\n" }
+ouput($file, map { chomp; "$_\n" }
header("partitions"), cat_("/proc/partitions"),
header("cpuinfo"), cat_("/proc/cpuinfo"),
header("fstab"), cat_("/etc/fstab"),
header("/etc/modules.conf"), cat_("/etc/modules.conf"),
- header("rpm -qa"), join ('', sort `rpm -qa`),
- header("mandrake version"), cat_('/etc/mandrake-release');
-close($FILE);
-`/usr/bin/bzip2 \\\-f $file`;
-open (my $F, "$file" . ".bz2") or die "Cannot open file : $!";
+ header("rpm -qa"), join('', sort `rpm -qa`),
+ header("mandrake version"), cat_('/etc/mandrake-release'));
+system("/usr/bin/bzip2 -f $file");
+open(my $F, $file . ".bz2") or die "Cannot open file : $!";
my ($chunk, $buffer);
while (read($F, $chunk, 60*57)) {
$buffer .= $chunk;
}
-close ($F);
-open (my $OUT, "> $file" . ".bz2.uue") or die "Cannot open file : $!";
+close($F);
+open(my $OUT, "> $file" . ".bz2.uue") or die "Cannot open file : $!";
print $OUT encode_base64($buffer);
-close ($OUT);
+close($OUT);
}
sub send_config {
@@ -92,13 +90,13 @@ sub send_config {
sub mv_files {
my ($source, $dest) = @_;
- -e $source and system("mv","$source","$dest");
+ -e $source and system("mv", $source, $dest);
}
sub automated_upgrades {
my ($conffile, $login, $passwd, $boxname, $key, $country, $auto) = @_;
my ($r) = get_release();
- output "$conffile",
+ output $conffile,
qq(# automatically generated file. Please don't edit
LOGIN=$login
PASS=$passwd
diff --git a/mdkupdate b/mdkupdate
index 6ce58926..e311120a 100755
--- a/mdkupdate
+++ b/mdkupdate
@@ -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`))));
}