summaryrefslogtreecommitdiffstats
path: root/mdkupdate
diff options
context:
space:
mode:
Diffstat (limited to 'mdkupdate')
-rwxr-xr-xmdkupdate44
1 files changed, 20 insertions, 24 deletions
diff --git a/mdkupdate b/mdkupdate
index aba9a107..225edd2b 100755
--- a/mdkupdate
+++ b/mdkupdate
@@ -43,7 +43,7 @@ my $logfile = '/var/tmp/mdkupdate.log';
my $onlineUrl = "https://www.mandrakeonline.net/";
my $url;
foreach (qw(online_dif online_update online3_RemoteAction wizard)) {
- $url->{$_} = $onlineUrl . $_ . '.php'
+ $url->{$_} = $onlineUrl . $_ . '.php';
}
my $VERSION = "1.1";
my $YEARS = "2002-2005";
@@ -83,7 +83,7 @@ if ($o{LOGIN} && $o{PASS} && $o{LOGIN} !~ /\s+/ && $o{PASS} !~ /\s+/) {
#print "CONTENTS = $contents \n";
-e $logfile and system "/bin/rm", $logfile;
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);
@@ -93,21 +93,21 @@ if ($o{LOGIN} && $o{PASS} && $o{LOGIN} !~ /\s+/ && $o{PASS} !~ /\s+/) {
# for debugging purpose
printf("FTP = %s\n", $c2h->{FTP});
#$c2h->{FTP} = 'ftp://ftp.lip6.fr/pub/linux/distributions/mandrake/updates';
- add_media($c2h->{FTP})
+ add_media($c2h->{FTP});
}
$scheduled = join(',', @{$c2h->{sched}});
$noscheduled = join(',', @{$c2h->{nosched}}); $noscheduled =~ s/\.rpm//g;
#printf "SCHEDULED = $scheduled\nNOSCHEDULED = $noscheduled\n";
-f $currentrpm or rpm_qa($currentrpm);
if ($opt eq '--applet') {
- system "/usr/bin/MandrakeUpdate", "--no-confirmation", "--media=update_source", "--pkg-sel=$scheduled", "--pkg-nosel=$noscheduled"
+ system "/usr/bin/MandrakeUpdate", "--no-confirmation", "--media=update_source", "--pkg-sel=$scheduled", "--pkg-nosel=$noscheduled";
} elsif ($opt eq '--noX') {
my $in = interactive->vnew;
my $pkgs = ask_pkgs($in);
install_pkgs($in, $pkgs) if $pkgs;
$in->exit(0);
} elsif ($opt eq '--auto') {
- $o{AUTO} eq 'TRUE' and auto_install_rpms($c2h->{sched})
+ $o{AUTO} eq 'TRUE' and auto_install_rpms($c2h->{sched});
}
rpm_qa($afterrpm);
my %new = getVarsFromSh($conffile);
@@ -122,16 +122,16 @@ if ($o{LOGIN} && $o{PASS} && $o{LOGIN} !~ /\s+/ && $o{PASS} !~ /\s+/) {
clean_dir();
},
80 => sub {
- output_p($logfile, "[mdkupdate] Error 80: Client password does not match in database")
+ output_p($logfile, "[mdkupdate] Error 80: Client password does not match in database");
},
81 => sub {
- output_p($logfile, "[mdkupdate] Error 81: Bad Authentification key. Please rerun mdkonline wizard")
+ output_p($logfile, "[mdkupdate] Error 81: Bad Authentification key. Please rerun mdkonline wizard");
},
82 => sub {
- output_p($logfile, "[mdkupdate] Error 82: No active Online service found for this host.")
+ output_p($logfile, "[mdkupdate] Error 82: No active Online service found for this host.");
},
83 => sub {
- output_p($logfile, "[mdkupdate] Error 83: Unknown problem, better relaunch mdkonline wizard or check connexion")
+ output_p($logfile, "[mdkupdate] Error 83: Unknown problem, better relaunch mdkonline wizard or check connexion");
}
};
$action->{$u}->();
@@ -149,7 +149,7 @@ sub ask_pkgs {
node_state => sub { $pkgs->{$_[0]}{selected} ? 'selected' : 'unselected' },
build_tree => sub {
my ($add_node, $flat) = @_;
- $add_node->($_, undef) foreach sort keys %{$pkgs};
+ $add_node->($_, undef) foreach sort keys %$pkgs;
},
grep_unselected => sub { grep { !$pkgs->{$_}{selected} } @_ },
toggle_nodes => sub {
@@ -161,15 +161,17 @@ sub ask_pkgs {
}
},
get_info => sub {},
- }) or return keys %{$pkgs}; #- no change on cancel.
- [ grep { $pkgs->{$_}{selected} } keys %{$pkgs} ];
+ }) or return keys %$pkgs; #- no change on cancel.
+ [ grep { $pkgs->{$_}{selected} } keys %$pkgs ];
}
sub install_pkgs {
my ($in, $choosed) = @_;
+ my $w = $in->wait_message(N("Please wait"), N("Installing packages ...\n"));
eval {
system "/usr/sbin/urpmi", "--auto", "--media", "update_source", @$choosed;
$? == 0 or die N("Unable to update packages from update_source medium.\n");
};
+ undef $w;
}
sub get_updatable_pkgs() {
my $urpm = new urpm;
@@ -206,14 +208,14 @@ sub split_contents {
($elem->{torf}, $elem->{NEWKEY}, $elem->{OLDKEY}, $elem->{FTP}) = splice(@$s, 0, 4);
($elem->{sched}, $elem->{nosched}) = partition { /(i586|ppc|ia64|noarch|x86_64|amd64|ppc64)$/ } @$s;
}
- $elem
+ $elem;
}
sub auto_install_rpms {
my ($pkgs) = shift;
my @pkg;
push(@pkg, $_ . '.rpm') foreach @$pkgs;
my $ret = update_pkgs(@pkg);
- $ret == 1 or output_p($logfile, "[mdkupdate] Error 100: Packages failed to upgrade")
+ $ret == 1 or output_p($logfile, "[mdkupdate] Error 100: Packages failed to upgrade");
}
sub update_conf {
my ($oldkey, $newkey) = @_;
@@ -239,7 +241,7 @@ sub add_media {
#sometimes server returns the full link http:// or ftp://
($is_x8664) = $da->{arch} =~ /(x86_64)/;
$dist_name = $da->{name};
- my $fullpath2mir = if_($mirror !~ m!^(?:http|ftp)://! , "ftp://") . $mirror . if_($is_x8664, "/$is_x8664") . if_($dist_name, "/$dist_name") ."/$r" . $path2new_arch;
+ my $fullpath2mir = if_($mirror !~ m!^(?:http|ftp)://! , "ftp://") . $mirror . if_($is_x8664, "/$is_x8664") . if_($dist_name, "/$dist_name") . "/$r" . $path2new_arch;
eval {
#Remove historical mdkupdate source
-f $media_varfile and system "/usr/sbin/urpmi.removemedia", "mdkupdate";
@@ -248,12 +250,6 @@ sub add_media {
};
$@ and die "Problem adding Update Media with urpmi";
}
-sub install_mnf_pkgs {
- my $transaction = "$$";
- my @pkg_to_upgrade = split(',', `config-wrapper.pl $transaction_name -g PackagesList`);
- my $ret = update_pkgs(@pkg_to_upgrade);
- $ret == 1 or system("config-wrapper.pl", "$transaction_name", "-a");
-}
sub update_pkgs {
@_ or return;
eval {
@@ -268,12 +264,12 @@ sub send_conf_update {
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)
+ ($res, $key);
}
sub get_rpm_diff {
my $isdif = `sdiff -s $afterrpm $currentrpm`;
$isdif and output_p($difflog, $isdif), return 1;
- return 0
+ return 0;
}
sub new_rpm_base {
-f $afterrpm and system('/bin/mv', $afterrpm, $currentrpm);
@@ -281,7 +277,7 @@ sub new_rpm_base {
sub clean_dir() {
new_rpm_base();
mdkonline::clean_confdir();
- output_p($logfile, 'OK')
+ output_p($logfile, 'OK');
}
sub rpm_qa {
my ($file) = @_;