3 # This script allows checking what patches are needed for a given
5 # Use it as ./patches_for_kernel.pl <version>
6 # The backport files are specified at: ../backports/backports.txt
10 my $version = shift or die "Need a version to apply patches";
12 my $file = "../backports/backports.txt";
13 open IN
, $file or die "can't find $file\n";
15 sub kernel_version
($) {
16 my ($version, $patchlevel, $sublevel) = $_[0] =~ m/^(\d+)\.(\d+)\.?(\d*)/;
18 # fix kernel version for distros that 'translated' 3.0 to 2.6.40
19 if ($version == 2 && $patchlevel == 6 && $sublevel >= 40) {
21 $patchlevel = $sublevel - 40;
24 $sublevel = 0 if ($sublevel == "");
25 return ($version * 65536 + $patchlevel * 256 + $sublevel);
28 my $kernel = kernel_version
($version);
30 die "Invalid kernel version" if (!$kernel);
40 $cur = kernel_version
($1);
44 next if ($cur < $kernel);
48 if (m/delete\s+(.*)/) {
49 next if ($cur < $kernel);
50 for (my $i = 0; $i < @patches; $i++) {
51 delete $patches[$i] if ($patches[$i] eq $1);
55 die "Can't process line $ln\n";
58 die ("Unsupported Kernel version $version") if ($cur > $kernel);
60 foreach my $patch (@patches) {