| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
use strict; |
| 4 |
|
| 5 |
# Now check to see if we've been told to use backports versions of any |
| 6 |
# of the packages in our list of packages. |
| 7 |
|
| 8 |
my $listin = shift; |
| 9 |
my $listout = shift; |
| 10 |
my $backports_list = read_env('BACKPORTS', ""); |
| 11 |
my $codename = read_env('CODENAME', ""); |
| 12 |
my %backports; |
| 13 |
|
| 14 |
sub read_env { |
| 15 |
my $env_var = shift; |
| 16 |
my $default = shift; |
| 17 |
|
| 18 |
if (exists($ENV{$env_var})) { |
| 19 |
return $ENV{$env_var}; |
| 20 |
} |
| 21 |
# else |
| 22 |
return $default; |
| 23 |
} |
| 24 |
|
| 25 |
# If not configured to use backports, bail |
| 26 |
if ($backports_list =~ /^$/) { |
| 27 |
exit 0; |
| 28 |
} |
| 29 |
|
| 30 |
# Read in the backports list |
| 31 |
open (BACKPORTS, "< $backports_list") or die "ERROR: Can't read configured backports list file $backports_list: $!\n"; |
| 32 |
while (defined($_=<BACKPORTS>)) { |
| 33 |
chomp; |
| 34 |
# Define to 1 here to say it needs to be included |
| 35 |
$backports{$_} = 1; |
| 36 |
} |
| 37 |
close BACKPORTS; |
| 38 |
|
| 39 |
print "Checking for desired backports in $backports_list\n"; |
| 40 |
|
| 41 |
open (LISTIN, "< $listin") or die "ERROR: Can't read the current list file $listin: $!\n"; |
| 42 |
open (LISTOUT, "> $listout") or die "ERROR: Can't write to $listout: $!\n"; |
| 43 |
|
| 44 |
# For any packages in our input list that are listed in the backports |
| 45 |
# file, switch to $pkg/backports |
| 46 |
while (defined($_=<LISTIN>)) { |
| 47 |
chomp; |
| 48 |
if (exists $backports{$_}) { |
| 49 |
# Horrible to hard-code stuff here, but for now I don't see a |
| 50 |
# better way. Keep the normal kernel on media *as well as* a |
| 51 |
# backports kernel. d-i will install the normal one first, |
| 52 |
# then later upgrade it. |
| 53 |
if (m/^linux-image-/) { |
| 54 |
print LISTOUT "$_/$codename-backports\n"; |
| 55 |
print LISTOUT "$_\n"; |
| 56 |
print " Keeping both $_ and $_/$codename-backports in $listout\n"; |
| 57 |
delete $backports{$_}; |
| 58 |
} else { |
| 59 |
print LISTOUT "$_/$codename-backports\n"; |
| 60 |
print " Replaced $_ with $_/$codename-backports in $listout\n"; |
| 61 |
delete $backports{$_}; |
| 62 |
} |
| 63 |
} else { |
| 64 |
print LISTOUT "$_\n"; |
| 65 |
} |
| 66 |
} |
| 67 |
close LISTIN; |
| 68 |
|
| 69 |
# Finally, any further packages in our backports list are explicitly |
| 70 |
# requested even if they weren't in the original list. Append to the |
| 71 |
# output file to force inclusion. This is before sort_deps will get |
| 72 |
# run, so dependencies will get resolved later |
| 73 |
foreach my $p (keys %backports) { |
| 74 |
print LISTOUT "$p/$codename-backports\n"; |
| 75 |
print " Appended $p/$codename-backports\n"; |
| 76 |
} |
| 77 |
close LISTOUT; |
| 78 |
|
| 79 |
exit 0; |