From 57573a55ce93cb59d88c04aae1c34d045a1589b5 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Wed, 29 Sep 2004 06:42:39 +0000 Subject: Add a new option -m to urpmf to get the media in which a package has been found. --- man/C/urpmf.8 | 2 ++ urpm.pm | 1 + urpm/args.pm | 1 + urpmf | 10 +++++++--- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/man/C/urpmf.8 b/man/C/urpmf.8 index efc1f7ee..0ab5840e 100644 --- a/man/C/urpmf.8 +++ b/man/C/urpmf.8 @@ -75,6 +75,8 @@ argument is the same argument given to \fB--bug\fP option. Ignore case distinctions in any patterns. .IP "\fB-f\fP" Print version, release and arch along with name of package. +.IP "\fB-m\fP" +Print the name of the media in which the package has been found. .IP "\fB-e\fP" Include code directly in generated perl expression. Use it with \fB--verbose\fP to look at perl code generated. But in any cases, use it only if you know perl. diff --git a/urpm.pm b/urpm.pm index 7fc05b6c..ccca9c1c 100644 --- a/urpm.pm +++ b/urpm.pm @@ -481,6 +481,7 @@ sub configure { my $second_pass; do { foreach (grep { !$_->{ignore} && (!$options{update} || $_->{update}) } @{$urpm->{media} || []}) { + our $currentmedia = $_; #- hack for urpmf delete @$_{qw(start end)}; if ($_->{virtual}) { my $path = $_->{url} =~ m{^(?:file:/*)?(/[^/].*[^/])/*$} && $1; diff --git a/urpm/args.pm b/urpm/args.pm index 8c3d589b..afe63c66 100644 --- a/urpm/args.pm +++ b/urpm/args.pm @@ -150,6 +150,7 @@ my %options_spec = ( files => \$::params{files}, conflicts => \$::params{conflicts}, obsoletes => \$::params{obsoletes}, + m => \$::params{media}, i => sub { $::pattern = 'i' }, f => sub { $::full = 'full' }, 'e=s' => sub { $::expr .= "($_[1])" }, diff --git a/urpmf b/urpmf index 2a88ff90..6130720f 100755 --- a/urpmf +++ b/urpmf @@ -66,6 +66,7 @@ usage: ") . N(" ( - left parenthesis to open group expression. ") . N(" ) - right parenthesis to close group expression. "); +#") . N(" -m - print the media in which the package was found. exit(0); } @@ -100,14 +101,17 @@ foreach (scalar(grep { defined $_ } values %params)) { #- build the callback matching the expression. my $callback = 'sub { my ($urpm, $pkg) = @_; '; #- it is a good start for a sub, no ;-) foreach (qw(filename group size epoch summary description sourcerpm packager buildhost url - provides requires files conflicts obsoletes)) { - $params{$_} and $callback .= ' - foreach my $e ($pkg->'.$_.') { + provides requires files conflicts obsoletes media)) { + if ($params{$_}) { + my $fi = $_ eq 'media' ? '$urpm::currentmedia->{name}' : '$pkg->'.$_; + $callback .= ' + foreach my $e ('.$fi.') { local $_ = $pkg->'.$full.'name."'.(!$quiet && ":$_").':$e"; '.$expr.' or next; '.($uniq && 'exists $uniq{$_} and next; $uniq{$_} = undef; ').'print "$_\n"; }'; + } } $callback .= ' 1; -- cgit v1.2.1