#!/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";