2
2
# Outputs a list of udebs to install. Pass it the type of image to build as
3
# the first parameter, then the kernel flavour, then the major kernel type
4
# (2.4, 2.6, etc), then the sub architecture (or an empty string if there
5
# are none) and then the kernel version(s) as the rest of the parameters.
6
# Reads the lists in pkg-lists.
3
# the first parameter. The second parameter can point to a different image
4
# type which the image is a driver disk for. Next the kernel flavour, then
5
# the major kernel type (2.4, 2.6, etc), then the sub architecture (or an
6
# empty string if there are none) and then the kernel version(s) as the rest
7
# of the parameters. Reads the lists in pkg-lists.
11
12
if (int(@ARGV) < 5) {
12
die "Usage: $0 type KERNEL_FLAVOUR KERNELMAJOR SUB_ARCH KERNEL_VERSION [KERNEL_VERSION ...]\n";
13
die "Usage: $0 type DRIVER_FOR KERNEL_FLAVOUR KERNELMAJOR SUB_ARCH KERNEL_VERSION [KERNEL_VERSION ...]\n";
15
17
my $kernel_flavour=shift;
16
18
my $kernel_major=shift;
17
19
my $sub_arch=shift;
20
22
my $deb_host_arch=`dpkg-architecture -qDEB_HOST_ARCH`;
21
23
chomp $deb_host_arch;
23
my @lists = ("pkg-lists/local");
25
foreach my $subtype (split "/", $type) {
32
push @lists, ("pkg-lists/$t/local", "pkg-lists/$t/common",
33
"pkg-lists/$t/$deb_host_arch.cfg");
34
push @lists, "pkg-lists/$t/$deb_host_arch/$sub_arch.cfg" if $sub_arch;
40
print STDERR "warning: missing list, $list, for type $type\n"
41
if $list !~ /local$/ && $list !~
42
m#$deb_host_arch/$sub_arch.cfg$#;
45
open (LIST, $list) || die "open $list $!";
50
if (/^#include \"(.*)\"/) {
52
if (-e "pkg-lists/kernel_specific/$kernel_major/$include") {
53
push @lists, "pkg-lists/kernel_specific/$kernel_major/$include";
56
push @lists, "pkg-lists/$include";
64
# normal kernel version substitution
65
if (/\${kernel:Version}/) {
66
foreach my $v (@kernel_versions) {
68
$l=~s/\${kernel:Version}/$v-$kernel_flavour/g;
71
next; # move on to the next line
74
# if nothing else matches print the line untouched
25
my ($collect, $exclude)=getlists($type);
26
my ($parentcollect, $parentexclude)=getlists($driver_for) if length $driver_for;
27
foreach my $p (sort keys %$collect) {
28
print "$p\n" unless $exclude->{$p} || $parentcollect->{$p};
30
# Warn about missing deps. This is not perfect, in since pkgdeps
31
# ignores dependencies on virtual packages and does not support
32
# alternates (which are not really allowed for udebs anyway).
33
# Still, it will catch most common mistakes.
34
foreach my $dep (pkgdeps($p)) {
35
if (! $collect->{$dep} && ! $exclude->{$dep} && ! $parentcollect->{$dep}) {
36
warning("in $type, $p has unsatisfied dependency on $dep");
41
# Add a package, possibly expanding dependencies.
46
if ($line=~/^(.*) \*$/) {
47
# Asterisk at end means include all dependencies of this
50
collectdeps($1, $collect);
52
elsif ($line=~/^(.*) \-$/) {
53
# Minus sign at the end means exclude this package from the
62
# Recursively add dependencies of package.
67
%seendeps=%{shift()} if @_;
68
return if $seendeps{$package};
69
$seendeps{$package}=1;
70
foreach my $dep (pkgdeps($package)) {
72
collectdeps($dep, $collect, \%seendeps);
76
# Get the dependencies of a package;
81
if (-f 'sources.list.udeb.local') {
82
$sourceslist='sources.list.udeb.local';
84
$sourceslist='sources.list.udeb';
86
my @deps=`LANG=C apt-cache \\
87
-o Dir::Etc::sourcelist=./$sourceslist \\
88
-o Dir::State=./apt.udeb/state \\
89
-o Dir::State::Status=./apt.udeb/state/status \\
90
-o Dir::Cache=./apt.udeb/cache depends $package`;
91
shift @deps; # package name;
92
foreach my $dep (@deps) {
94
# Note that this intentionally skips alternate
95
# dependencies, taking only the first.
96
if ($dep=~/^\s*Depends:\s/) {
97
$dep=~s/^\s*Depends:\s*//;
98
next if $dep=~/\<.*\>/; # skip virtual packages
105
# Return two hash references, one of udebs to include, one to exclude.
112
my @lists = ("pkg-lists/local", "pkg-lists/exclude");
114
foreach my $subtype (split "/", $type) {
121
push @lists, ("pkg-lists/$t/local", "pkg-lists/$t/common",
122
"pkg-lists/$t/$deb_host_arch.cfg");
123
push @lists, "pkg-lists/$t/$deb_host_arch/$sub_arch.cfg" if $sub_arch;
129
warning("missing list, $list, for type $type")
130
if $list !~ /local$/ && $list !~ m#$deb_host_arch/$sub_arch.cfg$#;
133
open (LIST, $list) || die "open $list $!";
138
if (/^#include \"(.*)\"/) {
140
if (-e "pkg-lists/kernel_specific/$kernel_major/$deb_host_arch/$sub_arch/$include") {
141
push @lists, "pkg-lists/kernel_specific/$kernel_major/$deb_host_arch/$sub_arch/$include";
143
if (-e "pkg-lists/kernel_specific/$kernel_major/$deb_host_arch/$include") {
144
push @lists, "pkg-lists/kernel_specific/$kernel_major/$deb_host_arch/$include";
146
if (-e "pkg-lists/kernel_specific/$kernel_major/$include") {
147
push @lists, "pkg-lists/kernel_specific/$kernel_major/$include";
150
push @lists, "pkg-lists/$include";
158
# normal kernel version substitution
159
if (/\${kernel:Version}/) {
160
foreach my $v (@kernel_versions) {
162
$l=~s/\${kernel:Version}/$v-$kernel_flavour/g;
163
collectpackage($l, \%collect, \%exclude);
165
next; # move on to the next line
167
collectpackage($_, \%collect, \%exclude);
173
return \%collect, \%exclude;
177
print STDERR "** warning: @_\n";