diff options
author | Francois Pons <fpons@mandriva.com> | 2003-02-19 16:43:01 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2003-02-19 16:43:01 +0000 |
commit | eacffeb9da469401d89ed2e9145305e712adebda (patch) | |
tree | 79cba136d50908b3a382e2e286ed710925fe8b40 | |
parent | 4150a7f34981a1c00ca6c3e204b5b9bb792a5700 (diff) | |
download | drakx-eacffeb9da469401d89ed2e9145305e712adebda.tar drakx-eacffeb9da469401d89ed2e9145305e712adebda.tar.gz drakx-eacffeb9da469401d89ed2e9145305e712adebda.tar.bz2 drakx-eacffeb9da469401d89ed2e9145305e712adebda.tar.xz drakx-eacffeb9da469401d89ed2e9145305e712adebda.zip |
add sanity code on error when reading hdlist (this will avoid update medium
being trashed if an error occurred during hdlist download and so ...)
-rw-r--r-- | perl-install/pkgs.pm | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index f38c056da..bb4f3ea75 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -377,23 +377,21 @@ sub psUsingHdlist { #- if the medium already exist, use it. $packages->{mediums}{$medium} and return $packages->{mediums}{$medium}; - my $m = $packages->{mediums}{$medium} = { hdlist => $hdlist, - method => $method, - medium => $medium, - rpmsdir => $rpmsdir, #- where is RPMS directory. - descr => $descr, - fakemedium => $fakemedium, -# min => $packages->{count}, -# max => -1, #- will be updated after reading current hdlist. - selected => $selected, #- default value is only CD1, it is really the minimal. - ignored => !$selected, #- keep track of ignored medium by DrakX. - }; + my $m = { hdlist => $hdlist, + method => $method, + medium => $medium, + rpmsdir => $rpmsdir, #- where is RPMS directory. + descr => $descr, + fakemedium => $fakemedium, + selected => $selected, #- default value is only CD1, it is really the minimal. + ignored => !$selected, #- keep track of ignored medium by DrakX. + }; #- copy hdlist file directly to $prefix/var/lib/urpmi, this will be used #- for getting header of package during installation or after by urpmi. my $newf = "$prefix/var/lib/urpmi/hdlist.$fakemedium.cz" . ($hdlist =~ /\.cz2/ && "2"); -e $newf and do { unlink $newf or die "cannot remove $newf: $!" }; - install_any::getAndSaveFile($fhdlist || "Mandrake/base/$hdlist", $newf) or die "no $hdlist found"; + install_any::getAndSaveFile($fhdlist || "Mandrake/base/$hdlist", $newf) or do { unlink $newf; die "no $hdlist found" }; $m->{hdlist_size} = -s $newf; #- keep track of size for post-check. symlinkf $newf, "/tmp/$hdlist"; @@ -406,6 +404,9 @@ sub psUsingHdlist { -s $newsf > 0 or unlink $newsf; } + #- integrate medium in media list, only here to avoid download error (update) to be propagated. + $packages->{mediums}{$medium} = $m; + #- avoid using more than one medium if Cd is not ejectable. #- but keep all medium here so that urpmi has the whole set. $method eq 'cdrom' && $medium > 1 && !common::usingRamdisk() and return; @@ -421,7 +422,10 @@ sub psUsingHdlist { } else { die "fatal: no hdlist nor synthesis to read for $fakemedium"; } - $m->{start} > $m->{end} and die "fatal: nothing read in hdlist or synthesis for $fakemedium"; + $m->{start} > $m->{end} and do { delete $packages->{mediums}{$medium}; + unlink $newf; + $fhdlist or unlink $newsf; + die "fatal: nothing read in hdlist or synthesis for $fakemedium" }; log::l("read " . ($m->{end} - $m->{start} + 1) . " packages in $hdlist"); } $m; |