summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xurpmi.addmedia94
-rw-r--r--urpmi.spec12
-rwxr-xr-xurpmi.update18
3 files changed, 108 insertions, 16 deletions
diff --git a/urpmi.addmedia b/urpmi.addmedia
index d4fcfd63..aee62216 100755
--- a/urpmi.addmedia
+++ b/urpmi.addmedia
@@ -26,6 +26,7 @@ import urpm _;
sub main {
my ($name, $url, $with, $relative_hdlist, %options);
+ my $mirrors = $ENV{URPMI_MIRRORS} || 'http://www.linux-mandrake.com/mirrorsfull.list';
# Translator: The URI types strings 'file:', 'ftp:', 'http:',
# Translator: and 'removable:' must not be translated!
# Translator: neither the ``with''.
@@ -47,9 +48,20 @@ and [options] are from
") . _(" --proxy-user - specify user and password to use for proxy
authentication (format is <user:password>).
") . _(" --update - create an update medium.
-") . _(" --distrib - automatically create all media from an installation medium.
+") . _(" --distrib - automatically create all media from an installation
+ medium.
+") . _(" --distrib-XXX - automatically create a medium for XXX part of a
+ distribution, XXX may be main, contrib, updates or
+ anything else that has been configured ;-)
+") . _(" --from - use specified url for list of mirrors, the default is
+ %s
+", $mirrors) . _(" --version - use specified version, the default is version of
+ mandrake-release package installed.
+") . _(" --arch - use specified architecture, the default is arch of
+ mandrake-release package installed.
") . _(" -c - clean headers cache directory.
-") . _(" -h - try to find and use synthesis or hdlist file.
+") . _(" -h - try to find and use synthesis or hdlist
+ file.
") . _(" -f - force generation of hdlist files.
");
@@ -79,7 +91,11 @@ and [options] are from
$urpm->{proxy}->{pwd} = $2;
next;
};
- /^--distrib$/ and $options{distrib} = 1, next;
+ /^--distrib$/ and $options{distrib} = undef, next;
+ /^--distrib-(.*)$/ and $options{distrib} = $1, next;
+ /^--from$/ and $options{mirrors_url} = shift @_, next;
+ /^--version$/ and $options{version} = shift @_, next;
+ /^--arch$/ and $options{arch} = shift @_, next;
/^--update$/ and $options{update} = 1, next;
/^-/ and die $usage . _("\nunknown options '%s'\n", $_);
($name, $url, $with, $relative_hdlist) = ($_, @_);
@@ -87,18 +103,72 @@ and [options] are from
}
#- allow not to give name immediately.
$url or ($url, $name) = ($name, '');
- my ($type) = $url =~ m,^([^:]*)://, or die $usage;
+ my ($type) = $url =~ m,^([^:]*)://, or $options{distrib} or die $usage;
$urpm->read_config;
- if ($options{distrib}) {
- $with || $relative_hdlist and die _("%s\nno need to give <relative path of hdlist> with --distrib", $usage);
+ if (exists $options{distrib}) {
+ if (defined $options{distrib}) {
+ #- extended distribution support, code is directly inlined here.
+ #- -h always set, updates should allow setting update flag.
+ $options{probe_with_hdlist} = 1;
+ $options{distrib} =~ /update/ and $options{update} = 1;
+ #- official site by default.
+ $options{from} ||= $mirrors;
+ #- get default value unless already provided.
+ unless ($options{version} && $options{arch}) {
+ my $db = URPM::DB::open;
+ $db->traverse_tag('name', [ qw(mandrake-release basesystem) ], sub {
+ my ($pkg) = @_;
+ $pkg->release =~ /0\./ and $options{version} ||= 'cooker';
+ $options{version} ||= $pkg->version;
+ $pkg->arch ne 'noarch' and $options{arch} ||= $pkg->arch;
+ });
+ }
+ #- sanity checks...
+ $options{distrib} eq 'updates' && $options{version} eq 'cooker' and
+ die _("cannot add updates of a cooker distribution\n");
+ #- get mirrors list file in urpmi cache.
+ my ($basename) = $options{from} =~ /^.*\/([^\/]+)\/*$/;
+ unlink "$urpm->{cachedir}/partial/$basename";
+ eval {
+ $urpm->{log}(_("retrieving mirrors at %s ...", $options{from}));
+ $urpm->{sync}({dir => "$urpm->{cachedir}/partial", quiet => 0, proxy => $urpm->{proxy}}, $options{from});
+ $urpm->{log}(_("...retrieving done"));
+ };
+ $@ and $urpm->{log}(_("...retrieving failed: %s", $@));
+ #- examine its contents and create all requested media, url is now a simple regex.
+ my $heading = quotemeta($options{version} eq 'cooker' ? 'cooker' : $options{distrib});
+ my $qarch = quotemeta($options{arch});
+ my $i = 1;
+ local *F;
+ open F, "$urpm->{cachedir}/partial/$basename";
+ while (<F>) {
+ chomp;
+ my ($burl, $relative_hdlist) = /^$heading$qarch:(.*?)(?:\s+with\+(.*))?$/ or next;
+ !$url || $burl =~ /$url/ or next;
+ $urpm->add_medium("$name$i",
+ $options{distrib} eq 'updates' ? "$burl/$options{version}/RPMS" :
+ $options{distrib} eq 'contrib' ? $burl."2" : $burl,
+ $options{distrib} eq 'contrib' ? '../base/hdlist2.cz' : $relative_hdlist,
+ update => $options{update});
+ ++$i;
+ }
+ close F;
+ } else {
+ $with || $relative_hdlist and die _("%s\nno need to give <relative path of hdlist> with --distrib", $usage);
- $urpm->add_distrib_media($name, $url, update => $options{update});
+ $urpm->add_distrib_media($name, $url, update => $options{update});
+ }
$urpm->update_media(%options);
if (my @unsynced_media = grep { $_->{modified} } @{$urpm->{media}}) {
- die join("\n", map { _("unable to update medium \"%s\"\n", $_->{name}) } @unsynced_media);
+ print STDERR join("\n", map { _("unable to update medium \"%s\"\n", $_->{name}) } @unsynced_media);
+
+ #- remove quietly the failing media.
+ $urpm->{log} = sub {};
+ $urpm->remove_selected_media;
+ $urpm->update_media(%options);
}
} else {
$name or die $usage;
@@ -115,7 +185,13 @@ and [options] are from
#- check creation of media (during update has been successfull)
my ($medium) = grep { $_->{name} eq $name } @{$urpm->{media}};
$medium or die _("unable to create medium \"%s\"\n", $name);
- $medium->{modified} and die _("unable to update medium \"%s\"\n", $name);
+ if ($medium->{modified}) {
+ print STDERR _("unable to update medium \"%s\"\n", $name);
+ #- remove quietly the failing media.
+ $urpm->{log} = sub {};
+ $urpm->remove_selected_media;
+ $urpm->update_media(%options);
+ }
}
}
diff --git a/urpmi.spec b/urpmi.spec
index 5fdf7cd9..997871c1 100644
--- a/urpmi.spec
+++ b/urpmi.spec
@@ -2,7 +2,7 @@
Name: urpmi
Version: 4.1
-Release: 2mdk
+Release: 3mdk
License: GPL
Source0: %{name}.tar.bz2
Source1: %{name}.logrotate
@@ -204,6 +204,16 @@ fi
%changelog
+* Thu Nov 28 2002 François Pons <fpons@mandrakesoft.com> 4.1-3mdk
+- added mirrors management for urpmi.addmedia, so added
+ --distrib-XXX, --from, --version, --arch options. <url>
+ is now just a regex for choosing a mirror, and <name>
+ will have an numeric index appended to it.
+ anyway for more info, look in the code or guess with
+ --help ;-)
+- urpmi.addmedia now delete failing media to create.
+- added --update option to urpmi.update, guess for what ?
+
* Thu Nov 28 2002 François Pons <fpons@mandrakesoft.com> 4.1-2mdk
- allow creating medium without list file.
- better handling of url without password to be displayed
diff --git a/urpmi.update b/urpmi.update
index 06373277..3325552f 100755
--- a/urpmi.update
+++ b/urpmi.update
@@ -35,11 +35,12 @@ sub main {
/^--?c/ and $options{noclean} = 0, next;
/^--?d/ and $options{depslist} = 1, next;
/^--?f/ and ++$options{force}, next;
- /^--wget/ and $urpm->{sync} = sub { my $options = shift @_;
- if (ref $options) { $options->{prefer} = 'wget' }
- else { $options = { dir => $options, prefer => 'wget' } }
- urpm::sync_webfetch($options, @_) }, next;
- /^--curl/ and $urpm->{sync} = \&urpm::sync_webfetch, next;
+ /^--update$/ and $options{update} = 1, next;
+ /^--wget$/ and $urpm->{sync} = sub { my $options = shift @_;
+ if (ref $options) { $options->{prefer} = 'wget' }
+ else { $options = { dir => $options, prefer => 'wget' } }
+ urpm::sync_webfetch($options, @_) }, next;
+ /^--curl$/ and $urpm->{sync} = \&urpm::sync_webfetch, next;
/^--proxy$/ and do {
my ($proxy, $port) = ($_ = shift @_) =~ m,^(?:http://)?([^:]+(:\d+)?)/*$, or
die _("bad proxy declaration on command line\n");
@@ -64,6 +65,7 @@ where <name> is a medium name to update.
to be 1080 by default (format is <proxyhost[:port]>).
") . _(" --proxy-user - specify user and password to use for proxy
authentication (format is <user:password>).
+") . _(" --update - update only update media.
") . _(" -a - select all non-removable media.
") . _(" -c - clean headers cache directory.
") . _(" -d - force complete computation of depslist.ordered file.
@@ -78,13 +80,17 @@ where <name> is a medium name to update.
if ($options{all}) {
@entries == 0 and die _("nothing to update (use urpmi.addmedia to add a media)\n");
} else {
- @toupdates == 0 and die _("the entry to update is missing\n(one of %s)\n", join(", ", @entries));
$urpm->select_media(@toupdates);
#- force ignored media to be returned alive.
+ my $something_todo = 0;
foreach (@{$urpm->{media}}) {
+ $options{update} && $_->{update} and $_->{modified} = 1;
$_->{modified} and delete $_->{ignore};
+ $_->{modified} and ++$something_todo;
}
+
+ $something_todo or die _("the entry to update is missing\n(one of %s)\n", join(", ", @entries));
}
$urpm->update_media(%options);