summaryrefslogtreecommitdiffstats
path: root/urpm.pm
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-12-01 17:49:35 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-12-01 17:49:35 +0000
commit12bdfddd24d59397ea65fe69fd58746aecd1a9d1 (patch)
tree1a5a38c1d78a98cd857f001eb5ca8727c86afd8d /urpm.pm
parent84c1e1b34871239b0790fbb85c1380144d3756f3 (diff)
downloadurpmi-12bdfddd24d59397ea65fe69fd58746aecd1a9d1.tar
urpmi-12bdfddd24d59397ea65fe69fd58746aecd1a9d1.tar.gz
urpmi-12bdfddd24d59397ea65fe69fd58746aecd1a9d1.tar.bz2
urpmi-12bdfddd24d59397ea65fe69fd58746aecd1a9d1.tar.xz
urpmi-12bdfddd24d59397ea65fe69fd58746aecd1a9d1.zip
Add return values for add_medium and add_distrib_media (the names of the
media added)
Diffstat (limited to 'urpm.pm')
-rw-r--r--urpm.pm21
1 files changed, 15 insertions, 6 deletions
diff --git a/urpm.pm b/urpm.pm
index 517b605e..48a3535e 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -612,6 +612,8 @@ sub configure {
}
#- add a new medium, sync the config file accordingly.
+#- returns the new medium's name. (might be different from the requested
+#- name if index_name was specified)
sub add_medium {
my ($urpm, $name, $url, $with_hdlist, %options) = @_;
@@ -669,9 +671,11 @@ sub add_medium {
#- keep in mind the database has been modified and base files need to be updated.
#- this will be done automatically by transfering modified flag from medium to global.
$urpm->{log}(N("added medium %s", $name));
+ $name;
}
#- add distribution media, according to url given.
+#- returns the list of names of added media.
sub add_distrib_media {
my ($urpm, $name, $url, %options) = @_;
my ($hdlists_file);
@@ -688,17 +692,18 @@ sub add_distrib_media {
$hdlists_file = reduce_pathname("$dir/$distrib_root/hdlists");
- $urpm->try_mounting($hdlists_file) or $urpm->{error}(N("unable to access first installation medium")), return;
+ $urpm->try_mounting($hdlists_file) or $urpm->{error}(N("unable to access first installation medium")), return ();
if (-e $hdlists_file) {
unlink "$urpm->{cachedir}/partial/hdlists";
$urpm->{log}(N("copying hdlists file..."));
urpm::util::copy($hdlists_file, "$urpm->{cachedir}/partial/hdlists")
? $urpm->{log}(N("...copying done"))
- : do { $urpm->{error}(N("...copying failed")); return };
+ : do { $urpm->{error}(N("...copying failed")); return () };
chown 0, 0, "$urpm->{cachedir}/partial/hdlists";
} else {
- $urpm->{error}(N("unable to access first installation medium (no hdlists file found)")), return;
+ $urpm->{error}(N("unable to access first installation medium (no hdlists file found)"));
+ return ();
}
} else {
#- try to get the description of the hdlists if it has been found.
@@ -721,13 +726,15 @@ sub add_distrib_media {
if (-e "$urpm->{cachedir}/partial/hdlists") {
$hdlists_file = "$urpm->{cachedir}/partial/hdlists";
} else {
- $urpm->{error}(N("unable to access first installation medium (no hdlists file found)")), return;
+ $urpm->{error}(N("unable to access first installation medium (no hdlists file found)"));
+ return ();
}
}
#- cosmetic update of name if it contains blank char.
$name =~ /\s/ and $name .= ' ';
+ my @newnames;
#- at this point, we have found an hdlists file, so parse it
#- and create all necessary media according to it.
if (open my $hdlistsfh, $hdlists_file) {
@@ -740,7 +747,7 @@ sub add_distrib_media {
m/^\s*(?:noauto:)?(hdlist\S*\.cz2?)\s+(\S+)\s*(.*)$/ or $urpm->{error}(N("invalid hdlist description \"%s\" in hdlists file", $_));
my ($hdlist, $rpmsdir, $descr) = ($1, $2, $3);
- $urpm->add_medium(
+ push @newnames, $urpm->add_medium(
$name ? "$descr ($name$medium)" : $descr,
"$url/$rpmsdir",
offset_pathname($url, $rpmsdir) . "/$distrib_root/" . ($options{probe_with} eq 'synthesis' ? 'synthesis.' : '') . $hdlist,
@@ -751,8 +758,10 @@ sub add_distrib_media {
++$medium;
}
close $hdlistsfh;
+ return @newnames;
} else {
- $urpm->{error}(N("unable to access first installation medium (no hdlists file found)")), return;
+ $urpm->{error}(N("unable to access first installation medium (no hdlists file found)"));
+ return ();
}
}