summaryrefslogtreecommitdiffstats
path: root/urpm.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2003-06-19 14:25:18 +0000
committerFrancois Pons <fpons@mandriva.com>2003-06-19 14:25:18 +0000
commit6ccf6ba7debe8f7761d37ae5b8e32bad5e46b6e0 (patch)
treee64e7b0bccaaa9d30d1d8925f433b1c6ac76d31f /urpm.pm
parent5f7858e393290836dab05a68373ec00511a9bd3b (diff)
downloadurpmi-6ccf6ba7debe8f7761d37ae5b8e32bad5e46b6e0.tar
urpmi-6ccf6ba7debe8f7761d37ae5b8e32bad5e46b6e0.tar.gz
urpmi-6ccf6ba7debe8f7761d37ae5b8e32bad5e46b6e0.tar.bz2
urpmi-6ccf6ba7debe8f7761d37ae5b8e32bad5e46b6e0.tar.xz
urpmi-6ccf6ba7debe8f7761d37ae5b8e32bad5e46b6e0.zip
4.4-5mdk
Diffstat (limited to 'urpm.pm')
-rw-r--r--urpm.pm232
1 files changed, 144 insertions, 88 deletions
diff --git a/urpm.pm b/urpm.pm
index 7b8e3f2e..604a782e 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -441,8 +441,8 @@ sub read_config {
while (<F>) {
chomp; s/#.*$//; s/^\s*//; s/\s*$//;
$_ eq '}' and last;
- /^(hdlist|with_hdlist|list|removable|md5sum|key_ids)\s*:\s*(.*)$/ and $medium->{$1} = $2, next;
- /^(update|ignore|synthesis)\s*$/ and $medium->{$1} = 1, next;
+ /^(hdlist|list|with_hdlist|removable|md5sum|key_ids)\s*:\s*(.*)$/ and $medium->{$1} = $2, next;
+ /^(update|ignore|synthesis|virtual)\s*$/ and $medium->{$1} = 1, next;
/^modified\s*$/ and next;
$_ and $urpm->{error}(N("syntax error in config file at line %s", $.));
}
@@ -531,49 +531,66 @@ sub probe_medium {
$medium->{url} ||= $medium->{clear_url};
- unless ($medium->{ignore} || $medium->{hdlist}) {
- $medium->{hdlist} = "hdlist.$medium->{name}.cz";
- -e "$urpm->{statedir}/$medium->{hdlist}" or $medium->{hdlist} = "hdlist.$medium->{name}.cz2";
- -e "$urpm->{statedir}/$medium->{hdlist}" or
- $medium->{ignore} = 1, $urpm->{error}(N("unable to find hdlist file for \"%s\", medium ignored", $medium->{name}));
- }
- unless ($medium->{ignore} || $medium->{list}) {
- unless (defined $medium->{url}) {
- $medium->{list} = "list.$medium->{name}";
- unless (-e "$urpm->{statedir}/$medium->{list}") {
- $medium->{ignore} = 1, $urpm->{error}(N("unable to find list file for \"%s\", medium ignored", $medium->{name}));
- }
- }
- }
-
- #- there is a little more to do at this point as url is not known, inspect directly list file for it.
- unless ($medium->{url}) {
- my %probe;
- if (-r "$urpm->{statedir}/$medium->{list}") {
- local *L;
- open L, "$urpm->{statedir}/$medium->{list}";
- while (<L>) {
- #- /./ is end of url marker in list file (typically generated by a
- #- find . -name "*.rpm" > list
- #- for exportable list file.
- /^(.*)\/\.\// and $probe{$1} = undef;
- /^(.*)\/[^\/]*$/ and $probe{$1} = undef;
- }
- close L;
- }
- foreach (sort { length($a) <=> length($b) } keys %probe) {
- if ($medium->{url}) {
- $medium->{url} eq substr($_, 0, length($medium->{url})) or
- $medium->{ignore} || $urpm->{error}(N("incoherent list file for \"%s\", medium ignored", $medium->{name})),
- $medium->{ignore} = 1, last;
- } else {
- $medium->{url} = $_;
+ if ($medium->{virtual}) {
+ #- a virtual medium need to have an url available without using a list file.
+ if ($medium->{hdlist} || $medium->{list}) {
+ $medium->{ignore} = 1;
+ $urpm->{error}(N("virtual medium \"%s\" should not have defined hdlist or list file, medium ignored",
+ $medium->{name}));
+ }
+ unless ($medium->{url}) {
+ $medium->{ignore} = 1;
+ $urpm->{error}(N("virtual medium \"%s\" should have a clear url, medium ignored",
+ $medium->{name}));
+ }
+ } else {
+ unless ($medium->{ignore} || $medium->{hdlist}) {
+ $medium->{hdlist} = "hdlist.$medium->{name}.cz";
+ -e "$urpm->{statedir}/$medium->{hdlist}" or $medium->{hdlist} = "hdlist.$medium->{name}.cz2";
+ -e "$urpm->{statedir}/$medium->{hdlist}" or
+ $medium->{ignore} = 1,
+ $urpm->{error}(N("unable to find hdlist file for \"%s\", medium ignored", $medium->{name}));
+ }
+ unless ($medium->{ignore} || $medium->{list}) {
+ unless (defined $medium->{url}) {
+ $medium->{list} = "list.$medium->{name}";
+ unless (-e "$urpm->{statedir}/$medium->{list}") {
+ $medium->{ignore} = 1,
+ $urpm->{error}(N("unable to find list file for \"%s\", medium ignored", $medium->{name}));
+ }
}
}
- unless ($options{nocheck_access}) {
- $medium->{url} or
- $medium->{ignore} || $urpm->{error}(N("unable to inspect list file for \"%s\", medium ignored", $medium->{name})),
- $medium->{ignore} = 1; #, last; keeping it cause perl to exit caller loop ...
+
+ #- there is a little more to do at this point as url is not known, inspect directly list file for it.
+ unless ($medium->{url}) {
+ my %probe;
+ if (-r "$urpm->{statedir}/$medium->{list}") {
+ local *L;
+ open L, "$urpm->{statedir}/$medium->{list}";
+ while (<L>) {
+ #- /./ is end of url marker in list file (typically generated by a
+ #- find . -name "*.rpm" > list
+ #- for exportable list file.
+ /^(.*)\/\.\// and $probe{$1} = undef;
+ /^(.*)\/[^\/]*$/ and $probe{$1} = undef;
+ }
+ close L;
+ }
+ foreach (sort { length($a) <=> length($b) } keys %probe) {
+ if ($medium->{url}) {
+ $medium->{url} eq substr($_, 0, length($medium->{url})) or
+ $medium->{ignore} || $urpm->{error}(N("incoherent list file for \"%s\", medium ignored", $medium->{name})),
+ $medium->{ignore} = 1, last;
+ } else {
+ $medium->{url} = $_;
+ }
+ }
+ unless ($options{nocheck_access}) {
+ $medium->{url} or
+ $medium->{ignore} || $urpm->{error}(N("unable to inspect list file for \"%s\", medium ignored",
+ $medium->{name})),
+ $medium->{ignore} = 1;
+ }
}
}
@@ -642,7 +659,7 @@ sub write_config {
foreach (qw(hdlist with_hdlist list removable md5sum key_ids)) {
$medium->{$_} and printf F " %s: %s\n", $_, $medium->{$_};
}
- foreach (qw(update ignore synthesis modified)) {
+ foreach (qw(update ignore synthesis modified virtual)) {
$medium->{$_} and printf F " %s\n", $_;
}
printf F "}\n\n";
@@ -746,7 +763,23 @@ sub configure {
unless ($options{nodepslist}) {
foreach (grep { !$_->{ignore} && (!$options{update} || $_->{update}) } @{$urpm->{media} || []}) {
delete @{$_}{qw(start end)};
- if ($options{callback}) {
+ if ($_->{virtual}) {
+ my $path = $_->{url} =~ /^file:\/*(\/[^\/].*[^\/])\/*$/ && $1;
+ if ($path) {
+ if ($_->{synthesis}) {
+ $urpm->{log}(N("examining synthesis file [%s]", "$path/$_->{with_hdlist}"));
+ eval { ($_->{start}, $_->{end}) = $urpm->parse_synthesis("$path/$_->{with_hdlist}",
+ callback => $options{callback}) };
+ } else {
+ $urpm->{log}(N("examining hdlist file [%s]", "$path/$_->{with_hdlist}"));
+ eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$path/$_->{with_hdlist}",
+ packing => 1, callback => $options{callback}) };
+ }
+ } else {
+ $urpm->{error}(N("virtual medium \"%s\" is not local, medium ignored", $_->{name}));
+ $_->{ignore} = 1;
+ }
+ } else {
if ($options{hdlist} && -s "$urpm->{statedir}/$_->{hdlist}" > 32) {
$urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}"));
eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}",
@@ -761,23 +794,12 @@ sub configure {
packing => 1, callback => $options{callback}) };
}
}
+ }
+ unless ($_->{ignore}) {
unless (defined $_->{start} && defined $_->{end}) {
- $urpm->{error}(N("problem reading hdlist file of medium \"%s\"", $_->{name}));
+ $urpm->{error}(N("problem reading hdlist or synthesis file of medium \"%s\"", $_->{name}));
$_->{ignore} = 1;
}
- } else {
- if (-s "$urpm->{statedir}/synthesis.$_->{hdlist}" > 32) {
- $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$_->{hdlist}"));
- eval { ($_->{start}, $_->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$_->{hdlist}") };
- }
- unless (defined $_->{start} && defined $_->{end}) {
- $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}"));
- eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}", packing => 1) };
- unless (defined $_->{start} && defined $_->{end}) {
- $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $_->{name}));
- $_->{ignore} = 1;
- }
- }
}
}
}
@@ -847,20 +869,30 @@ sub add_medium {
$url =~ s|(.*?)/*$|$1|;
#- creating the medium info.
- $medium = { name => $name,
- url => $url,
- hdlist => "hdlist.$name.cz",
- list => "list.$name",
- update => $options{update},
- modified => 1,
- };
+ if ($options{virtual}) {
+ $url =~ m|^file:/*(/[^/].*)/| or $urpm->{fatal}(5, N("virtual medium need to local"));
+
+ $medium = { name => $name,
+ url => $url,
+ update => $options{update},
+ virtual => 1,
+ };
+ } else {
+ $medium = { name => $name,
+ url => $url,
+ hdlist => "hdlist.$name.cz",
+ list => "list.$name",
+ update => $options{update},
+ modified => 1,
+ };
+
+ #- check to see if the medium is using file protocol or removable medium.
+ $url =~ /^(removable[^:]*|file):\/(.*)/ and $urpm->probe_removable_device($medium);
+ }
#- check if a password is visible, if not set clear_url.
$url =~ m|([^:]*://[^/:\@]*:)[^/:\@]*(\@.*)| or $medium->{clear_url} = $url;
- #- check to see if the medium is using file protocol or removable medium.
- $url =~ /^(removable[^:]*|file):\/(.*)/ and $urpm->probe_removable_device($medium);
-
#- all flags once everything has been computed.
$with_hdlist and $medium->{with_hdlist} = $with_hdlist;
@@ -1077,14 +1109,34 @@ sub update_media {
#- we still need to read it and all synthesis will be written if
#- a unresolved provides is found.
#- to speed up the process, we only read the synthesis at the begining.
- $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
- eval { ($medium->{start}, $medium->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}") };
- unless (defined $medium->{start} && defined $medium->{end}) {
- $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$medium->{hdlist}"));
- eval { ($medium->{start}, $medium->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1) };
+ delete @{$medium}{qw(start end)};
+ if ($medium->{virtual}) {
+ my $path = $medium->{url} =~ /^file:\/*(\/[^\/].*[^\/])\/*$/ && $1;
+ if ($path) {
+ if ($medium->{synthesis}) {
+ $urpm->{log}(N("examining synthesis file [%s]", "$path/$medium->{with_hdlist}"));
+ eval { ($medium->{start}, $medium->{end}) = $urpm->parse_synthesis("$path/$medium->{with_hdlist}") };
+ } else {
+ $urpm->{log}(N("examining hdlist file [%s]", "$path/$medium->{with_hdlist}"));
+ eval { ($medium->{start}, $medium->{end}) = $urpm->parse_hdlist("$path/$medium->{with_hdlist}",
+ packing => 1) };
+ }
+ } else {
+ $urpm->{error}(N("virtual medium \"%s\" is not local, medium ignored", $medium->{name}));
+ $_->{ignore} = 1;
+ }
+ } else {
+ $urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
+ eval { ($medium->{start}, $medium->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}") };
+ unless (defined $medium->{start} && defined $medium->{end}) {
+ $urpm->{log}(N("examining hdlist file [%s]", "$urpm->{statedir}/$medium->{hdlist}"));
+ eval { ($medium->{start}, $medium->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1) };
+ }
+ }
+ unless ($medium->{ignore}) {
unless (defined $medium->{start} && defined $medium->{end}) {
#- this is almost a fatal error, ignore it by default?
- $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $medium->{name}));
+ $urpm->{error}(N("Aproblem reading synthesis file of medium \"%s\"", $medium->{name}));
$medium->{ignore} = 1;
}
}
@@ -1198,7 +1250,7 @@ sub update_media {
eval { ($medium->{start}, $medium->{end}) =
$urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1) };
unless (defined $medium->{start} && defined $medium->{end}) {
- $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $medium->{name}));
+ $urpm->{error}(N("Bproblem reading synthesis file of medium \"%s\"", $medium->{name}));
$medium->{ignore} = 1;
}
}
@@ -1254,7 +1306,7 @@ sub update_media {
eval { ($medium->{start}, $medium->{end}) =
$urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1) };
unless (defined $medium->{start} && defined $medium->{end}) {
- $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $medium->{name}));
+ $urpm->{error}(N("Cproblem reading synthesis file of medium \"%s\"", $medium->{name}));
$medium->{ignore} = 1;
}
}
@@ -1407,7 +1459,7 @@ sub update_media {
eval { ($medium->{start}, $medium->{end}) =
$urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1) };
unless (defined $medium->{start} && defined $medium->{end}) {
- $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $medium->{name}));
+ $urpm->{error}(N("Cproblem reading synthesis file of medium \"%s\"", $medium->{name}));
$medium->{ignore} = 1;
}
}
@@ -1505,7 +1557,7 @@ sub update_media {
eval { ($medium->{start}, $medium->{end}) =
$urpm->parse_hdlist("$urpm->{statedir}/$medium->{hdlist}", packing => 1) };
unless (defined $medium->{start} && defined $medium->{end}) {
- $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $medium->{name}));
+ $urpm->{error}(N("Dproblem reading synthesis file of medium \"%s\"", $medium->{name}));
$medium->{ignore} = 1;
}
}
@@ -1655,7 +1707,7 @@ sub update_media {
$urpm->{log}(N("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$medium->{hdlist}"));
eval { ($medium->{start}, $medium->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$medium->{hdlist}") };
unless (defined $medium->{start} && defined $medium->{end}) {
- $urpm->{error}(N("problem reading synthesis file of medium \"%s\"", $medium->{name}));
+ $urpm->{error}(N("Eproblem reading synthesis file of medium \"%s\"", $medium->{name}));
$medium->{ignore} = 1;
}
} else {
@@ -1736,11 +1788,13 @@ sub update_media {
}
#- check if synthesis file can be built.
if (($urpm->{second_pass} || $medium->{modified_synthesis}) && !$medium->{modified}) {
- $urpm->build_synthesis(start => $medium->{start},
- end => $medium->{end},
- synthesis => "$urpm->{statedir}/synthesis.$medium->{hdlist}",
- );
- $urpm->{log}(N("built hdlist synthesis file for medium \"%s\"", $medium->{name}));
+ unless ($medium->{virtual}) {
+ $urpm->build_synthesis(start => $medium->{start},
+ end => $medium->{end},
+ synthesis => "$urpm->{statedir}/synthesis.$medium->{hdlist}",
+ );
+ $urpm->{log}(N("built hdlist synthesis file for medium \"%s\"", $medium->{name}));
+ }
#- keep in mind we have modified database, sure at this point.
$urpm->{modified} = 1;
}
@@ -2870,10 +2924,12 @@ sub unselected_packages {
sub translate_why_unselected {
my ($urpm, $state, @l) = @_;
- map { my @froms = keys %{$state->{rejected}{$_}{backtrack}{closure} || {}};
- my @unsatisfied = @{$state->{rejected}{$_}{backtrack}{unsatisfied} || []};
+ map { my $rb = $state->{rejected}{$_}{backtrack};
+ my @froms = keys %{$rb->{closure} || {}};
+ my @unsatisfied = @{$rb->{unsatisfied} || []};
my $s = join ", ", ((map { N("due to missing %s", $_) } @froms),
- (map { N("due to unsatisfied %s", $_) } @unsatisfied));
+ (map { N("due to unsatisfied %s", $_) } @unsatisfied),
+ $rb->{promote} ? N("trying to promote %s by selection of %s", $rb->{promote}, $rb->{psel}) : @{[]});
$_ . ($s ? " ($s)" : '');
} @l;
}