OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Michael van Elst
Root: /e/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-re Date: 12-Nov-2002 15:36:15
Branch: HEAD Handle: 2002111214361400
Modified files:
openpkg-re openpkg-build
Log:
add support for "with" macros
Summary:
Revision Changes Path
1.4 +62 -20 openpkg-re/openpkg-build
____________________________________________________________________________
Index: openpkg-re/openpkg-build
============================================================
$ cvs diff -u -r1.3 -r1.4 openpkg-build
--- openpkg-re/openpkg-build 12 Nov 2002 08:42:48 -0000 1.3
+++ openpkg-re/openpkg-build 12 Nov 2002 14:36:14 -0000 1.4
@@ -46,11 +46,46 @@
}
getopts('R:r:f:u');
-die "usage: $0 [-R rpm] [-r repository] [-f index.rdf] [-u] package\n"
+die "usage: $0 [-R rpm] [-r repository] [-f index.rdf] [-u] package [with..]\n"
unless $ARGV[0] =~ /^\S+$/;
##########################################################################
+sub conditional ($$) {
+ my($cond,$with) = @_;
+ my(%with) = map { $_ => 1 } @$with;
+ my(@s,$res);
+
+ return 1 if $cond eq '';
+
+ foreach (split(/\s+/,$cond)) {
+ if ($_ eq '+') {
+ die "FATAL: stack underflow in: $cond\n" if scalar(@s)<2;
+ my($a) = pop @s;
+ my($b) = pop @s;
+ push @s, $a && $b;
+ } elsif ($_ eq '|') {
+ die "FATAL: stack underflow in: $cond\n" if scalar(@s)<2;
+ my($a) = pop @s;
+ my($b) = pop @s;
+ push @s, $a && $b;
+ } elsif ($_ eq '!') {
+ die "FATAL: stack underflow in: $cond\n" if scalar(@s)<1;
+ my($a) = pop @s;
+ push @s, !$a;
+ } else {
+ push @s, $with{$_} + 0;
+ }
+ }
+ die "FATAL: stack underflow in: $cond\n" if scalar(@s)<1;
+ $res = pop @s;
+
+ die "FATAL: stack not empty in: $cond\n" if scalar(@s)>0;
+ return $res;
+}
+
+##########################################################################
+
my($RPM,$PROG);
$RPM = $opt_R || 'rpm';
@@ -171,8 +206,8 @@
return $pid;
}
-sub get_index ($$) {
- my($url,$fn) = @_;
+sub get_index ($$@) {
+ my($url,$fn,@with) = @_;
my($ua,$req,$res,$rdf);
my($pid);
my(%map);
@@ -228,6 +263,7 @@
my(@prereq,@bprereq);
my(@provides,$rec);
my($tag,$cond,$body);
+ my($useit);
while (<RFH>) {
@@ -245,23 +281,21 @@
}
next unless defined $href;
- ($tag,$cond,$body) = /<(\/?[\w:]+)\s*(cond="[^"]+")?>([^<]*)/;
+ ($tag,$cond,$body) = /<(\/?[\w:]+)\s*(?:cond="([^"]+)")?>([^<]*)/;
next unless $tag;
- next if $cond ne '';
+
+ $useit = conditional($cond,\@with);
if ($tag eq 'PreReq') {
- $section = 'prereq';
- @prereq = ();
+ $section = 'prereq' if $useit;
} elsif ($tag eq '/PreReq') {
$section = undef;
} elsif ($tag eq 'BuildPreReq') {
- $section = 'bprereq';
- @bprereq = ();
+ $section = 'bprereq' if $useit;
} elsif ($tag eq '/BuildPreReq') {
$section = undef;
} elsif ($tag eq 'Provides') {
- $section = 'provides';
- @provides = ();
+ $section = 'provides' if $useit;
} elsif ($tag eq '/Provides') {
$section = undef;
} elsif ($tag eq 'Name') {
@@ -534,7 +568,7 @@
}
sub build_list ($$) {
- my($pattern, $env) = @_;
+ my($env, $pattern) = @_;
my(@goals,@targets,@keeps,$bonly,$t);
my($name,$r,@vers);
@@ -582,17 +616,21 @@
#######################################################################
-sub print_list1 ($$$$) {
- my($list,$c,$url,$uncond) = @_;
- my($spkg,$bpkg);
+sub print_list1 ($$$$@) {
+ my($list,$c,$url,$uncond,@with) = @_;
+ my($spkg,$bpkg,$with);
$url .= '/' unless $url =~ m{/$}s;
+ if (@with) {
+ $with = ' '.join(' ',map { "--define '$_ yes'" } @with);
+ }
+
foreach (@$list) {
$spkg = $_->{href};
$bpkg = target2rpm($_, $c);
if ($uncond || !-f $bpkg) {
- print "$RPM --rebuild $url$spkg || exit 1\n";
+ print "$RPM$with --rebuild $url$spkg || exit 1\n";
}
print "$RPM -Uvh $bpkg\n";
}
@@ -611,6 +649,10 @@
#######################################################################
my($config,$url,$repository,$installed,$list,$bonly);
+my($pattern,@with);
+
+$pattern = shift @ARGV;
+@with = map { "with_$_" } @ARGV;
$config = get_config();
@@ -622,16 +664,16 @@
}
$installed = get_installed();
-$repository = get_index($url,$opt_f);
+$repository = get_index($url,$opt_f,@with);
-($list,$bonly) = build_list($ARGV[0], {
+($list,$bonly) = build_list({
installed => $installed,
repository => $repository,
built => {}
- });
+ }, $pattern);
die "FATAL: cannot find package\n" unless defined $list;
-print_list1($list,$config,$url,$opt_u);
+print_list1($list,$config,$url,$opt_u,@with);
print_list2($bonly,$config);
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [EMAIL PROTECTED]