summaryrefslogtreecommitdiff
path: root/order
diff options
context:
space:
mode:
authorZhang Qiang <qiang.z.zhang@intel.com>2014-04-03 15:53:09 +0800
committerZhang Qiang <qiang.z.zhang@intel.com>2014-04-03 15:53:09 +0800
commitb979ae3b9b879ce19582770e2ba89eb3e66f964a (patch)
tree758e7684bbaa43d8899ccbc49b133ff0112d3a88 /order
downloadbuild-b979ae3b9b879ce19582770e2ba89eb3e66f964a.tar.gz
build-b979ae3b9b879ce19582770e2ba89eb3e66f964a.tar.bz2
build-b979ae3b9b879ce19582770e2ba89eb3e66f964a.zip
Imported Upstream version 2013.11.12upstream/2013.11.12
Diffstat (limited to 'order')
-rwxr-xr-xorder80
1 files changed, 80 insertions, 0 deletions
diff --git a/order b/order
new file mode 100755
index 0000000..6682fd6
--- /dev/null
+++ b/order
@@ -0,0 +1,80 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
+}
+
+use Build;
+use strict;
+
+my ($dist, $archs, $configdir, $manifest);
+
+
+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;
+my $cachedir = shift @ARGV;
+
+my @p;
+if ($manifest) {
+ if ($manifest eq '-') {
+ @p = <STDIN>;
+ } else {
+ local *F;
+ open(F, '<', $manifest) || die("$manifest: $!\n");
+ @p = <F>;
+ close F;
+ }
+ chomp @p;
+}
+
+push @p, @ARGV;
+
+my $config = Build::read_config_dist($dist, $archs, $configdir);
+
+my %deps;
+my %bins;
+
+for my $p (@p) {
+ my $q;
+ for my $suf ('rpm', 'deb', 'arch') {
+ next unless -f "$cachedir/$p.$suf";
+ if (! -s "$cachedir/$p.$suf") {
+ $q = {'provides' => [], 'requires' => []}; # package from preinstallimage, no need to order
+ last;
+ }
+ $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'};
+ last;
+ }
+ die("binary not found: $p\n") unless $q;
+ $deps{$p} = $q;
+}
+
+Build::readdeps($config, undef, \%deps);
+@p = Build::order($config, @p);
+print "@p\n";