force enable DO_CUMULATE
[platform/upstream/build.git] / order
diff --git a/order b/order
index d85a8d8..6682fd6 100755 (executable)
--- 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,17 +52,20 @@ 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;
 
 for my $p (@p) {
   my $q;
-  for my $suf ('rpm', 'deb') {
+  for my $suf ('rpm', 'deb', 'arch') {
     next unless -f "$cachedir/$p.$suf";
-    $q = Build::query("$cachedir/$p.$suf", undef, 1);
+    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'};