summaryrefslogtreecommitdiffstats
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
parent95219b3451a5a6365849eaf7a6c4610c21ef9e4a (diff)
downloadurpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.tar
urpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.tar.gz
urpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.tar.bz2
urpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.tar.xz
urpmi-471cbdf53eb00c292cb426b3f6978a513ae18989.zip
*** empty log message ***
-rw-r--r--urpm.pm30
-rwxr-xr-xurpmi.addmedia7
-rwxr-xr-xurpmi.removemedia7
-rw-r--r--urpmi.spec6
-rwxr-xr-xurpmi.update7
5 files changed, 44 insertions, 13 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}]");
diff --git a/urpmi.addmedia b/urpmi.addmedia
index 8917a945..8ad65c3e 100755
--- a/urpmi.addmedia
+++ b/urpmi.addmedia
@@ -48,7 +48,7 @@ where <url> is one of
$dev && -e "/dev/$dev" or die(sprintf _("%s\ndevice `%s' do not exist\n"), $usage, $dev);
} elsif ($with eq "with") {
$relative_hdlist or die(sprintf _("%s\n<relative path of hdlist> missing\n"), $usage);
- } elsif ($with) {
+ } elsif ($ftp) {
$with eq "with" or die(sprintf _("%s\n`with' missing for ftp media\n"), $usage);
}
@@ -57,6 +57,11 @@ where <url> is one of
$urpm->read_config;
$urpm->add_medium($name, $url, $relative_hdlist);
$urpm->update_media;
+
+ #- check creation of media (during update has been successfull)
+ my ($medium) = grep { $_->{name} eq $name } @{$urpm->{media}};
+ $medium or die(sprintf _("unable to create medium \"%s\"\n"), $name);
+ $medium->{modified} and die(sprintf _("unable to update medium \"%s\"\n"), $name);
}
main(@ARGV);
diff --git a/urpmi.removemedia b/urpmi.removemedia
index d68c230f..c4f8f706 100755
--- a/urpmi.removemedia
+++ b/urpmi.removemedia
@@ -35,7 +35,12 @@ sub main {
foreach (@_) {
/^--?a/ and $options{all} = 1, next;
- /^-/ and die sprintf(_("unknown options \"%s\"\n"), $_);
+ /^-/ and die sprintf(
+_("usage: urpmi.removemedia [-a] <name> ...
+where <name> is a medium name to remove.
+ -a select all media.
+
+unknown options \"%s\"\n"), $_);
push @toremoves, $_;
}
diff --git a/urpmi.spec b/urpmi.spec
index 872a2a44..7e651cb9 100644
--- a/urpmi.spec
+++ b/urpmi.spec
@@ -2,7 +2,7 @@
Name: urpmi
Version: 1.5
-Release: 26mdk
+Release: 27mdk
License: GPL
Source0: %{name}.tar.bz2
Summary: User mode rpm install
@@ -114,6 +114,10 @@ autoirpm.uninstall
%changelog
+* Tue Apr 3 2001 François Pons <fpons@mandrakesoft.com> 1.5-27mdk
+- added better error management.
+- fixed some typo for cache management (creating /partial).
+
* Tue Mar 27 2001 François Pons <fpons@mandrakesoft.com> 1.5-26mdk
- added --WID=id
- let grpmi make the upload of packages.
diff --git a/urpmi.update b/urpmi.update
index a5ff2627..7d0e012c 100755
--- a/urpmi.update
+++ b/urpmi.update
@@ -39,7 +39,12 @@ sub main {
/^--?c/ and $options{noclean} = 0, next;
/^--?f/ and $options{force} = 1, next;
/^--?noa/ and next; #- default, keeped for compability.
- /^-/ and die sprintf(_("unknown options \"%s\"\n"), $_);
+ /^-/ and die sprintf(
+_("usage: urpmi.update [-a] <name> ...
+where <name> is a medium name to update.
+ -a select all non-removable media.
+
+unknown options \"%s\"\n"), $_);
push @toupdates, $_;
}