summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schröder <mls@suse.de>2007-07-23 17:04:54 +0000
committerMichael Schröder <mls@suse.de>2007-07-23 17:04:54 +0000
commit43e0b04ef36abaeadb4cc10daf0636f198143b71 (patch)
tree40220d3579ab29b369399833e84e3463c8eb21a3
parent36d8c05f9e79137eef6e119ab2cf87603c694614 (diff)
downloadobs-build-43e0b04ef36abaeadb4cc10daf0636f198143b71.tar.gz
obs-build-43e0b04ef36abaeadb4cc10daf0636f198143b71.tar.bz2
obs-build-43e0b04ef36abaeadb4cc10daf0636f198143b71.zip
- fix dependency substitution for deps with '('
- new config parameter: order, enforce package ordering - make query function support generic options - support description queries
-rw-r--r--Build.pm37
-rw-r--r--Build/Deb.pm7
-rw-r--r--Build/Rpm.pm28
-rwxr-xr-xinit_buildsystem2
-rwxr-xr-xorder33
-rwxr-xr-xsubstitutedeps2
6 files changed, 79 insertions, 30 deletions
diff --git a/Build.pm b/Build.pm
index 8237880..c9c76dd 100644
--- a/Build.pm
+++ b/Build.pm
@@ -130,9 +130,11 @@ sub read_config {
$config->{'substitute'} = {};
$config->{'substitute_vers'} = {};
$config->{'optflags'} = {};
+ $config->{'order'} = {};
$config->{'rawmacros'} = '';
$config->{'release'} = '<CI_CNT>.<B_CNT>';
$config->{'repotype'} = [];
+ $config->{'patterntype'} = [];
for my $l (@spec) {
$l = $l->[1] if ref $l;
next unless defined $l;
@@ -159,20 +161,26 @@ sub read_config {
} elsif ($l0 eq 'substitute:') {
next unless @l;
$ll = shift @l;
- push @{$config->{'substitute'}->{$ll}}, @l;
+ $config->{'substitute'}->{$ll} = [ @l ];
} elsif ($l0 eq 'optflags:') {
next unless @l;
$ll = shift @l;
$config->{'optflags'}->{$ll} = join(' ', @l);
+ } elsif ($l0 eq 'order:') {
+ for (@l) {
+ $config->{'order'}->{$_} = 1;
+ }
} elsif ($l0 eq 'repotype:') {
$config->{'repotype'} = [ @l ];
+ } elsif ($l0 eq 'patterntype:') {
+ $config->{'patterntype'} = [ @l ];
} elsif ($l0 eq 'release:') {
$config->{'release'} = $l[0];
} elsif ($l0 !~ /^[#%]/) {
warn("unknown keyword in config: $l0\n");
}
}
- for my $l (qw{preinstall vminstall required support keep runscripts repotype}) {
+ for my $l (qw{preinstall vminstall required support keep runscripts repotype patterntype}) {
$config->{$l} = [ unify(@{$config->{$l}}) ];
}
for my $l (keys %{$config->{'substitute'}}) {
@@ -565,6 +573,9 @@ sub order {
my @q = @{$whatprovides->{$r} || addproviders($config, $r)};
push @r, grep {$_ ne $p && $p{$_}} @q;
}
+ if (%{$config->{'order'} || {}}) {
+ push @r, grep {$_ ne $p && $config->{'order'}->{"$_:$p"}} @p;
+ }
@r = unify(@r);
$deps{$p} = \@r;
$needed{$p} = @r;
@@ -621,11 +632,21 @@ sub order {
}
unshift @todo, $cycv;
print STDERR "cycle: ".join(' -> ', @cyc)."\n";
- my $breakv = (sort {$needed{$a} <=> $needed{$b} || $a cmp $b} @cyc)[-1];
- push @cyc, $cyc[0];
+ my $breakv;
+ my @breakv = (@cyc, $cyc[0]);
+ while (@breakv > 1) {
+ last if $config->{'order'}->{"$breakv[0]:$breakv[1]"};
+ shift @breakv;
+ }
+ if (@breakv > 1) {
+ $breakv = $breakv[0];
+ } else {
+ $breakv = (sort {$needed{$a} <=> $needed{$b} || $a cmp $b} @cyc)[-1];
+ }
+ push @cyc, $cyc[0]; # make it loop
shift @cyc while $cyc[0] ne $breakv;
$v = $cyc[1];
- print STDERR " breaking with $breakv -> $v\n";
+ print STDERR " breaking dependency $breakv -> $v\n";
$deps{$breakv} = [ grep {$_ ne $v} @{$deps{$breakv}} ];
$rdeps{$v} = [ grep {$_ ne $breakv} @{$rdeps{$v}} ];
$needed{$breakv}--;
@@ -659,14 +680,14 @@ sub parse {
}
sub query {
- my ($binname, $withevra, $withfilelist) = @_;
+ my ($binname, %opts) = @_;
my $handle = $binname;
if (ref($binname) eq 'ARRAY') {
$handle = $binname->[1];
$binname = $binname->[0];
}
- return Build::Rpm::query($handle, $withevra, $withfilelist) if $do_rpm && $binname =~ /\.rpm$/;
- return Build::Deb::query($handle, $withevra, $withfilelist) if $do_deb && $binname =~ /\.deb$/;
+ return Build::Rpm::query($handle, %opts) if $do_rpm && $binname =~ /\.rpm$/;
+ return Build::Deb::query($handle, %opts) if $do_deb && $binname =~ /\.deb$/;
return undef;
}
diff --git a/Build/Deb.pm b/Build/Deb.pm
index 041c615..3037437 100644
--- a/Build/Deb.pm
+++ b/Build/Deb.pm
@@ -213,7 +213,7 @@ sub debq {
}
sub query {
- my ($handle, $withevra, $withfilelist) = @_;
+ my ($handle, %opts) = @_;
my %res = debq($handle);
return undef unless %res;
@@ -238,7 +238,7 @@ sub query {
requires => \@depends,
};
$data->{'source'} = $src if $src ne '';
- if ($withevra) {
+ if ($opts{'evra'}) {
if ($res{'VERSION'} =~ /^(.*)-(.*?)$/) {
$data->{'version'} = $1;
$data->{'release'} = $2;
@@ -247,6 +247,9 @@ sub query {
}
$data->{'arch'} = $res{'ARCHITECTURE'};
}
+ if ($opts{'description'}) {
+ $data->{'description'} = $res{'DESCRIPTION'};
+ }
return $data;
}
diff --git a/Build/Rpm.pm b/Build/Rpm.pm
index ee53bbe..057130c 100644
--- a/Build/Rpm.pm
+++ b/Build/Rpm.pm
@@ -314,7 +314,7 @@ sub parse {
}
if ($line =~ /^PreReq:\s*(\S.*)$/i) {
my $deps = $1;
- my @deps = $deps =~ /([^\s\[\(,]+)(\s+[<=>]+\s+[^\s\[,]+)?(\s+\[[^\]]+\])?[\s,]*/g;
+ my @deps = $deps =~ /([^\s\[,]+)(\s+[<=>]+\s+[^\s\[,]+)?(\s+\[[^\]]+\])?[\s,]*/g;
while (@deps) {
my ($pack, $vers, $qual) = splice(@deps, 0, 3);
next if $pack =~ /\//;
@@ -326,7 +326,7 @@ sub parse {
my $what = $1;
my $deps = $2;
$ifdeps = 1 if $hasif;
- my @deps = $deps =~ /([^\s\[\(,]+)(\s+[<=>]+\s+[^\s\[,]+)?(\s+\[[^\]]+\])?[\s,]*/g;
+ my @deps = $deps =~ /([^\s\[,]+)(\s+[<=>]+\s+[^\s\[,]+)?(\s+\[[^\]]+\])?[\s,]*/g;
my $replace = 0;
my @ndeps = ();
while (@deps) {
@@ -358,7 +358,7 @@ sub parse {
}
$replace = 1 if grep {/^-/} @ndeps;
- if ($what ne 'BuildRequires') {
+ if (lc($what) ne 'buildrequires') {
push @packdeps, map {"-$_"} @ndeps;
next;
}
@@ -375,7 +375,7 @@ sub parse {
if ($replace) {
my @cndeps = grep {!/^-/} @ndeps;
if (@cndeps) {
- $xspec->[-1] = [ $xspec->[-1], "BuildRequires: ".join(' ', @cndeps) ];
+ $xspec->[-1] = [ $xspec->[-1], "$what: ".join(' ', @cndeps) ];
} else {
$xspec->[-1] = [ $xspec->[-1], ''];
}
@@ -429,6 +429,8 @@ my %rpmstag = (
"VERSION" => 1001,
"RELEASE" => 1002,
"EPOCH" => 1003,
+ "SUMMARY" => 1004,
+ "DESCRIPTION" => 1005,
"ARCH" => 1022,
"OLDFILENAMES" => 1027,
"SOURCERPM" => 1044,
@@ -689,11 +691,12 @@ sub verscmp {
}
sub query {
- my ($handle, $withevra, $withfilelist) = @_;
+ my ($handle, %opts) = @_;
my @tags = qw{NAME SOURCERPM NOSOURCE NOPATCH SIGTAG_MD5 PROVIDENAME PROVIDEFLAGS PROVIDEVERSION REQUIRENAME REQUIREFLAGS REQUIREVERSION};
- push @tags, qw{EPOCH VERSION RELEASE ARCH} if $withevra;
- push @tags, qw{FILENAMES} if $withfilelist;
+ push @tags, qw{EPOCH VERSION RELEASE ARCH} if $opts{'evra'};
+ push @tags, qw{FILENAMES} if $opts{'filelist'};
+ push @tags, qw{SUMMARY DESCRIPTION} if $opts{'description'};
my %res = rpmq($handle, @tags);
return undef unless %res;
my $src = $res{'SOURCERPM'}->[0];
@@ -705,8 +708,7 @@ sub query {
name => $res{'NAME'}->[0],
hdrmd5 => unpack('H32', $res{'SIGTAG_MD5'}->[0]),
};
- # XXX hack, make this another option!
- if ($withfilelist) {
+ if ($opts{'alldeps'}) {
$data->{'provides'} = [ @{$res{'PROVIDENAME'} || []} ];
$data->{'requires'} = [ @{$res{'REQUIRENAME'} || []} ];
} else {
@@ -714,7 +716,7 @@ sub query {
$data->{'requires'} = [ grep {!/^rpmlib\(/ && !/^\//} @{$res{'REQUIRENAME'} || []} ];
}
$data->{'source'} = $src if $src ne '';
- if ($withevra) {
+ if ($opts{'evra'}) {
my $arch = $res{'ARCH'}->[0];
$arch = $res{'NOSOURCE'} || $res{'NOPATCH'} ? 'nosrc' : 'src' unless $src ne '';
$data->{'version'} = $res{'VERSION'}->[0];
@@ -722,9 +724,13 @@ sub query {
$data->{'arch'} = $arch;
$data->{'epoch'} = $res{'EPOCH'}->[0] if exists $res{'EPOCH'};
}
- if ($withfilelist) {
+ if ($opts{'filelist'}) {
$data->{'filelist'} = $res{'FILENAMES'};
}
+ if ($opts{'description'}) {
+ $data->{'summary'} = $res{'SUMMARY'}->[0];
+ $data->{'description'} = $res{'DESCRIPTION'}->[0];
+ }
return $data;
}
diff --git a/init_buildsystem b/init_buildsystem
index 571363e..ce2f383 100755
--- a/init_buildsystem
+++ b/init_buildsystem
@@ -150,7 +150,7 @@ function reorder {
for PKG in "$@" ; do
echo "$PKG" >> $BUILD_ROOT/.init_b_cache/order.manifest
done
- $BUILD_DIR/order --manifest $BUILD_ROOT/.init_b_cache/order.manifest $BUILD_ROOT/.init_b_cache/rpms
+ $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $BUILD_DIR/configs --manifest $BUILD_ROOT/.init_b_cache/order.manifest $BUILD_ROOT/.init_b_cache/rpms
rm -f $BUILD_ROOT/.init_b_cache/order.manifest
}
diff --git a/order b/order
index d85a8d8..8e30670 100755
--- a/order
+++ b/order
@@ -7,11 +7,31 @@ BEGIN {
use Build;
use strict;
-my $manifest;
+my ($dist, $archs, $configdir, $manifest);
-if (@ARGV && $ARGV[0] eq '--manifest') {
- shift @ARGV;
- $manifest = shift @ARGV;
+
+while (@ARGV) {
+ if ($ARGV[0] eq '--dist') {
+ shift @ARGV;
+ $dist = shift @ARGV;
+ next;
+ }
+ if ($ARGV[0] eq '--archpath') {
+ shift @ARGV;
+ $archs = shift @ARGV;
+ next;
+ }
+ if ($ARGV[0] eq '--configdir') {
+ shift @ARGV;
+ $configdir = shift @ARGV;
+ next;
+ }
+ if (@ARGV && $ARGV[0] eq '--manifest') {
+ shift @ARGV;
+ $manifest = shift @ARGV;
+ next;
+ }
+ last;
}
die("usage: order [--manifest manifest] cachedir [packages...]\n") unless @ARGV;
@@ -32,8 +52,7 @@ if ($manifest) {
push @p, @ARGV;
-# dummy config is enough for sorting purposes
-my $config = Build::read_config('noarch');
+my $config = Build::read_config_dist($dist, $archs, $configdir);
my %deps;
my %bins;
@@ -42,7 +61,7 @@ for my $p (@p) {
my $q;
for my $suf ('rpm', 'deb') {
next unless -f "$cachedir/$p.$suf";
- $q = Build::query("$cachedir/$p.$suf", undef, 1);
+ $q = Build::query("$cachedir/$p.$suf", 'filelist' => 1, 'alldeps' => 1);
die("bad binary: $p.$suf\n") unless $q;
push @{$q->{'provides'}}, @{$q->{'filelist'}} if $suf eq 'rpm' && $q->{'filelist'};
delete $q->{'filelist'};
diff --git a/substitutedeps b/substitutedeps
index b6ce0c9..426ae7d 100755
--- a/substitutedeps
+++ b/substitutedeps
@@ -91,7 +91,7 @@ for my $l (@$xspec) {
$isbuildrequires = 1 if $l =~ /^BuildRequires:/i;
my $r = $l;
$r =~ s/^[^:]*:\s*//;
- my @deps = $r =~ /([^\s\[\(,]+)(\s+[<=>]+\s+[^\s\[,]+)?[\s,]*/g;
+ my @deps = $r =~ /([^\s\[,]+)(\s+[<=>]+\s+[^\s\[,]+)?[\s,]*/g;
my @ndeps = ();
my $replace = 0;
my @f2 = Build::do_subst_vers($cf, @deps);