diff options
author | Daouda Lo <daouda@mandriva.com> | 2004-11-19 13:45:31 +0000 |
---|---|---|
committer | Daouda Lo <daouda@mandriva.com> | 2004-11-19 13:45:31 +0000 |
commit | 042390af2cb30915f471f12f639f07b0b9ceb9a9 (patch) | |
tree | 95cbf6a51bc81e42fe1c0982bb5c1dcb760e2df5 | |
parent | 740be7813fae11cacde92a77fdc61e622c0b7b8c (diff) | |
download | mgaonline-042390af2cb30915f471f12f639f07b0b9ceb9a9.tar mgaonline-042390af2cb30915f471f12f639f07b0b9ceb9a9.tar.gz mgaonline-042390af2cb30915f471f12f639f07b0b9ceb9a9.tar.bz2 mgaonline-042390af2cb30915f471f12f639f07b0b9ceb9a9.tar.xz mgaonline-042390af2cb30915f471f12f639f07b0b9ceb9a9.zip |
- new layout to upload config after install
- update rpms base once a day.
- minor fixes
-rwxr-xr-x | mdkupdate | 41 |
1 files changed, 19 insertions, 22 deletions
@@ -31,6 +31,10 @@ require_root_capability(); my $confdir = '/root/.MdkOnline'; my $conffile = "$confdir/mdkupdate"; +my $difflog = '/tmp/diff.log'; + +my $currentrpm = "$confdir/rpm_qa_installed_current"; +my $afterrpm = "$confdir/rpm_qa_installed_after"; my $logfile = '/tmp/mdkupdate.log'; @@ -90,21 +94,20 @@ if ($o{LOGIN} && $o{PASS} && $o{LOGIN} !~ /\s+/ && $o{PASS} !~ /\s+/) { $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=mdkupdate", "--pkg-sel=$scheduled", "--pkg-nosel=$noscheduled"; + system "/usr/bin/MandrakeUpdate", "--no-confirmation", "--media=mdkupdate", "--pkg-sel=$scheduled", "--pkg-nosel=$noscheduled" } 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("$confdir/rpm_qa_installed_after"); + rpm_qa($afterrpm); my %new = getVarsFromSh($conffile); - if (! -s "$confdir/mdkupdate.rpms" || $opt eq '--auto') { + my $need_upload = get_rpm_dif(); + if ($need_upload || $opt eq '--auto') { #- send configuration and get back key to use... my $r; ($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}); } clean_dir(); }, @@ -184,23 +187,17 @@ sub send_conf_update { my ($res, $key) = mdkonline::send_config($url->{wizard}, $tag); ($res, $key) } -sub send_rpm_dif { - 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 exit(1); - my $tag = { submit => "upload_dif", dif_file => [ "$confdir/$login.$password.$boxname.$oldkey.dif" ] }; - my ($res, $key) = mdkonline::send_config($url->{online_dif}, $tag); - #- update mdkupdate.rpms with newer version just sent. - if ($res eq 'TRUE') { - unlink "$confdir/mdkupdate.rpms"; - rename "$confdir/rpm_qa_installed_after", "$confdir/mdkupdate.rpms"; - } else { - output($logfile, 'send_rpm_dif' . N("Connection problem") . "\n" . N("Mandrakeupdate could not upload the diff files. Send a mail to support [at] mandrakeonline [dot] net")); - return - } +sub get_rpm_diff { + my $isdif = `sdiff -s $afterrpm $currentrpm`; + $isdif and output($difflog, $isdif), return 1; + return 0 +} +sub new_rpm_base { + -f $afterrpm and system('/bin/mv', $afterrpm, $currentrpm); } sub clean_dir() { - system "/bin/rm", "-f", "$confdir/*log.bz2", "$confdir/*log.bz2.uue", "$confdir/*.dif $confdir/rpm_qa_installed_before", "$confdir/rpm_qa_installed_after"; + new_rpm_base(); + mdkonline::clean_confdir(); output($logfile, 'OK') } sub rpm_qa { |