From b979ae3b9b879ce19582770e2ba89eb3e66f964a Mon Sep 17 00:00:00 2001 From: Zhang Qiang Date: Thu, 3 Apr 2014 15:53:09 +0800 Subject: Imported Upstream version 2013.11.12 --- order | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 order (limited to 'order') 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 = ; + } else { + local *F; + open(F, '<', $manifest) || die("$manifest: $!\n"); + @p = ; + 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"; -- cgit v1.2.3