$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;
} 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'}}) {
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;
}
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}--;
}
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;
}
}
sub query {
- my ($handle, $withevra, $withfilelist) = @_;
+ my ($handle, %opts) = @_;
my %res = debq($handle);
return undef unless %res;
requires => \@depends,
};
$data->{'source'} = $src if $src ne '';
- if ($withevra) {
+ if ($opts{'evra'}) {
if ($res{'VERSION'} =~ /^(.*)-(.*?)$/) {
$data->{'version'} = $1;
$data->{'release'} = $2;
}
$data->{'arch'} = $res{'ARCHITECTURE'};
}
+ if ($opts{'description'}) {
+ $data->{'description'} = $res{'DESCRIPTION'};
+ }
return $data;
}
}
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 =~ /\//;
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) {
}
$replace = 1 if grep {/^-/} @ndeps;
- if ($what ne 'BuildRequires') {
+ if (lc($what) ne 'buildrequires') {
push @packdeps, map {"-$_"} @ndeps;
next;
}
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], ''];
}
"VERSION" => 1001,
"RELEASE" => 1002,
"EPOCH" => 1003,
+ "SUMMARY" => 1004,
+ "DESCRIPTION" => 1005,
"ARCH" => 1022,
"OLDFILENAMES" => 1027,
"SOURCERPM" => 1044,
}
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];
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 {
$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];
$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;
}
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
}
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;
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;
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'};
$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);