~tsimonq2/debian-cd/lubuntu-cosmic-changes

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
81
82
83
84
85
#!/usr/bin/perl -w
# Generate a list of packages required for debian-installer
# This script makes use of the following variables that need to be preset:
# MIRROR, DI_CODENAME, BASEDIR
die "Missing \$MIRROR variable" unless $ENV{MIRROR};
die "Missing \$DI_CODENAME variable" unless $ENV{DI_CODENAME};

my @ARCHES;
if ($ENV{ARCHES}) {
	@ARCHES = split ' ', $ENV{ARCHES};
} else {
	@ARCHES=qw{amd64 i386 ia64 powerpc};
}
my $DATE=`date`;
chomp $DATE;
open(OUT, ">debian-installer-$ENV{DI_CODENAME}") || die "write: $!";
print OUT << "EOF";
/* List of udebs to be included so that debian-installer works fine 
 *
 * This list can be generated with the command:
 * ../tools/generate_di_list
 *
 * DO NOT EDIT THIS FILE, edit the above script
 *
 * Last update: $DATE
 */
EOF

my @common_excludes = read_exclude("exclude-udebs");

foreach my $arch (@ARCHES) {
	my $packagefile="$ENV{MIRROR}/dists/$ENV{DI_CODENAME}/main/debian-installer/binary-$arch/Packages.gz";
	unless (-f $packagefile) {
		print "Missing package file for arch $arch.\n";
		next;
	}
	(my $cpparch = $arch) =~ s/-/_/g;
	print OUT "#ifdef ARCH_$cpparch\n";
	my @exclude = @common_excludes;
	push @exclude, read_exclude("exclude-udebs-$arch")
		if -e exclude_path("exclude-udebs-$arch");
	@udebs = map { chomp; $_ } `zcat \Q$packagefile\E | grep-dctrl -n -s Package ''`;
	if ($ENV{RESTRICTED}) {
		$restrictedpackagefile = "$ENV{MIRROR}/dists/$ENV{DI_CODENAME}/restricted/debian-installer/binary-$arch/Packages.gz";
		if (-f $packagefile) {
			push @udebs, map { chomp; $_ } `zcat \Q$restrictedpackagefile\E | grep-dctrl -n -s Package ''`;
		}
	}
	if (defined $ENV{LOCALDEBS}) {
		$localpackagefile = "$ENV{LOCALDEBS}/dists/$ENV{DI_CODENAME}/local/debian-installer/binary-$arch/Packages.gz";
		if (-f $packagefile) {
			push @udebs, map { chomp; $_ } `zcat \Q$localpackagefile\E | grep-dctrl -n -s Package ''`;
		}
	}
UDEB:	foreach my $udeb (@udebs) {
		foreach my $pattern (@exclude) {
			if ($udeb =~ /^$pattern$/) {
				next UDEB;
			}
		}
		print OUT "$udeb\n";
	}
	print OUT "#endif /* ARCH_$cpparch */\n";
}

sub read_exclude {
	my $file=exclude_path(shift);
	open (IN, "<$file") || warn "failed to read exclude file $file";
	my @ret;
	while (<IN>) {
		chomp;
		s/^#.*//;
		next unless length;
		$_=quotemeta($_);
		$_=~s/\\\*/.*/g;
		push @ret, $_;
	}
	close IN;
	return @ret;
}

sub exclude_path {
	my $file=shift;
	return "$ENV{BASEDIR}/data/$ENV{DI_CODENAME}/$file";
}