summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmdkonline42
-rwxr-xr-xmdkupdate105
2 files changed, 81 insertions, 66 deletions
diff --git a/mdkonline b/mdkonline
index 2459ed8c..566d1cf4 100755
--- a/mdkonline
+++ b/mdkonline
@@ -66,16 +66,13 @@ my $link_to_mdkonline="http://www.mandrakeexpert.com/index2.php";
my $check_custid=0;
my $true=1;
my $false=0;
-$::isWizard = "@ARGV" =~ /--wizard/;
-$::isWizard=1;
-my %locations = ( _("Africa") => 'ftp://africa',
- _("Asia") => 'ftp://asia',
- _("Australia") => 'ftp://australia',
- _("Europe") => 'ftp://europe',
- _("USA") =>'ftp://usa',
- _("South America") => 'ftp://southamerica',
+my %locations = ( _("Africa") => ['ftp.univie.ac.at/systems/linux/Mandrake/updates','ftp.lip6.fr/pub/linux/distributions/mandrake/updates'],
+ _("Asia") => ['ftp.surfnet.nl/pub/os/Linux/distr/Mandrake/Mandrake/updates','ftp.math.utah.edu/pub/linux/Mandrake/updates'],
+ _("Australia") => ['ftp-linux.cc.gatech.edu/pub/linux/distributions/mandrake/updates','mandrake.redbox.cz/Mandrake/updates'],
+ _("Europe") => ['ftp.club-internet.fr/pub/unix/linux/distributions/Mandrake/updates','ftp.gwdg.de/pub/linux/mandrake/updates'],
+ _("North America") =>['mirrors.secsup.org/pub/linux/mandrake/Mandrake/updates','ftp.stealth.net/pub/mirrors/ftp.mandrake.com/Mandrake/updates'],
+ _("South America") => ['ftp.proxad.net/pub/Distributions_Linux/Mandrake/updates','carroll.cac.psu.edu/pub/linux/distributions/mandrake/updates'],
);
-
require Gtk;
require Gtk::Gdk::ImlibImage;
@@ -126,6 +123,7 @@ my $box_user= new Gtk::Entry();
my $login = "";
my $passwd = "";
my $box_name = "";
+my $key = "";
my %actions = (
2 => \&test_passwd,
@@ -343,7 +341,7 @@ sub send_config {
print "REPONSE: ".$response->content."\n";
if ($response->is_success) {
$result = ($response->content =~ /^TRUE(.*)/) ? 0 : -1;
- print("key is $1");
+ print("key is $1\n");
$key = $1;
} else {
# pb with the connection ?
@@ -376,7 +374,7 @@ sub step_wizard {
$hbox_subs->pack_start($check_subs,0,0,1);
$button_subs->set_sensitive(0);
$check_subs->signal_connect (clicked => sub {$test_tog=$check_subs->get_active();
- $button_subs->set_sensitive($test_tog);
+ $button_su4bs->set_sensitive($test_tog);
$Button_Next->set_sensitive(!$test_tog); });
$button_subs->signal_connect('clicked' => \&subscribe_mdkonline);
$hbox_subs->pack_start($button_subs,0,0,1);
@@ -423,10 +421,6 @@ sub step_wizard {
$vbox_frame_auto->pack_start($check_cron,$false ,$false,1);
#$check_cron->set_uposition(70,245);
my $hboxfr1 = new Gtk::HBox(0,0);
- #my $label_user_mail = new Gtk::Label(_("I want this (local) user to get email alerts"));
- #$hboxfr1->pack_start($label_user_mail,$true ,$true,5);
- #$gtkcombo_user->set_popdown_strings(parse_etc_passwd());
- #$hboxfr1->pack_end($gtkcombo_user,$true ,$true,5);
my $hboxfr2 = new Gtk::HBox(0,0);
my $label_mirror = new Gtk::Label(_("Choose your geographical location"));
$hboxfr2->pack_start($label_mirror,$true ,$true,5);
@@ -443,20 +437,6 @@ sub step_wizard {
$notebook_global->append_page($vbox_oksend,new Gtk::Label("oksend"));
}
-sub parse_etc_passwd ()
-{
- my (@usernames,$uname, $uid);
- my $uid=0;
- setpwent();
- do {
- @user_info = getpwent();
- ($uname, $uid) = @user_info[0,2];
- push (@usernames, $uname) if ($uid > 500);
- } while (@user_info);
- unshift @usernames,'root';
- @usernames;
-}
-
sub report_config {
my ($file) = @_;
#touch($file);
@@ -492,7 +472,7 @@ sub automated_upgrades {
while (<VERS>) {
@info_tree = split / /, $_;
}
- $mirror_site = $locations{$gtkcombo_mirror->entry->get_text()};
+ $mirror_site = $locations{$gtkcombo_mirror->entry->get_text()}[rand (2)];
my $version=$info_tree[3];
my $host = hostname;
output "/root/.mdkupdate",
@@ -502,7 +482,7 @@ PASS=$passwd
BOX=$box_name
VER=$version
MIRROR=$mirror_site
-CURRENTKEY= $key
+CURRENTKEY=$key
);
output_p "/etc/cron.daily/mdkupdate",
qq(#!/bin/bash
diff --git a/mdkupdate b/mdkupdate
index 1d07b992..5cbf7335 100755
--- a/mdkupdate
+++ b/mdkupdate
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
################################################################################
# Mdkupdate #
# #
@@ -38,6 +38,10 @@ sub _ {
sprintf(Locale::GetText::I_($format), @params);
}
+$logfile = "/var/log/mdkupdate.log";
+my $url_upload_diff = "https://www.mandrakeonline.net/testonline/online_dif.php";
+my $url_get_rpms = "https://www.mandrakeonline.net/testonline/online_update.php";
+my $rpms_rep = "/var/cache/urpmi/rpms/";
my $VERSION = "0.16";
my $security = 0;
@@ -54,61 +58,92 @@ usage:
exit(0);
}
-#parse the file and leave the comments out
-my @parsed = grep {!/^#/} parse_file("/root/.mdkupdate");
-
-# authenticate before
-my $valid_customer = connect_site("http://mandrakeonline.net/online_user.php");
+my %o = getVarsFromSh("/root/.mdkupdate");
+rpm_qa("/root/rpm_qa_installed_before");
+update_rpms($o{LOGIN},$o{PASS},$o{BOX},$o{CURRENTKEY});
+rpm_qa("/root/rpm_qa_installed_after");
+foreach (@rpm_qadiff) { print "$_\n";};
-#`urpmi.addmedia --update security_$parsed[3] $parsed[4] with ../base/hdlist.cz`;
-
-sub connect_site () {
- my ($url) =@_;
+sub update_rpms () {
+ my ($login,$password,$box_name,$curkey) =@_;
my $result = -1;
- my $login = $parsed[1];
- my $passwd= $parsed[2];
+ my $string;
- if ($login && $passwd && $login !~ /\s+/ && $passwd !~ /\s+/) {
+ if ($login && $password && $login !~ /\s+/ && $password !~ /\s+/) {
my $ua = LWP::UserAgent->new;
$ua->agent("MdkUpdateAgent/0.15" . $ua->agent);
- my $request = HTTP::Request->new(GET => $url.'?log='.$login.'&pass='.$passwd.'$name_machine');
- #add hostname to authentication.
+ my $request = HTTP::Request->new(GET => $url_get_rpms.'?log='.$login.'&pass='.$password.'&host='.$box_name.'&key='.$curkey);
my $response = $ua->request($request);
- # Check the outcome of the response
+ $string = $response->content;
if ($response->is_success) {
- $result = ($response->content =~ /TRUE/) ? 0 : -1;
+ $result = ($response->content =~ /^TRUE/) ? 0 : -1;
} else {
- print STDERR _("Connection problem")."\n"._("MandrakeOnline could not be contacted, we will try again");
- return;
+ log_it(_("Connection problem")."\n"._("MandrakeUpdate could not contact the site, we will try again"));
+ exit -1;
}
} else {
- $result = -1; # not needed, but this way it's clear
+ $result = -1;
}
-
- # if correct, return 1
+ # if correct, return 0
if (! $result) {
- $result;
+ @str_m = split '\n', $string;
+ my %l = getVarsFromSh "/root/.mdkupdate";
+ if ($str_m[0] eq 'TRUE') {
+ setVarsInSh("/root/.mdkupdate", {
+ OLDKEY => $str_m[2],
+ CURRENTKEY => $str_m[1],
+ MIRROR => $l{MIRROR},
+ VER => $l{VER},
+ BOX => $l{BOX},
+ PASS => $l{PASS},
+ LOGIN => $l{LOGIN} ,
+ });
+ my @junk= splice(@str_m,0,3);
+ my $mir_full = $l{MIRROR} . "/" . $l{VER} ."/" . "RPMS";
+ @str_m and update_packages(@str_m,$mir_full);
+
+ } else { print "problem occur $str_m\n";}
+
} else {
- print STDERR _("Wrong password")."\n"._("Your login or password was wrong")."\n"._("You'll need to have an account on MandrakeOnline, or update your subscription. For any problems send mail to support@mandrakeonline.com");
- return -1;
+ log_it(_("Your login or password may be wrong")."\n"._("You'll need to have an account on MandrakeOnline, or update your subscription")."\n"._("For any problem send mail to support\@mandrakeonline.com\n"));
+ exit -1;
}
}
-sub parse_file {
- my ($file)=@_;
- my @list_hosts;
- open( FILE, $file ) or die "load_text: missing file $file : $!";
- while (<FILE>) {
- chomp;
- unshift(@list_hosts,$_);
+sub update_packages {
+ my (@str,$mir) = @_;
+ chdir ($rpms_rep);
+ $full_rpm = join(' ',@strm);
+ foreach (@str) {
+ -x "/usr/bin/wget" or die _("wget is missing\n");
+ `/usr/bin/wget $mir/$_`;
}
- close( FILE );
- reverse @list_hosts;
+ `urpmi $full_rpm`;
+}
+
+sub send_rpm_dif {
+ my ($login,$password,$box_name,$oldkey) =@_;
+ `sdiff -o /root/$login.$password.$box_name.$old_key.dif -s /root/rpm_qa_installed_after /root/rpm_qa_installed_before `;
+ my $response = $ua->request(POST $url_upload_diff,
+
+ Content_Type => 'form-data',
+ Content => [submit => "upload_dif",
+ dif_file => ["$root-dir/$login.$password.$box_name.$old_key.dif"]
+ ]);
+ # Check the outcome of the response
+ print "REPONSE: ".$response->content."\n";
+}
+
+sub rpm_qa {
+ my ($file) = @_;
+ open (FILE,"> $file") || die "Couldn't open $file : $!";
+ join '', map { chomp; print FILE "$_" }
+ join('',sort `rpm -qa`);
}
sub log_it {
local *LOG;
- open LOG, ">>/var/log/mdkupdate.log" or die "can't output to log file\n";
+ open LOG, ">> $logfile" or die "can't output to log file\n";
print LOG @_;
}