summaryrefslogtreecommitdiffstats
path: root/urpm.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2001-04-03 12:50:35 +0000
committerFrancois Pons <fpons@mandriva.com>2001-04-03 12:50:35 +0000
commit471cbdf53eb00c292cb426b3f6978a513ae18989 (patch)
tree7d7a6e187afd96de4948b8e381f59db12f680146 /urpm.pm
parent95219b3451a5a6365849eaf7a6c4610c21ef9e4a (diff)
downloadurpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.tar
urpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.tar.gz
urpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.tar.bz2
urpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.tar.xz
urpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.zip
*** empty log message ***
Diffstat (limited to 'urpm.pm')
-rw-r--r--urpm.pm30
1 files changed, 21 insertions, 9 deletions
diff --git a/urpm.pm b/urpm.pm
index e259952e..a56b231b 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -66,6 +66,7 @@ sub new {
media => undef,
params => new rpmtools,
+ fatal => sub { die(sprintf "%s\n", $_[0]) },
error => sub { printf STDERR "%s\n", $_[0] },
log => sub { printf STDERR "%s\n", $_[0] },
}, $class;
@@ -238,7 +239,7 @@ sub write_config {
$urpm->{media} or return;
local *F;
- open F, ">$urpm->{config}" or $urpm->{error}("unable to write config file [$urpm->{config}]");
+ open F, ">$urpm->{config}" or $urpm->{fatal}("unable to write config file [$urpm->{config}]");
foreach my $medium (@{$urpm->{media}}) {
printf F "%s %s {\n", quotespace($medium->{name}), quotespace($medium->{clear_url});
foreach (qw(hdlist with_hdlist list removable)) {
@@ -266,7 +267,7 @@ sub add_medium {
foreach (@{$urpm->{media}}) {
$_->{name} eq $2 and $medium = $_;
}
- $medium and $urpm->{error}("medium \"$medium\" already exists"), return;
+ $medium and $urpm->{fatal}("medium \"$medium\" already exists");
#- creating the medium info.
$medium = { name => $name,
@@ -305,7 +306,7 @@ sub add_medium {
push @{$urpm->{media}}, $medium;
#- keep in mind the database has been modified and base files need to be updated.
- $urpm->{modified} = 1;
+ #- this will be done automatically by transfering modified flag from medium to global.
}
sub remove_media {
@@ -319,6 +320,7 @@ sub remove_media {
#- remove file associated with this medium.
#- this is the hdlist and the list files.
+ unlink "$urpm->{statedir}/synthesis.$_->{hdlist}";
unlink "$urpm->{statedir}/$_->{hdlist}";
unlink "$urpm->{statedir}/$_->{list}";
} else {
@@ -463,6 +465,8 @@ sub update_media {
system("cp", "-a", "$urpm->{statedir}/$medium->{hdlist}", "$urpm->{cachedir}/partial/$basename");
system("wget", "-NP", "$urpm->{cachedir}/partial", "$medium->{url}/$medium->{with_hdlist}");
$? == 0 or $error = 1, $urpm->{error}("wget of [<source_url>/$medium->{with_hdlist}] failed (maybe wget is missing?)");
+ -s "$urpm->{cachedir}/partial/$basename" or
+ $error = 1, $urpm->{error}("wget of [<source_url>/$medium->{with_hdlist}] failed");
unless ($error) {
my @sstat = stat "$urpm->{cachedir}/partial/$basename";
my @lstat = stat "$urpm->{statedir}/$medium->{hdlist}";
@@ -479,6 +483,11 @@ sub update_media {
}
#- build list file according to hdlist used.
+ unless (-s "$urpm->{cachedir}/partial/$medium->{hdlist}") {
+ $error = 1;
+ $urpm->{error}("no hdlist file found for medium \"$medium->{name}\"");
+ }
+
#- make sure group and other does not have any access to this file.
unless ($error) {
#- sort list file contents according to depslist.ordered file.
@@ -495,9 +504,12 @@ sub update_media {
/\/([^\/]*)-[^-\/]*-[^-\/]*\.[^\/]*\.rpm/;
$list{"$medium->{url}/$_"} = ($urpm->{params}{info}{$1} || { id => 1000000000 })->{id};
}
- close F;
+ close F or $error = 1, $urpm->{error}("unable to parse hdlist file of \"$medium->{name}\"");
}
+ #- check there is something found.
+ %list or $error = 1, $urpm->{error}("nothing to write in list file for \"$medium->{name}\"");
+
#- write list file.
local *LIST;
my $mask = umask 077;
@@ -579,7 +591,7 @@ sub update_media {
foreach my $medium (@{$urpm->{media}}) {
$medium->{ignore} and next;
$urpm->{log}("reading hdlist file [$urpm->{statedir}/$medium->{hdlist}]");
- $urpm->{params}->read_hdlists("$urpm->{statedir}/$medium->{hdlist}");
+ $urpm->{params}->read_hdlists("$urpm->{statedir}/$medium->{hdlist}") or next;
eval {
local *F;
open F, "| gzip >'$urpm->{statedir}/synthesis.$medium->{hdlist}'";
@@ -606,7 +618,7 @@ sub update_media {
foreach my $medium (@{$urpm->{media}}) {
$medium->{ignore} and next;
$urpm->{log}("reading hdlist file [$urpm->{statedir}/$medium->{hdlist}]");
- $urpm->{params}->read_hdlists("$urpm->{statedir}/$medium->{hdlist}");
+ $urpm->{params}->read_hdlists("$urpm->{statedir}/$medium->{hdlist}") or next;
$urpm->{log}("computing dependancy");
$urpm->{params}->compute_depslist();
}
@@ -717,17 +729,17 @@ sub write_base_files {
my ($urpm) = @_;
local *F;
- open F, ">$urpm->{depslist}" or $urpm->{error}("unable to write depslist file [$urpm->{depslist}]");
+ open F, ">$urpm->{depslist}" or $urpm->{fatal}("unable to write depslist file [$urpm->{depslist}]");
$urpm->{params}->write_depslist(\*F);
close F;
$urpm->{log}("write depslist file [$urpm->{depslist}]");
- open F, ">$urpm->{provides}" or $urpm->{error}("unable to write provides file [$urpm->{provides}]");
+ open F, ">$urpm->{provides}" or $urpm->{fatal}("unable to write provides file [$urpm->{provides}]");
$urpm->{params}->write_provides(\*F);
close F;
$urpm->{log}("write provides file [$urpm->{provides}]");
- open F, ">$urpm->{compss}" or $urpm->{error}("unable to write compss file [$urpm->{compss}]");
+ open F, ">$urpm->{compss}" or $urpm->{fatal}("unable to write compss file [$urpm->{compss}]");
$urpm->{params}->write_compss(\*F);
close F;
$urpm->{log}("write compss file [$urpm->{compss}]");