Debian Codegraph @

tools/generate_debian-edu_task

raw
1 #!/usr/bin/perl -w
2 #
3 # generate_debian-edu_task
4 #
5 # Work out which education packages we need
6 #
7 # Copyright Steve McIntyre <[email protected]> 2018
8 #
9 # GPL 2
10 #
11
12 my ($mirror, $codename, $archlist, $outfile, $localdebs);
13 my $date;
14 my $pkgfiles = "";
15 my ($pkg, $filename, $arch);
16 my %seen;
17
18 $codename = $ENV{'CODENAME'};
19 $mirror = $ENV{'MIRROR'};
20 $localdebs = $ENV{'LOCALDEBS'};
21 $archlist = shift;
22 $outfile = shift;
23
24 if (!defined($codename) || !defined($mirror) ||
25 !defined($archlist) || !defined($outfile)) {
26 die "Error in arguments\n";
27 }
28
29 foreach $arch (split(' ', $archlist)) {
30 $pkgfiles = "$pkgfiles $mirror/dists/$codename/*/binary-$arch/Packages.gz";
31 $pkgfiles = "$pkgfiles $mirror/dists/$codename/*/binary-$arch/Packages.xz";
32 }
33
34 if (defined($localdebs)) {
35 foreach $arch (split(' ', $archlist)) {
36 $pkgfiles = "$pkgfiles $localdebs/dists/$codename/*/binary-$arch/Packages.gz";
37 $pkgfiles = "$pkgfiles $localdebs/dists/$codename/*/binary-$arch/Packages.xz";
38 }
39 }
40
41 open (OUT, "> $outfile") or die "Can't open outfile for writing: $!\n";
42
43 $date = `date -u`;
44 chomp $date;
45
46 print OUT "/*\n";
47 print OUT " * 'debian-edu-full' task file; generated automatically by generate_debian-edu_task\n";
48 print OUT " * for \"$archlist\" on $date\n";
49 print OUT " * Do not edit - changes will not be preserved\n";
50 print OUT " */\n";
51
52 open (INPKG, "\$BASEDIR/tools/catz $pkgfiles |") or die "Can't read input package files: $!\n";
53 $/ = ''; # Browse by paragraph
54
55 # Ignore a few tasks that we don't want, e.g. education-development,
56 # it's too big and pulls in all sorts of things that most end users won't
57 # want/need.
58 my @ignore_list = ('education-development', 'education-video');
59
60 while (defined($_ = <INPKG>)) {
61 m/^Package: (\S+)/m and $pkg = $1;
62 m/^Filename: (\S+)/m and $filename = $1;
63
64 # We want all packages matching "^education-" and "^debian-edu-".
65 # Also wanted: all tasks; these are supposed to pull in localization related
66 # packages. Add otherwise missing gimp-help and thunderbird localization.
67 if (! ($pkg =~ /^education-|^debian-edu-|^task-|^gimp-help-|thunderbird-l10n-all/)) {
68 next;
69 }
70
71 # Except things on the ignore list
72 if (grep {$_ eq $pkg} @ignore_list) {
73 next;
74 }
75
76 print OUT "$pkg\n";
77 }
78
79 close INPKG;
80 close OUT;