File: check_backports_packages

package info (click to toggle)
debian-cd 3.2.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,848 kB
  • sloc: sh: 6,129; perl: 4,129; makefile: 413
file content (79 lines) | stat: -rwxr-xr-x 2,292 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl -w

use strict;

# Now check to see if we've been told to use backports versions of any
# of the packages in our list of packages.

my $listin = shift;
my $listout = shift;
my $backports_list = read_env('BACKPORTS', "");
my $codename = read_env('CODENAME', "");
my %backports;

sub read_env {
    my $env_var = shift;
    my $default = shift;

    if (exists($ENV{$env_var})) {
        return $ENV{$env_var};
    }
    # else
    return $default;
}

# If not configured to use backports, bail
if ($backports_list =~ /^$/) {
    exit 0;
}

# Read in the backports list
open (BACKPORTS, "< $backports_list") or die "ERROR: Can't read configured backports list file $backports_list: $!\n";
while (defined($_=<BACKPORTS>)) {
    chomp;
    # Define to 1 here to say it needs to be included
    $backports{$_} = 1;
}
close BACKPORTS;

print "Checking for desired backports in $backports_list\n";

open (LISTIN, "< $listin") or die "ERROR: Can't read the current list file $listin: $!\n";
open (LISTOUT, "> $listout") or die "ERROR: Can't write to $listout: $!\n";

# For any packages in our input list that are listed in the backports
# file, switch to $pkg/backports
while (defined($_=<LISTIN>)) {
    chomp;
    if (exists $backports{$_}) {
	# Horrible to hard-code stuff here, but for now I don't see a
	# better way. Keep the normal kernel on media *as well as* a
	# backports kernel. d-i will install the normal one first,
	# then later upgrade it.
	if (m/^linux-image-/) {
	    print LISTOUT "$_/$codename-backports\n";
	    print LISTOUT "$_\n";
	    print "  Keeping both  $_ and $_/$codename-backports in $listout\n";
	    delete $backports{$_};
	} else {
	    print LISTOUT "$_/$codename-backports\n";
	    print "  Replaced $_ with $_/$codename-backports in $listout\n";
	    delete $backports{$_};
	}
    } else {
	print LISTOUT "$_\n";	
    }
}
close LISTIN;

# Finally, any further packages in our backports list are explicitly
# requested even if they weren't in the original list. Append to the
# output file to force inclusion. This is before sort_deps will get
# run, so dependencies will get resolved later
foreach my $p (keys %backports) {
    print LISTOUT "$p/$codename-backports\n";
    print "  Appended $p/$codename-backports\n";
}
close LISTOUT;

exit 0;