aboutsummaryrefslogtreecommitdiffstats
path: root/URPM/Build.pm
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mandriva.org>2004-04-17 23:31:06 +0000
committerOlivier Thauvin <nanardon@mandriva.org>2004-04-17 23:31:06 +0000
commit2b6f8157feaaa81b00604a3f0a383ae06df36e0c (patch)
tree86946038ce48c32dda7745b3f779b19642df33c0 /URPM/Build.pm
parent8f3e4966fe4ed5cd5705f29d0af6acecf05be600 (diff)
downloadperl-URPM-2b6f8157feaaa81b00604a3f0a383ae06df36e0c.tar
perl-URPM-2b6f8157feaaa81b00604a3f0a383ae06df36e0c.tar.gz
perl-URPM-2b6f8157feaaa81b00604a3f0a383ae06df36e0c.tar.bz2
perl-URPM-2b6f8157feaaa81b00604a3f0a383ae06df36e0c.tar.xz
perl-URPM-2b6f8157feaaa81b00604a3f0a383ae06df36e0c.zip
- add Query.pm (starting to code)
- add fuzzy_parse function, transparency parse hdlist, synthesis, rpms or dir (dir/*.rpm) - add parse_rpms function to have same behaviours than parse_{hdlists,synthesis}
Diffstat (limited to 'URPM/Build.pm')
-rw-r--r--URPM/Build.pm48
1 files changed, 46 insertions, 2 deletions
diff --git a/URPM/Build.pm b/URPM/Build.pm
index 0282c8b..88e6d5b 100644
--- a/URPM/Build.pm
+++ b/URPM/Build.pm
@@ -65,13 +65,11 @@ sub parse_rpms_build_headers {
}
}
-
my $pkg = $urpm->{depslist}[$id];
$filename = $pkg->fullname;
"$filename.rpm" eq $pkg->filename or $filename .= ":$key";
- $options{silent} or print STDERR "$dir/$filename\n";
unless (-s "$dir/$filename") {
open F, ">$dir/$filename" or die "unable to open $dir/$filename for writing\n";
$pkg->build_header(fileno *F);
@@ -85,6 +83,11 @@ sub parse_rpms_build_headers {
} else {
$pkg->pack_header;
}
+
+ # Olivier Thauvin <thauvin@aerov.jussieu.fr>
+ # isn't this code better, but maybe it will break some tools:
+ # $options{callback}->($urpm, $id, %options, (file => $_)) if ($options{callback});
+ # $pkg->pack_header;
}
#- keep track of header associated (to avoid rereading rpm filename directly
@@ -127,6 +130,47 @@ sub parse_headers {
defined $id ? ($start, $id) : @{[]};
}
+# parse_rpms, to same bevaviour than parse_{hdlist, synthesis}
+# ie: ($start, $end) = parse_*(filestoparse, %options);
+
+sub parse_rpms {
+ my ($urpm, $rpms, %options) = @_;
+ my ($start, $end);
+ $urpm->parse_rpms_build_headers(
+ rpms => $rpms,
+ %options,
+ callback => sub {
+ my ($urpm, $id) = @_;
+ $start = $id if($start > $id || ! defined($start));
+ $end = $id if($end < $id || ! defined($end));
+ }
+ ) ? ($start, $end) : ();
+}
+
+# fuzzy_parse is a simple wrapper for parse_rpm* function
+# It detect if the file passed is a dir, an hdlist, a synthesis or a rpm
+# it call the good function.
+sub fuzzy_parse {
+ my ($urpm, %options) = @_;
+ my ($start, $end);
+ foreach my $entry (@{$options{paths} || []}) {
+ if (-d $entry) { # it is a dir
+ ($start, $end) = $urpm->parse_rpms([ glob("$entry/*.rpm") ], %options);
+ defined ($start) and return ($start .. $end);
+ } else { # we try some methode to load the file
+ ($start, $end) = $urpm->parse_hdlist($entry);
+ defined ($start) and return ($start .. $end);
+
+ ($start, $end) = $urpm->parse_synthesis($entry);
+ defined ($start) and return ($start .. $end);
+
+ ($start, $end) = $urpm->parse_rpms([ $entry ], %options);
+ defined ($start) and return ($start .. $end);
+ }
+ }
+ ()
+}
+
#- compute dependencies, result in stored in info values of urpm.
#- operations are incremental, it is possible to read just one hdlist, compute
#- dependencies and read another hdlist, and again.