aboutsummaryrefslogtreecommitdiffstats
path: root/URPM/Query.pm
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2004-04-18 23:15:37 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2004-04-18 23:15:37 +0000
commit5e2dce8c729730cba981d35fe431ccfd689661df (patch)
treec27167e06851066157b94788b1ee5a719f934efe /URPM/Query.pm
parent2b6f8157feaaa81b00604a3f0a383ae06df36e0c (diff)
downloadperl-URPM-5e2dce8c729730cba981d35fe431ccfd689661df.tar
perl-URPM-5e2dce8c729730cba981d35fe431ccfd689661df.tar.gz
perl-URPM-5e2dce8c729730cba981d35fe431ccfd689661df.tar.bz2
perl-URPM-5e2dce8c729730cba981d35fe431ccfd689661df.tar.xz
perl-URPM-5e2dce8c729730cba981d35fe431ccfd689661df.zip
- add query_pkg function
- transmit %options to parse_rpm in parse_rpms_build_headers
Diffstat (limited to 'URPM/Query.pm')
-rw-r--r--URPM/Query.pm20
1 files changed, 20 insertions, 0 deletions
diff --git a/URPM/Query.pm b/URPM/Query.pm
index 6e639c8..7929ce6 100644
--- a/URPM/Query.pm
+++ b/URPM/Query.pm
@@ -188,4 +188,24 @@ sub id2tag {
@ret
}
+sub query_pkg {
+ my ($urpm, $pkg, $query) = @_;
+ my @tags = map {
+ [ $pkg->get_tag(tag2id($_)) ]
+ } $query =~ m/\%\{([^{}]*)\}*/g;
+
+ $query =~ s/\%\{[^{}]*\}/%s/g;
+ $query =~ s/\\n/\n/g;
+ $query =~ s/\\t/\t/g;
+ my ($max, @res) = 0;
+
+ foreach (@tags) { $max < $#{$_} and $max = $#{$_} };
+
+ foreach my $i (0 .. $max) {
+ push(@res, sprintf($query, map { ${$_}[ $#{$_} < $i ? $#{$_} : $i ] } @tags));
+ }
+ @res
+}
+
+
1;