forked from openSUSE/obs-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order
executable file
·80 lines (68 loc) · 1.59 KB
/
order
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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";