aboutsummaryrefslogtreecommitdiffstats
path: root/debian
diff options
context:
space:
mode:
authorLeann Ogasawara <leann.ogasawara@canonical.com>2010-03-12 20:13:25 -0500
committerLeann Ogasawara <leann.ogasawara@canonical.com>2011-08-30 13:14:15 -0400
commit5908b13c314952d55aa23a74355d5a1891a62474 (patch)
treeb6bd470e1bafa36c0824db145d6374c8a4a238df /debian
parent04aa37b5f943920017ad094e776cd5514b1a9246 (diff)
UBUNTU: (no-up) fold down debian for ubuntu-oneiric 3.0-rc1 rebase
Ignore: yes Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
Diffstat (limited to 'debian')
-rw-r--r--debian/commit-templates/bumpabi3
-rw-r--r--debian/commit-templates/config-updates15
-rw-r--r--debian/commit-templates/external-driver20
-rw-r--r--debian/commit-templates/missing-modules3
-rw-r--r--debian/commit-templates/newrelease3
-rw-r--r--debian/commit-templates/sauce-patch40
-rw-r--r--debian/commit-templates/upstream-patch27
-rw-r--r--debian/compat1
-rw-r--r--debian/control-scripts/headers-postinst126
-rw-r--r--debian/control-scripts/postinst1095
-rw-r--r--debian/control-scripts/postrm361
-rw-r--r--debian/control-scripts/preinst306
-rw-r--r--debian/control-scripts/prerm312
-rw-r--r--debian/debian.env1
-rw-r--r--debian/docs/README.inclusion-list51
-rwxr-xr-xdebian/rules235
-rw-r--r--debian/rules.d/0-common-vars.mk225
-rw-r--r--debian/rules.d/1-maintainer.mk122
-rw-r--r--debian/rules.d/2-binary-arch.mk407
-rw-r--r--debian/rules.d/3-binary-indep.mk132
-rw-r--r--debian/rules.d/4-checks.mk34
-rw-r--r--debian/rules.d/5-udebs.mk38
-rwxr-xr-xdebian/scripts/abi-check210
-rwxr-xr-xdebian/scripts/config-check389
-rwxr-xr-xdebian/scripts/control-create25
-rwxr-xr-xdebian/scripts/link-headers42
-rwxr-xr-xdebian/scripts/misc/getabis76
-rwxr-xr-xdebian/scripts/misc/git-ubuntu-log232
-rwxr-xr-xdebian/scripts/misc/insert-changes.pl36
-rwxr-xr-xdebian/scripts/misc/insert-ubuntu-changes58
-rwxr-xr-xdebian/scripts/misc/kernelconfig172
-rwxr-xr-xdebian/scripts/misc/retag34
-rwxr-xr-xdebian/scripts/misc/splitconfig.pl111
-rwxr-xr-xdebian/scripts/module-check120
-rwxr-xr-xdebian/scripts/module-inclusion51
-rw-r--r--debian/scripts/sub-flavour69
-rw-r--r--debian/source/format1
-rw-r--r--debian/stamps/keep-dir1
-rw-r--r--debian/tests/README21
-rwxr-xr-xdebian/tests/check-aliases24
-rw-r--r--debian/tools/perf16
41 files changed, 5245 insertions, 0 deletions
diff --git a/debian/commit-templates/bumpabi b/debian/commit-templates/bumpabi
new file mode 100644
index 00000000000..6c373c9726b
--- /dev/null
+++ b/debian/commit-templates/bumpabi
@@ -0,0 +1,3 @@
1UBUNTU: Bump ABI
2
3Ignore: yes
diff --git a/debian/commit-templates/config-updates b/debian/commit-templates/config-updates
new file mode 100644
index 00000000000..4b62c299965
--- /dev/null
+++ b/debian/commit-templates/config-updates
@@ -0,0 +1,15 @@
1#
2# This template is used for commit messages that don't need to
3# show up in debian/changelog. Administrative stuff like config
4# updates, ABI bumps, etc. Setting 'Ignore: yes' prevents
5# 'debian/rules insertchanges' from inserting this commit meesage
6# as a changelog entry.
7#
8# Please give a one-line description of the config change followed
9# by a detailed explanation if necessary
10
11UBUNTU: [Config] XXXX
12
13# BugLink: http://bugs.launchpad.net/bugs/<enter bug# here>
14# Ignore: yes
15# Other text below here.
diff --git a/debian/commit-templates/external-driver b/debian/commit-templates/external-driver
new file mode 100644
index 00000000000..decdc897bdd
--- /dev/null
+++ b/debian/commit-templates/external-driver
@@ -0,0 +1,20 @@
1# Ubuntu external driver commit.
2#
3# NOTE: This gets reformatted for README.Ubuntu-External-Drivers and
4# debian/changelog.
5#
6# This is only needed when a driver is added, updated or removed. It is
7# not needed when patches or fixes are applied to the driver. If the
8# driver is being removed, add the line:
9#
10# Removing: yes
11#
12# to the commit, and you can remove all other tags (except UBUNTU:).
13#
14UBUNTU:
15
16ExternalDriver:
17Description:
18Url:
19Mask:
20Version:
diff --git a/debian/commit-templates/missing-modules b/debian/commit-templates/missing-modules
new file mode 100644
index 00000000000..f4872e7568c
--- /dev/null
+++ b/debian/commit-templates/missing-modules
@@ -0,0 +1,3 @@
1UBUNTU: build/modules: Add modules that have intentionally gone missing
2
3Ignore: yes
diff --git a/debian/commit-templates/newrelease b/debian/commit-templates/newrelease
new file mode 100644
index 00000000000..5f8931c40cd
--- /dev/null
+++ b/debian/commit-templates/newrelease
@@ -0,0 +1,3 @@
1UBUNTU: Start new release
2
3Ignore: yes
diff --git a/debian/commit-templates/sauce-patch b/debian/commit-templates/sauce-patch
new file mode 100644
index 00000000000..08720a8c20f
--- /dev/null
+++ b/debian/commit-templates/sauce-patch
@@ -0,0 +1,40 @@
1# Ubuntu commit template.
2#
3# NOTE: This gets reformatted for debian/changelog
4#
5#
6# SAUCE refers to the fact that this patch might not go upstream, but we need to
7# carry it to successive releases. In most cases you DONOT want to use this
8# template.
9#
10# An example of a SAUCE patch is the ACPI DSDT-in-initramfs patch which has been
11# refused upstream, but still provides useful functionality to users with broken
12# BIOSes.
13#
14#-------------------------------------------------------------------------
15#
16# The initial UBUNTU is a flag that this is an Ubuntu commit. It will be
17# referenced to the Author in the debian/changelog entry.
18#
19# The text following is the short message that will be placed in the
20# changelog. Extra text on the following lines will be ignored, but left
21# in the git commit. Lines with # will be ignored in the commit.
22#
23# OriginalAuthor allows for alternate attribution.
24#
25# OriginalLocation allows for a URL or description of where the patch came
26# from.
27#
28# BugLink is a URL to a Malone bug.
29#
30# Ignore: yes will keep this commit from showing up in the changelog.
31#
32UBUNTU: SAUCE:
33
34<Why is this patch not going upstream?>
35
36# OriginalAuthor:
37# OriginalLocation:
38# BugLink: http://bugs.launchpad.net/bugs/<enter bug# here>
39# Ignore: yes
40# Other text below here.
diff --git a/debian/commit-templates/upstream-patch b/debian/commit-templates/upstream-patch
new file mode 100644
index 00000000000..671ab6a0921
--- /dev/null
+++ b/debian/commit-templates/upstream-patch
@@ -0,0 +1,27 @@
1# Ubuntu commit template.
2#
3# NOTE: This gets reformatted for debian/changelog
4#
5# The initial UBUNTU is a flag that this is an Ubuntu commit. It will be
6# referenced to the Author in the debian/changelog entry.
7#
8# The text following is the short message that will be placed in the
9# changelog. Extra text on the following lines will be ignored, but left
10# in the git commit. Lines with # will be ignored in the commit.
11#
12# OriginalAuthor allows for alternate attribution.
13#
14# OriginalLocation allows for a URL or description of where the patch came
15# from.
16#
17# BugLink is a URL to a Malone bug.
18#
19# Ignore: yes will keep this commit from showing up in the changelog.
20#
21UBUNTU: [Upstream]
22
23# OriginalAuthor:
24# OriginalLocation:
25# BugLink: http://bugs.launchpad.net/bugs/<enter bug# here>
26# Ignore: yes
27# Other text below here.
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 00000000000..7ed6ff82de6
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
5
diff --git a/debian/control-scripts/headers-postinst b/debian/control-scripts/headers-postinst
new file mode 100644
index 00000000000..2fb2be858a4
--- /dev/null
+++ b/debian/control-scripts/headers-postinst
@@ -0,0 +1,126 @@
1#!/usr/bin/perl
2# -*- Mode: Cperl -*-
3# debian.postinst ---
4# Author : Manoj Srivastava ( srivasta@pilgrim.umass.edu )
5# Created On : Sat Apr 27 05:42:43 1996
6# Created On Node : melkor.pilgrim.umass.edu
7# Last Modified By : Manoj Srivastava
8# Last Modified On : Sat Aug 5 13:20:22 2006
9# Last Machine Used: glaurung.internal.golden-gryphon.com
10# Update Count : 45
11# Status : Unknown, Use with caution!
12# HISTORY :
13# Description :
14#
15#
16#
17# arch-tag: 1c716174-2f0a-476d-a626-a1322e62503a
18#
19
20
21$|=1;
22
23# Predefined values:
24my $version = "=V";
25my $kimage = "=K";
26my $package_name = "linux-image-$version";
27
28
29# Ignore all invocations uxcept when called on to configure.
30exit 0 unless ($ARGV[0] && $ARGV[0] =~ /configure/);
31
32#known variables
33my $image_dest = "/";
34my $realimageloc = "/boot/";
35my $silent_modules = '';
36my $modules_base = '/lib/modules';
37my $CONF_LOC = '/etc/kernel-img.conf';
38# remove multiple leading slashes; make sure there is at least one.
39$realimageloc =~ s|^/*|/|o;
40$realimageloc =~ s|/+|/|o;
41
42chdir '/usr/src' or die "Could not chdir to /usr/src:$!";
43
44if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
45 if (open(CONF, "$CONF_LOC")) {
46 while (<CONF>) {
47 chomp;
48 s/\#.*$//g;
49 next if /^\s*$/;
50
51 $header_postinst_hook = "$1" if /^\s*header_postinst_hook\s*=\s*(\S+)/ig;
52 }
53 close CONF;
54 }
55}
56
57sub exec_script {
58 my $type = shift;
59 my $script = shift;
60 print STDERR "Running $type hook script $script.\n";
61 system ("$script $version $realimageloc$kimage-$version") &&
62 print STDERR "User $type hook script [$script] ";
63 if ($?) {
64 if ($? == -1) {
65 print STDERR "failed to execute: $!\n";
66 }
67 elsif ($? & 127) {
68 printf STDERR "died with signal %d, %s coredump\n",
69 ($? & 127), ($? & 128) ? 'with' : 'without';
70 }
71 else {
72 printf STDERR "exited with value %d\n", $? >> 8;
73 }
74 exit $? >> 8;
75 }
76}
77sub run_hook {
78 my $type = shift;
79 my $script = shift;
80 if ($script =~ m,^/,) {
81 # Full path provided for the hook script
82 if (-x "$script") {
83 &exec_script($type,$script);
84 }
85 else {
86 die "The provided $type hook script [$script] could not be run.\n";
87 }
88 }
89 else {
90 # Look for it in a safe path
91 for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
92 if (-x "$path/$script") {
93 &exec_script($type, "$path/$script");
94 return 0;
95 }
96 }
97 # No luck
98 print STDERR "Could not find $type hook script [$script].\n";
99 die "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
100 }
101}
102
103## Run user hook script here, if any
104if (-x "$header_postinst_hook") {
105 &run_hook("postinst", $header_postinst_hook);
106}
107
108if (-d "/etc/kernel/header_postinst.d") {
109 print STDERR "Examining /etc/kernel/header_postinst.d.\n";
110 system ("run-parts --verbose --exit-on-error --arg=$version " .
111 "--arg=$realimageloc$kimage-$version " .
112 "/etc/kernel/header_postinst.d") &&
113 die "Failed to process /etc/kernel/header_postinst.d";
114}
115
116if (-d "/etc/kernel/header_postinst.d/$version") {
117 print STDERR "Examining /etc/kernel/header_postinst.d/$version.\n";
118 system ("run-parts --verbose --exit-on-error --arg=$version " .
119 "--arg=$realimageloc$kimage-$version " .
120 "/etc/kernel/header_postinst.d/$version") &&
121 die "Failed to process /etc/kernel/header_postinst.d/$version";
122}
123
124exit 0;
125
126__END__
diff --git a/debian/control-scripts/postinst b/debian/control-scripts/postinst
new file mode 100644
index 00000000000..ce5ae569a09
--- /dev/null
+++ b/debian/control-scripts/postinst
@@ -0,0 +1,1095 @@
1#! /usr/bin/perl
2# OriginalAuthor : Manoj Srivastava ( srivasta@pilgrim.umass.edu )
3#
4# Customized for Ubuntu by: Ben Collins <bcollins@ubuntu.com>
5
6#use strict; #for debugging
7use Cwd 'abs_path';
8
9$|=1;
10
11# Predefined values:
12my $version = "=V";
13my $link_in_boot = ""; # Should be empty, mostly
14my $no_symlink = ""; # Should be empty, mostly
15my $reverse_symlink = ""; # Should be empty, mostly
16my $do_symlink = "Yes"; # target machine defined
17my $do_boot_enable = "Yes"; # target machine defined
18my $do_bootfloppy = "Yes"; # target machine defined
19my $do_bootloader = "Yes"; # target machine defined
20my $move_image = ''; # target machine defined
21my $kimage = "=K"; # Should be empty, mostly
22my $loader = "=L"; # lilo, silo, quik, palo, vmelilo, nettrom, arcboot or delo
23my $image_dir = "/boot"; # where the image is located
24my $clobber_modules = ''; # target machine defined
25my $relative_links = ""; # target machine defined
26my $initrd = "YES"; # initrd kernel
27my $do_initrd = ''; # Normally we do not
28my $use_hard_links = ''; # hardlinks do not work across fs boundaries
29my $postinst_hook = ''; #Normally we do not
30my $postrm_hook = ''; #Normally we do not
31my $preinst_hook = ''; #Normally we do not
32my $prerm_hook = ''; #Normally we do not
33my $minimal_swap = ''; # Do not swap symlinks
34my $ignore_depmod_err = ''; # normally we do not
35my $kernel_arch = "=B";
36my $ramdisk = "/usr/sbin/update-initramfs"; # List of tools to create initial ram fs.
37my $notifier = "/usr/share/update-notifier/notify-reboot-required";
38my $package_name = "linux-image-$version";
39my $explicit_do_loader = 'Yes';
40
41my $Loader = "NoLOADER"; #
42$Loader = "LILO" if $loader =~ /^lilo/io;
43$Loader = "SILO" if $loader =~ /^silo/io;
44$Loader = "QUIK" if $loader =~ /^quik/io;
45$Loader = "yaboot" if $loader =~ /^yaboot/io;
46$Loader = "PALO" if $loader =~ /^palo/io;
47$Loader = "NETTROM" if $loader =~ /^nettrom/io;
48$Loader = "VMELILO" if $loader =~ /^vmelilo/io;
49$Loader = "ZIPL" if $loader =~ /^zipl/io;
50$Loader = "ELILO" if $loader =~ /^elilo/io;
51$Loader = "ARCBOOT" if $loader =~ /^arcboot/io;
52$Loader = "DELO" if $loader =~ /^delo/io;
53
54# This should not point to /tmp, because of security risks.
55my $temp_file_name = "/var/log/$loader" . "_log.$$";
56
57#known variables
58my $image_dest = "/";
59my $realimageloc = "/$image_dir/";
60my $have_conffile = "";
61my $silent_modules = '';
62my $silent_loader = '';
63my $warn_reboot = 'Yes'; # Warn that we are installing a version of
64 # the kernel we are running
65
66my $modules_base = '/lib/modules';
67my $CONF_LOC = '/etc/kernel-img.conf';
68
69# Ignore all invocations except when called on to configure.
70exit 0 unless $ARGV[0] =~ /configure/;
71
72my $DEBUG = 0;
73
74# Do some preliminary sanity checks here to ensure we actually have an
75# valid image dir
76chdir('/') or die "could not chdir to /:$!\n";
77die "Internal Error: ($image_dir) is not a directory!\n"
78 unless -d $image_dir;
79
80# remove multiple leading slashes; make sure there is at least one.
81$realimageloc =~ s|^/*|/|o;
82$realimageloc =~ s|/+|/|o;
83die "Internal Error: ($realimageloc) is not a directory!\n"
84 unless -d $realimageloc;
85
86if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
87 if (open(CONF, "$CONF_LOC")) {
88 while (<CONF>) {
89 chomp;
90 s/\#.*$//g;
91 next if /^\s*$/;
92
93 $do_symlink = "" if /^\s*do_symlinks\s*=\s*(no|false|0)\s*$/ig;
94 $no_symlink = "" if /^\s*no_symlinks\s*=\s*(no|false|0)\s*$/ig;
95 $reverse_symlink = "" if /^\s*reverse_symlink\s*=\s*(no|false|0)\s*$/ig;
96 $link_in_boot = "" if /^\s*image_in_boot\s*=\s*(no|false|0)\s*$/ig;
97 $link_in_boot = "" if /^\s*link_in_boot\s*=\s*(no|false|0)\s*$/ig;
98 $move_image = "" if /^\s*move_image\s*=\s*(no|false|0)\s*$/ig;
99 $clobber_modules = '' if /^\s*clobber_modules\s*=\s*(no|false|0)\s*$/ig;
100 $do_boot_enable = '' if /^\s*do_boot_enable\s*=\s*(no|false|0)\s*$/ig;
101 $do_bootfloppy = '' if /^\s*do_bootfloppy\s*=\s*(no|false|0)\s*$/ig;
102 $relative_links = '' if /^\s*relative_links \s*=\s*(no|false|0)\s*$/ig;
103 $do_bootloader = '' if /^\s*do_bootloader\s*=\s*(no|false|0)\s*$/ig;
104 $explicit_do_loader = '' if /^\s*do_bootloader\s*=\s*(no|false|0)\s*$/ig;
105 $do_initrd = '' if /^\s*do_initrd\s*=\s*(no|false|0)\s*$/ig;
106 $use_hard_links = '' if /^\s*use_hard_links\s*=\s*(no|false|0)\s*$/ig;
107 $silent_modules = '' if /^\s*silent_modules\s*=\s*(no|false|0)\s*$/ig;
108 $silent_loader = '' if /^\s*silent_loader\s*=\s*(no|false|0)\s*$/ig;
109 $warn_reboot = '' if /^\s*warn_reboot\s*=\s*(no|false|0)\s*$/ig;
110 $minimal_swap = '' if /^\s*minimal_swap\s*=\s*(no|false|0)\s*$/ig;
111 $ignore_depmod_err = '' if /^\s*ignore_depmod_err\s*=\s*(no|false|0)\s*$/ig;
112
113 $do_symlink = "Yes" if /^\s*do_symlinks\s*=\s*(yes|true|1)\s*$/ig;
114 $no_symlink = "Yes" if /^\s*no_symlinks\s*=\s*(yes|true|1)\s*$/ig;
115 $reverse_symlink = "Yes" if /^\s*reverse_symlinks\s*=\s*(yes|true|1)\s*$/ig;
116 $link_in_boot = "Yes" if /^\s*image_in_boot\s*=\s*(yes|true|1)\s*$/ig;
117 $link_in_boot = "Yes" if /^\s*link_in_boot\s*=\s*(yes|true|1)\s*$/ig;
118 $move_image = "Yes" if /^\s*move_image\s*=\s*(yes|true|1)\s*$/ig;
119 $clobber_modules = "Yes" if /^\s*clobber_modules\s*=\s*(yes|true|1)\s*$/ig;
120 $do_boot_enable = "Yes" if /^\s*do_boot_enable\s*=\s*(yes|true|1)\s*$/ig;
121 $do_bootfloppy = "Yes" if /^\s*do_bootfloppy\s*=\s*(yes|true|1)\s*$/ig;
122 $do_bootloader = "Yes" if /^\s*do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
123 $explicit_do_loader = "YES" if /^\s*do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
124 $relative_links = "Yes" if /^\s*relative_links\s*=\s*(yes|true|1)\s*$/ig;
125 $do_initrd = "Yes" if /^\s*do_initrd\s*=\s*(yes|true|1)\s*$/ig;
126 $use_hard_links = "Yes" if /^\s*use_hard_links\s*=\s*(yes|true|1)\s*$/ig;
127 $silent_modules = 'Yes' if /^\s*silent_modules\s*=\s*(yes|true|1)\s*$/ig;
128 $silent_loader = 'Yes' if /^\s*silent_loader\s*=\s*(yes|true|1)\s*$/ig;
129 $warn_reboot = 'Yes' if /^\s*warn_reboot\s*=\s*(yes|true|1)\s*$/ig;
130 $minimal_swap = 'Yes' if /^\s*minimal_swap\s*=\s*(yes|true|1)\s*$/ig;
131 $ignore_depmod_err = 'Yes' if /^\s*ignore_depmod_err\s*=\s*(yes|true|1)\s*$/ig;
132
133 $image_dest = "$1" if /^\s*image_dest\s*=\s*(\S+)/ig;
134 $postinst_hook = "$1" if /^\s*postinst_hook\s*=\s*(\S+)/ig;
135 $postrm_hook = "$1" if /^\s*postrm_hook\s*=\s*(\S+)/ig;
136 $preinst_hook = "$1" if /^\s*preinst_hook\s*=\s*(\S+)/ig;
137 $prerm_hook = "$1" if /^\s*prerm_hook\s*=\s*(\S+)/ig;
138 $ramdisk = "$1" if /^\s*ramdisk\s*=\s*(.+)$/ig;
139 }
140 close CONF;
141 $have_conffile = "Yes";
142 }
143}
144
145
146
147# For some versions of kernel-package, we had this warning in the
148# postinst, but the rules did not really interpolate the value in.
149# Here is a sanity check.
150my $pattern = "=" . "I";
151$initrd=~ s/^$pattern$//;
152
153if ($link_in_boot) {
154 $image_dest = "/$image_dir/"; # same as realimageloc
155}
156
157# Tack on at least one trainling /
158$image_dest = "$image_dest/";
159$image_dest =~ s|^/*|/|o;
160$image_dest =~ s|/+$|/|o;
161
162if (! -d "$image_dest") {
163 die "Expected Image Destination dir ($image_dest) to be a valid directory!\n";
164}
165
166# sanity
167if (!($do_bootfloppy || $do_bootloader)) {
168 $do_boot_enable = '';
169}
170if ($do_symlink && $no_symlink) {
171 warn "Both do_symlinks and no_symlinks options enabled; disabling no_symlinks\n";
172 $no_symlink = 0;
173}
174
175# most of our work is done in $image_dest (nominally /)
176chdir("$image_dest") or die "could not chdir to $image_dest:$!\n";
177
178# Paranoid check to make sure that the correct value is put in there
179if (! $kimage) { $kimage = "vmlinuz"; } # Hmm. empty
180elsif ($kimage =~ m/^b?uImage$/o) { $kimage = "vmlinuz"; } # these produce vmlinuz
181elsif ($kimage =~ m/^b?zImage$/o) { $kimage = "vmlinuz"; } # these produce vmlinuz
182elsif ($kimage =~ m/^[iI]mage$/o) { my $nop = $kimage; }
183elsif ($kimage =~ m/^vmlinux$/o) { my $nop = $kimage; }
184else { $kimage = "vmlinuz"; } # Default
185
186$ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
187
188
189die "Internal Error: Could not find image (" . $realimageloc
190 . "$kimage-$version)\n" unless -e $realimageloc
191 . "$kimage-$version";
192
193# search for the boot loader in the path
194my $loader_exec;
195($loader_exec = $loader) =~ s|.*/||;
196my ($loaderloc) = grep -x, map "$_/$loader_exec",
197 map { length($_) ? $_ : "." } split /:/, $ENV{PATH};
198
199
200######################################################################
201######################################################################
202########### Test whether a relative symlinkwould be OK #######
203######################################################################
204######################################################################
205sub test_relative {
206 my %params = @_;
207 my $cwd;
208
209 die "Internal Error: Missing Required paramater 'Old Dir' "
210 unless $params{'Old Dir'};
211 die "Internal Error: Missing Required paramater New Dir' "
212 unless $params{'New Dir'};
213
214
215 die "Internal Error: No such dir $params{'Old Dir'} "
216 unless -d $params{'Old Dir'};
217 die "Internal Error: No such dir $params{'New Dir'} "
218 unless -d $params{'New Dir'};
219
220 warn "Test relative: testing $params{'Old Dir'} -> $params{'New Dir'}"
221 if $DEBUG;
222 chomp($cwd = `pwd`);
223 chdir ($params{'New Dir'}) or die "Could not chdir to $params{'New Dir'}:$!";
224 my $ok = 0;
225 $params{'Old Dir'} =~ s|^/*||o;
226 if (-d $params{'Old Dir'} ) {
227 if (defined $params{'Test File'}) {
228 if (-e $params{'Old Dir'} . $params{'Test File'}) {
229 $ok = 1;
230 }
231 } else {
232 $ok = 1; # well, backward compatibility
233 }
234 }
235 chdir ($cwd) or die "Could not chdir to $params{'New Dir'}:$!";
236 return $ok;
237}
238
239######################################################################
240######################################################################
241############
242######################################################################
243######################################################################
244# sub CanonicalizePath {
245# my $path = join '/', @_;
246# my @work = split '/', $path;
247# my @out;
248# my $is_absolute;
249
250# if (@work && $work[0] eq "") {
251# $is_absolute = 1; shift @work;
252# }
253
254# while (@work) {
255# my $seg = shift @work;
256# if ($seg eq "." || $seg eq "") {
257# }
258# elsif ($seg eq "..") {
259# if (@out && $out[-1] ne "..") {
260# pop @out;
261# }
262# else {
263# # Leading "..", or "../..", etc.
264# push @out, $seg;
265# }
266# }
267# else {
268# push @out, $seg;
269# }
270# }
271
272# unshift @out, "" if $is_absolute;
273# return join('/', @out);
274# }
275######################################################################
276######################################################################
277############
278######################################################################
279######################################################################
280
281sub spath {
282 my %params = @_;
283
284 die "Missing Required paramater 'Old'" unless $params{'Old'};
285 die "Missing Required paramater 'New'" unless $params{'New'};
286
287 my @olddir = split '/', `readlink -q -m $params{'Old'}`;
288 my @newdir = split '/', `readlink -q -m $params{'New'}`;
289 my @outdir = @olddir;
290
291 my $out = '';
292 my $i;
293 for ($i = 0; $i <= $#olddir && $i <= $#newdir; $i++) {
294 $out++ if ($olddir[$i] ne $newdir[$i]);
295 shift @outdir unless $out;
296 unshift @outdir, ".." if $out;
297 }
298 if ($#newdir > $#olddir) {
299 for ($i=0; $i < $#newdir; $i++) {
300 unshift @outdir, "..";
301 }
302 }
303 return join ('/', @outdir);
304}
305######################################################################
306######################################################################
307############
308######################################################################
309######################################################################
310
311
312# This routine actually moves the kernel image
313# From: $realimageloc/$kimage-$version (/boot/vmlinuz-2.6.12)
314# To: $image_dest/$kimage-$version (/vmlinuz-2.6.12)
315# Note that the image is moved to a versioned destination, but ordinary
316# symlinks we create otherwise are not normally versioned
317sub really_move_image {
318 my $src_dir = $_[0];
319 my $target = $_[1];
320 my $dest_dir = $_[2];
321
322 warn "Really move image: src_dir=$src_dir, target=$target,\n destdir=$dest_dir"
323 if $DEBUG;
324 if (-e "$target") {
325 # we should be in dir $dest_dir == $image_dest /, normally
326 rename("$target", "$target.$$") ||
327 die "failed to move " . $dest_dir . "$target:$!";
328 warn "mv $target $target.$$" if $DEBUG;
329 }
330 warn "mv -f $src_dir$target $target" if $DEBUG;
331 my $ret = system("mv -f " . $src_dir . "$target " .
332 " $target");
333 if ($ret) {
334 die("Failed to move " . $src_dir . "$target to "
335 . $dest_dir . "$target.\n");
336 }
337 # Ok, now we may clobber the previous .old files
338 if (-e "$target.$$") {
339 rename("$target.$$", "$target.old") ||
340 die "failed to move " . $dest_dir . "$target:$!";
341 warn "mv $target.$$ $target " if $DEBUG;
342 }
343}
344
345# Normally called after really_move_image; and only called if we asked for
346# reversed link this routine reverses the symbolic link that is notmally
347# created. Since the real kernel image has been moved over to
348# $image_dest/$kimage-$version. So, this routine links
349# From: $image_dest/$kimage-$version (/vmlinuz-2.6.12)
350# To: $realimageloc/$kimage-$version (/boot/vmlinuz-2.6.12)
351sub really_reverse_link {
352 my $src_dir = $_[0];
353 my $link_name = $_[1];
354 my $dest_dir = $_[2];
355 warn "Really reverse link: src_dir=$src_dir, link name=$link_name\n" .
356 "\tdestdir=$dest_dir" if $DEBUG;
357
358 my $Old = $dest_dir;
359 if (test_relative ('Old Dir' => $Old, 'New Dir' => $src_dir,
360 'Test File' => "$link_name")) {
361 $Old =~ s|^/*||o;
362 }
363 # Special case is they are in the same dir
364 my $rel_path = spath('Old' => "$Old", 'New' => "$src_dir" );
365 $Old ="" if $rel_path =~ m/^\s*$/o;
366
367 if ($use_hard_links =~ m/YES/i) {
368 link($Old . "$link_name", $src_dir . "$link_name") ||
369 die("Failed to link " . $dest_dir . "$link_name to " . $src_dir .
370 "$link_name .\n");
371 warn "ln " . $Old . "$link_name " . $src_dir . "$link_name" if $DEBUG;
372 }
373 else {
374 symlink($Old . "$link_name", $src_dir . "$link_name") ||
375 die("Failed to symbolic-link " . $dest_dir . "$link_name to " . $src_dir
376 . "$link_name : $!\n");
377 warn "ln -s " . $Old . "$link_name " . $src_dir . "$link_name" if $DEBUG;
378 }
379}
380
381# This routine is invoked if there is a symbolic link in place
382# in $image_dest/$kimage -- so a symlink exists in the destination.
383# What we are trying to determine is if we need to move the symbolic link over
384# to the the .old location
385sub move_p {
386 my $kimage = $_[0]; # Name of the symbolic link
387 my $image_dest = $_[1]; # The directory the links goes into
388 my $image_name = $_[2];
389 my $src_dir = $_[3];
390 my $force_move = 0;
391 warn "Move?: kimage=$kimage, image_dest=$image_dest, \n" .
392 "\timage_name=$image_name, src_dir=$src_dir" if $DEBUG;
393
394 if ($no_symlink || $reverse_symlink) {
395 # we do not want links, yet we have a symbolic link here!
396 warn "found a symbolic link in " . $image_dest . "$kimage \n" .
397 "even though no_symlink is defined\n" if $no_symlink;
398 warn "found a symbolic link in " . $image_dest . "$kimage \n" .
399 "even though reverse_symlink is defined\n" if $reverse_symlink;
400 # make sure we change this state of affairs
401 $force_move = 1;
402 return $force_move;
403 }
404
405 warn "DEBUG: OK. We found symlink, and we should have a symlink here.\n"
406 if $DEBUG;
407 my $vmlinuz_target = readlink "$kimage";
408 my $real_target = '';
409 my $target = `readlink -q -m "${realimageloc}${kimage-$version}"`;
410 $real_target = abs_path($vmlinuz_target) if defined($vmlinuz_target);
411
412 if (!defined($vmlinuz_target) || ! -f "$real_target") {
413 # what, a dangling symlink?
414 warn "The link " . $image_dest . "$kimage is a dangling link" .
415 "to $real_target\n";
416 $force_move = 1;
417 return $force_move;
418 }
419
420
421 warn "DEBUG: The link $kimage points to ($vmlinuz_target)\n" if $DEBUG;
422 warn "DEBUG: ($vmlinuz_target) is really ($real_target)\n" if $DEBUG;
423 my $cwd;
424 chomp ($cwd=`pwd`);
425 if ($vmlinuz_target !~ m|^/|o) {
426 $vmlinuz_target = $cwd . "/" . $vmlinuz_target;
427 $vmlinuz_target =~ s|/+|/|o;
428 }
429 $vmlinuz_target = `readlink -q -m $vmlinuz_target`;
430
431 if ("$vmlinuz_target" ne "$target") {
432 warn "DEBUG: We need to handle this.\n" if $DEBUG;
433 if ($minimal_swap) {
434 warn "DEBUG: Minimal swap.\n" if $DEBUG;
435 if (-l "$kimage.old") {
436 warn "DEBUG: There is an old link at $kimage.old\n" if $DEBUG;
437 my $old_target = readlink "$kimage.old";
438 my $real_old_target = '';
439 $real_old_target=abs_path($old_target) if defined ($old_target);
440
441 if ($real_old_target && -f "$real_old_target") {
442 if ($old_target !~ m|^/|o) {
443 $old_target = $cwd . "/" . $old_target;
444 $old_target =~ s|/+|/|o;
445 }
446 $old_target = `readlink -q -m $old_target`;
447 if ("$old_target" ne "$target") {
448 $force_move = 1;
449 warn "DEBUG: Old link ($old_target) does not point to us ($target)\n"
450 if $DEBUG;
451 }
452 else { # The .old points to the current
453 warn "$kimage.old --> $target -- doing nothing";
454 $force_move = 0;
455 }
456 }
457 else {
458 warn "DEBUG: Well, the old link does not exist -- so we move\n"
459 if $DEBUG;
460 $force_move = 1;
461 }
462 }
463 else {
464 warn "DEBUG: No .old link -- OK to move\n"
465 if $DEBUG;
466 $force_move = 1;
467 }
468 }
469 else {
470 warn "DEBUG: ok, minimal swap is no-- so we move.\n"
471 if $DEBUG;
472 $force_move = 1;
473 }
474 }
475 else { # already have proper link
476 warn "$kimage($vmlinuz_target) points to $target ($real_target) -- doing nothing";
477 $force_move = 0;
478 }
479 return $force_move;
480}
481
482
483# This routine moves the symbolic link around (/vmlinuz -> /vmlinuz.old)
484# It pays attention to whether we should the fact whether we should be using
485# hard links or not.
486sub really_move_link {
487 my $kimage = $_[0]; # Name of the symbolic link
488 my $image_dest = $_[1]; # The directory the links goes into
489 my $image_name = $_[2];
490 my $src_dir = $_[3];
491 warn "really_move_link: kimage=$kimage, image_dest=$image_dest\n" .
492 "\t image_name=$image_name, src_dir=$src_dir" if $DEBUG;
493
494 # don't clobber $kimage.old quite yet
495 rename("$kimage", "$kimage.$$") ||
496 die "failed to move " . $image_dest . "$kimage:$!";
497 warn "mv $kimage $kimage.$$" if $DEBUG;
498 my $Old = $src_dir;
499 my $cwd;
500
501 chomp($cwd=`pwd`);
502 if (test_relative ('Old Dir' => $Old, 'New Dir' => $cwd,
503 'Test File' => "$image_name")) {
504 $Old =~ s|^/*||o;
505 }
506 # Special case is they are in the same dir
507 my $rel_path = spath('Old' => "$Old", 'New' => "$cwd" );
508 $Old ="" if $rel_path =~ m/^\s*$/o;
509
510 if ($use_hard_links =~ m/YES/i) {
511 warn "ln ${Old}${image_name} $kimage" if $DEBUG;
512 if (! link("${Old}${image_name}", "$kimage")) {
513 rename("$kimage.$$", "$kimage");
514 die("Failed to link ${Old}${image_name} to " .
515 "${image_dest}${kimage}.\n");
516 }
517 }
518 else {
519 warn "ln -s ${Old}${image_name} $kimage" if $DEBUG;
520 if (! symlink("${Old}${image_name}", "$kimage")) {
521 rename("$kimage.$$", "$kimage");
522 die("Failed to symbolic-link ${Old}${image_name} to " .
523 "${image_dest}${kimage}: $!\n");
524 }
525 }
526
527 # Ok, now we may clobber the previous .old file
528 if (-l "$kimage.old" || ! -e "$kimage.old" ) {
529 rename("$kimage.$$", "$kimage.old");
530 warn "mv $kimage.$$ $kimage.old" if $DEBUG;
531 }
532 else {
533 warn "$kimage.old is not a symlink, not clobbering\n";
534 warn "rm $kimage.$$";
535 unlink "$kimage.$$" if $DEBUG;
536 }
537}
538
539# This routine handles a request to do symlinks, but there is no
540# symlink file already there. Either we are supposed to use copy, or we are
541# installing on a pristine system, or the user does not want symbolic links at
542# all. We use a configuration file to tell the last two cases apart, creating
543# a config file if needed.
544sub handle_missing_link {
545 my $kimage = $_[0]; # Name of the symbolic link
546 my $image_dest = $_[1]; # The directory the links goes into
547 my $image_name = $_[2];
548 my $src_dir = $_[3];
549 warn "handle_missing_link: kimage=$kimage, image_dest=$image_dest\n" .
550 "\t image_name=$image_name, src_dir=$src_dir" if $DEBUG;
551
552 if ($no_symlink) {
553 warn "cp -a --backup=t $realimageloc$image_name $kimage" if $DEBUG;
554 my $ret = system("cp -a --backup=t " . $realimageloc .
555 "$image_name " . " $kimage");
556 if ($ret) {
557 die("Failed to copy " . $realimageloc . "$image_name to "
558 . $image_dest . "$kimage .\n");
559 }
560 }
561 elsif ($reverse_symlink) {
562 warn "mv -f $realimageloc$image_name $kimage" if $DEBUG;
563 my $ret = system("mv -f " . $realimageloc . "$image_name "
564 . "$kimage");
565 if ($ret) {
566 die("Failed to move " . $realimageloc . "$image_name to "
567 . $image_dest . "$kimage .\n");
568 }
569 }
570 else {
571 if (! $have_conffile) {
572 my $ret;
573 my $answer='';
574 $do_symlink = "Yes";
575
576 if (open(CONF, ">$CONF_LOC")) {
577 print CONF "# Kernel Image management overrides\n";
578 print CONF "# See kernel-img.conf(5) for details\n";
579 if ($loader =~ /palo/i) {
580 print CONF "link_in_boot = Yes\n";
581 print CONF "do_symlinks = Yes\n";
582 print CONF "relative_links = Yes\n";
583 print CONF "do_bootloader = No\n";
584 } else {
585 print CONF "do_symlinks = $do_symlink\n";
586 }
587 close CONF;
588 }
589 $have_conffile = "Yes";
590 }
591 }
592
593 if (! $no_symlink && $do_symlink =~ /Yes/i) {
594 my $Old = $realimageloc;
595 my $New = $image_dest;
596 my $Name = "$image_name";
597 my $Link_Dest = "$kimage";
598
599 if ($reverse_symlink) {
600 $Old = $image_dest;
601 $New = $realimageloc;
602 $Name = "$kimage";
603 $Link_Dest = $realimageloc . "$image_name";
604 }
605 if (test_relative ('Old Dir' => $Old,
606 'New Dir' => $New,
607 'Test File' => $Name)) {
608 $Old =~ s|^/*||o;
609 }
610 # Special case is they are in the same dir
611 my $rel_path = spath('Old' => "$Old", 'New' => "$New" );
612 $Old ="" if $rel_path =~ m/^\s*$/o;
613
614 symlink($Old . "$Name", "$Link_Dest") ||
615 die("Failed to symbolic-link ${Old}$Name to $Link_Dest: $!\n");
616 warn "ln -s ${Old}$Name $Link_Dest" if $DEBUG;
617
618 }
619}
620
621# This routine handles the rest of the cases, where the user has requested
622# non-traditional handling, like using cp, or reverse symlinks, or hard links.
623sub handle_non_symlinks {
624 my $kimage = $_[0]; # Name of the symbolic link
625 my $image_dest = $_[1]; # The directory the links goes into
626 my $image_name = $_[2];
627 my $src_dir = $_[3];
628 warn "handle_non_link: kimage=$kimage, image_dest=$image_dest\n" .
629 "\t image_name=$image_name, src_dir=$src_dir" if $DEBUG;
630
631 # Save the current image. We do this in all four cases
632 rename("$kimage", "$kimage.$$") ||
633 die "failed to move " . $image_dest . "$kimage:$!";
634 warn "mv $kimage $kimage.$$" if $DEBUG;
635
636 ##,####
637 # case One
638 #`####
639 if ($no_symlink) {
640 # Maybe /$image_dest is on a dos system?
641 warn "cp -a --backup=t $realimageloc$image_name $kimage" if $DEBUG;
642 my $ret = system("cp -a --backup=t " . $realimageloc
643 . "$image_name " . "$kimage");
644 if ($ret) {
645 if (-e "$kimage.$$") {
646 rename("$kimage.$$", "$kimage");
647 warn "mv $kimage.$$ $kimage" if $DEBUG;
648 }
649 die("Failed to copy " . $realimageloc . "$image_name to "
650 . $image_dest . "$kimage .\n");
651 }
652 }
653 ##,####
654 # case Two
655 #`####
656 elsif ($reverse_symlink) { # Maybe /$image_dest is on a dos system?
657 warn "mv -f $realimageloc$image_name $kimage" if $DEBUG;
658 my $ret = system("mv -f " . $realimageloc . "$image_name "
659 . $image_dest . "$kimage");
660 if ($ret) {
661 if (-e "$kimage.$$") {
662 rename("$kimage.$$", "$kimage");
663 warn "mv $kimage.$$ $kimage" if $DEBUG;
664 }
665 die("Failed to move " . $realimageloc . "$image_name to "
666 . $image_dest . "$kimage .\n");
667 }
668 my $Old = $image_dest;
669 if (test_relative ('Old Dir' => $Old, 'New Dir' => $realimageloc,
670 'Test File' => "$kimage")) {
671 $Old =~ s|^/*||o;
672 }
673 # Special case is they are in the same dir
674 my $rel_path = spath('Old' => "$Old", 'New' => "$realimageloc" );
675 $Old ="" if $rel_path =~ m/^\s*$/o;
676
677 if ($use_hard_links =~ m/YES/i) {
678 warn "ln " . $Old . "$kimage " . $realimageloc . "$image_name" if $DEBUG;
679 if (! link($Old . "$kimage", $realimageloc . "$image_name")) {
680 warn "Could not link " . $image_dest .
681 "$kimage to $image_name :$!";
682 }
683 }
684 else {
685 warn "ln -s " . $Old . "$kimage " . $realimageloc . "$image_name" if $DEBUG;
686 if (! symlink($Old . "$kimage", $realimageloc . "$image_name")) {
687 warn "Could not symlink " . $image_dest .
688 "$kimage to $image_name :$!";
689 }
690 }
691 }
692 ##,####
693 # case Three
694 #`####
695 elsif ($use_hard_links =~ m/YES/i ) {
696 # Ok then. this ought to be a hard link, and hence fair game
697 # don't clobber $kimage.old quite yet
698 my $Old = $realimageloc;
699 my $cwd;
700 chomp($cwd=`pwd`);
701 if (test_relative ('Old Dir' => $Old, 'New Dir' => $cwd,
702 'Test File' => "$image_name")) {
703 $Old =~ s|^/*||o;
704 }
705 # Special case is they are in the same dir
706 my $rel_path = spath('Old' => "$Old", 'New' => "$cwd" );
707 $Old ="" if $rel_path =~ m/^\s*$/o;
708
709 warn "ln " . $Old . "$image_name " . "$kimage" if $DEBUG;
710 if (! link($Old . "$image_name", "$kimage")) {
711 warn "mv $kimage.$$ $kimage" if $DEBUG;
712 rename("$kimage.$$", "$kimage");
713 die("Failed to link " . $realimageloc . "$image_name to "
714 . $image_dest . "$kimage .\n");
715 }
716 }
717 ##,####
718 # case Four
719 #`####
720 else {
721 # We just use cp
722 warn "cp -a --backup=t $realimageloc$image_name $kimage" if $DEBUG;
723 my $ret = system("cp -a --backup=t " . $realimageloc
724 . "$image_name " . "$kimage");
725 if ($ret) {
726 if (-e "$kimage.$$") {
727 warn "mv $kimage.$$ $kimage" if $DEBUG;
728 rename("$kimage.$$", "$kimage");
729 }
730 die("Failed to copy " . $realimageloc . "$image_name to "
731 . $image_dest . "$kimage .\n");
732 }
733 }
734 # Ok, now we may clobber the previous .old file
735 warn "mv $kimage.$$ $kimage.old if -e $kimage.$$" if $DEBUG;
736 rename("$kimage.$$", "$kimage.old") if -e "$kimage.$$";
737}
738
739# This routine is responsible for setting up the symbolic links
740# So, the actual kernel image lives in
741# $realimageloc/$image_name (/boot/vmlinuz-2.6.12).
742# This routine creates symbolic links in $image_dest/$kimage (/vmlinuz)
743sub image_magic {
744 my $kimage = $_[0]; # Name of the symbolic link
745 my $image_dest = $_[1]; # The directory the links goes into
746 my $image_name = "$kimage-$version";
747 my $src_dir = $realimageloc;
748 warn "image_magic: kimage=$kimage, image_dest=$image_dest\n" .
749 "\t image_name=$image_name, src_dir=$src_dir" if $DEBUG;
750
751 # Well, in any case, if the destination (the symlink we are trying
752 # to create) is a directory, we should do nothing, except throw a
753 # diagnostic.
754 if (-d "$kimage" ) {
755 die ("Hmm. $kimage is a directory, which I did not expect. I am\n" .
756 "trying to create a symbolic link with that name linked to \n" .
757 "$image_dest . Since a directory exists here, my assumptions \n" .
758 "are way off, and I am aborting.\n" );
759 exit (3);
760 }
761
762 if ($move_image) { # Maybe $image_dest is in on dos, or something?
763 # source dir, link name, dest dir
764 really_move_image( $realimageloc, $image_name, $image_dest);
765 really_reverse_link($realimageloc, $image_name, $image_dest)
766 if $reverse_symlink;
767 return;
768 }
769
770 if (-l "$kimage") { # There is a symbolic link
771 warn "DEBUG: There is a symlink for $kimage\n" if $DEBUG;
772 my $force_move = move_p($kimage, $image_dest, $image_name, $src_dir);
773
774 if ($force_move) {
775 really_move_link($kimage, $image_dest, $image_name, $src_dir);
776 }
777 }
778 elsif (! -e "$kimage") {
779 # Hmm. Pristine system? How can that be? Installing from scratch?
780 # Or maybe the user does not want a symbolic link here.
781 # Possibly they do not want a link here. (we should be in /
782 # here[$image_dest, really]
783 handle_missing_link($kimage, $image_dest, $image_name, $src_dir);
784 }
785 elsif (-e "$kimage" ) {
786 # OK, $kimage exists -- but is not a link
787 handle_non_symlinks($kimage, $image_dest, $image_name, $src_dir);
788 }
789}
790
791######################################################################
792######################################################################
793######################################################################
794######################################################################
795
796# We may not have any modules installed
797if ( -d "$modules_base/$version" ) {
798 print STDERR "Running depmod.\n";
799 my $ret = system("depmod -a $version");
800 if ($ret) {
801 print STDERR "Failed to run depmod\n";
802 exit(1);
803 }
804}
805
806
807
808sub find_initrd_tool {
809 my $hostversion = shift;
810 my $version = shift;
811 print STDERR "Finding valid ramdisk creators.\n";
812 my @ramdisks =
813 grep {
814 my $args =
815 "$_ " .
816 "--supported-host-version=$hostversion " .
817 "--supported-target-version=$version " .
818 "1>/dev/null 2>&1"
819 ;
820 system($args) == 0;
821 }
822 split (/[:,\s]+/, $ramdisk);
823}
824
825# The initrd symlink should probably be in the same dir that the
826# symlinks are in
827if ($initrd) {
828 my $success = 0;
829
830 # Update-initramfs is called slightly different than mkinitrd and
831 # mkinitramfs. XXX It should really be made compatible with this stuff
832 # some how.
833 my $upgrading = 1;
834 if (! defined $ARGV[1] || ! $ARGV[1] || $ARGV[1] =~ m/<unknown>/og) {
835 $upgrading = 0;
836 }
837 my $ret = system("$ramdisk " . ($upgrading ? "-u" : "-c") . " -k " . $version . " >&2");
838 $success = 1 unless $ret;
839 die "Failed to create initrd image.\n" unless $success;
840 if (! defined $ARGV[1] || ! $ARGV[1] || $ARGV[1] =~ m/<unknown>/og) {
841 image_magic("initrd.img", $image_dest);
842 }
843 else {
844 if (! -e "initrd.img") {
845 handle_missing_link("initrd.img", $image_dest, "initrd.img-$version",
846 $realimageloc);
847 }
848 else {
849 print STDERR
850 "Not updating initrd symbolic links since we are being updated/reinstalled \n";
851 print STDERR
852 "($ARGV[1] was configured last, according to dpkg)\n";
853 }
854 }
855
856 if ($initrd && -l "initrd" ) {
857 unlink "initrd";
858 }
859
860 if ($initrd && -l "$image_dir/initrd" && ! $link_in_boot) {
861 unlink "$image_dir/initrd";
862 }
863}
864else { # Not making an initrd emage
865 if (-l "initrd.img") {
866 # Ooh, last image was an initrd image? in any case, we should move it.
867 my $target = readlink "initrd.img";
868 my $real_target = '';
869 $real_target = abs_path($target) if defined ($target);
870
871 if (!defined($target) || ! -f "$real_target") {
872 # Eh. dangling link. can safely be removed.
873 unlink("initrd.img");
874 } else {
875 if (-l "initrd.img.old" || ! -e "initrd.img.old" ) {
876 rename("initrd.img", "initrd.img.old");
877 } else {
878 warn "initrd.img.old is not a symlink, not clobbering\n";
879 unlink("initrd.img");
880 }
881 }
882 }
883}
884
885# Warn of a reboot
886if (-x $notifier) {
887 system($notifier);
888}
889
890# Let programs know not to hibernate if the kernel that would be used for
891# resume-from-hibernate is likely to differ from the currently running kernel.
892system("mountpoint -q /var/run");
893if ($? eq 0) {
894 system("touch /var/run/do-not-hibernate");
895}
896
897# Only change the symlinks if we are not being upgraded
898if (! defined $ARGV[1] || ! $ARGV[1] || $ARGV[1] =~ m/<unknown>/og) {
899 image_magic($kimage, $image_dest);
900}
901else {
902 if (! -e "$kimage") {
903 handle_missing_link($kimage, $image_dest, "$kimage-$version",
904 $realimageloc);
905 }
906 else {
907 print STDERR
908 "Not updating image symbolic links since we are being updated/reinstalled \n";
909 print STDERR
910 "($ARGV[1] was configured last, according to dpkg)\n";
911 }
912}
913
914# We used to have System.* files in /
915if (-e "/System.map" || -e "/System.old") {
916 unlink '/System.map' if -e '/System.map';
917 unlink '/System.old' if -e '/System.old';
918}
919
920# creating some info about kernel and initrd
921if ($DEBUG) {
922 my $ksize=sprintf("%.0f",(stat($realimageloc .
923 "$kimage-$version"))[7]/1024)."kB";
924 my $initrdsize='';
925 if ($initrd) {
926 $initrdsize=sprintf("%.0f",(stat($realimageloc .
927 "initrd.img-$version"))[7]/1024)."kB";
928 }
929
930 print STDERR <<"EOMSG";
931A new kernel image has been installed at $realimageloc$kimage-$version
932 (Size: $ksize)
933
934Symbolic links, unless otherwise specified, can be found in $image_dest
935
936EOMSG
937 ;
938
939 if ($initrd) {
940 print STDERR <<"EOMSGA";
941
942 Initial rootdisk image: ${realimageloc}initrd.img-$version (Size: $initrdsize)
943EOMSGA
944 ;
945 }
946}
947
948# set the env var stem
949$ENV{'STEM'} = "linux";
950sub exec_script {
951 my $type = shift;
952 my $script = shift;
953 print STDERR "Running $type hook script $script.\n";
954 system ("$script $version $realimageloc$kimage-$version") &&
955 print STDERR "User $type hook script [$script] ";
956 if ($?) {
957 if ($? == -1) {
958 print STDERR "failed to execute: $!\n";
959 }
960 elsif ($? & 127) {
961 printf STDERR "died with signal %d, %s coredump\n",
962 ($? & 127), ($? & 128) ? 'with' : 'without';
963 }
964 else {
965 printf STDERR "exited with value %d\n", $? >> 8;
966 }
967 exit $? >> 8;
968 }
969}
970sub run_hook {
971 my $type = shift;
972 my $script = shift;
973 if ($script =~ m,^/,) {
974 # Full path provided for the hook script
975 if (-x "$script") {
976 &exec_script($type,$script);
977 }
978 else {
979 die "The provided $type hook script [$script] could not be run.\n";
980 }
981 }
982 else {
983 # Look for it in a safe path
984 for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
985 if (-x "$path/$script") {
986 &exec_script($type, "$path/$script");
987 return 0;
988 }
989 }
990 # No luck
991 print STDERR "Could not find $type hook script [$script].\n";
992 die "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
993 }
994}
995
996my $options;
997for (@ARGV) {
998 s,','\\'',g;
999 $options .= " '$_'";
1000}
1001$ENV{'DEB_MAINT_PARAMS'}="$options";
1002
1003## Run user hook script here, if any
1004if ($postinst_hook) {
1005 &run_hook("postinst", $postinst_hook);
1006}
1007
1008if (-d "/etc/kernel/postinst.d") {
1009 print STDERR "Examining /etc/kernel/postinst.d.\n";
1010 system ("run-parts --verbose --exit-on-error --arg=$version " .
1011 "--arg=$realimageloc$kimage-$version " .
1012 "/etc/kernel/postinst.d") &&
1013 die "Failed to process /etc/kernel/postinst.d";
1014}
1015
1016if (-d "/etc/kernel/postinst.d/$version") {
1017 print STDERR "Examining /etc/kernel/postinst.d/$version.\n";
1018 system ("run-parts --verbose --exit-on-error --arg=$version " .
1019 "--arg=$realimageloc$kimage-$version " .
1020 "/etc/kernel/postinst.d/$version") &&
1021 die "Failed to process /etc/kernel/postinst.d/$version";
1022}
1023
1024LOADER: {
1025 last unless $do_boot_enable; # Exit if explicitly asked to
1026
1027 last if $loader =~ /silo/i; # SILO does not have to be executed.
1028 last if $loader =~ /yaboot/i; # yaboot does not have to be executed.
1029 last if $loader =~ /milo/i; # MILO does not have to be executed.
1030 last if $loader =~ /nettrom/i; # NETTROM does not have to be executed.
1031 last if $loader =~ /arcboot/i; # ARCBOOT does not have to be executed.
1032 last if $loader =~ /delo/i; # DELO does not have to be executed.
1033 last if $loader =~ /quik/i; # maintainer asked quik invocation to be ignored
1034
1035 last unless $loaderloc;
1036 last unless -x $loaderloc;
1037 last unless $do_bootloader;
1038
1039 if (-T "/etc/$loader.conf") {
1040 # Trust and use the existing lilo.conf.
1041 print STDERR "You already have a $Loader configuration in /etc/$loader.conf\n";
1042 my $ret = &run_lilo();
1043 exit $ret if $ret;
1044 }
1045}
1046
1047
1048sub run_lilo (){
1049 my $ret;
1050 # Try and figure out if the user really wants lilo to be run --
1051 # since the default is to run the boot laoder, which is ! grub -- but
1052 # the user may be using grub now, and not changed the default.
1053
1054 # So, if the user has explicitly asked for the loader to be run, or
1055 # if there is no postinst hook, or if there is no grub installed --
1056 # we are OK. Or else, we ask.
1057 if ($explicit_do_loader || (! ($postinst_hook && -x '/usr/sbin/grub'))) {
1058 print STDERR "Running boot loader as requested\n";
1059 } else {
1060 print STDERR "Ok, not running $loader\n";
1061 }
1062 if ($loader =~ /^lilo/io or $loader =~ /vmelilo/io) {
1063 print STDERR "Testing $loader.conf ... \n";
1064 unlink $temp_file_name; # security
1065 $ret = system("$loaderloc -t >$temp_file_name 2>&1");
1066 if ($ret) {
1067 print STDERR "Boot loader test failed\n";
1068 return $ret;
1069 }
1070 unlink "$temp_file_name";
1071 print STDERR "Testing successful.\n";
1072 print STDERR "Installing the ";
1073 print STDERR "partition " if $loader =~ /^lilo/io;
1074 print STDERR "boot sector... \n";
1075 }
1076
1077 print STDERR "Running $loaderloc ... \n";
1078 if ($loader =~ /^elilo/io) {
1079 $ret = system("$loaderloc 2>&1 | tee $temp_file_name");
1080 } else {
1081 $ret = system("$loaderloc >$temp_file_name 2>&1");
1082 }
1083 if ($ret) {
1084 print STDERR "Boot loader failed to run\n";
1085 return $ret;
1086 }
1087 unlink $temp_file_name;
1088 print STDERR "Installation successful.\n";
1089 return 0;
1090}
1091
1092exit 0;
1093
1094__END__
1095
diff --git a/debian/control-scripts/postrm b/debian/control-scripts/postrm
new file mode 100644
index 00000000000..227e351fc59
--- /dev/null
+++ b/debian/control-scripts/postrm
@@ -0,0 +1,361 @@
1#! /usr/bin/perl
2# -*- Mode: Cperl -*-
3# image.postrm ---
4# Author : Manoj Srivastava ( srivasta@glaurung.green-gryphon.com )
5# Created On : Sat May 15 11:05:13 1999
6# Created On Node : glaurung.green-gryphon.com
7# Last Modified By : Manoj Srivastava
8# Last Modified On : Wed Sep 13 11:26:19 2006
9# Last Machine Used: glaurung.internal.golden-gryphon.com
10# Update Count : 57
11# Status : Unknown, Use with caution!
12# HISTORY :
13# Description :
14#
15# $Id: image.postrm,v 1.31 2003/10/07 16:24:20 srivasta Exp $
16#
17
18
19#
20#use strict; #for debugging
21use Cwd 'abs_path';
22
23$|=1;
24
25# Predefined values:
26my $version = "=V";
27my $link_in_boot = ""; # Should be empty, mostly
28my $no_symlink = ""; # Should be empty, mostly
29my $reverse_symlink = ""; # Should be empty, mostly
30my $do_symlink = "Yes"; # target machine defined
31my $do_boot_enable = "Yes"; # target machine defined
32my $do_bootfloppy = "Yes"; # target machine defined
33my $do_bootloader = "Yes"; # target machine defined
34my $move_image = ''; # target machine defined
35my $kimage = "=K"; # Should be empty, mostly
36my $loader = "=L"; # lilo, silo, quik, palo, vmelilo, or nettrom
37my $image_dir = "/boot"; # where the image is located
38my $clobber_modules = ''; # target machine defined
39my $initrd = "YES"; # initrd kernel
40my $do_initrd = ''; # Normally, we don't
41my $warn_initrd = 'YES'; # Normally we do
42my $use_hard_links = ''; # hardlinks do not work across fs boundaries
43my $postinst_hook = ''; #Normally we do not
44my $postrm_hook = ''; #Normally we do not
45my $preinst_hook = ''; #Normally we do not
46my $prerm_hook = ''; #Normally we do not
47my $minimal_swap = ''; # Do not swap symlinks
48my $ignore_depmod_err = ''; # normally we do not
49my $relink_build_link = 'YES'; # There is no harm in checking the link
50my $force_build_link = ''; # we shall not create a dangling link
51my $kernel_arch = "=B";
52my $ramdisk = "/usr/sbin/update-initramfs";
53my $package_name = "linux-image-$version";
54
55my $Loader = "NoLOADER"; #
56$Loader = "LILO" if $loader =~ /^lilo/io;
57$Loader = "SILO" if $loader =~ /^silo/io;
58$Loader = "QUIK" if $loader =~ /^quik/io;
59$Loader = "yaboot" if $loader =~ /^yaboot/io;
60$Loader = "PALO" if $loader =~ /^palo/io;
61$Loader = "NETTROM" if $loader =~ /^nettrom/io;
62$Loader = "VMELILO" if $loader =~ /^vmelilo/io;
63$Loader = "ZIPL" if $loader =~ /^zipl/io;
64$Loader = "ELILO" if $loader =~ /^elilo/io;
65
66
67# This should not point to /tmp, because of security risks.
68my $temp_file_name = "/var/log/$loader" . "_log.$$";
69
70#known variables
71my @boilerplate = ();
72my @silotemplate = ();
73my @quiktemplate = ();
74my @palotemplate = ();
75my @vmelilotemplate = ();
76my $bootdevice = '';
77my $rootdevice = '';
78my $rootdisk = '';
79my $rootpartition = '';
80my $image_dest = "/";
81my $realimageloc = "/$image_dir/";
82my $have_conffile = "";
83my $CONF_LOC = '/etc/kernel-img.conf';
84my $relative_links = '';
85my $silent_modules = '';
86my $silent_loader = '';
87my $warn_reboot = 'Yes'; # Warn that we are installing a version of
88 # the kernel we are running
89
90chdir('/') or die "could not chdir to /:$!\n";
91# remove multiple leading slashes; make sure there is at least one.
92$realimageloc =~ s|^/*|/|o;
93$realimageloc =~ s|/+|/|o;
94
95
96if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
97 if (open(CONF, "$CONF_LOC")) {
98 while (<CONF>) {
99 chomp;
100 s/\#.*$//g;
101 next if /^\s*$/;
102
103 $do_symlink = "" if /^\s*do_symlinks\s*=\s*(no|false|0)\s*$/ig;
104 $no_symlink = "" if /^\s*no_symlinks\s*=\s*(no|false|0)\s*$/ig;
105 $reverse_symlink = "" if /^\s*reverse_symlinks\s*=\s*(no|false|0)\s*$/ig;
106 $link_in_boot = "" if /^\s*image_in_boot\s*=\s*(no|false|0)\s*$/ig;
107 $link_in_boot = "" if /^\s*link_in_boot\s*=\s*(no|false|0)\s*$/ig;
108 $move_image = "" if /^\s*move_image\s*=\s*(no|false|0)\s*$/ig;
109 $clobber_modules = '' if /^\s*clobber_modules\s*=\s*(no|false|0)\s*$/ig;
110 $do_boot_enable = '' if /^\s*do_boot_enable\s*=\s*(no|false|0)\s*$/ig;
111 $do_bootfloppy = '' if /^\s*do_bootfloppy\s*=\s*(no|false|0)\s*$/ig;
112 $relative_links = '' if /^\s*relative_links \s*=\s*(no|false|0)\s*$/ig;
113 $do_bootloader = '' if /^\s*do_bootloader\s*=\s*(no|false|0)\s*$/ig;
114 $do_initrd = '' if /^\s*do_initrd\s*=\s*(no|false|0)\s*$/ig;
115 $warn_initrd = '' if /^\s*warn_initrd\s*=\s*(no|false|0)\s*$/ig;
116 $use_hard_links = '' if /^\s*use_hard_links\s*=\s*(no|false|0)\s*$/ig;
117 $silent_modules = '' if /^\s*silent_modules\s*=\s*(no|false|0)\s*$/ig;
118 $silent_loader = '' if /^\s*silent_loader\s*=\s*(no|false|0)\s*$/ig;
119 $warn_reboot = '' if /^\s*warn_reboot\s*=\s*(no|false|0)\s*$/ig;
120 $minimal_swap = '' if /^\s*minimal_swap\s*=\s*(no|false|0)\s*$/ig;
121 $ignore_depmod_err = '' if /^\s*ignore_depmod_err\s*=\s*(no|false|0)\s*$/ig;
122 $relink_build_link = '' if /^\s*relink_build_link\s*=\s*(no|false|0)\s*$/ig;
123 $force_build_link = '' if /^\s*force_build_link\s*=\s*(no|false|0)\s*$/ig;
124
125 $do_symlink = "Yes" if /^\s*do_symlinks\s*=\s*(yes|true|1)\s*$/ig;
126 $no_symlink = "Yes" if /^\s*no_symlinks\s*=\s*(yes|true|1)\s*$/ig;
127 $reverse_symlink = "Yes" if /^\s*reverse_symlinks\s*=\s*(yes|true|1)\s*$/ig;
128 $link_in_boot = "Yes" if /^\s*image_in_boot\s*=\s*(yes|true|1)\s*$/ig;
129 $link_in_boot = "Yes" if /^\s*link_in_boot\s*=\s*(yes|true|1)\s*$/ig;
130 $move_image = "Yes" if /^\s*move_image\s*=\s*(yes|true|1)\s*$/ig;
131 $clobber_modules = "Yes" if /^\s*clobber_modules\s*=\s*(yes|true|1)\s*$/ig;
132 $do_boot_enable = "Yes" if /^\s*do_boot_enable\s*=\s*(yes|true|1)\s*$/ig;
133 $do_bootfloppy = "Yes" if /^\s*do_bootfloppy\s*=\s*(yes|true|1)\s*$/ig;
134 $do_bootloader = "Yes" if /^\s*do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
135 $relative_links = "Yes" if /^\s*relative_links\s*=\s*(yes|true|1)\s*$/ig;
136 $do_initrd = "Yes" if /^\s*do_initrd\s*=\s*(yes|true|1)\s*$/ig;
137 $warn_initrd = "Yes" if /^\s*warn_initrd\s*=\s*(yes|true|1)\s*$/ig;
138 $use_hard_links = "Yes" if /^\s*use_hard_links\s*=\s*(yes|true|1)\s*$/ig;
139 $silent_modules = 'Yes' if /^\s*silent_modules\s*=\s*(yes|true|1)\s*$/ig;
140 $silent_loader = 'Yes' if /^\s*silent_loader\s*=\s*(yes|true|1)\s*$/ig;
141 $warn_reboot = 'Yes' if /^\s*warn_reboot\s*=\s*(yes|true|1)\s*$/ig;
142 $minimal_swap = 'Yes' if /^\s*minimal_swap\s*=\s*(yes|true|1)\s*$/ig;
143 $ignore_depmod_err = 'Yes' if /^\s*ignore_depmod_err\s*=\s*(yes|true|1)\s*$/ig;
144 $relink_build_link = 'Yes' if /^\s*relink_build_link\s*=\s*(yes|true|1)\s*$/ig;
145 $force_build_link = 'Yes' if /^\s*force_build_link\s*=\s*(yes|true|1)\s*$/ig;
146
147 $image_dest = "$1" if /^\s*image_dest\s*=\s*(\S+)/ig;
148 $postinst_hook = "$1" if /^\s*postinst_hook\s*=\s*(\S+)/ig;
149 $postrm_hook = "$1" if /^\s*postrm_hook\s*=\s*(\S+)/ig;
150 $preinst_hook = "$1" if /^\s*preinst_hook\s*=\s*(\S+)/ig;
151 $prerm_hook = "$1" if /^\s*prerm_hook\s*=\s*(\S+)/ig;
152 $ramdisk = "$1" if /^\s*ramdisk\s*=\s*(.+)$/ig;
153 }
154 close CONF;
155 $have_conffile = "Yes";
156 }
157}
158
159if ($link_in_boot) {
160 $image_dest = "/$image_dir/";
161 $image_dest =~ s|^/*|/|o;
162}
163
164$image_dest = "$image_dest/";
165$image_dest =~ s|/+$|/|o;
166
167# The destdir may be gone by now.
168if (-d "$image_dest") {
169 chdir("$image_dest") or die "could not chdir to $image_dest:$!\n";
170}
171
172# Paranoid check to make sure that the correct value is put in there
173if (! $kimage) {$kimage = "vmlinuz"} # Hmm. empty
174elsif ($kimage =~ m/^b?uImage$/o) {$kimage = "vmlinuz"} # these produce vmlinuz
175elsif ($kimage =~ m/^b?zImage$/o) {$kimage = "vmlinuz"} # these produce vmlinuz
176elsif ($kimage =~ m/^[iI]mage$/o) { my $nop = $kimage;}
177elsif ($kimage =~ m/^vmlinux$/o) { my $nop = $kimage;}
178else {$kimage = "vmlinuz"} # default
179
180$ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
181
182
183######################################################################
184######################################################################
185############
186######################################################################
187######################################################################
188sub remove_sym_link {
189 my $bad_image = $_[0];
190
191 warn "Removing symbolic link $bad_image \n";
192 if ($loader =~ /lilo/i)
193 {
194 warn "Unless you used the optional flag in lilo, \n";
195 }
196 warn " you may need to re-run your boot loader" . ($loader ? "[$loader]":"")
197 . "\n";
198 # Remove the dangling link
199 unlink "$bad_image";
200}
201
202######################################################################
203######################################################################
204############
205######################################################################
206######################################################################
207sub CanonicalizePath {
208 my $path = join '/', @_;
209 my @work = split '/', $path;
210 my @out;
211 my $is_absolute;
212
213 if (@work && $work[0] eq "") { $is_absolute = 1; shift @work; }
214
215 while (@work) {
216 my $seg = shift @work;
217 if ($seg eq "." || $seg eq "") {
218 } elsif ($seg eq "..") {
219 if (@out && $out[-1] ne "..") {
220 pop @out;
221 } else {
222 # Leading "..", or "../..", etc.
223 push @out, $seg;
224 }
225 } else {
226 push @out, $seg;
227 }
228 }
229
230 unshift @out, "" if $is_absolute;
231 return join('/', @out);
232}
233
234######################################################################
235######################################################################
236############
237######################################################################
238######################################################################
239# This removes dangling symlinks. What do we do about hard links? Surely a
240# something with the nane $image_dest . "$kimage" ought not to be left behind?
241sub image_magic {
242 my $kimage = $_[0];
243 my $image_dest = $_[1];
244
245 if (-l "$kimage") {
246 # There is a symbolic link
247 my $force_move = 0;
248 my $vmlinuz_target = readlink "$kimage";
249 my $real_target = '';
250 $real_target = abs_path($vmlinuz_target) if defined ($vmlinuz_target);
251 if (!defined($vmlinuz_target) || ! -f "$real_target") {
252 # what, a dangling symlink?
253 warn "The link " . $image_dest . "$kimage is a damaged link\n";
254 # Remove the dangling link
255 &remove_sym_link("$kimage");
256 }
257 else {
258 my $canonical_target = CanonicalizePath("$vmlinuz_target");
259 if (! -e $canonical_target) {
260 warn "The link " . $image_dest . "$kimage is a dangling link\n";
261 &remove_sym_link("$kimage");
262 }
263 }
264 }
265}
266
267# set the env var stem
268$ENV{'STEM'} = "linux";
269
270sub exec_script {
271 my $type = shift;
272 my $script = shift;
273 print STDERR "Running $type hook script $script.\n";
274 system ("$script $version $realimageloc$kimage-$version") &&
275 print STDERR "User $type hook script [$script] ";
276 if ($?) {
277 if ($? == -1) {
278 print STDERR "failed to execute: $!\n";
279 }
280 elsif ($? & 127) {
281 printf STDERR "died with signal %d, %s coredump\n",
282 ($? & 127), ($? & 128) ? 'with' : 'without';
283 }
284 else {
285 printf STDERR "exited with value %d\n", $? >> 8;
286 }
287 }
288}
289sub run_hook {
290 my $type = shift;
291 my $script = shift;
292 if ($script =~ m,^/,) {
293 # Full path provided for the hook script
294 if (-x "$script") {
295 &exec_script($type,$script);
296 }
297 else {
298 warn "The provided $type hook script [$script] could not be run.\n";
299 }
300 }
301 else {
302 # Look for it in a safe path
303 for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
304 if (-x "$path/$script") {
305 &exec_script($type, "$path/$script");
306 return 0;
307 }
308 }
309 # No luck
310 print STDERR "Could not find $type hook script [$script].\n";
311 warn "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
312 }
313}
314
315my $options;
316for (@ARGV) {
317 s,','\\'',g;
318 $options .= " '$_'";
319}
320$ENV{'DEB_MAINT_PARAMS'}="$options";
321
322## Run user hook script here, if any
323if ($postrm_hook) {
324 &run_hook("postrm", $postrm_hook);
325}
326if (-d "/etc/kernel/postrm.d") {
327 warn "Examining /etc/kernel/postrm.d .\n";
328 system ("run-parts --verbose --exit-on-error --arg=$version " .
329 "--arg=$realimageloc$kimage-$version " .
330 "/etc/kernel/postrm.d") &&
331 die "Failed to process /etc/kernel/postrm.d";
332}
333if (-d "/etc/kernel/postrm.d/$version") {
334 warn "Examining /etc/kernel/postrm.d/$version .\n";
335 system ("run-parts --verbose --exit-on-error --arg=$version " .
336 "--arg=$realimageloc$kimage-$version " .
337 "/etc/kernel/postrm.d/$version") &&
338 die "Failed to process /etc/kernel/postrm.d/$version";
339}
340
341# check and remove damaged and dangling symlinks
342if ($ARGV[0] !~ /upgrade/) {
343 system("$ramdisk -d -k " . $version . " > /dev/null 2>&1");
344 if (-f $realimageloc . "initrd.img-$version.bak") {
345 unlink $realimageloc . "initrd.img-$version.bak";
346 }
347 image_magic($kimage, $image_dest);
348 image_magic($kimage . ".old", $image_dest);
349 image_magic("initrd.img", $image_dest) if $initrd;
350 image_magic("initrd.img.old", $image_dest) if $initrd;
351}
352
353exit 0;
354
355__END__
356
357
358
359
360
361
diff --git a/debian/control-scripts/preinst b/debian/control-scripts/preinst
new file mode 100644
index 00000000000..6824225faa2
--- /dev/null
+++ b/debian/control-scripts/preinst
@@ -0,0 +1,306 @@
1#! /usr/bin/perl
2# -*- Mode: Cperl -*-
3# image.preinst ---
4# Author : Manoj Srivastava ( srivasta@tiamat.datasync.com )
5# Created On : Sun Jun 14 03:38:02 1998
6# Created On Node : tiamat.datasync.com
7# Last Modified By : Manoj Srivastava
8# Last Modified On : Sun Sep 24 14:04:42 2006
9# Last Machine Used: glaurung.internal.golden-gryphon.com
10# Update Count : 99
11# Status : Unknown, Use with caution!
12# HISTORY :
13# Description :
14#
15#
16
17#
18#use strict; #for debugging
19
20use Debconf::Client::ConfModule qw(:all);
21version('2.0');
22my $capb=capb("backup");
23
24$|=1;
25
26# Predefined values:
27my $version = "=V";
28my $link_in_boot = ""; # Should be empty, mostly
29my $no_symlink = ""; # Should be empty, mostly
30my $reverse_symlink = ""; # Should be empty, mostly
31my $do_symlink = "Yes"; # target machine defined
32my $do_boot_enable = "Yes"; # target machine defined
33my $do_bootfloppy = "Yes"; # target machine defined
34my $do_bootloader = "Yes"; # target machine defined
35my $move_image = ''; # target machine defined
36my $kimage = "=K"; # Should be empty, mostly
37my $loader = "=L"; # lilo, silo, quik, palo, vmelilo, nettrom
38 # or elilo
39my $image_dir = "/boot"; # where the image is located
40my $initrd = "YES"; # initrd kernel
41my $use_hard_links = ''; # hardlinks do not wirk across fs boundaries
42my $postinst_hook = ''; #Normally we do not
43my $postrm_hook = ''; #Normally we do not
44my $preinst_hook = ''; #Normally we do not
45my $prerm_hook = ''; #Normally we do not
46my $minimal_swap = ''; # Do not swap symlinks
47my $ignore_depmod_err = ''; # normally we do not
48my $relink_src_link = 'YES'; # There is no harm in checking the link
49my $relink_build_link = 'YES'; # There is no harm in checking the link
50my $force_build_link = ''; # There is no harm in checking the link
51my $kernel_arch = "=B";
52my $ramdisk = "/usr/sbin/update-initramfs"; # List of tools to create initial ram fs.
53my $package_name = "linux-image-$version";
54
55my $Loader = "NoLOADER"; #
56$Loader = "LILO" if $loader =~ /^lilo/io;
57$Loader = "SILO" if $loader =~ /^silo/io;
58$Loader = "QUIK" if $loader =~ /^quik/io;
59$Loader = "yaboot" if $loader =~ /^yaboot/io;
60$Loader = "PALO" if $loader =~ /^palo/io;
61$Loader = "NETTROM" if $loader =~ /^nettrom/io;
62$Loader = "VMELILO" if $loader =~ /^vmelilo/io;
63$Loader = "ZIPL" if $loader =~ /^zipl/io;
64$Loader = "ELILO" if $loader =~ /^elilo/io;
65
66
67#known variables
68my @boilerplate = ();
69my @silotemplate = ();
70my @quiktemplate = ();
71my @palotemplate = ();
72my @vmelilotemplate = ();
73my $bootdevice = '';
74my $rootdevice = '';
75my $rootdisk = '';
76my $rootpartition = '';
77my $image_dest = "/";
78my $realimageloc = "/$image_dir/";
79my $have_conffile = "";
80my $CONF_LOC = '/etc/kernel-img.conf';
81my $relative_links = '';
82my $silent_loader = '';
83my $warn_reboot = ''; # Warn that we are installing a version of
84 # the kernel we are running
85
86my $modules_base = '/lib/modules';
87
88die "Pre inst Internal error. Aborting." unless $version;
89
90exit 0 if $ARGV[0] =~ /abort-upgrade/;
91exit 1 unless $ARGV[0] =~ /(install|upgrade)/;
92
93# remove multiple leading slashes; make sure there is at least one.
94$realimageloc =~ s|^/*|/|o;
95$realimageloc =~ s|/+|/|o;
96
97if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
98 if (open(CONF, "$CONF_LOC")) {
99 while (<CONF>) {
100 chomp;
101 s/\#.*$//g;
102 next if /^\s*$/;
103
104 $do_symlink = "" if /^\s*do_symlinks\s*=\s*(no|false|0)\s*$/ig;
105 $no_symlink = "" if /^\s*no_symlinks\s*=\s*(no|false|0)\s*$/ig;
106 $reverse_symlink = "" if /^\s*reverse_symlinks\s*=\s*(no|false|0)\s*$/ig;
107 $link_in_boot = "" if /^\s*image_in_boot\s*=\s*(no|false|0)\s*$/ig;
108 $link_in_boot = "" if /^\s*link_in_boot\s*=\s*(no|false|0)\s*$/ig;
109 $move_image = "" if /^\s*move_image\s*=\s*(no|false|0)\s*$/ig;
110 $do_boot_enable = '' if /^\s*do_boot_enable\s*=\s*(no|false|0)\s*$/ig;
111 $do_bootfloppy = '' if /^\s*do_bootfloppy\s*=\s*(no|false|0)\s*$/ig;
112 $do_bootloader = '' if /^\s*do_bootloader\s*=\s*(no|false|0)\s*$/ig;
113 $relative_links = '' if /^\s*relative_links \s*=\s*(no|false|0)\s*$/ig;
114 $use_hard_links = '' if /^\s*use_hard_links\s*=\s*(no|false|0)\s*$/ig;
115 $silent_loader = '' if /^\s*silent_loader\s*=\s*(no|false|0)\s*$/ig;
116 $warn_reboot = '' if /^\s*warn_reboot\s*=\s*(no|false|0)\s*$/ig;
117 $minimal_swap = '' if /^\s*minimal_swap\s*=\s*(no|false|0)\s*$/ig;
118 $ignore_depmod_err = '' if /^\s*ignore_depmod_err\s*=\s*(no|false|0)\s*$/ig;
119 $relink_src_link = '' if /^\s*relink_src_link\s*=\s*(no|false|0)\s*$/ig;
120 $relink_build_link = '' if /^\s*relink_build_link\s*=\s*(no|false|0)\s*$/ig;
121 $force_build_link = '' if /^\s*force_build_link\s*=\s*(no|false|0)\s*$/ig;
122
123 $do_symlink = "Yes" if /^\s*do_symlinks\s*=\s*(yes|true|1)\s*$/ig;
124 $no_symlink = "Yes" if /^\s*no_symlinks\s*=\s*(yes|true|1)\s*$/ig;
125 $reverse_symlink = "Yes" if /^\s*reverse_symlinks\s*=\s*(yes|true|1)\s*$/ig;
126 $link_in_boot = "Yes" if /^\s*image_in_boot\s*=\s*(yes|true|1)\s*$/ig;
127 $link_in_boot = "Yes" if /^\s*link_in_boot\s*=\s*(yes|true|1)\s*$/ig;
128 $move_image = "Yes" if /^\s*move_image\s*=\s*(yes|true|1)\s*$/ig;
129 $do_boot_enable = "Yes" if /^\s*do_boot_enable\s*=\s*(yes|true|1)\s*$/ig;
130 $do_bootfloppy = "Yes" if /^\s*do_bootfloppy\s*=\s*(yes|true|1)\s*$/ig;
131 $do_bootloader = "Yes" if /^\s*do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
132 $relative_links = "Yes" if /^\s*relative_links\s*=\s*(yes|true|1)\s*$/ig;
133 $use_hard_links = "Yes" if /^\s*use_hard_links\s*=\s*(yes|true|1)\s*$/ig;
134 $silent_loader = 'Yes' if /^\s*silent_loader\s*=\s*(yes|true|1)\s*$/ig;
135 $warn_reboot = 'Yes' if /^\s*warn_reboot\s*=\s*(yes|true|1)\s*$/ig;
136 $minimal_swap = 'Yes' if /^\s*minimal_swap\s*=\s*(yes|true|1)\s*$/ig;
137 $ignore_depmod_err = 'Yes' if /^\s*ignore_depmod_err\s*=\s*(yes|true|1)\s*$/ig;
138 $relink_src_link = 'Yes' if /^\s*relink_src_link\s*=\s*(yes|true|1)\s*$/ig;
139 $relink_build_link = 'Yes' if /^\s*relink_build_link\s*=\s*(yes|true|1)\s*$/ig;
140 $force_build_link = 'Yes' if /^\s*force_build_link\s*=\s*(yes|true|1)\s*$/ig;
141
142 $image_dest = "$1" if /^\s*image_dest\s*=\s*(\S+)/ig;
143 $postinst_hook = "$1" if /^\s*postinst_hook\s*=\s*(\S+)/ig;
144 $postrm_hook = "$1" if /^\s*postrm_hook\s*=\s*(\S+)/ig;
145 $preinst_hook = "$1" if /^\s*preinst_hook\s*=\s*(\S+)/ig;
146 $prerm_hook = "$1" if /^\s*prerm_hook\s*=\s*(\S+)/ig;
147 $ramdisk = "$1" if /^\s*ramdisk\s*=\s*(.+)$/ig;
148 }
149 close CONF;
150 $have_conffile = "Yes";
151 $have_conffile = "Yes"; # stop perl complaining
152 }
153}
154
155$ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
156
157# About to upgrade this package from version $2 TO THIS VERSION.
158# "prerm upgrade" has already been called for the old version of
159# this package.
160
161sub find_initrd_tool {
162 my $hostversion = shift;
163 my $version = shift;
164 my @ramdisks =
165 grep {
166 my $args =
167 "$_ " .
168 "--supported-host-version=$hostversion " .
169 "--supported-target-version=$version " .
170 "1>/dev/null 2>&1"
171 ;
172 system($args) == 0;
173 }
174 split (/[:,\s]+/, $ramdisk);
175}
176
177sub check {
178 my $version = shift;
179 my $lib_modules="$modules_base/$version";
180 my $message = '';
181
182 if (-d "$lib_modules") {
183 opendir(DIR, $lib_modules) || die "can’t opendir $lib_modules: $!";
184 my @children = readdir(DIR);
185 if ($#children > 1) {
186 my @dirs = grep { -d "$lib_modules/$_" } @children;
187 if ($#dirs > 1) { # we have subdirs
188 my $dir_message='';
189 for my $dir (@dirs) {
190 if ($dir =~/kernel$/) {
191 $dir_message="An older install was detected.\n";
192 }
193 else {
194 $dir_message="Module sub-directories were detected.\n"
195 unless $dir_message;
196 }
197 }
198 $message += $dir_message if $dir_message;
199 }
200
201 my @links = grep { -l "$lib_modules/$_" } @children;
202 if ($#links > -1) {
203 my $links_message = '';
204 for my $link (@links) {
205 next if ($link =~ /^build$/);
206 next if ($link =~ /^source$/);
207 $links_message = "Symbolic links were detected in $modules_base/$version.\n";
208 }
209 $message += $links_message if $links_message;
210 }
211 my @files = grep { -f "$lib_modules/$_" } @children;
212 $message += "Additional files also exist in $modules_base/$version.\n"
213 if ($#files > -1);
214 }
215 }
216 else { $message .= "$lib_modules does not exist. ";}
217 return $message;
218}
219
220if (-d "$modules_base/$version") {
221 my $errors=check($version);
222 warn "Info:\n$errors\n" if $errors;
223}
224
225# set the env var stem
226$ENV{'STEM'} = "linux";
227
228sub exec_script {
229 my $type = shift;
230 my $script = shift;
231 print STDERR "Running $type hook script $script.\n";
232 system ("$script $version $realimageloc$kimage-$version") &&
233 print STDERR "User $type hook script [$script] ";
234 if ($?) {
235 if ($? == -1) {
236 print STDERR "failed to execute: $!\n";
237 }
238 elsif ($? & 127) {
239 printf STDERR "died with signal %d, %s coredump\n",
240 ($? & 127), ($? & 128) ? 'with' : 'without';
241 }
242 else {
243 printf STDERR "exited with value %d\n", $? >> 8;
244 }
245 exit $? >> 8;
246 }
247}
248sub run_hook {
249 my $type = shift;
250 my $script = shift;
251 if ($script =~ m,^/,) {
252 # Full path provided for the hook script
253 if (-x "$script") {
254 &exec_script($type,$script);
255 }
256 else {
257 die "The provided $type hook script [$script] could not be run.\n";
258 }
259 }
260 else {
261 # Look for it in a safe path
262 for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
263 if (-x "$path/$script") {
264 &exec_script($type, "$path/$script");
265 return 0;
266 }
267 }
268 # No luck
269 print STDERR "Could not find $type hook script [$script].\n";
270 die "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
271 }
272}
273
274
275my $options;
276for (@ARGV) {
277 s,','\\'',g;
278 $options .= " '$_'";
279}
280$ENV{'DEB_MAINT_PARAMS'}="$options";
281
282## Run user hook script here, if any
283if (-x "$preinst_hook") {
284 &run_hook("preinst", $preinst_hook);
285}
286if (-d "/etc/kernel/preinst.d") {
287 print STDERR "Examining /etc/kernel/preinst.d/\n";
288 system ("run-parts --verbose --exit-on-error --arg=$version" .
289 " --arg=$realimageloc$kimage-$version" .
290 " /etc/kernel/preinst.d") &&
291 die "Failed to process /etc/kernel/preinst.d";
292}
293if (-d "/etc/kernel/preinst.d/$version") {
294 print STDERR "Examining /etc/kernel/preinst.d/$version.\n";
295 system ("run-parts --verbose --exit-on-error --arg=$version" .
296 " --arg=$realimageloc$kimage-$version" .
297 " /etc/kernel/preinst.d/$version") &&
298 die "Failed to process /etc/kernel/preinst.d/$version";
299}
300print STDERR "Done.\n";
301
302exit 0;
303
304__END__
305
306
diff --git a/debian/control-scripts/prerm b/debian/control-scripts/prerm
new file mode 100644
index 00000000000..07e41461d3a
--- /dev/null
+++ b/debian/control-scripts/prerm
@@ -0,0 +1,312 @@
1#! /usr/bin/perl
2# -*- Mode: Perl -*-
3# image.prerm ---
4# Author : root ( root@melkor.pilgrim.umass.edu )
5# Created On : Fri May 17 03:28:59 1996
6# Created On Node : melkor.pilgrim.umass.edu
7# Last Modified By : Manoj Srivastava
8# Last Modified On : Sat Aug 5 13:14:17 2006
9# Last Machine Used: glaurung.internal.golden-gryphon.com
10# Update Count : 85
11# Status : Unknown, Use with caution!
12# HISTORY :
13# Description :
14#
15#
16# $Id: image.prerm,v 1.22 2003/10/07 16:24:20 srivasta Exp $
17#
18#
19#use strict;
20
21$|=1;
22# Predefined values:
23my $version = "=V";
24my $link_in_boot = ""; # Should be empty, mostly
25my $no_symlink = ""; # Should be empty, mostly
26my $reverse_symlink = ""; # Should be empty, mostly
27my $do_symlinks = "Yes"; # target machine defined
28my $do_boot_enable = "Yes"; # target machine defined
29my $do_bootfloppy = "Yes"; # target machine defined
30my $do_bootloader = "Yes"; # target machine defined
31my $move_image = ''; # target machine defined
32my $kimage = "=K"; # Should be empty, mostly
33my $loader = "=L"; # lilo, silo, quik, palo, vmelilo, or nettrom
34my $image_dir = "/boot"; # where the image is located
35my $clobber_modules = ''; # target machine defined
36my $initrd = "YES"; # initrd kernel
37my $use_hard_links = ''; # hardlinks do not wirk across fs boundaries
38my $postinst_hook = ''; #Normally we do not
39my $postrm_hook = ''; #Normally we do not
40my $preinst_hook = ''; #Normally we do not
41my $prerm_hook = ''; #Normally we do not
42my $minimal_swap = ''; # Do not swap symlinks
43my $ignore_depmod_err = ''; # normally we do not
44my $relink_build_link = 'YES'; # There is no harm in checking the link
45my $force_build_link = ''; # There is no harm in checking the link
46my $kernel_arch = "=B";
47my $ramdisk = "/usr/sbin/update-initramfs";
48my $package_name = "linux-image-$version";
49
50my $Loader = "NoLOADER"; #
51$Loader = "LILO" if $loader =~ /^lilo/io;
52$Loader = "SILO" if $loader =~ /^silo/io;
53$Loader = "QUIK" if $loader =~ /^quik/io;
54$Loader = "yaboot" if $loader =~ /^yaboot/io;
55$Loader = "PALO" if $loader =~ /^palo/io;
56$Loader = "NETTROM" if $loader =~ /^nettrom/io;
57$Loader = "VMELILO" if $loader =~ /^vmelilo/io;
58$Loader = "ZIPL" if $loader =~ /^zipl/io;
59$Loader = "ELILO" if $loader =~ /^elilo/io;
60
61
62# This should not point to /tmp, because of security risks.
63my $temp_file_name = "/var/log/$loader" . "_log.$$";
64
65#known variables
66my $image_dest = "/";
67my $realimageloc = "/$image_dir/";
68my $have_conffile = "";
69my $CONF_LOC = '/etc/kernel-img.conf';
70my $relative_links = '';
71my $silent_loader = '';
72my $warn_reboot = 'Yes'; # Warn that we are installing a version of
73 # the kernel we are running
74
75# remove multiple leading slashes; make sure there is at least one.
76$realimageloc =~ s|^/*|/|o;
77$realimageloc =~ s|/+|/|o;
78
79my $DEBUG = 0;
80
81# Variables used
82my $image='';
83my $ret=0;
84my $seen='';
85my $answer='';
86my $running = '';
87my $WouldInvalidate = 0;
88
89if ($ARGV[0] && ($ARGV[0] =~ /remove/ || $ARGV[0] =~ /upgrade/)) {
90 if (-l "/usr/doc/linux-image-$version") {
91 unlink "/usr/doc/linux-image-$version";
92 }
93}
94
95# Ignore all invocations uxcept when called on to remove
96exit 0 unless ($ARGV[0] && $ARGV[0] =~ /remove/) ;
97
98# Paranoid check to make sure that the correct value is put in there
99if (! $kimage) { $kimage = "vmlinuz";} # Hmm. empty
100elsif ($kimage =~ m/^b?uImage$/o) { $kimage = "vmlinuz";} # these produce vmlinuz
101elsif ($kimage =~ m/^b?zImage$/o) { $kimage = "vmlinuz";} # these produce vmlinuz
102elsif ($kimage =~ m/^[iI]mage$/o) { my $nop = $kimage; }
103elsif ($kimage =~ m/^vmlinux$/o) { my $nop = $kimage; }
104else { $kimage = "vmlinuz";} # Default
105
106if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
107 if (open(CONF, "$CONF_LOC")) {
108 while (<CONF>) {
109 chomp;
110 s/\#.*$//g;
111 next if /^\s*$/;
112
113 $do_symlink = "" if /^\s*do_symlinks\s*=\s*(no|false|0)\s*$/ig;
114 $no_symlink = "" if /^\s*no_symlinks\s*=\s*(no|false|0)\s*$/ig;
115 $reverse_symlink = "" if /^\s*reverse_symlinks\s*=\s*(no|false|0)\s*$/ig;
116 $link_in_boot = "" if /^\s*image_in_boot\s*=\s*(no|false|0)\s*$/ig;
117 $link_in_boot = "" if /^\s*link_in_boot\s*=\s*(no|false|0)\s*$/ig;
118 $move_image = "" if /^\s*move_image\s*=\s*(no|false|0)\s*$/ig;
119 $clobber_modules = '' if /^\s*clobber_modules\s*=\s*(no|false|0)\s*$/ig;
120 $do_boot_enable = '' if /^\s*do_boot_enable\s*=\s*(no|false|0)\s*$/ig;
121 $do_bootfloppy = '' if /^\s*do_bootfloppy\s*=\s*(no|false|0)\s*$/ig;
122 $relative_links = '' if /^\s*relative_links \s*=\s*(no|false|0)\s*$/ig;
123 $do_bootloader = '' if /^\s*do_bootloader\s*=\s*(no|false|0)\s*$/ig;
124 $do_initrd = '' if /^\s*do_initrd\s*=\s*(no|false|0)\s*$/ig;
125 $use_hard_links = '' if /^\s*use_hard_links\s*=\s*(no|false|0)\s*$/ig;
126 $silent_loader = '' if /^\s*silent_loader\s*=\s*(no|false|0)\s*$/ig;
127 $warn_reboot = '' if /^\s*warn_reboot\s*=\s*(no|false|0)\s*$/ig;
128 $minimal_swap = '' if /^\s*minimal_swap\s*=\s*(no|false|0)\s*$/ig;
129 $ignore_depmod_err = '' if /^\s*ignore_depmod_err\s*=\s*(no|false|0)\s*$/ig;
130 $relink_build_link = '' if /^\s*relink_build_link\s*=\s*(no|false|0)\s*$/ig;
131 $force_build_link = '' if /^\s*force_build_link\s*=\s*(no|false|0)\s*$/ig;
132
133
134 $do_symlink = "Yes" if /^\s*do_symlinks\s*=\s*(yes|true|1)\s*$/ig;
135 $no_symlink = "Yes" if /^\s*no_symlinks\s*=\s*(yes|true|1)\s*$/ig;
136 $reverse_symlink = "Yes" if /^\s*reverse_symlinks\s*=\s*(yes|true|1)\s*$/ig;
137 $link_in_boot = "Yes" if /^\s*image_in_boot\s*=\s*(yes|true|1)\s*$/ig;
138 $link_in_boot = "Yes" if /^\s*link_in_boot\s*=\s*(yes|true|1)\s*$/ig;
139 $move_image = "Yes" if /^\s*move_image\s*=\s*(yes|true|1)\s*$/ig;
140 $clobber_modules = "Yes" if /^\s*clobber_modules\s*=\s*(yes|true|1)\s*$/ig;
141 $do_boot_enable = "Yes" if /^\s*do_boot_enable\s*=\s*(yes|true|1)\s*$/ig;
142 $do_bootfloppy = "Yes" if /^\s*do_bootfloppy\s*=\s*(yes|true|1)\s*$/ig;
143 $do_bootloader = "Yes" if /^\s*do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
144 $relative_links = "Yes" if /^\s*relative_links\s*=\s*(yes|true|1)\s*$/ig;
145 $do_initrd = "Yes" if /^\s*do_initrd\s*=\s*(yes|true|1)\s*$/ig;
146 $use_hard_links = "Yes" if /^\s*use_hard_links\s*=\s*(yes|true|1)\s*$/ig;
147 $silent_loader = 'Yes' if /^\s*silent_loader\s*=\s*(yes|true|1)\s*$/ig;
148 $warn_reboot = 'Yes' if /^\s*warn_reboot\s*=\s*(yes|true|1)\s*$/ig;
149 $minimal_swap = 'Yes' if /^\s*minimal_swap\s*=\s*(yes|true|1)\s*$/ig;
150 $ignore_depmod_err = 'Yes' if /^\s*ignore_depmod_err\s*=\s*(yes|true|1)\s*$/ig;
151 $relink_build_link = 'Yes' if /^\s*relink_build_link\s*=\s*(yes|true|1)\s*$/ig;
152 $force_build_link = 'Yes' if /^\s*force_build_link\s*=\s*(yes|true|1)\s*$/ig;
153
154 $image_dest = "$1" if /^\s*image_dest\s*=\s*(\S+)/ig;
155 $postinst_hook = "$1" if /^\s*postinst_hook\s*=\s*(\S+)/ig;
156 $postrm_hook = "$1" if /^\s*postrm_hook\s*=\s*(\S+)/ig;
157 $preinst_hook = "$1" if /^\s*preinst_hook\s*=\s*(\S+)/ig;
158 $prerm_hook = "$1" if /^\s*prerm_hook\s*=\s*(\S+)/ig;
159 $ramdisk = "$1" if /^\s*ramdisk\s*=\s*(.+)$/ig;
160 }
161 close CONF;
162 $have_conffile = "Yes";
163 }
164}
165
166
167$ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
168
169#check to see if we are trying to remove a running kernel
170# if so we abort right now.
171chop($running=`uname -r`);
172if ($running eq $version) {
173 print STDERR "WARN: Proceeding with removing running kernel image.\n";
174}
175
176#Now, they have an alternate kernel which they are currently running
177
178# This is just us being nice to lilo users.
179
180chdir("/") or die "could not chdir to /:$!\n";
181
182if (-f "/etc/$loader.conf") { #I know, could be a link, but ..
183 open (LILO, "/etc/$loader.conf") || &success(); # this is not critical
184 while (<LILO>) {
185 chop;
186 s/\#.*//; # nix the comments
187 next unless /^\s*image\s*=\s(\S+)/o;
188 $image = $1;
189 if ($image && -e $image) {
190 while (defined($image) && -l $image) {
191 $image = readlink ($image);
192 }
193 if (defined($image) && -e $image) {
194 $WouldInvalidate |= $image =~ /$kimage-$version/;
195 }
196 else {
197 &success(); # invalid $loader.conf file
198 }
199 }
200 else {
201 &success(); # invalid $loader.conf file
202 }
203 }
204 close (LILO);
205 if ($WouldInvalidate) {
206 print STFERR "WARN: Proceeding with removing running kernel image.\n";
207 &success();
208 }
209}
210
211
212# set the env var stem
213$ENV{'STEM'} = "linux";
214
215sub exec_script {
216 my $type = shift;
217 my $script = shift;
218 print STDERR "Running $type hook script $script.\n";
219 system ("$script $version $realimageloc$kimage-$version") &&
220 print STDERR "User $type hook script [$script] ";
221 if ($?) {
222 if ($? == -1) {
223 print STDERR "failed to execute: $!\n";
224 }
225 elsif ($? & 127) {
226 printf STDERR "died with signal %d, %s coredump\n",
227 ($? & 127), ($? & 128) ? 'with' : 'without';
228 }
229 else {
230 printf STDERR "exited with value %d\n", $? >> 8;
231 }
232 exit $? >> 8;
233 }
234}
235sub run_hook {
236 my $type = shift;
237 my $script = shift;
238 if ($script =~ m,^/,) {
239 # Full path provided for the hook script
240 if (-x "$script") {
241 &exec_script($type,$script);
242 }
243 else {
244 die "The provided $type hook script [$script] could not be run.\n";
245 }
246 }
247 else {
248 # Look for it in a safe path
249 for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
250 if (-x "$path/$script") {
251 &exec_script($type, "$path/$script");
252 return 0;
253 }
254 }
255 # No luck
256 print STDERR "Could not find $type hook script [$script].\n";
257 die "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
258 }
259}
260
261
262my $options;
263for (@ARGV) {
264 s,','\\'',g;
265 $options .= " '$_'";
266}
267$ENV{'DEB_MAINT_PARAMS'}="$options";
268
269## Run user hook script here, if any
270if (-x "$prerm_hook") {
271 &run_hook("prerm", $prerm_hook);
272}
273if (-d "/etc/kernel/prerm.d") {
274 print STDERR "Examining /etc/kernel/prerm.d.\n";
275 system ("run-parts --verbose --exit-on-error --arg=$version " .
276 "--arg=$realimageloc$kimage-$version /etc/kernel/prerm.d") &&
277 die "Failed to process /etc/kernel/prerm.d";
278}
279if (-d "/etc/kernel/prerm.d/$version") {
280 print STDERR "Examining /etc/kernel/prerm.d/$version.\n";
281 system ("run-parts --verbose --exit-on-error --arg=$version" .
282 " --arg=$realimageloc$kimage-$version " .
283 "/etc/kernel/prerm.d/$version") &&
284 die "Failed to process /etc/kernel/prerm.d/$version";
285}
286
287sub success () {
288 # NOTE: need to keep this list in sync with rules.d/2-binary-arch.mk
289 my %files_to_keep = (
290 'modules.builtin' => 1,
291 'modules.order' => 1,
292 );
293 my $short;
294 for my $file (</lib/modules/$version/modules.*>) {
295 $short = $file; $short =~ s,.*/,,;
296 if (!defined $files_to_keep{$short}) {
297 unlink "$file";
298 }
299 }
300 exit 0;
301}
302
303
304
305&success();
306exit 0;
307__END__
308
309
310
311
312
diff --git a/debian/debian.env b/debian/debian.env
new file mode 100644
index 00000000000..be31a0c2701
--- /dev/null
+++ b/debian/debian.env
@@ -0,0 +1 @@
DEBIAN=debian.master
diff --git a/debian/docs/README.inclusion-list b/debian/docs/README.inclusion-list
new file mode 100644
index 00000000000..b025393e7c1
--- /dev/null
+++ b/debian/docs/README.inclusion-list
@@ -0,0 +1,51 @@
1This README describes the reason for, and the use of, module
2inclusion lists.
3
4The original Hardy release had the notion of sub-flavours,
5e.g., a flavour that was constructed as a subset of an existing flavour.
6For example, the virtual flavour was extracted from the server flavour using
7a subset of the server flavour modules. However, there were some difficult
8mainteneance issues with regard to packaging, make rules, and scripts. This
9re-implementation of the sub-flavours philosophy is hopefully simpler,
10and retrofitable to all releases.
11
12A module inclusion list looks at the problem of of constructing a package
13from the perspective of what modules do we _want_ in the package, as opposed
14to what modules we _don't_ want. As the kernel matures, more and more devices are added
15which makes the problem of configuration maintenance a real pain in the ass.
16If we took the approach of disabling all of the config options that we don't want,
17then the differences between flavours will quickly become quite large, making
18it difficult to quickly compare the individual flavour configs. Each time a
19new config option is added then we also have to make a decision about disabling in
20order to continue to keep the minimal number of modules.
21
22A module inclusion list is applied on a per-flavour basis. For example,
23debian.<BRANCH>/control.d/${flavour}.inclusion-list. For example, the
24config for virtual is very close to server and generic, but the inclusion list
25causes the virtual package to be constructed with _only_ the modules described
26in the inclusion list.
27
28The inclusion list format is a simple bash regular expression list of files. For example,
29
30arch/*/{crypto,kernel,oprofile}
31drivers/acpi/*
32drivers/ata/ahci.ko
33
34These 3 regular expression forms are suitable for expansion by bash and as inputs to 'find'.
35See debian/scripts/module-inclusion for details.
36
37There are 2 log files created as a side effect of the application of the module
38inclusion list; $(flavour).inclusion-list.log and $(flavour).depmod.log.
39
40$(flavour).inclusion-list.log : This log is created while the inclusion list
41modules are being copied. If any are missing, then those warnings go in this log.
42While its not considered a fatal error, you should endevour to correct your inclusion
43list such that there are no missing modules.
44
45$(flavour).depmod.log : The log is created as a result of running depmod on the
46resulting set of modules. If there are missing symbols then you'll find that information
47here. Again, you should modify your inclusion list such that there are no missing
48symbols.
49
50Tim Gardner <tim.gardner@canonical.com>
51June 2, 2010
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 00000000000..92ec033af3e
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,235 @@
1#!/usr/bin/make -f
2#
3# $(DEBIAN)/rules for Ubuntu linux
4#
5# Use this however you want, just give credit where credit is due.
6#
7# Copyright (c) 2007 Ben Collins <bcollins@ubuntu.com>
8#
9
10DEBIAN=$(shell awk -F= '($$1 == "DEBIAN") { print $$2 }' <debian/debian.env)
11
12# dpkg-buildpackage passes options that are incomptatible
13# with the kernel build.
14unexport CFLAGS
15unexport LDFLAGS
16
17export LC_ALL=C
18export SHELL=/bin/bash -e
19
20# Where do we find the common configuration.
21export DROOT=debian
22
23# Common variables for all architectures
24include $(DROOT)/rules.d/0-common-vars.mk
25
26# Pull in some arch specific stuff
27-include $(DEBIAN)/rules.d/$(arch).mk
28
29# Maintainer targets
30include $(DROOT)/rules.d/1-maintainer.mk
31
32# Stages
33ifeq ($(DEB_STAGE),stage1)
34 do_tools=false
35 do_doc_package=false
36 do_source_package=false
37 do_flavour_image_package=false
38 do_flavour_header_package=false
39endif
40
41# Debian Build System targets
42binary: binary-indep binary-arch
43
44build: build-arch build-indep
45
46clean: debian/control
47 dh_testdir
48 dh_testroot
49 dh_clean
50
51 # d-i stuff
52 rm -rf $(DEBIAN)/d-i-$(arch)
53
54 # normal build junk
55 rm -rf $(DEBIAN)/abi/$(release)-$(revision)
56 rm -rf $(builddir)
57 rm -f $(stampdir)/stamp-*
58 rm -rf $(DEBIAN)/linux-*
59
60 # This gets rid of the d-i packages in control
61 cp -f $(DEBIAN)/control.stub $(DEBIAN)/control
62 cp $(DEBIAN)/changelog debian/changelog
63
64 # Install the copyright information.
65 cp $(DEBIAN)/copyright debian/copyright
66
67distclean: clean
68 rm -rf $(DEBIAN)/control $(DEBIAN)/control.stub \
69 $(DEBIAN)/d-i/kernel-versions debian/changelog \
70 debian/control debian/control.stub debian/copyright
71
72# Builds the image, arch headers and debug packages
73include $(DROOT)/rules.d/2-binary-arch.mk
74
75# Rules for building the udebs ($(DEBIAN)-installer)
76include $(DROOT)/rules.d/5-udebs.mk
77
78# Builds the source, doc and linux-headers indep packages
79include $(DROOT)/rules.d/3-binary-indep.mk
80
81# Various checks to be performed on builds
82include $(DROOT)/rules.d/4-checks.mk
83
84# Misc stuff
85$(DEBIAN)/control.stub: $(DEBIAN)/d-i/kernel-versions.in \
86 $(DROOT)/scripts/control-create \
87 $(DEBIAN)/control.stub.in \
88 $(DEBIAN)/changelog \
89 $(wildcard $(DEBIAN)/control.d/* $(DEBIAN)/sub-flavours/*.vars)
90 for i in $(DEBIAN)/d-i/kernel-versions.in $(DEBIAN)/control.stub.in; do \
91 new=`echo $$i | sed 's/\.in$$//'`; \
92 cat $$i | sed -e 's/PKGVER/$(release)/g' \
93 -e 's/ABINUM/$(abinum)/g' \
94 -e 's/SRCPKGNAME/$(src_pkg_name)/g' \
95 > $$new; \
96 done
97 flavours="$(wildcard $(DEBIAN)/control.d/vars.* $(DEBIAN)/sub-flavours/*.vars)";\
98 for i in $$flavours; do \
99 $(SHELL) $(DROOT)/scripts/control-create $$i | \
100 sed -e 's/PKGVER/$(release)/g' \
101 -e 's/ABINUM/$(abinum)/g' \
102 -e 's/SRCPKGNAME/$(src_pkg_name)/g' \
103 >> $(DEBIAN)/control.stub; \
104 done
105 cp $(DEBIAN)/control.stub $(DEBIAN)/control
106
107.PHONY: debian/control
108debian/control: $(DEBIAN)/control.stub
109 rm -rf $(builddir)/modules $(builddir)/firmware \
110 $(builddir)/kernel-versions $(builddir)/package-list \
111 $(builddir)/$(DEBIAN)
112 mkdir -p $(builddir)/modules/$(arch)/
113 cp $(DEBIAN)/d-i/modules/* $(builddir)/modules/$(arch)/
114 mkdir -p $(builddir)/firmware/$(arch)/
115 cp $(DEBIAN)/d-i/firmware/* $(builddir)/firmware/$(arch)/
116 cp $(DEBIAN)/d-i/package-list $(DEBIAN)/d-i/kernel-versions $(builddir)/
117 touch $(builddir)/modules/$(arch)/kernel-image
118 # kernel-wedge needs to poke around in $(DEBIAN)/
119 ln -nsf $(CURDIR)/debian $(builddir)/debian
120
121 # Some files may need to differ between architectures
122 if [ -d $(DEBIAN)/d-i/modules-$(arch) ]; then \
123 cp $(DEBIAN)/d-i/modules-$(arch)/* \
124 $(builddir)/modules/$(arch)/; \
125 fi
126 if [ -d $(DEBIAN)/d-i/firmware-$(arch) ]; then \
127 cp $(DEBIAN)/d-i/firmware-$(arch)/* \
128 $(builddir)/firmware/$(arch)/; \
129 fi
130
131 # Remove unwanted stuff for this architecture
132 if [ -r "$(DEBIAN)/d-i/exclude-modules.$(arch)" ]; then \
133 (cat $(DEBIAN)/d-i/exclude-modules.$(arch); \
134 ls $(builddir)/modules/$(arch)/) | sort | uniq -d | \
135 (cd $(builddir)/modules/$(arch)/; xargs rm -f); \
136 fi
137 if [ -r "$(DEBIAN)/d-i/exclude-firmware.$(arch)" ]; then \
138 (cat $(DEBIAN)/d-i/exclude-firmware.$(arch); \
139 ls $(builddir)/firmware/$(arch)/) | sort | uniq -d | \
140 (cd $(builddir)/firmware/$(arch)/; xargs rm -f); \
141 fi
142
143 # Per flavour module lists
144 flavour_modules=`ls $(DEBIAN)/d-i/modules.$(arch)-* 2>/dev/null` \
145 || true; \
146 if [ "$$flavour_modules" != "" ]; then \
147 for flav in $$flavour_modules; do \
148 name=`echo $$flav | sed 's/.*\/modules.$(arch)-//'`; \
149 mkdir $(builddir)/modules/$(arch)-$$name; \
150 (cd $(builddir)/modules/; tar cf - `cat ../$$flav`) | \
151 (cd $(builddir)/modules/$(arch)-$$name/; tar xf -); \
152 touch $(builddir)/modules/$(arch)-$$name/kernel-image; \
153 done; \
154 fi
155 flavour_firmware=`ls $(DEBIAN)/d-i/firmware.$(arch)-* 2>/dev/null` \
156 || true; \
157 if [ "$$flavour_firmware" != "" ]; then \
158 for flav in $$flavour_firmware; do \
159 name=`echo $$flav | sed 's/.*\/firmware.$(arch)-//'`; \
160 mkdir $(builddir)/firmware/$(arch)-$$name; \
161 (cd $(builddir)/firmware/; tar cf - `cat ../$$flav`) | \
162 (cd $(builddir)/firmware/$(arch)-$$name/; tar xf -);\
163 touch $(builddir)/firmware/$(arch)-$$name/kernel-image; \
164 done; \
165 fi
166
167 # Some files may need to differ between flavours
168 flavour_module_dirs=`ls -d $(DEBIAN)/d-i/modules-$(arch)-* 2>/dev/null`\
169 || true; \
170 if [ "$$flavour_module_dirs" ]; then \
171 for flav in $$flavour_module_dirs; do \
172 name=`echo $$flav | sed 's/.*\/modules-$(arch)-//'`; \
173 [ -d $(builddir)/modules/$(arch)-$$name ] || \
174 cp -a $(builddir)/modules/$(arch) \
175 modules/$(arch)-$$name; \
176 cp $$flav/* $(builddir)/modules/$(arch)-$$name/; \
177 done; \
178 fi
179 flavour_firmware_dirs=`ls -d $(DEBIAN)/d-i/firmware-$(arch)-* 2>/dev/null`\
180 || true; \
181 if [ "$$flavour_firmware_dirs" ]; then \
182 for flav in $$flavour_firmware_dirs; do \
183 name=`echo $$flav | sed 's/.*\/firmware-$(arch)-//'`; \
184 [ -d $(builddir)/firmware/$(arch)-$$name ] || \
185 cp -a $(builddir)/firmware/$(arch) \
186 firmware/$(arch)-$$name; \
187 cp $$flav/* $(builddir)/firmware/$(arch)-$$name/; \
188 done; \
189 fi
190
191 # Remove unwanted stuff for each flavour
192 flavour_exclude=`ls $(DEBIAN)/d-i/exclude-modules.$(arch)-* 2>/dev/null`\
193 || true; \
194 if [ "$$flavour_exclude" ]; then \
195 for flav in $$flavour_exclude; do \
196 name=`echo $$flav | sed 's/.*\/exclude-modules.$(arch)-//'`;\
197 [ -d $(builddir)/modules/$(arch)-$$name ] || \
198 cp -a $(builddir)/modules/$(arch) \
199 $(builddir)/modules/$(arch)-$$name; \
200 (cat $$flav; \
201 ls $(builddir)/modules/$(arch)-$$name) | \
202 sort | uniq -d | \
203 (cd $(builddir)/modules/$(arch)-$$name/; \
204 xargs rm -f); \
205 done; \
206 fi
207 flavour_exclude=`ls $(DEBIAN)/d-i/exclude-firmware.$(arch)-* 2>/dev/null`\
208 || true; \
209 if [ "$$flavour_exclude" ]; then \
210 for flav in $$flavour_exclude; do \
211 name=`echo $$flav | sed 's/.*\/exclude-firmware.$(arch)-//'`;\
212 [ -d $(builddir)/firmware/$(arch)-$$name ] || \
213 cp -a $(builddir)/firmware/$(arch) \
214 $(builddir)/firmware/$(arch)-$$name; \
215 (cat $$flav; \
216 ls $(builddir)/firmware/$(arch)-$$name) | \
217 sort | uniq -d | \
218 (cd $(builddir)/firmware/$(arch)-$$name/; \
219 xargs rm -f); \
220 done; \
221 fi
222
223 if [ ! -d $(builddir)/modules/$(build_arch) ]; then \
224 mkdir -p $(builddir)/modules/$(build_arch); \
225 cp $(builddir)/modules/$(arch)/* \
226 $(builddir)/modules/$(build_arch); \
227 fi
228 if [ ! -d $(builddir)/firmware/$(build_arch) ]; then \
229 mkdir -p $(builddir)/firmware/$(build_arch); \
230 cp $(builddir)/firmware/$(arch)/* \
231 $(builddir)/firmware/$(build_arch); \
232 fi
233
234 cp $(DEBIAN)/control.stub debian/control.stub
235 cd $(builddir) && kernel-wedge gen-control > $(CURDIR)/debian/control
diff --git a/debian/rules.d/0-common-vars.mk b/debian/rules.d/0-common-vars.mk
new file mode 100644
index 00000000000..dd9daff2759
--- /dev/null
+++ b/debian/rules.d/0-common-vars.mk
@@ -0,0 +1,225 @@
1#
2# The source package name will be the first token from $(DEBIAN)/changelog
3#
4src_pkg_name=$(shell sed -n '1s/^\(.*\) (.*).*$$/\1/p' $(DEBIAN)/changelog)
5
6# Get some version info
7series := natty
8release := $(shell sed -n '1s/^$(src_pkg_name).*(\(.*\)-.*).*$$/\1/p' $(DEBIAN)/changelog)
9revisions := $(shell sed -n 's/^$(src_pkg_name)\ .*($(release)-\(.*\)).*$$/\1/p' $(DEBIAN)/changelog | tac)
10revision ?= $(word $(words $(revisions)),$(revisions))
11prev_revisions := $(filter-out $(revision),0.0 $(revisions))
12prev_revision := $(word $(words $(prev_revisions)),$(prev_revisions))
13
14family=ubuntu
15
16# This is an internally used mechanism for the daily kernel builds. It
17# creates packages whose ABI is suffixed with a minimal representation of
18# the current git HEAD sha. If .git/HEAD is not present, then it uses the
19# uuidgen program,
20#
21# AUTOBUILD can also be used by anyone wanting to build a custom kernel
22# image, or rebuild the entire set of Ubuntu packages using custom patches
23# or configs.
24AUTOBUILD=
25
26#
27# This is a way to support some external variables. A good example is
28# a local setup for ccache and distcc See LOCAL_ENV_CC and
29# LOCAL_ENV_DISTCC_HOSTS in the definition of kmake.
30# For example:
31# LOCAL_ENV_CC="ccache distcc"
32# LOCAL_ENV_DISTCC_HOSTS="localhost 10.0.2.5 10.0.2.221"
33#
34-include $(CURDIR)/../.$(series)-env
35
36ifneq ($(AUTOBUILD),)
37skipabi = true
38skipmodule = true
39skipdbg = true
40gitver=$(shell if test -f .git/HEAD; then cat .git/HEAD; else uuidgen; fi)
41gitverpre=$(shell echo $(gitver) | cut -b -3)
42gitverpost=$(shell echo $(gitver) | cut -b 38-40)
43abi_suffix = -$(gitverpre)$(gitverpost)
44endif
45
46ifneq ($(NOKERNLOG),)
47ubuntu_log_opts += --no-kern-log
48endif
49ifneq ($(PRINTSHAS),)
50ubuntu_log_opts += --print-shas
51endif
52
53# Get the kernels own extra version to be added to the release signature.
54extraversion=$(shell awk '/EXTRAVERSION =/ { print $$3 }' <Makefile)
55
56#
57# full_build -- are we doing a full buildd style build
58#
59ifeq ($(wildcard /CurrentlyBuilding),)
60full_build?=false
61else
62full_build?=true
63endif
64
65#
66# The debug packages are ginormous, so you probably want to skip
67# building them (as a developer).
68#
69ifeq ($(full_build),false)
70skipdbg=true
71endif
72
73abinum := $(shell echo $(revision) | sed -e 's/\..*//')$(abi_suffix)
74prev_abinum := $(shell echo $(prev_revision) | sed -e 's/\..*//')$(abi_suffix)
75abi_release := $(release)-$(abinum)
76
77uploadnum := $(shell echo $(revision) | sed -e 's/.*\.//')
78ifneq ($(full_build),false)
79 uploadnum := $(uploadnum)-Ubuntu
80endif
81
82# XXX: linux-libc-dev got bumped to -803.N inadvertantly by a ti-omap4 upload
83# shift our version higher for this package only. Ensure this only
84# occurs for the v2.6.35 kernel so that we do not propogate this into
85# any other series.
86raw_uploadnum := $(shell echo $(revision) | sed -e 's/.*\.//')
87libc_dev_version :=
88ifeq ($(DEBIAN),debian.master)
89ifeq ($(release),2.6.35)
90libc_dev_version := -v$(release)-$(shell expr "$(abinum)" + 1000).$(raw_uploadnum)
91endif
92endif
93
94# We force the sublevel to be exactly what we want. The actual source may
95# be an in development git tree. We want to force it here instead of
96# committing changes to the top level Makefile
97SUBLEVEL := $(shell echo $(release) | awk -F. '{print $$3}')
98
99DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
100DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
101DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
102DEB_BUILD_ARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH)
103
104#
105# Detect invocations of the form 'fakeroot debian/rules binary arch=armel'
106# within an x86'en schroot. This only gets you part of the way since the
107# packaging phase fails, but you can at least compile the kernel quickly.
108#
109arch := $(DEB_HOST_ARCH)
110ifneq ($(arch),$(DEB_HOST_ARCH))
111 CROSS_COMPILE ?= $(shell dpkg-architecture -a$(arch) -qDEB_HOST_GNU_TYPE -f 2>/dev/null)-
112endif
113
114#
115# Detect invocations of the form 'dpkg-buildpackage -B -aarmel' within
116# an x86'en schroot. This is the only way to build all of the packages
117# (except for tools).
118#
119ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
120 CROSS_COMPILE ?= $(DEB_HOST_GNU_TYPE)-
121endif
122
123abidir := $(CURDIR)/$(DEBIAN)/abi/$(release)-$(revision)/$(arch)
124prev_abidir := $(CURDIR)/$(DEBIAN)/abi/$(release)-$(prev_revision)/$(arch)
125commonconfdir := $(CURDIR)/$(DEBIAN)/config
126archconfdir := $(CURDIR)/$(DEBIAN)/config/$(arch)
127sharedconfdir := $(CURDIR)/debian.master/config
128builddir := $(CURDIR)/debian/build
129stampdir := $(CURDIR)/debian/stamps
130
131#
132# The binary package name always starts with linux-image-$KVER-$ABI.$UPLOAD_NUM. There
133# are places that you'll find linux-image hard coded, but I guess thats OK since the
134# assumption that the binary package always starts with linux-image will never change.
135#
136bin_pkg_name=linux-image-$(abi_release)
137hdrs_pkg_name=linux-headers-$(abi_release)
138#
139# The generation of content in the doc package depends on both 'AUTOBUILD=' and
140# 'do_doc_package_content=true'. There are usually build errors during the development
141# cycle, so its OK to leave 'do_doc_package_content=false' until those build
142# failures get sorted out. Finally, the doc package doesn't really need to be built
143# for developer testing (its kind of slow), so only do it if on a buildd.
144do_doc_package=true
145do_doc_package_content=true
146ifeq ($(full_build),false)
147do_doc_package_content=false
148endif
149doc_pkg_name=$(src_pkg_name)-doc
150
151#
152# Similarly with the linux-source package, you need not build it as a developer. Its
153# somewhat I/O intensive and utterly useless.
154#
155do_source_package=true
156do_source_package_content=true
157ifeq ($(full_build),false)
158do_source_package_content=false
159endif
160
161# linux-libc-dev may not be needed, default to building it.
162do_libc_dev_package=true
163
164# common headers normally is built as an indep package, but may be arch
165do_common_headers_indep=true
166
167# add a 'full source' mode
168do_full_source=false
169
170# build tools
171ifneq ($(wildcard $(CURDIR)/tools),)
172do_tools?=true
173else
174do_tools?=false
175endif
176tools_pkg_name=$(src_pkg_name)-tools-$(abi_release)
177tools_common_pkg_name=$(src_pkg_name)-tools-common
178
179# The general flavour specific image package.
180do_flavour_image_package=true
181
182# The general flavour specific header package.
183do_flavour_header_package=true
184
185# Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008)
186#
187# These 2 environment variables set the -j value of the kernel build. For example,
188# CONCURRENCY_LEVEL=16 fakeroot $(DEBIAN)/rules binary-debs
189# or
190# DEB_BUILD_OPTIONS=parallel=16 fakeroot $(DEBIAN)/rules binary-debs
191#
192# The default is to use the number of CPUs.
193#
194COMMA=,
195DEB_BUILD_OPTIONS_PARA = $(subst parallel=,,$(filter parallel=%,$(subst $(COMMA), ,$(DEB_BUILD_OPTIONS))))
196ifneq (,$(DEB_BUILD_OPTIONS_PARA))
197 CONCURRENCY_LEVEL := $(DEB_BUILD_OPTIONS_PARA)
198endif
199
200ifeq ($(CONCURRENCY_LEVEL),)
201 # Check the environment
202 CONCURRENCY_LEVEL := $(shell echo $$CONCURRENCY_LEVEL)
203 # No? Then build with the number of CPUs on the host.
204 ifeq ($(CONCURRENCY_LEVEL),)
205 CONCURRENCY_LEVEL := $(shell expr `getconf _NPROCESSORS_ONLN` \* 1)
206 endif
207 # Oh hell, give 'em one
208 ifeq ($(CONCURRENCY_LEVEL),)
209 CONCURRENCY_LEVEL := 1
210 endif
211endif
212
213conc_level = -j$(CONCURRENCY_LEVEL)
214
215# target_flavour is filled in for each step
216kmake = make ARCH=$(build_arch) \
217 CROSS_COMPILE=$(CROSS_COMPILE) \
218 EXTRAVERSION=-$(abinum)-$(target_flavour) \
219 CONFIG_DEBUG_SECTION_MISMATCH=y SUBLEVEL=$(SUBLEVEL) \
220 KBUILD_BUILD_VERSION="$(uploadnum)" \
221 LOCALVERSION= localver-extra=
222ifneq ($(LOCAL_ENV_CC),)
223kmake += CC=$(LOCAL_ENV_CC) DISTCC_HOSTS=$(LOCAL_ENV_DISTCC_HOSTS)
224endif
225
diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk
new file mode 100644
index 00000000000..2360dcad13d
--- /dev/null
+++ b/debian/rules.d/1-maintainer.mk
@@ -0,0 +1,122 @@
1# The following targets are for the maintainer only! do not run if you don't
2# know what they do.
3
4.PHONY: printenv updateconfigs printchanges insertchanges startnewrelease diffupstream help updateportsconfigs editportsconfigs
5
6help:
7 @echo "These are the targets in addition to the normal $(DEBIAN) ones:"
8 @echo
9 @echo " printenv : Print some variables used in the build"
10 @echo
11 @echo " updateconfigs : Update core arch configs"
12 @echo
13 @echo " editconfigs : Update core arch configs interractively"
14 @echo " genconfigs : Generate core arch configs in CONFIGS/*"
15 @echo
16 @echo " updateportsconfigs : Update ports arch configs"
17 @echo
18 @echo " editportsconfigs : Update ports arch configs interactivly"
19 @echo " genportconfigs : Generate ports arch configs in CONFIGS/*"
20 @echo
21 @echo " printchanges : Print the current changelog entries (from git)"
22 @echo
23 @echo " insertchanges : Insert current changelog entries (from git)"
24 @echo
25 @echo " startnewrelease : Start a new changelog set"
26 @echo
27 @echo " diffupstream : Diff stock kernel code against upstream (git)"
28 @echo
29 @echo " help : If you are kernel hacking, you need the professional"
30 @echo " version of this"
31 @echo
32 @echo "Environment variables:"
33 @echo
34 @echo " NOKERNLOG : Do not add upstream kernel commits to changelog"
35 @echo " CONCURRENCY_LEVEL=X"
36 @echo " : Use -jX for kernel compile"
37 @echo " PRINTSHAS : Include SHAs for commits in changelog"
38
39printdebian:
40 @echo "$(DEBIAN)"
41
42updateconfigs defaultconfigs editconfigs genconfigs dumpconfigs:
43 dh_testdir;
44 $(SHELL) $(DROOT)/scripts/misc/kernelconfig $@
45 rm -rf build
46
47updateportsconfigs defaultportsconfigs editportsconfigs genportsconfigs askconfigs:
48 dh_testdir;
49 $(SHELL) $(DROOT)/scripts/misc/kernelconfig $@ ports
50 rm -rf build
51
52printenv:
53 dh_testdir
54 @echo "src package name = $(src_pkg_name)"
55 @echo "release = $(release)"
56 @echo "revisions = $(revisions)"
57 @echo "revision = $(revision)"
58 @echo "uploadnum = $(uploadnum)"
59 @echo "prev_revisions = $(prev_revisions)"
60 @echo "prev_revision = $(prev_revision)"
61 @echo "abinum = $(abinum)"
62 @echo "gitver = $(gitver)"
63 @echo "flavours = $(flavours)"
64 @echo "skipabi = $(skipabi)"
65 @echo "skipmodule = $(skipmodule)"
66 @echo "skipdbg = $(skipdbg)"
67 @echo "ubuntu_log_opts = $(ubuntu_log_opts)"
68ifneq ($(SUBLEVEL),)
69 @echo "SUBLEVEL = $(SUBLEVEL)"
70endif
71 @echo "CONCURRENCY_LEVEL = $(CONCURRENCY_LEVEL)"
72 @echo "bin package name = $(bin_pkg_name)"
73 @echo "hdr package name = $(hdrs_pkg_name)"
74 @echo "doc package name = $(doc_pkg_name)"
75 @echo "do_doc_package = $(do_doc_package)"
76 @echo "do_doc_package_content = $(do_doc_package_content)"
77 @echo "do_source_package = $(do_source_package)"
78 @echo "do_source_package_content = $(do_source_package_content)"
79 @echo "do_libc_dev_package = $(do_libc_dev_package)"
80 @echo "do_flavour_image_package = $(do_flavour_image_package)"
81 @echo "do_flavour_header_package = $(do_flavour_header_package)"
82 @echo "do_common_headers_indep = $(do_common_headers_indep)"
83 @echo "do_full_source = $(do_full_source)"
84 @echo "do_tools = $(do_tools)"
85 @echo "full_build = $(full_build)"
86 @echo "libc_dev_version = $(libc_dev_version)"
87 @echo "DEB_HOST_GNU_TYPE = $(DEB_HOST_GNU_TYPE)"
88 @echo "DEB_BUILD_GNU_TYPE = $(DEB_BUILD_GNU_TYPE)"
89 @echo "DEB_HOST_ARCH = $(DEB_HOST_ARCH)"
90 @echo "DEB_BUILD_ARCH = $(DEB_BUILD_ARCH)"
91 @echo "arch = $(arch)"
92 @echo "kmake = $(kmake)"
93
94printchanges:
95 @baseCommit=$$(git log --pretty=format:'%H %s' | \
96 awk '/UBUNTU: '".*Ubuntu-$(release)-$(prev_revision)"'$$/ { print $$1; exit }'); \
97 git log "$$baseCommit"..HEAD | \
98 perl -w -f $(DROOT)/scripts/misc/git-ubuntu-log $(ubuntu_log_opts)
99
100insertchanges:
101 @perl -w -f $(DROOT)/scripts/misc/insert-changes.pl $(DROOT) $(DEBIAN)
102
103diffupstream:
104 @git diff-tree -p refs/remotes/linux-2.6/master..HEAD $(shell ls | grep -vE '^(ubuntu|$(DEBIAN)|\.git.*)')
105
106startnewrelease:
107 dh_testdir
108 @nextminor=$(shell expr `echo $(revision) | awk -F. '{print $$2}'` + 1); \
109 now="$(shell date -R)"; \
110 echo "Creating new changelog set for $(abi_release).$$nextminor..."; \
111 echo -e "$(src_pkg_name) ($(abi_release).$$nextminor) UNRELEASED; urgency=low\n" > $(DEBIAN)/changelog.new; \
112 echo " CHANGELOG: Do not edit directly. Autogenerated at release." >> \
113 $(DEBIAN)/changelog.new; \
114 echo " CHANGELOG: Use the printchanges target to see the curent changes." \
115 >> $(DEBIAN)/changelog.new; \
116 echo " CHANGELOG: Use the insertchanges target to create the final log." \
117 >> $(DEBIAN)/changelog.new; \
118 echo -e "\n -- $$DEBFULLNAME <$$DEBEMAIL> $$now\n" >> \
119 $(DEBIAN)/changelog.new ; \
120 cat $(DEBIAN)/changelog >> $(DEBIAN)/changelog.new; \
121 mv $(DEBIAN)/changelog.new $(DEBIAN)/changelog
122
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
new file mode 100644
index 00000000000..c31ab14ebb6
--- /dev/null
+++ b/debian/rules.d/2-binary-arch.mk
@@ -0,0 +1,407 @@
1# We don't want make removing intermediary stamps
2.SECONDARY :
3
4# Prepare the out-of-tree build directory
5ifeq ($(do_full_source),true)
6build_cd = cd $(builddir)/build-$*; #
7build_O =
8else
9build_cd =
10build_O = O=$(builddir)/build-$*
11endif
12
13prepare-%: $(stampdir)/stamp-prepare-%
14 @# Empty for make to be happy
15$(stampdir)/stamp-prepare-%: $(stampdir)/stamp-prepare-tree-% prepare-checks-%
16 @touch $@
17$(stampdir)/stamp-prepare-tree-%: target_flavour = $*
18$(stampdir)/stamp-prepare-tree-%: $(commonconfdir)/config.common.$(family) $(archconfdir)/config.common.$(arch) $(archconfdir)/config.flavour.%
19 @echo "Preparing $*..."
20 install -d $(builddir)/build-$*
21 touch $(builddir)/build-$*/ubuntu-build
22 [ "$(do_full_source)" != 'true' ] && true || \
23 rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) * $(builddir)/build-$*
24 cat $^ | sed -e 's/.*CONFIG_VERSION_SIGNATURE.*/CONFIG_VERSION_SIGNATURE="Ubuntu $(release)-$(revision)-$* $(release)$(extraversion)"/' > $(builddir)/build-$*/.config
25 find $(builddir)/build-$* -name "*.ko" | xargs rm -f
26 $(build_cd) $(kmake) $(build_O) silentoldconfig prepare scripts
27 touch $@
28
29# Do the actual build, including image and modules
30build-%: $(stampdir)/stamp-build-%
31 @# Empty for make to be happy
32$(stampdir)/stamp-build-%: target_flavour = $*
33$(stampdir)/stamp-build-%: prepare-%
34 @echo "Building $*..."
35 $(build_cd) $(kmake) $(build_O) $(conc_level) $(build_image)
36 $(build_cd) $(kmake) $(build_O) $(conc_level) modules
37 @touch $@
38
39# Install the finished build
40install-%: pkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*
41install-%: bindoc = $(pkgdir)/usr/share/doc/$(bin_pkg_name)-$*
42install-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
43install-%: basepkg = $(hdrs_pkg_name)
44install-%: hdrdir = $(CURDIR)/debian/$(basepkg)-$*/usr/src/$(basepkg)-$*
45install-%: target_flavour = $*
46install-%: $(stampdir)/stamp-build-% checks-%
47 dh_testdir
48 dh_testroot
49 dh_clean -k -p$(bin_pkg_name)-$*
50 dh_clean -k -p$(hdrs_pkg_name)-$*
51 dh_clean -k -p$(dbg_pkg_name)-$*
52
53 # The main image
54 # compress_file logic required because not all architectures
55 # generate a zImage automatically out of the box
56ifeq ($(compress_file),)
57 install -m644 -D $(builddir)/build-$*/$(kernel_file) \
58 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
59else
60 install -d $(pkgdir)/boot
61 gzip -c9v $(builddir)/build-$*/$(kernel_file) > \
62 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
63 chmod 644 $(pkgdir)/boot/$(install_file)-$(abi_release)-$*
64endif
65
66 install -m644 $(builddir)/build-$*/.config \
67 $(pkgdir)/boot/config-$(abi_release)-$*
68 install -m644 $(abidir)/$* \
69 $(pkgdir)/boot/abi-$(abi_release)-$*
70 install -m600 $(builddir)/build-$*/System.map \
71 $(pkgdir)/boot/System.map-$(abi_release)-$*
72ifeq ($(no_dumpfile),)
73 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
74 -x $(builddir)/build-$*/vmlinux
75 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
76endif
77
78 $(build_cd) $(kmake) $(build_O) modules_install \
79 INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$(pkgdir)/ \
80 INSTALL_FW_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*
81
82 #
83 # Remove all modules not in the inclusion list.
84 #
85 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
86 $(SHELL) $(DROOT)/scripts/module-inclusion $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
87 $(DEBIAN)/control.d/$(target_flavour).inclusion-list 2>&1 | \
88 tee $(target_flavour).inclusion-list.log; \
89 /sbin/depmod -b $(pkgdir) -ea -F $(pkgdir)/boot/System.map-$(abi_release)-$* \
90 $(abi_release)-$* 2>&1 |tee $(target_flavour).depmod.log; \
91 fi
92
93ifeq ($(no_dumpfile),)
94 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
95 -x $(builddir)/build-$*/vmlinux
96 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
97endif
98 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/build
99 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/source
100
101 # Some initramfs-tools specific modules
102 install -d $(pkgdir)/lib/modules/$(abi_release)-$*/initrd
103 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko ]; then\
104 ln -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko \
105 $(pkgdir)/lib/modules/$(abi_release)-$*/initrd/; \
106 fi
107
108 # Now the image scripts
109 install -d $(pkgdir)/DEBIAN
110 for script in postinst postrm preinst prerm; do \
111 sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(install_file)/g' \
112 -e 's/=L/$(loader)/g' -e 's@=B@$(build_arch)@g' \
113 $(DROOT)/control-scripts/$$script > $(pkgdir)/DEBIAN/$$script; \
114 chmod 755 $(pkgdir)/DEBIAN/$$script; \
115 done
116
117 # Install the full changelog.
118ifeq ($(do_doc_package),true)
119 install -d $(bindoc)
120 cat $(DEBIAN)/changelog $(DEBIAN)/changelog.historical | \
121 gzip -9 >$(bindoc)/changelog.Debian.old.gz
122 chmod 644 $(bindoc)/changelog.Debian.old.gz
123endif
124
125ifneq ($(skipsub),true)
126 for sub in $($(*)_sub); do \
127 if ! (TO=$$sub FROM=$* ABI_RELEASE=$(abi_release) $(SHELL) \
128 $(DROOT)/scripts/sub-flavour); then exit 1; fi; \
129 /sbin/depmod -b debian/$(bin_pkg_name)-$$sub \
130 -ea -F debian/$(bin_pkg_name)-$$sub/boot/System.map-$(abi_release)-$* \
131 $(abi_release)-$*; \
132 install -d debian/$(bin_pkg_name)-$$sub/DEBIAN; \
133 for script in postinst postrm preinst prerm; do \
134 sed -e 's/=V/$(abi_release)-$*/g' \
135 -e 's/=K/$(install_file)/g' \
136 -e 's/=L/$(loader)/g' \
137 -e 's@=B@$(build_arch)@g' \
138 $(DROOT)/control-scripts/$$script > \
139 debian/$(bin_pkg_name)-$$sub/DEBIAN/$$script;\
140 chmod 755 debian/$(bin_pkg_name)-$$sub/DEBIAN/$$script;\
141 done; \
142 done
143endif
144
145ifneq ($(skipdbg),true)
146 # Debug image is simple
147 install -m644 -D $(builddir)/build-$*/vmlinux \
148 $(dbgpkgdir)/usr/lib/debug/boot/vmlinux-$(abi_release)-$*
149 $(build_cd) $(kmake) $(build_O) modules_install \
150 INSTALL_MOD_PATH=$(dbgpkgdir)/usr/lib/debug
151 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/build
152 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/source
153 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/modules.*
154 rm -fr $(dbgpkgdir)/usr/lib/debug/lib/firmware
155endif
156
157 # The flavour specific headers image
158 # TODO: Would be nice if we didn't have to dupe the original builddir
159 install -d -m755 $(hdrdir)
160 cat $(builddir)/build-$*/.config | \
161 sed -e 's/.*CONFIG_DEBUG_INFO=.*/# CONFIG_DEBUG_INFO is not set/g' > \
162 $(hdrdir)/.config
163 chmod 644 $(hdrdir)/.config
164 $(kmake) O=$(hdrdir) silentoldconfig prepare scripts
165 # We'll symlink this stuff
166 rm -f $(hdrdir)/Makefile
167 rm -rf $(hdrdir)/include2
168 # powerpc seems to need some .o files for external module linking. Add them in.
169ifeq ($(arch),powerpc)
170 mkdir -p $(hdrdir)/arch/powerpc/lib
171 cp $(builddir)/build-$*/arch/powerpc/lib/*.o $(hdrdir)/arch/powerpc/lib
172endif
173 # Script to symlink everything up
174 $(SHELL) $(DROOT)/scripts/link-headers "$(hdrdir)" "$(basepkg)" "$*"
175 # Setup the proper asm symlink
176 rm -f $(hdrdir)/include/asm
177 ln -s asm-$(asm_link) $(hdrdir)/include/asm
178 # The build symlink
179 install -d debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*
180 ln -s /usr/src/$(basepkg)-$* \
181 debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*/build
182 # And finally the symvers
183 install -m644 $(builddir)/build-$*/Module.symvers \
184 $(hdrdir)/Module.symvers
185
186 # Now the header scripts
187 install -d $(CURDIR)/debian/$(basepkg)-$*/DEBIAN
188 for script in postinst; do \
189 sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(install_file)/g' \
190 $(DROOT)/control-scripts/headers-$$script > \
191 $(CURDIR)/debian/$(basepkg)-$*/DEBIAN/$$script; \
192 chmod 755 $(CURDIR)/debian/$(basepkg)-$*/DEBIAN/$$script; \
193 done
194
195 # At the end of the package prep, call the tests
196 DPKG_ARCH="$(arch)" KERN_ARCH="$(build_arch)" FLAVOUR="$*" \
197 VERSION="$(abi_release)" REVISION="$(revision)" \
198 PREV_REVISION="$(prev_revision)" ABI_NUM="$(abinum)" \
199 PREV_ABI_NUM="$(prev_abinum)" BUILD_DIR="$(builddir)/build-$*" \
200 INSTALL_DIR="$(pkgdir)" SOURCE_DIR="$(CURDIR)" \
201 run-parts -v $(DROOT)/tests
202
203 #
204 # Remove files which are generated at installation by postinst,
205 # except for modules.order and modules.builtin
206 #
207 # NOTE: need to keep this list in sync with postrm
208 #
209 mkdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
210 mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.order \
211 $(pkgdir)/lib/modules/$(abi_release)-$*/_
212 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin ] ; then \
213 mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin \
214 $(pkgdir)/lib/modules/$(abi_release)-$*/_; \
215 fi
216 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.*
217 mv $(pkgdir)/lib/modules/$(abi_release)-$*/_/* \
218 $(pkgdir)/lib/modules/$(abi_release)-$*
219 rmdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
220
221headers_tmp := $(CURDIR)/debian/tmp-headers
222headers_dir := $(CURDIR)/debian/linux-libc-dev
223
224hmake := $(MAKE) -C $(CURDIR) O=$(headers_tmp) SUBLEVEL=$(SUBLEVEL) \
225 EXTRAVERSION=-$(abinum) INSTALL_HDR_PATH=$(headers_tmp)/install \
226 SHELL="$(SHELL)" ARCH=$(header_arch)
227
228install-arch-headers:
229 dh_testdir
230 dh_testroot
231 dh_clean -k -plinux-libc-dev
232
233 rm -rf $(headers_tmp)
234 install -d $(headers_tmp) $(headers_dir)/usr/include/
235
236 $(hmake) $(defconfig)
237 mv $(headers_tmp)/.config $(headers_tmp)/.config.old
238 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
239 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
240 $(headers_tmp)/.config.old > $(headers_tmp)/.config
241 $(hmake) silentoldconfig
242 $(hmake) headers_install
243
244 ( cd $(headers_tmp)/install/include/ && \
245 find . -name '.' -o -name '.*' -prune -o -print | \
246 cpio -pvd --preserve-modification-time \
247 $(headers_dir)/usr/include/ )
248
249 rm -rf $(headers_tmp)
250
251binary-arch-headers: install-arch-headers
252 dh_testdir
253 dh_testroot
254ifeq ($(do_libc_dev_package),true)
255ifneq ($(DEBIAN),debian.master)
256 echo "non-master branch building linux-libc-dev, aborting"
257 exit 1
258endif
259 dh_installchangelogs -plinux-libc-dev
260 dh_installdocs -plinux-libc-dev
261 dh_compress -plinux-libc-dev
262 dh_fixperms -plinux-libc-dev
263 dh_installdeb -plinux-libc-dev
264 dh_gencontrol -plinux-libc-dev -- $(libc_dev_version)
265 dh_md5sums -plinux-libc-dev
266 dh_builddeb -plinux-libc-dev
267endif
268
269binary-%: pkgimg = $(bin_pkg_name)-$*
270binary-%: pkghdr = $(hdrs_pkg_name)-$*
271binary-%: dbgpkg = $(bin_pkg_name)-$*-dbgsym
272binary-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
273binary-%: install-%
274 dh_testdir
275 dh_testroot
276
277 dh_installchangelogs -p$(pkgimg)
278 dh_installdocs -p$(pkgimg)
279 dh_compress -p$(pkgimg)
280 dh_fixperms -p$(pkgimg) -X/boot/
281 dh_installdeb -p$(pkgimg)
282 dh_shlibdeps -p$(pkgimg)
283 dh_gencontrol -p$(pkgimg)
284 dh_md5sums -p$(pkgimg)
285 dh_builddeb -p$(pkgimg) -- -Zbzip2 -z9
286
287 dh_installchangelogs -p$(pkghdr)
288 dh_installdocs -p$(pkghdr)
289 dh_compress -p$(pkghdr)
290 dh_fixperms -p$(pkghdr)
291 dh_shlibdeps -p$(pkghdr)
292 dh_installdeb -p$(pkghdr)
293 dh_gencontrol -p$(pkghdr)
294 dh_md5sums -p$(pkghdr)
295 dh_builddeb -p$(pkghdr)
296
297ifneq ($(skipsub),true)
298 @set -e; for sub in $($(*)_sub); do \
299 pkg=$(bin_pkg_name)-$$sub; \
300 dh_installchangelogs -p$$pkg; \
301 dh_installdocs -p$$pkg; \
302 dh_compress -p$$pkg; \
303 dh_fixperms -p$$pkg -X/boot/; \
304 dh_shlibdeps -p$$pkg; \
305 dh_installdeb -p$$pkg; \
306 dh_gencontrol -p$$pkg; \
307 dh_md5sums -p$$pkg; \
308 dh_builddeb -p$$pkg; \
309 done
310endif
311
312ifneq ($(skipdbg),true)
313 dh_installchangelogs -p$(dbgpkg)
314 dh_installdocs -p$(dbgpkg)
315 dh_compress -p$(dbgpkg)
316 dh_fixperms -p$(dbgpkg)
317 dh_installdeb -p$(dbgpkg)
318 dh_gencontrol -p$(dbgpkg)
319 dh_md5sums -p$(dbgpkg)
320 dh_builddeb -p$(dbgpkg)
321
322 # Hokay...here's where we do a little twiddling...
323 # Renaming the debug package prevents it from getting into
324 # the primary archive, and therefore prevents this very large
325 # package from being mirrored. It is instead, through some
326 # archive admin hackery, copied to http://ddebs.ubuntu.com.
327 #
328 mv ../$(dbgpkg)_$(release)-$(revision)_$(arch).deb \
329 ../$(dbgpkg)_$(release)-$(revision)_$(arch).ddeb
330 set -e; \
331 if grep -qs '^Build-Debug-Symbols: yes$$' /CurrentlyBuilding; then \
332 sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files; \
333 else \
334 grep -v '^$(dbgpkg)_.*$$' debian/files > debian/files.new; \
335 mv debian/files.new debian/files; \
336 fi
337 # Now, the package wont get into the archive, but it will get put
338 # into the debug system.
339endif
340ifneq ($(full_build),false)
341 # Clean out this flavours build directory.
342 rm -rf $(builddir)/build-$*
343 # Clean out the debugging package source directory.
344 rm -rf $(dbgpkgdir)
345endif
346
347$(stampdir)/stamp-flavours:
348 @echo $(flavours) > $@
349
350#
351# per-architecture packages
352#
353$(stampdir)/stamp-prepare-perarch:
354 @echo "Preparing perarch ..."
355ifeq ($(do_tools),true)
356 rm -rf $(builddir)/tools-$*
357 install -d $(builddir)/tools-$*
358 for i in *; do ln -s $(CURDIR)/$$i $(builddir)/tools-$*/; done
359 rm $(builddir)/tools-$*/tools
360 rsync -a tools/ $(builddir)/tools-$*/tools/
361endif
362 touch $@
363
364$(stampdir)/stamp-build-perarch: prepare-perarch
365ifeq ($(do_tools),true)
366 cd $(builddir)/tools-$*/tools/perf && make $(CROSS_COMPILE)
367endif
368 @touch $@
369
370install-perarch: toolspkgdir = $(CURDIR)/debian/$(tools_pkg_name)
371install-perarch: $(stampdir)/stamp-build-perarch
372 # Add the tools.
373ifeq ($(do_tools),true)
374 install -d $(toolspkgdir)/usr/bin
375 install -s -m755 $(builddir)/tools-$*/tools/perf/perf \
376 $(toolspkgdir)/usr/bin/perf_$(abi_release)
377endif
378
379binary-perarch: toolspkg = $(tools_pkg_name)
380binary-perarch: install-perarch
381 @# Empty for make to be happy
382ifeq ($(do_tools),true)
383 dh_installchangelogs -p$(toolspkg)
384 dh_installdocs -p$(toolspkg)
385 dh_compress -p$(toolspkg)
386 dh_fixperms -p$(toolspkg)
387 dh_shlibdeps -p$(toolspkg)
388 dh_installdeb -p$(toolspkg)
389 dh_gencontrol -p$(toolspkg)
390 dh_md5sums -p$(toolspkg)
391 dh_builddeb -p$(toolspkg)
392endif
393
394binary-debs: binary-perarch $(stampdir)/stamp-flavours $(addprefix binary-,$(flavours))
395
396build-arch-deps-$(do_flavour_image_package) += $(addprefix build-,$(flavours))
397build-arch: $(build-arch-deps-true)
398
399binary-arch-deps-$(do_flavour_image_package) = binary-debs
400ifeq ($(AUTOBUILD),)
401binary-arch-deps-$(do_flavour_image_package) += binary-udebs
402endif
403binary-arch-deps-$(do_libc_dev_package) += binary-arch-headers
404ifneq ($(do_common_headers_indep),true)
405binary-arch-deps-$(do_flavour_header_package) += binary-headers
406endif
407binary-arch: $(binary-arch-deps-true)
diff --git a/debian/rules.d/3-binary-indep.mk b/debian/rules.d/3-binary-indep.mk
new file mode 100644
index 00000000000..d929bd56b31
--- /dev/null
+++ b/debian/rules.d/3-binary-indep.mk
@@ -0,0 +1,132 @@
1build-indep:
2
3docpkg = $(doc_pkg_name)
4docdir = $(CURDIR)/debian/$(docpkg)/usr/share/doc/$(docpkg)
5install-doc:
6 dh_testdir
7 dh_testroot
8 dh_clean -k -p$(docpkg)
9
10 install -d $(docdir)
11ifeq ($(do_doc_package_content),true)
12 # First the html docs. We skip these for autobuilds
13 if [ -z "$(AUTOBUILD)" ]; then \
14 install -d $(docdir)/$(doc_pkg_name)-tmp; \
15 $(kmake) O=$(docdir)/$(doc_pkg_name)-tmp htmldocs; \
16 mv $(docdir)/$(doc_pkg_name)-tmp/Documentation/DocBook \
17 $(docdir)/html; \
18 rm -rf $(docdir)/$(doc_pkg_name)-tmp; \
19 fi
20endif
21 # Copy the rest
22 cp -a Documentation/* $(docdir)
23 rm -rf $(docdir)/DocBook
24 find $(docdir) -name .gitignore | xargs rm -f
25
26indep_hdrpkg = $(hdrs_pkg_name)
27indep_hdrdir = $(CURDIR)/debian/$(indep_hdrpkg)/usr/src/$(indep_hdrpkg)
28install-headers:
29 dh_testdir
30 dh_testroot
31 dh_clean -k -p$(indep_hdrpkg)
32
33 install -d $(indep_hdrdir)
34 find . -path './debian' -prune -o -path './$(DEBIAN)' -prune \
35 -o -path './include/*' -prune \
36 -o -path './scripts/*' -prune -o -type f \
37 \( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
38 -name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \
39 -print | cpio -pd --preserve-modification-time $(indep_hdrdir)
40 cp -a drivers/media/dvb/dvb-core/*.h $(indep_hdrdir)/drivers/media/dvb/dvb-core
41 cp -a drivers/media/video/*.h $(indep_hdrdir)/drivers/media/video
42 cp -a drivers/media/dvb/frontends/*.h $(indep_hdrdir)/drivers/media/dvb/frontends
43 cp -a scripts include $(indep_hdrdir)
44 (find arch -name include -type d -print | \
45 xargs -n1 -i: find : -type f) | \
46 cpio -pd --preserve-modification-time $(indep_hdrdir)
47
48srcpkg = $(src_pkg_name)-source-$(release)
49srcdir = $(CURDIR)/debian/$(srcpkg)/usr/src/$(srcpkg)
50balldir = $(CURDIR)/debian/$(srcpkg)/usr/src/$(srcpkg)/$(srcpkg)
51install-source:
52 dh_testdir
53 dh_testroot
54 dh_clean -k -p$(srcpkg)
55
56 install -d $(srcdir)
57ifeq ($(do_source_package_content),true)
58 find . -path './debian' -prune -o -path './$(DEBIAN)' -prune -o \
59 -path './.*' -prune -o -print | \
60 cpio -pd --preserve-modification-time $(balldir)
61 (cd $(srcdir); tar cf - $(srcpkg)) | bzip2 -9c > \
62 $(srcdir)/$(srcpkg).tar.bz2
63 rm -rf $(balldir)
64 find './debian' './$(DEBIAN)' \
65 -path './debian/linux-*' -prune -o \
66 -path './debian/$(src_pkg_name)-*' -prune -o \
67 -path './debian/build' -prune -o \
68 -path './debian/files' -prune -o \
69 -path './debian/stamps' -prune -o \
70 -path './debian/tmp' -prune -o \
71 -print | \
72 cpio -pd --preserve-modification-time $(srcdir)
73 ln -s $(srcpkg)/$(srcpkg).tar.bz2 $(srcdir)/..
74endif
75
76install-tools: toolspkg = $(tools_common_pkg_name)
77install-tools: toolsbin = $(CURDIR)/debian/$(toolspkg)/usr/bin
78install-tools: toolsman = $(CURDIR)/debian/$(toolspkg)/usr/share/man
79install-tools:
80 dh_testdir
81 dh_testroot
82 dh_clean -k -p$(toolspkg)
83
84 install -d $(toolsbin)
85 install -d $(toolsman)/man1
86
87 install -m755 debian/tools/perf $(toolsbin)/perf
88
89 rm -rf $(builddir)/tools
90 install -d $(builddir)/tools
91 for i in *; do ln -s $(CURDIR)/$$i $(builddir)/tools/; done
92 rm $(builddir)/tools/tools
93 rsync -a tools/ $(builddir)/tools/tools/
94
95 cd $(builddir)/tools/tools/perf && make man
96 install -m644 $(builddir)/tools/tools/perf/Documentation/*.1 \
97 $(toolsman)/man1
98
99ifeq ($(do_common_headers_indep),true)
100install-indep-deps-$(do_flavour_header_package) += install-headers
101endif
102install-indep-deps-$(do_doc_package) += install-doc
103install-indep-deps-$(do_source_package) += install-source
104install-indep-deps-$(do_tools) += install-tools
105install-indep: $(install-indep-deps-true)
106
107# This is just to make it easy to call manually. Normally done in
108# binary-indep target during builds.
109binary-headers: install-headers
110 dh_testdir
111 dh_testroot
112 dh_installchangelogs -p$(indep_hdrpkg)
113 dh_installdocs -p$(indep_hdrpkg)
114 dh_compress -p$(indep_hdrpkg)
115 dh_fixperms -p$(indep_hdrpkg)
116 dh_installdeb -p$(indep_hdrpkg)
117 dh_gencontrol -p$(indep_hdrpkg)
118 dh_md5sums -p$(indep_hdrpkg)
119 dh_builddeb -p$(indep_hdrpkg)
120
121binary-indep: install-indep
122 dh_testdir
123 dh_testroot
124
125 dh_installchangelogs -i
126 dh_installdocs -i
127 dh_compress -i
128 dh_fixperms -i
129 dh_installdeb -i
130 dh_gencontrol -i
131 dh_md5sums -i
132 dh_builddeb -i
diff --git a/debian/rules.d/4-checks.mk b/debian/rules.d/4-checks.mk
new file mode 100644
index 00000000000..d48c05d6260
--- /dev/null
+++ b/debian/rules.d/4-checks.mk
@@ -0,0 +1,34 @@
1# Check ABI for package against last release (if not same abinum)
2abi-%: $(abidir)/%
3 @# Empty for make to be happy
4$(abidir)/%: $(stampdir)/stamp-build-%
5 install -d $(abidir)
6 sed -e 's/^\(.\+\)[[:space:]]\+\(.\+\)[[:space:]]\(.\+\)$$/\3 \2 \1/' \
7 $(builddir)/build-$*/Module.symvers | sort > $@
8
9abi-check-%: $(abidir)/%
10 @perl -f $(DROOT)/scripts/abi-check "$*" "$(prev_abinum)" "$(abinum)" \
11 "$(prev_abidir)" "$(abidir)" "$(skipabi)"
12
13# Check the module list against the last release (always)
14module-%: $(abidir)/%.modules
15 @# Empty for make to be happy
16$(abidir)/%.modules: $(stampdir)/stamp-build-%
17 install -d $(abidir)
18 find $(builddir)/build-$*/ -name \*.ko | \
19 sed -e 's/.*\/\([^\/]*\)\.ko/\1/' | sort > $@
20
21module-check-%: $(abidir)/%.modules
22 @perl -f $(DROOT)/scripts/module-check "$*" \
23 "$(prev_abidir)" "$(abidir)" $(skipmodule)
24
25checks-%: abi-check-% module-check-%
26 @# Will be calling more stuff later
27
28# Check the config against the known options list.
29config-prepare-check-%: $(stampdir)/stamp-prepare-tree-%
30 @perl -f $(DROOT)/scripts/config-check \
31 $(builddir)/build-$*/.config "$(arch)" "$*" "$(sharedconfdir)" "$(skipconfig)"
32
33prepare-checks-%: config-prepare-check-%
34 @# Will be calling more stuff later
diff --git a/debian/rules.d/5-udebs.mk b/debian/rules.d/5-udebs.mk
new file mode 100644
index 00000000000..24fbadffc8d
--- /dev/null
+++ b/debian/rules.d/5-udebs.mk
@@ -0,0 +1,38 @@
1# Do udebs if not disabled in the arch-specific makefile
2binary-udebs: binary-debs debian/control
3ifeq ($(disable_d_i),)
4 @$(MAKE) --no-print-directory -f $(DROOT)/rules DEBIAN=$(DEBIAN) \
5 do-binary-udebs
6endif
7
8do-binary-udebs:
9 dh_testdir
10 dh_testroot
11
12 # unpack the kernels into a temporary directory
13 mkdir -p debian/d-i-${arch}
14
15 imagelist=$$(cat $(builddir)/kernel-versions | grep ^${arch} | awk '{print $$4}') && \
16 for i in $$imagelist; do \
17 dpkg -x $$(ls ../linux-image-$$i\_$(release)-$(revision)_${arch}.deb) \
18 debian/d-i-${arch}; \
19 /sbin/depmod -b debian/d-i-${arch} $$i; \
20 done
21
22 # kernel-wedge will error if no modules unless this is touched
23 touch $(CURDIR)/debian/build/no-modules
24
25 touch ignore-dups
26 export SOURCEDIR=$(CURDIR)/debian/d-i-${arch} && \
27 cd $(builddir) && \
28 kernel-wedge install-files && \
29 kernel-wedge check
30
31 # Build just the udebs
32 dilist=$$(dh_listpackages -s | grep "\-di$$") && \
33 [ -z "$dilist" ] || \
34 for i in $$dilist; do \
35 dh_fixperms -p$$i; \
36 dh_gencontrol -p$$i; \
37 dh_builddeb -p$$i; \
38 done
diff --git a/debian/scripts/abi-check b/debian/scripts/abi-check
new file mode 100755
index 00000000000..c7a02c5589a
--- /dev/null
+++ b/debian/scripts/abi-check
@@ -0,0 +1,210 @@
1#!/usr/bin/perl -w
2
3my $flavour = shift;
4my $prev_abinum = shift;
5my $abinum = shift;
6my $prev_abidir = shift;
7my $abidir = shift;
8my $skipabi = shift;
9
10my $fail_exit = 1;
11my $EE = "EE:";
12my $errors = 0;
13my $abiskip = 0;
14
15my $count;
16
17print "II: Checking ABI for $flavour...\n";
18
19if (-f "$prev_abidir/ignore"
20 or -f "$prev_abidir/$flavour.ignore" or "$skipabi" eq "true") {
21 print "WW: Explicitly asked to ignore ABI, running in no-fail mode\n";
22 $fail_exit = 0;
23 $abiskip = 1;
24 $EE = "WW:";
25}
26
27if ($prev_abinum != $abinum) {
28 print "II: Different ABI's, running in no-fail mode\n";
29 $fail_exit = 0;
30 $EE = "WW:";
31}
32
33if (not -f "$abidir/$flavour" or not -f "$prev_abidir/$flavour") {
34 print "EE: Previous or current ABI file missing!\n";
35 print " $abidir/$flavour\n" if not -f "$abidir/$flavour";
36 print " $prev_abidir/$flavour\n" if not -f "$prev_abidir/$flavour";
37
38 # Exit if the ABI files are missing, but return status based on whether
39 # skip ABI was indicated.
40 if ("$abiskip" eq "1") {
41 exit(0);
42 } else {
43 exit(1);
44 }
45}
46
47my %symbols;
48my %symbols_ignore;
49my %modules_ignore;
50my %module_syms;
51
52# See if we have any ignores
53my $ignore = 0;
54print " Reading symbols/modules to ignore...";
55
56for $file ("$prev_abidir/../blacklist", "$prev_abidir/../../perm-blacklist") {
57 if (-f $file) {
58 open(IGNORE, "< $file") or
59 die "Could not open $file";
60 while (<IGNORE>) {
61 chomp;
62 if ($_ =~ m/M: (.*)/) {
63 $modules_ignore{$1} = 1;
64 } else {
65 $symbols_ignore{$_} = 1;
66 }
67 $ignore++;
68 }
69 close(IGNORE);
70 }
71}
72print "read $ignore symbols/modules.\n";
73
74sub is_ignored($$) {
75 my ($mod, $sym) = @_;
76
77 die "Missing module name in is_ignored()" if not defined($mod);
78 die "Missing symbol name in is_ignored()" if not defined($sym);
79
80 if (defined($symbols_ignore{$sym}) or defined($modules_ignore{$mod})) {
81 return 1;
82 }
83 return 0;
84}
85
86# Read new syms first
87print " Reading new symbols ($abinum)...";
88$count = 0;
89open(NEW, "< $abidir/$flavour") or
90 die "Could not open $abidir/$flavour";
91while (<NEW>) {
92 chomp;
93 m/^(\S+)\s(.+)\s(0x[0-9a-f]+)\s(.+)$/;
94 $symbols{$4}{'type'} = $1;
95 $symbols{$4}{'loc'} = $2;
96 $symbols{$4}{'hash'} = $3;
97 $module_syms{$2} = 0;
98 $count++;
99}
100close(NEW);
101print "read $count symbols.\n";
102
103# Now the old symbols, checking for missing ones
104print " Reading old symbols ($prev_abinum)...";
105$count = 0;
106open(OLD, "< $prev_abidir/$flavour") or
107 die "Could not open $prev_abidir/$flavour";
108while (<OLD>) {
109 chomp;
110 m/^(\S+)\s(.+)\s(0x[0-9a-f]+)\s(.+)$/;
111 $symbols{$4}{'old_type'} = $1;
112 $symbols{$4}{'old_loc'} = $2;
113 $symbols{$4}{'old_hash'} = $3;
114 $count++;
115}
116close(OLD);
117
118print "read $count symbols.\n";
119
120print "II: Checking for missing symbols in new ABI...";
121$count = 0;
122foreach $sym (keys(%symbols)) {
123 if (!defined($symbols{$sym}{'type'})) {
124 print "\n" if not $count;
125 printf(" MISS : %s%s\n", $sym,
126 is_ignored($symbols{$sym}{'old_loc'}, $sym) ? " (ignored)" : "");
127 $count++ if !is_ignored($symbols{$sym}{'old_loc'}, $sym);
128 }
129}
130print " " if $count;
131print "found $count missing symbols\n";
132if ($count) {
133 print "$EE Symbols gone missing (what did you do!?!)\n";
134 $errors++;
135}
136
137
138print "II: Checking for new symbols in new ABI...";
139$count = 0;
140foreach $sym (keys(%symbols)) {
141 if (!defined($symbols{$sym}{'old_type'})) {
142 print "\n" if not $count;
143 print " NEW : $sym\n";
144 $count++;
145 }
146}
147print " " if $count;
148print "found $count new symbols\n";
149if ($count and $prev_abinum == $abinum) {
150 print "WW: Found new symbols within same ABI. Not recommended\n";
151}
152
153print "II: Checking for changes to ABI...\n";
154$count = 0;
155my $moved = 0;
156my $changed_type = 0;
157my $changed_hash = 0;
158foreach $sym (keys(%symbols)) {
159 if (!defined($symbols{$sym}{'old_type'}) or
160 !defined($symbols{$sym}{'type'})) {
161 next;
162 }
163
164 # Changes in location don't hurt us, but log it anyway
165 if ($symbols{$sym}{'loc'} ne $symbols{$sym}{'old_loc'}) {
166 printf(" MOVE : %-40s : %s => %s\n", $sym, $symbols{$sym}{'old_loc'},
167 $symbols{$sym}{'loc'});
168 $moved++;
169 }
170
171 # Changes to export type are only bad if new type isn't
172 # EXPORT_SYMBOL. Changing things to GPL are bad.
173 if ($symbols{$sym}{'type'} ne $symbols{$sym}{'old_type'}) {
174 printf(" TYPE : %-40s : %s => %s%s\n", $sym, $symbols{$sym}{'old_type'}.
175 $symbols{$sym}{'type'}, is_ignored($symbols{$sym}{'loc'}, $sym)
176 ? " (ignored)" : "");
177 $changed_type++ if $symbols{$sym}{'type'} ne "EXPORT_SYMBOL"
178 and !is_ignored($symbols{$sym}{'loc'}, $sym);
179 }
180
181 # Changes to the hash are always bad
182 if ($symbols{$sym}{'hash'} ne $symbols{$sym}{'old_hash'}) {
183 printf(" HASH : %-40s : %s => %s%s\n", $sym, $symbols{$sym}{'old_hash'},
184 $symbols{$sym}{'hash'}, is_ignored($symbols{$sym}{'loc'}, $sym)
185 ? " (ignored)" : "");
186 $changed_hash++ if !is_ignored($symbols{$sym}{'loc'}, $sym);
187 $module_syms{$symbols{$sym}{'loc'}}++;
188 }
189}
190
191print "WW: $moved symbols changed location\n" if $moved;
192print "$EE $changed_type symbols changed export type and weren't ignored\n" if $changed_type;
193print "$EE $changed_hash symbols changed hash and weren't ignored\n" if $changed_hash;
194
195$errors++ if $changed_hash or $changed_type;
196if ($changed_hash) {
197 print "II: Module hash change summary...\n";
198 foreach $mod (sort { $module_syms{$b} <=> $module_syms{$a} } keys %module_syms) {
199 next if ! $module_syms{$mod};
200 printf(" %-40s: %d\n", $mod, $module_syms{$mod});
201 }
202}
203
204print "II: Done\n";
205
206if ($errors) {
207 exit($fail_exit);
208} else {
209 exit(0);
210}
diff --git a/debian/scripts/config-check b/debian/scripts/config-check
new file mode 100755
index 00000000000..47166f49681
--- /dev/null
+++ b/debian/scripts/config-check
@@ -0,0 +1,389 @@
1#!/usr/bin/perl
2#
3# check-config -- check the current config for issues
4#
5use strict;
6
7my $P = 'check-config';
8
9my $test = -1;
10if ($ARGV[0] eq '--test') {
11 $test = $ARGV[1] + 0;
12} elsif ($#ARGV != 4) {
13 die "Usage: $P <config> <arch> <flavour> <commonconfig> <warn-only>\n";
14}
15
16my ($config, $arch, $flavour, $commonconfig, $warn_only) = @ARGV;
17
18my $checks = "$commonconfig/enforce";
19my %values = ();
20
21# If we are in overridden then still perform the checks and emit the messages
22# but do not return failure. Those items marked FATAL will alway trigger
23# failure.
24my $fail_exit = 1;
25$fail_exit = 0 if ($warn_only eq 'true' || $warn_only eq '1');
26my $exit_val = 0;
27
28# Predicate execution engine.
29sub pred_first {
30 my ($rest) = @_;
31 my $depth = 0;
32 my $off;
33 my $char;
34 my $pred;
35
36 for ($off = 0; $off <= length($rest); $off++) {
37 $char = substr($rest, $off, 1);
38 if ($char eq '(') {
39 $depth++;
40 } elsif ($char eq ')') {
41 $depth--;
42 } elsif ($depth == 0 && $char eq '&') {
43 last;
44 } elsif ($depth == 0 && $char eq '|') {
45 last;
46 }
47 }
48 if ($depth > 0) {
49 die "$P: $rest: missing close parenthesis ')'\n";
50 } elsif ($depth < 0) {
51 die "$P: $rest: missing open parenthesis '('\n";
52 }
53
54 ($pred, $rest) = (substr($rest, 0, $off), substr($rest, $off + 1));
55
56 $pred =~ s/^\s*//;
57 $pred =~ s/\s*$//;
58
59 #print "pred<$pred> rest<$rest> char<$char>\n";
60 ($pred, $rest, $char);
61}
62
63sub pred_do {
64 my ($pred) = @_;
65 my (@a) = split(' ', $pred);
66
67 if ($a[0] eq 'arch') {
68 die "$P: $pred: malformed -- $pred <arch>\n" if ($#a != 1);
69 #print " *** ARCH<$arch ?? $a[1]>\n";
70 return ($arch eq $a[1])
71 } elsif ($a[0] eq 'flavour') {
72 die "$P: $pred: malformed -- $pred <flavour>\n" if ($#a != 1);
73 #print " *** FLAVOUR<$flavour ?? $a[1]>\n";
74 return ($flavour eq $a[1])
75 } elsif ($a[0] eq 'value') {
76 die "$P: $pred: malformed -- $pred <name> <val>\n" if ($#a != 2);
77 #print " *** CHECK<$a[1] $a[2] ?? " . $values{$a[1]} . ">\n";
78 return ($values{$a[1]} eq $a[2]);
79 } elsif ($a[0] eq 'exists') {
80 die "$P: $pred: malformed -- $pred <name>\n" if ($#a != 1);
81 return (defined $values{$a[1]});
82 } else {
83 die "$P: $pred: unknown predicate\n";
84 }
85 return 1;
86}
87sub pred_exec {
88 my ($rest) = @_;
89 my $pred;
90 my $res;
91 my $sep;
92
93 #print "pred_exec<$rest>\n";
94
95 ($pred, $rest, $sep) = pred_first($rest);
96
97 # Leading ! implies inversion.
98 if ($pred =~ /^\s*!\s*(.*)$/) {
99 #print " invert<$1>\n";
100 $res = !pred_exec($1);
101
102 # Recurse left for complex expressions.
103 } elsif ($pred =~ /^\s*\((.*)\)\s*$/) {
104 #print " left<$1>\n";
105 $res = pred_exec($1);
106
107 # Check for common syntax issues.
108 } elsif ($pred eq '') {
109 if ($sep eq '&' || $sep eq '|') {
110 die "$P: $pred$rest: malformed binary operator\n";
111 } else {
112 die "$P: $pred$rest: syntax error\n";
113 }
114
115 # A predicate, execute it.
116 } else {
117 #print " DO<$pred> sep<$sep>\n";
118 $res = pred_do($pred);
119 }
120
121 #print " pre-return res<$res> sep<$sep>\n";
122 if ($sep eq '') {
123 #
124
125 # Recurse right for binary operators -- note these are lazy.
126 } elsif ($sep eq '&' || $sep eq '|') {
127 #print " right<$rest> ? sep<$sep> res<$res>\n";
128 if ($rest =~ /^\s*($|\||\&)/) {
129 die "$P: $pred$rest: malformed binary operator\n";
130 }
131 if (($res && $sep eq '&') || (!$res && $sep eq '|')) {
132 #print " right<$rest>\n";
133 $res = pred_exec($rest);
134 }
135
136 } else {
137 die "$P: $pred$rest: malformed predicate\n";
138 }
139 #print " return res<$res> sep<$sep>\n";
140 return $res;
141}
142
143#
144# PREDICATE TESTS
145#
146my $test_total = 1;
147my $test_good = 0;
148sub pred_test {
149 my ($pred, $eres, $eerr) = @_;
150 my ($res, $err, $fail);
151
152 $test_total++;
153 if ($test != 0 && $test != $test_total - 1) {
154 return;
155 }
156
157 eval {
158 $res = pred_exec($pred);
159 };
160 $err = $@;
161 chomp($err);
162
163 $res = !!$res;
164 $eres = !!$eres;
165
166 $fail = '';
167 if (defined $eres && $res != $eres) {
168 $fail = "result missmatch, expected $eres returned $res";
169 }
170 if (defined $eerr && $err eq '') {
171 $fail = "error missmatch, expected '$eerr' returned success";
172 } elsif (defined $eerr && $err !~ /$eerr/) {
173 $fail = "error missmatch, expected '$eerr' returned '$err'";
174 } elsif (!defined $eerr && $err ne '') {
175 $fail = "error missmatch, expected success returned '$err'";
176 }
177
178 if ($fail eq '') {
179 $test_good++;
180 } else {
181 print "$pred: $test_total: FAIL: $fail\n";
182 }
183 #print "TEST<$pred> eres<$eres> eerr<$eerr> res<$res> err<$err>\n";
184}
185if ($test >= 0) {
186 $arch = 'MYARCH';
187 $flavour = 'MYFLAVOUR';
188 %values = ( 'ENABLED' => 'y', 'DISABLED' => 'n' );
189
190 # Errors.
191 my $eunkn = 'unknown predicate';
192 my $epred = 'malformed';
193 my $eclose = 'missing close parenthesis';
194 my $eopen = 'missing open parenthesis';
195 my $ebinary = 'malformed binary operator';
196
197 # Basic predicate tests.
198 print "TEST: $test_total: basic predicate tests ...\n";
199
200 pred_test('nosuchcommand', undef, $eunkn);
201 pred_test('arch', undef, $epred);
202 pred_test('arch MYARCH MYARCH', undef, $epred);
203 pred_test('arch MYARCH', 1, undef);
204 pred_test('arch NOTMYARCH', 0, undef);
205
206 pred_test('flavour', undef, $epred);
207 pred_test('flavour MYFLAVOUR myflavour', undef, $epred);
208 pred_test('flavour MYFLAVOUR', 1, undef);
209 pred_test('flavour NOTMYFLAVOUR', 0, undef);
210
211 pred_test('value', undef, $epred);
212 pred_test('value ENABLED', undef, $epred);
213 pred_test('value ENABLED ENABLED ENABLED', undef, $epred);
214 pred_test('value ENABLED y', 1, undef);
215 pred_test('value ENABLED n', 0, undef);
216 pred_test('value DISABLED n', 1, undef);
217 pred_test('value DISABLED y', 0, undef);
218
219 pred_test('exists', undef, $epred);
220 pred_test('exists ENABLED ENABLED', undef, $epred);
221 pred_test('exists ENABLED', 1, undef);
222 pred_test('exists DISABLED', 1, undef);
223 pred_test('exists MISSING', 0, undef);
224
225 print "TEST: $test_total: inversion tests ...\n";
226 pred_test('!exists ENABLED', 0, undef);
227 pred_test('!exists MISSING', 1, undef);
228 pred_test('!!exists ENABLED', 1, undef);
229 pred_test('!!exists MISSING', 0, undef);
230 pred_test('!!!exists ENABLED', 0, undef);
231 pred_test('!!!exists MISSING', 1, undef);
232
233 print "TEST: $test_total: parentheses tests ...\n";
234 pred_test('(exists ENABLED)', 1, undef);
235 pred_test('((exists ENABLED))', 1, undef);
236 pred_test('(((exists ENABLED)))', 1, undef);
237 pred_test('(exists MISSING)', 0, undef);
238 pred_test('((exists MISSING))', 0, undef);
239 pred_test('(((exists MISSING)))', 0, undef);
240
241 pred_test('(!exists ENABLED)', 0, undef);
242 pred_test('((!exists ENABLED))', 0, undef);
243 pred_test('(((!exists ENABLED)))', 0, undef);
244 pred_test('(!exists MISSING)', 1, undef);
245 pred_test('((!exists MISSING))', 1, undef);
246 pred_test('(((!exists MISSING)))', 1, undef);
247
248 pred_test('((!(exists ENABLED)))', 0, undef);
249 pred_test('((!(exists MISSING)))', 1, undef);
250 pred_test('(!((exists ENABLED)))', 0, undef);
251 pred_test('(!((exists MISSING)))', 1, undef);
252 pred_test('!(((exists ENABLED)))', 0, undef);
253 pred_test('!(((exists MISSING)))', 1, undef);
254 pred_test('!((!(exists ENABLED)))', 1, undef);
255 pred_test('!((!(exists MISSING)))', 0, undef);
256 pred_test('!(!(!(exists ENABLED)))', 0, undef);
257 pred_test('!(!(!(exists MISSING)))', 1, undef);
258
259 pred_test('(', undef, $eclose);
260 pred_test('()(', undef, $eclose);
261 pred_test('(())(', undef, $eclose);
262 pred_test('((()))(', undef, $eclose);
263 pred_test('(()', undef, $eclose);
264 pred_test('((())', undef, $eclose);
265 pred_test('(((()))', undef, $eclose);
266 pred_test('(()()', undef, $eclose);
267 pred_test('((())()', undef, $eclose);
268
269 pred_test(')', undef, $eopen);
270 pred_test('())', undef, $eopen);
271 pred_test('(()))', undef, $eopen);
272 pred_test('((())))', undef, $eopen);
273
274 print "TEST: $test_total: binary and tests ...\n";
275
276 pred_test('exists ENABLED &', undef, $ebinary);
277 pred_test('& exists ENABLED', undef, $ebinary);
278 pred_test('exists ENABLED & & exists ENABLED', undef, $ebinary);
279
280 pred_test('exists MISSING & exists MISSING', 0, undef);
281 pred_test('exists MISSING & exists ENABLED', 0, undef);
282 pred_test('exists ENABLED & exists MISSING', 0, undef);
283 pred_test('exists ENABLED & exists ENABLED', 1, undef);
284
285 pred_test('exists MISSING & exists MISSING & exists MISSING', 0, undef);
286 pred_test('exists MISSING & exists MISSING & exists ENABLED', 0, undef);
287 pred_test('exists MISSING & exists ENABLED & exists MISSING', 0, undef);
288 pred_test('exists MISSING & exists ENABLED & exists ENABLED', 0, undef);
289 pred_test('exists ENABLED & exists MISSING & exists MISSING', 0, undef);
290 pred_test('exists ENABLED & exists MISSING & exists ENABLED', 0, undef);
291 pred_test('exists ENABLED & exists ENABLED & exists MISSING', 0, undef);
292 pred_test('exists ENABLED & exists ENABLED & exists ENABLED', 1, undef);
293
294 print "TEST: $test_total: binary or tests ...\n";
295
296 pred_test('exists ENABLED |', undef, $ebinary);
297 pred_test('| exists ENABLED', undef, $ebinary);
298 pred_test('exists ENABLED | | exists ENABLED', undef, $ebinary);
299
300 pred_test('exists MISSING | exists MISSING', 0, undef);
301 pred_test('exists MISSING | exists ENABLED', 1, undef);
302 pred_test('exists ENABLED | exists MISSING', 1, undef);
303 pred_test('exists ENABLED | exists ENABLED', 1, undef);
304
305 pred_test('exists MISSING | exists MISSING | exists MISSING', 0, undef);
306 pred_test('exists MISSING | exists MISSING | exists ENABLED', 1, undef);
307 pred_test('exists MISSING | exists ENABLED | exists MISSING', 1, undef);
308 pred_test('exists MISSING | exists ENABLED | exists ENABLED', 1, undef);
309 pred_test('exists ENABLED | exists MISSING | exists MISSING', 1, undef);
310 pred_test('exists ENABLED | exists MISSING | exists ENABLED', 1, undef);
311 pred_test('exists ENABLED | exists ENABLED | exists MISSING', 1, undef);
312 pred_test('exists ENABLED | exists ENABLED | exists ENABLED', 1, undef);
313
314 print "TEST: $test_total: binary or/and combination tests ...\n";
315
316 pred_test('exists MISSING | exists MISSING & exists MISSING', 0, undef);
317 pred_test('exists MISSING | exists MISSING & exists ENABLED', 0, undef);
318 pred_test('exists MISSING | exists ENABLED & exists MISSING', 0, undef);
319 pred_test('exists MISSING | exists ENABLED & exists ENABLED', 1, undef);
320 pred_test('exists ENABLED | exists MISSING & exists MISSING', 1, undef);
321 pred_test('exists ENABLED | exists MISSING & exists ENABLED', 1, undef);
322 pred_test('exists ENABLED | exists ENABLED & exists MISSING', 1, undef);
323 pred_test('exists ENABLED | exists ENABLED & exists ENABLED', 1, undef);
324
325 print "TEST: $test_total: binary and/or combination tests ...\n";
326
327 pred_test('exists MISSING & exists MISSING | exists MISSING', 0, undef);
328 pred_test('exists MISSING & exists MISSING | exists ENABLED', 0, undef);
329 pred_test('exists MISSING & exists ENABLED | exists MISSING', 0, undef);
330 pred_test('exists MISSING & exists ENABLED | exists ENABLED', 0, undef);
331 pred_test('exists ENABLED & exists MISSING | exists MISSING', 0, undef);
332 pred_test('exists ENABLED & exists MISSING | exists ENABLED', 1, undef);
333 pred_test('exists ENABLED & exists ENABLED | exists MISSING', 1, undef);
334 pred_test('exists ENABLED & exists ENABLED | exists ENABLED', 1, undef);
335
336 $test_total--;
337 print "TEST: $test_good/$test_total succeeded\n";
338
339 exit $exit_val;
340}
341
342# Load up the current configuration values -- FATAL if this fails
343print "$P: $config: loading config\n";
344open(CONFIG, "<$config") || die "$P: $config: open failed -- $! -- aborting\n";
345while (<CONFIG>) {
346 # Pull out values.
347 /^#*\s*(CONFIG_\w+)[\s=](.*)$/ or next;
348 if ($2 eq 'is not set') {
349 $values{$1} = 'n';
350 } else {
351 $values{$1} = $2;
352 }
353}
354close(CONFIG);
355
356# FATAL: Check if we have an enforcement list.
357my $pass = 0;
358my $total = 0;
359my $line = '';
360print "$P: $checks: loading checks\n";
361open(CHECKS, "<$checks") || die "$P: $checks: open failed -- $! -- aborting\n";
362while (<CHECKS>) {
363 /^#/ && next;
364 chomp;
365
366 $line .= $_;
367 if ($line =~ /\\$/) {
368 chop($line);
369 $line .= " ";
370 next;
371 }
372 $line =~ /^\s*$/ && next;
373
374 #print "CHECK: <$line>\n";
375 $total++;
376 my $result = pred_exec($line);
377 if (!$result) {
378 print "$P: FAIL: $line\n";
379 $exit_val = $fail_exit;
380 } else {
381 $pass++;
382 }
383
384 $line = '';
385}
386close(CHECKS);
387
388print "$P: $pass/$total checks passed -- exit $exit_val\n";
389exit $exit_val;
diff --git a/debian/scripts/control-create b/debian/scripts/control-create
new file mode 100755
index 00000000000..f8ee9a2408e
--- /dev/null
+++ b/debian/scripts/control-create
@@ -0,0 +1,25 @@
1#!/bin/bash
2
3. debian/debian.env
4
5vars=$1
6
7. $vars
8
9if [ "$is_sub" = "" ]; then
10 flavour=$(basename $vars | sed 's/.*\.//')
11 stub=${DEBIAN}/control.d/flavour-control.stub
12else
13 flavour=$(basename $vars .vars)
14 stub=${DEBIAN}/sub-flavours/control.stub
15fi
16
17cat $stub | grep -v '^#' | sed \
18 -e "s#FLAVOUR#$flavour#g" \
19 -e "s#DESC#$desc#g" \
20 -e "s#ARCH#$arch#g" \
21 -e "s#SUPPORTED#$supported#g" \
22 -e "s#TARGET#$target#g" \
23 -e "s#BOOTLOADER#$bootloader#g" \
24 -e "s#=PROVIDES=#$provides#g" \
25 -e "s#=CONFLICTS=#$conflicts#g"
diff --git a/debian/scripts/link-headers b/debian/scripts/link-headers
new file mode 100755
index 00000000000..fb42dbd12e4
--- /dev/null
+++ b/debian/scripts/link-headers
@@ -0,0 +1,42 @@
1#!/bin/bash -e
2
3. debian/debian.env
4
5hdrdir="$1"
6symdir="$2"
7flavour="$3"
8
9echo "Symlinking and copying headers for $flavour..."
10
11excludes="( -path ./debian -prune -o -path ./${DEBIAN} -prune -o -path ./.git ) -prune -o"
12
13(
14find . $excludes -type f \
15 \( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
16 -name '*.sh' -o -name '*.pl' -o -name '*.lds' \) -print
17find ./include ./scripts -name .gitignore -prune -o -type f -print
18find ./include -mindepth 1 -maxdepth 1 $excludes -type d -print
19) | (
20while read file; do
21 dir=$file
22 lastdir=$file
23
24 if [ -e "$hdrdir/$file" -o -L "$hdrdir/$file" ]; then
25 continue
26 fi
27
28 while [ ! -e "$hdrdir/$dir" -a ! -L "$hdrdir/$dir" ]; do
29 lastdir=$dir
30 dir=`dirname $dir`
31 done
32 # If the last item to exist is a symlink we assume all is good
33 if [ ! -L "$hdrdir/$dir" ]; then
34 # Turns things like "./foo" into "../"
35 deref="`echo -n $lastdir | sed -e 's/^\.//' -e's,/[^/]*,../,g'`"
36 item="`echo -n $lastdir | sed -e 's/^\.\///'`"
37 ln -s $deref$symdir/$item $hdrdir/$item
38 fi
39done
40)
41
42exit
diff --git a/debian/scripts/misc/getabis b/debian/scripts/misc/getabis
new file mode 100755
index 00000000000..2a1fc552819
--- /dev/null
+++ b/debian/scripts/misc/getabis
@@ -0,0 +1,76 @@
1#!/bin/bash
2
3. debian/debian.env
4
5if [ "$#" != "2" ]; then
6 echo "Usage: $0 <release> <revision>" 1>&2
7 exit 1
8fi
9
10ver=$1
11revision=$2
12abi=$(echo $revision | awk -F. '{print $1}')
13
14verabi=$ver-$abi
15verfull=$ver-$revision
16
17WGET="wget --quiet -c"
18
19abidir="`pwd`/$DEBIAN/abi/$verfull"
20tmpdir="`pwd`/abi-tmp-$verfull"
21origdir="`pwd`"
22
23test -d $tmpdir || mkdir $tmpdir
24
25getall() {
26 arch=$1
27 shift
28
29 mkdir -p $abidir/$arch
30
31 for sub in $@; do
32 if [ -f $abidir/$arch/$sub ]; then
33 echo "Exists: $sub"
34 continue
35 fi
36 echo -n "Fetching $sub..."
37 filename=linux-image-${verabi}-${sub}_${verfull}_${arch}.deb
38 cd $tmpdir
39 for r in "${repo_list[@]}"
40 do
41 if ! [ -f $filename ]; then
42 $WGET $r/$filename
43 fi
44 done
45 if [ "$?" = "0" ]; then
46 echo -n "extracting..."
47 dpkg-deb --extract $filename tmp
48 if [ -f tmp/boot/abi-* ]; then
49 mv tmp/boot/abi-* $abidir/$arch/$sub
50 else
51 echo -n "NO ABI FILE..."
52 fi
53 (cd tmp; find lib/modules/$verabi-$sub/kernel -name '*.ko') | \
54 sed -e 's/.*\/\([^\/]*\)\.ko/\1/' | sort > \
55 $abidir/$arch/$sub.modules
56 rm -rf tmp $filename
57 echo "done."
58 else
59 echo "FAILED."
60 fi
61 cd $origdir
62 done
63}
64
65# MAIN
66
67# Setup abi directory
68mkdir -p $abidir
69echo $abi > $abidir/abiname
70
71# NOTE: The flavours are hardcoded, because they may have changed from the
72# current build.
73
74. $DEBIAN/etc/getabis
75
76rmdir $tmpdir
diff --git a/debian/scripts/misc/git-ubuntu-log b/debian/scripts/misc/git-ubuntu-log
new file mode 100755
index 00000000000..2967d875bd6
--- /dev/null
+++ b/debian/scripts/misc/git-ubuntu-log
@@ -0,0 +1,232 @@
1#!/usr/bin/perl -w
2
3use strict;
4use Text::Wrap;
5
6my $kernel_auth = "Upstream Kernel Changes";
7
8my (%map, @reverts);
9my $pstate = 1;
10my $no_kern_log = 0;
11my $print_shas = 0;
12my $first_print = 1;
13
14while (@ARGV) {
15 my $opt = $ARGV[0];
16 shift;
17 if ($opt eq "--no-kern-log") {
18 $no_kern_log = 1;
19 } elsif ($opt eq "--print-shas") {
20 $print_shas = 1;
21 } else {
22 print STDERR "Unknown options: $opt\n";
23 exit(1);
24 }
25}
26
27sub check_reverts($) {
28 my ($entry) = @_;
29 my ($check);
30
31 foreach $check (reverse @reverts) {
32 my $desc = "Revert \"" . $entry->{'desc'} . "\"";
33 if ($check->{'desc'} eq $desc) {
34 @reverts = grep($_->{'desc'} ne $desc, @reverts);
35 return 1;
36 }
37 }
38
39 return 0;
40}
41
42sub add_entry($) {
43 my ($entry) = @_;
44 my $key = $entry->{'author'};
45
46 # store description in array, in email->{desc list} map
47 if (exists $map{$key}) {
48 # grab ref
49 my $obj = $map{$key};
50
51 # add desc to array
52 push(@$obj, $entry);
53 } else {
54 # create new array, containing 1 item
55 my @arr = ($entry);
56
57 # store ref to array
58 $map{$key} = \@arr;
59 }
60}
61
62sub shortlog_entry($$$$$) {
63 my ($name, $desc, $bug, $cve, $commit) = @_;
64 my $entry;
65
66 $desc =~ s#/pub/scm/linux/kernel/git/#/.../#g;
67 $desc =~ s#\[PATCH\] ##g;
68
69 $desc =~ s#^\s*##g;
70 $desc =~ s# *UBUNTU: ##g;
71
72 $entry->{'desc'} = $desc;
73 if ($bug ne '') {
74 $entry->{'bugno'} = $bug;
75 }
76 $entry->{'cve'} = $cve;
77 $entry->{'commit'} = $commit;
78 $entry->{'author'} = $name;
79
80 if ($desc =~ /^Revert "/) {
81 push(@reverts, $entry);
82 return;
83 }
84
85 return if check_reverts($entry);
86
87 add_entry($entry);
88}
89
90# sort comparison function
91sub by_name($$) {
92 my ($a, $b) = @_;
93
94 uc($a) cmp uc($b);
95}
96
97sub shortlog_output {
98 my ($obj, $key, $entry);
99
100 foreach $key (sort by_name keys %map) {
101 next if $key eq $kernel_auth and $no_kern_log;
102
103 print "\n" unless $first_print;
104 $first_print = 0;
105
106 # output author
107 printf " [ %s ]\n\n", $key;
108
109 # output author's 1-line summaries
110 $obj = $map{$key};
111 foreach $entry (reverse @$obj) {
112 print wrap(" * ", " ", $entry->{'desc'}) . "\n";
113 # For non upstream changes, add other info.
114 if ($key ne $kernel_auth) {
115 if ($print_shas) {
116 print " - GIT-SHA " . $entry->{'commit'} .
117 "\n";
118 }
119 }
120 if (defined($entry->{'bugno'})) {
121 print " - LP: #" . $entry->{'bugno'} . "\n";
122 }
123 if (defined($entry->{'cve'})) {
124 print " - " . $entry->{'cve'} . "\n";
125 }
126 }
127 }
128}
129
130sub changelog_input {
131 my ($author, $desc, $commit, $entry, $cve);
132
133 while (<STDIN>) {
134 # get commit
135 if ($pstate == 1) {
136 next unless /^commit (.*)/;
137
138 $commit = $1;
139
140 $pstate++;
141 }
142
143 # get author and email
144 elsif ($pstate == 2) {
145 my ($email);
146
147 next unless /^[Aa]uthor:?\s*(.*?)\s*<(.*)>/;
148
149 $author = $1;
150 $email = $2;
151 $desc = undef;
152 $cve = undef;
153
154 # cset author fixups
155 if (!$author) {
156 $author = $email;
157 }
158 $pstate++;
159 }
160
161 # skip to blank line
162 elsif ($pstate == 3) {
163 next unless /^\s*$/;
164 $pstate++;
165 }
166
167 # skip to non-blank line
168 elsif ($pstate == 4) {
169 next unless /^\s*?(.*)/;
170 my $ignore = 0;
171 my $do_ignore = 0;
172 my $bug = undef;
173 my %bugz = ();
174 my $k;
175
176 # skip lines that are obviously not
177 # a 1-line cset description
178 next if /^\s*From: /;
179
180 chomp;
181 $desc = $1;
182
183 if ($desc =~ /^ *(Revert "|)UBUNTU:/) {
184 $do_ignore = 1;
185 } else {
186 $do_ignore = 0;
187 $author = $kernel_auth;
188 $ignore = 1 if $desc =~ /Merge /;
189 }
190 while (<STDIN>) {
191 $ignore = 1 if ($do_ignore && /^ *Ignore: yes/i);
192 if (/^ *Bug: *(#|)([0-9#,\s]*)\s*$/i) {
193 foreach $k (split('(,|\s)\s*(#|)', $2)) {
194 $bugz{$k} = 1 if (($k ne '') and ($k =~ /[0-9]+/));
195 }
196 }
197 elsif (/^ *BugLink: *http.*:\/\/.*\/([0-9]+)/i) {
198 $bugz{$1} = 1;
199 }
200 elsif (/^ *(CVE-.*)/) {
201 $cve = $1
202 }
203 last if /^commit /;
204 }
205
206 $bug = join(", #", sort keys(%bugz));
207 if (!$ignore) {
208 &shortlog_entry($author, $desc, $bug,
209 $cve, $commit, 0);
210 }
211
212 $pstate = 1;
213 if ($_ && /^commit (.*)/) {
214 $commit = $1;
215 $pstate++;
216 }
217 }
218
219 else {
220 die "invalid parse state $pstate";
221 }
222 }
223
224 foreach $entry (@reverts) {
225 add_entry($entry);
226 }
227}
228
229&changelog_input;
230&shortlog_output;
231
232exit(0);
diff --git a/debian/scripts/misc/insert-changes.pl b/debian/scripts/misc/insert-changes.pl
new file mode 100755
index 00000000000..c820597a9fc
--- /dev/null
+++ b/debian/scripts/misc/insert-changes.pl
@@ -0,0 +1,36 @@
1#!/usr/bin/perl -w
2
3my $debian;
4$droot = $ARGV[0] if (defined $ARGV[0]);
5$droot = 'debian' if (!defined $droot);
6$debian = $ARGV[1] if (defined $ARGV[1]);
7$debian = 'debian.master' if (!defined $debian);
8
9system("make -s -f $droot/rules printchanges > $debian/changes");
10
11open(CHANGELOG, "< $debian/changelog") or die "Cannot open changelog";
12open(CHANGES, "< $debian/changes") or die "Cannot open new changes";
13open(NEW, "> $debian/changelog.new") or die "Cannot open new changelog";
14
15$printed = 0;
16
17while (<CHANGELOG>) {
18 if (/^ CHANGELOG: /) {
19 next if $printed;
20
21 while (<CHANGES>) {
22 print NEW;
23 }
24
25 $printed = 1;
26 } else {
27 print NEW;
28 }
29}
30
31close(NEW);
32close(CHANGES);
33close(CHANGELOG);
34
35rename("$debian/changelog.new", "$debian/changelog");
36unlink("$debian/changes");
diff --git a/debian/scripts/misc/insert-ubuntu-changes b/debian/scripts/misc/insert-ubuntu-changes
new file mode 100755
index 00000000000..9ede7f3950d
--- /dev/null
+++ b/debian/scripts/misc/insert-ubuntu-changes
@@ -0,0 +1,58 @@
1#!/usr/bin/perl
2
3if ($#ARGV != 2) {
4 die "Usage: $0 <changelog> <stop at> <start at>\n";
5}
6my ($changelog, $end, $start) = @ARGV;
7
8$end =~ s/.*\.//;
9$start =~ s/.*\.//;
10
11my @changes = ();
12my $output = 0;
13open(CHG, "<debian.master/changelog") ||
14 open(CHG, "<debian/changelog") ||
15 die "$0: debian/changelog: open failed - $!\n";
16while (<CHG>) {
17 if (/^\S+\s+\((.*\.(\d+))\)/) {
18 if ($2 <= $end) {
19 last;
20 }
21 if ($2 == $start) {
22 $output = 1;
23 }
24 if ($output) {
25 push(@changes, "\n [ Ubuntu: $1 ]\n\n");
26 next;
27 }
28 }
29 next if ($output == 0);
30
31 next if (/^\s*$/);
32 next if (/^\s--/);
33 next if (/^\s\s[^\*\s]/);
34
35 push(@changes, $_);
36}
37close(CHG);
38
39open(CHANGELOG, "< $changelog") or die "Cannot open changelog";
40open(NEW, "> $changelog.new") or die "Cannot open new changelog";
41
42$printed = 3;
43while (<CHANGELOG>) {
44 if (/^ CHANGELOG: /) {
45 $printed--;
46 print NEW;
47 if ($printed == 0) {
48 print NEW @changes;
49 }
50 next;
51 }
52 print NEW;
53}
54
55close(NEW);
56close(CHANGELOG);
57
58rename("$changelog.new", "$changelog");
diff --git a/debian/scripts/misc/kernelconfig b/debian/scripts/misc/kernelconfig
new file mode 100755
index 00000000000..8812b61c6e5
--- /dev/null
+++ b/debian/scripts/misc/kernelconfig
@@ -0,0 +1,172 @@
1#!/bin/bash
2
3. debian/debian.env
4
5# Script to merge all configs and run 'make silentoldconfig' on it to wade out bad juju.
6# Then split the configs into distro-commmon and flavour-specific parts
7
8# We have to be in the top level kernel source directory
9if [ ! -f MAINTAINERS ] || [ ! -f Makefile ]; then
10 echo "This does not appear to be the kernel source directory." 1>&2
11 exit 1
12fi
13
14mode=${1:?"Usage: $0 [oldconfig|editconfig]"}
15yes=0
16case "$mode" in
17 update*configs) mode='silentoldconfig' ;;
18 default*configs) mode='oldconfig'; yes=1 ;;
19 edit*configs) ;; # All is good
20 gen*configs) mode='genconfigs' ;; # All is good
21 dump*configs) mode='config'; yes=1 ;;
22 *) echo "$0 called with invalid mode" 1>&2
23 exit 1 ;;
24esac
25kerneldir="`pwd`"
26confdir="$kerneldir/${DEBIAN}/config"
27sharedconfdir="$kerneldir/debian.master/config"
28variant="$2"
29
30. $DEBIAN/etc/kernelconfig
31
32bindir="`pwd`/${DROOT}/scripts/misc"
33common_conf="$confdir/config.common.$family"
34tmpdir=`mktemp -d`
35mkdir "$tmpdir/CONFIGS"
36
37if [ "$mode" = "genconfigs" ]; then
38 keep=1
39 mode="oldconfig"
40 test -d CONFIGS || mkdir CONFIGS
41fi
42
43for arch in $archs; do
44 rm -rf build
45 mkdir build
46
47 # Map debian archs to kernel archs
48 case "$arch" in
49 ppc64) kernarch="powerpc" ;;
50 amd64) kernarch="x86_64" ;;
51 lpia) kernarch="x86" ;;
52 sparc) kernarch="sparc64" ;;
53 armel|armhf) kernarch="arm" ;;
54 *) kernarch="$arch" ;;
55 esac
56
57 archconfdir=$confdir/$arch
58 flavourconfigs=$(cd $archconfdir && ls config.flavour.*)
59
60 # Merge configs
61 # We merge config.common.ubuntu + config.common.<arch> +
62 # config.flavour.<flavour>
63
64 for config in $flavourconfigs; do
65 fullconf="$tmpdir/$arch-$config-full"
66 case $config in
67 *)
68 : >"$fullconf"
69 if [ -f $common_conf ]; then
70 cat $common_conf >> "$fullconf"
71 fi
72 if [ -f $archconfdir/config.common.$arch ]; then
73 cat $archconfdir/config.common.$arch >> "$fullconf"
74 fi
75 cat "$archconfdir/$config" >>"$fullconf"
76 if [ -f $confdir/OVERRIDES ]; then
77 cat $confdir/OVERRIDES >> "$fullconf"
78 fi
79 ;;
80 esac
81 done
82
83 for config in $flavourconfigs; do
84 if [ -f $archconfdir/$config ]; then
85 fullconf="$tmpdir/$arch-$config-full"
86 cat "$fullconf" > build/.config
87 # Call oldconfig or menuconfig
88 case "$mode" in
89 editconfigs)
90 # Interactively edit config parameters
91 while : ; do
92 echo -n "Do you want to edit config: $arch/$config? [Y/n] "
93 read choice
94
95 case "$choice" in
96 y* | Y* | "" )
97 make O=`pwd`/build ARCH=$kernarch menuconfig
98 break ;;
99 n* | N* )
100 break ;;
101 *)
102 echo "Entry not valid"
103 esac
104 done
105 ;;
106 *)
107 echo "* Run $mode (yes=$yes) on $arch/$config ..."
108 if [ "$yes" -eq 1 ]; then
109 yes "" | make O=`pwd`/build ARCH=$kernarch "$mode"
110 else
111 make O=`pwd`/build ARCH=$kernarch "$mode"
112 fi ;;
113 esac
114 cat build/.config > $archconfdir/$config
115 cat build/.config > "$tmpdir/CONFIGS/$arch-$config"
116 if [ "$keep" = "1" ]; then
117 cat build/.config > CONFIGS/$arch-$config
118 fi
119 else
120 echo "!! Config not found $archconfdir/$config..."
121 fi
122 done
123
124 echo "Running splitconfig.pl for $arch"
125 echo
126
127 # Can we make this more robust by avoiding $tmpdir completely?
128 # This approach was used for now because I didn't want to change
129 # splitconfig.pl
130 (cd $archconfdir; $bindir/splitconfig.pl; mv config.common \
131 config.common.$arch; cp config.common.$arch $tmpdir)
132done
133
134rm -f $common_conf
135
136# Now run splitconfig.pl on all the config.common.<arch> copied to
137# $tmpdir
138(cd $tmpdir; $bindir/splitconfig.pl)
139(
140 cd $confdir;
141 rm -f *-full
142 grep -v 'is UNMERGABLE' <$tmpdir/config.common >$common_conf
143 for arch in $archs; do
144 grep -v 'is UNMERGABLE' <$tmpdir/config.common.$arch \
145 >$arch/config.common.$arch
146 done
147)
148
149echo ""
150echo "Running config-check for all configurations ..."
151echo ""
152fail=0
153for arch in $archs; do
154 archconfdir=$confdir/$arch
155 flavourconfigs=$(cd $archconfdir && ls config.flavour.*)
156 for config in $flavourconfigs; do
157 flavour="${config##*.}"
158 if [ -f $archconfdir/$config ]; then
159 fullconf="$tmpdir/CONFIGS/$arch-$config"
160 "$bindir/../config-check" "$fullconf" "$arch" "$flavour" "$sharedconfdir" "0" || let "fail=$fail+1"
161 fi
162 done
163done
164
165if [ "$fail" != 0 ]; then
166 echo ""
167 echo "*** ERROR: $fail config-check failures detected"
168 echo ""
169fi
170
171rm -rf build
172
diff --git a/debian/scripts/misc/retag b/debian/scripts/misc/retag
new file mode 100755
index 00000000000..94cf169a076
--- /dev/null
+++ b/debian/scripts/misc/retag
@@ -0,0 +1,34 @@
1#!/usr/bin/perl -w
2
3open(TAGS, "git tag -l |") or die "Could not get list of tags";
4@tags = <TAGS>;
5close(TAGS);
6
7open(LOGS, "git log --pretty=short |") or die "ERROR: Calling git log";
8my $commit = "";
9
10while (<LOGS>) {
11 my $origtag;
12
13 if (m|^commit (.*)$|) {
14 $commit = $1;
15 next;
16 }
17
18 m|\s*UBUNTU: (Ubuntu-2\.6\..*)| or next;
19
20 $tag = $1;
21
22 ($origtag) = grep(/^$tag.orig$/, @tags);
23
24 if (!defined($origtag)) {
25 print "I: Adding original tag for $tag\n";
26 system("git tag -m $tag $tag.orig $tag");
27 }
28
29 print "I: Tagging $tag => $commit\n";
30
31 system("git tag -f -m $tag $tag $commit");
32}
33
34close(LOGS);
diff --git a/debian/scripts/misc/splitconfig.pl b/debian/scripts/misc/splitconfig.pl
new file mode 100755
index 00000000000..3dca468fca6
--- /dev/null
+++ b/debian/scripts/misc/splitconfig.pl
@@ -0,0 +1,111 @@
1#!/usr/bin/perl -w
2
3%allconfigs = ();
4%common = ();
5
6print "Reading config's ...\n";
7
8opendir(DIR, ".");
9
10while (defined($config = readdir(DIR))) {
11 # Only config.*
12 next if $config !~ /^config\..*/;
13 # Nothing that is disabled, or remnant
14 next if $config =~ /.*\.(default|disabled|stub)$/;
15
16 %{$allconfigs{$config}} = ();
17
18 print " processing $config ... ";
19
20 open(CONFIG, "< $config");
21
22 while (<CONFIG>) {
23 # Skip comments
24 /^#*\s*CONFIG_(\w+)[\s=](.*)$/ or next;
25
26 ${$allconfigs{$config}}{$1} = $2;
27
28 $common{$1} = $2;
29 }
30
31 close(CONFIG);
32
33 print "done.\n";
34}
35
36closedir(DIR);
37
38print "\n";
39
40print "Merging lists ... \n";
41
42# %options - pointer to flavour config inside the allconfigs array
43for $config (keys(%allconfigs)) {
44 my %options = %{$allconfigs{$config}};
45
46 print " processing $config ... ";
47
48 for $key (keys(%common)) {
49 next if not defined $common{$key};
50
51 # If we don't have the common option, then it isn't
52 # common. If we do have that option, it must have the same
53 # value. EXCEPT where this file does not have a value at all
54 # which may safely be merged with any other value; the value
55 # will be elided during recombination of the parts.
56 if (!defined($options{$key})) {
57 # Its ok really ... let it merge
58 } elsif (not defined($options{$key})) {
59 undef $common{$key};
60 } elsif ($common{$key} ne $options{$key}) {
61 undef $common{$key};
62 }
63 }
64
65 print "done.\n";
66}
67
68print "\n";
69
70print "Creating common config ... ";
71
72open(COMMON, "> config.common");
73print COMMON "#\n# Common config options automatically generated by splitconfig.pl\n#\n";
74
75for $key (sort(keys(%common))) {
76 if (not defined $common{$key}) {
77 print COMMON "# CONFIG_$key is UNMERGABLE\n";
78 } elsif ($common{$key} eq "is not set") {
79 print COMMON "# CONFIG_$key is not set\n";
80 } else {
81 print COMMON "CONFIG_$key=$common{$key}\n";
82 }
83}
84close(COMMON);
85
86print "done.\n\n";
87
88print "Creating stub configs ...\n";
89
90for $config (keys(%allconfigs)) {
91 my %options = %{$allconfigs{$config}};
92
93 print " processing $config ... ";
94
95 open(STUB, "> $config");
96 print STUB "#\n# Config options for $config automatically generated by splitconfig.pl\n#\n";
97
98 for $key (sort(keys(%options))) {
99 next if defined $common{$key};
100
101 if ($options{$key} =~ /^is /) {
102 print STUB "# CONFIG_$key $options{$key}\n";
103 } else {
104 print STUB "CONFIG_$key=$options{$key}\n";
105 }
106 }
107
108 close(STUB);
109
110 print "done.\n";
111}
diff --git a/debian/scripts/module-check b/debian/scripts/module-check
new file mode 100755
index 00000000000..c754ea368cf
--- /dev/null
+++ b/debian/scripts/module-check
@@ -0,0 +1,120 @@
1#!/usr/bin/perl -w
2
3$flavour = shift;
4$prev_abidir = shift;
5$abidir = shift;
6$skipmodule = shift;
7
8print "II: Checking modules for $flavour...";
9
10if (-f "$prev_abidir/ignore.modules"
11 or -f "$prev_abidir/$flavour.ignore.modules") {
12 print "explicitly ignoring modules\n";
13 exit(0);
14}
15
16if (not -f "$abidir/$flavour.modules" or not -f
17 "$prev_abidir/$flavour.modules") {
18 print "previous or current modules file missing!\n";
19 print " $abidir/$flavour.modules\n";
20 print " $prev_abidir/$flavour.modules\n";
21 if (defined($skipmodule)) {
22 exit(0);
23 } else {
24 exit(1);
25 }
26}
27
28print "\n";
29
30my %modules;
31my %modules_ignore;
32my $missing = 0;
33my $new = 0;
34my $errors = 0;
35
36# See if we have any ignores
37if (-f "$prev_abidir/../modules.ignore") {
38 my $ignore = 0;
39 open(IGNORE, "< $prev_abidir/../modules.ignore") or
40 die "Could not open $prev_abidir/../modules.ignore";
41 print " reading modules to ignore...";
42 while (<IGNORE>) {
43 chomp;
44 next if /\s*#/;
45 $modules_ignore{$_} = 1;
46 $ignore++;
47 }
48 close(IGNORE);
49 print "read $ignore modules.\n";
50}
51
52# Read new modules first
53print " reading new modules...";
54$new_count = 0;
55open(NEW, "< $abidir/$flavour.modules") or
56 die "Could not open $abidir/$flavour.modules";
57while (<NEW>) {
58 chomp;
59 $modules{$_} = 1;
60 $new_count++;
61}
62close(NEW);
63print "read $new_count modules.\n";
64
65# Now the old modules, checking for missing ones
66print " reading old modules...";
67$old_count = 0;
68open(OLD, "< $prev_abidir/$flavour.modules") or
69 die "Could not open $prev_abidir/$flavour.modules";
70while (<OLD>) {
71 chomp;
72 if (not defined($modules{$_})) {
73 print "\n" if not $missing;
74 $missing++;
75 if (not defined($modules_ignore{$_})) {
76 print " MISS: $_\n";
77 $errors++;
78 } else {
79 print " MISS: $_ (ignored)\n";
80 }
81 } else {
82 $modules{$_}++;
83 }
84 $old_count++;
85}
86close(OLD);
87# Check for new modules
88foreach $mod (keys(%modules)) {
89 if ($modules{$mod} < 2) {
90 print "\n" if not $missing and not $new;
91 print " NEW : $mod\n";
92 $new++;
93 }
94}
95if ($new or $missing) {
96 print " read $old_count modules : new($new) missing($missing)\n";
97} else {
98 print "read $old_count modules.\n";
99}
100
101
102# Let's see where we stand...
103if ($errors) {
104 if (defined($skipmodule)) {
105 print "WW: Explicitly asked to ignore failures (probably not good)\n";
106 } else {
107 print "EE: Missing modules (start begging for mercy)\n";
108 exit 1
109 }
110}
111
112if ($new) {
113 print "II: New modules (you've been busy, wipe the poop off your nose)\n";
114} else {
115 print "II: No new modules (hope you're happy, slacker)\n";
116}
117
118print "II: Done\n";
119
120exit(0);
diff --git a/debian/scripts/module-inclusion b/debian/scripts/module-inclusion
new file mode 100755
index 00000000000..ec3ce5e0cd5
--- /dev/null
+++ b/debian/scripts/module-inclusion
@@ -0,0 +1,51 @@
1#!/bin/bash
2
3#
4# Build a new directory of modules based on an inclusion list.
5# The includsion list format must be a bash regular expression.
6#
7# usage: $0 ROOT INCLUSION_LIST
8# example: $0 debian/build/build-virtual debian.master/control.d/virtual.inclusion-list
9ROOT=$1
10ILIST=$2
11
12NROOT=${ROOT}.new
13
14#
15# Prep a destination directory.
16#
17mkdir -p ${NROOT}
18rsync -a --exclude="*.ko" ${ROOT}/ ${NROOT}
19
20cat ${ILIST} |while read i
21do
22 #
23 # 'find' blurts a warning if it cannot find any ko files.
24 #
25 if echo "$i" | grep '\*' > /dev/null
26 then
27 (cd ${ROOT}; eval find "${i}" -name "*.ko") |while read f
28 do
29 mkdir -p ${NROOT}/`dirname $f`
30 cp ${ROOT}/$f ${NROOT}/$f
31 done
32 else
33 if [ -f "${ROOT}/$i" ]
34 then
35 mkdir -p ${NROOT}/`dirname $i`
36 cp ${ROOT}/$i ${NROOT}/$i
37 else
38 echo Warning: Could not find ${ROOT}/$i
39 fi
40 fi
41
42done
43
44#
45# Cleanup
46#
47rm -rf ${ROOT}
48mv ${NROOT} ${ROOT}
49
50exit 0
51
diff --git a/debian/scripts/sub-flavour b/debian/scripts/sub-flavour
new file mode 100644
index 00000000000..45456bba924
--- /dev/null
+++ b/debian/scripts/sub-flavour
@@ -0,0 +1,69 @@
1#!/bin/bash
2
3. debian/debian.env
4
5echo "SUB_PROCESS $FROM => $TO"
6
7export from_pkg="linux-image-$ABI_RELEASE-$FROM"
8export to_pkg="linux-image-$ABI_RELEASE-$TO"
9
10from_moddir="debian/$from_pkg/lib/modules/$ABI_RELEASE-$FROM"
11to_moddir="debian/$to_pkg/lib/modules/$ABI_RELEASE-$FROM"
12
13install -d "debian/$to_pkg/boot"
14install -m644 debian/$from_pkg/boot/{vmlinuz,config}-$ABI_RELEASE-$FROM \
15 debian/$to_pkg/boot/
16install -m600 debian/$from_pkg/boot/System.map-$ABI_RELEASE-$FROM \
17 debian/$to_pkg/boot/
18
19#
20# Print some warnings if there are files in the sub-flavours list
21# that do not actually exist.
22#
23cat ${DEBIAN}/sub-flavours/$TO.list | while read line
24do
25(
26 cd debian/$from_pkg/lib/modules/$ABI_RELEASE-$FROM/kernel;
27 #
28 # If its a wildcard, then check that there are files that match.
29 #
30 if echo "$line" | grep '\*' > /dev/null
31 then
32 if [ `eval find "$line" -name '*.ko' 2>/dev/null|wc -l` -lt 1 ]
33 then
34 echo SUB_INST Warning - No files in $line
35 fi
36 #
37 # Else it should be a single file reference.
38 #
39 elif [ ! -f "$line" ]
40 then
41 echo SUB_INST Warning - could not find "$line"
42 fi
43)
44done
45
46cat ${DEBIAN}/sub-flavours/$TO.list | while read line; do
47 (
48 cd debian/$from_pkg/lib/modules/$ABI_RELEASE-$FROM/kernel;
49 if echo "$line" | grep '\*' > /dev/null
50 then
51 eval find "$line" -name '*.ko' 2>/dev/null || true
52 elif [ -f "$line" ]
53 then
54 echo "$line"
55 fi
56 );
57done | while read mod; do
58 echo "SUB_INST checking: $mod"
59 fromdir="/lib/modules/$ABI_RELEASE-$FROM/"
60 egrep "^($fromdir)?kernel/$mod:" \
61 $from_moddir/modules.dep | sed -e "s|^$fromdir||" -e 's/://' -e 's/ /\n/g' | \
62 while read m; do
63 m="${fromdir}$m"
64 test -f debian/$to_pkg/$m && continue
65 echo "SUB_INST installing: $m"
66 install -D -m644 debian/$from_pkg/$m \
67 debian/$to_pkg/$m
68 done
69done
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 00000000000..d3827e75a5c
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
1.0
diff --git a/debian/stamps/keep-dir b/debian/stamps/keep-dir
new file mode 100644
index 00000000000..5c38d4a5c41
--- /dev/null
+++ b/debian/stamps/keep-dir
@@ -0,0 +1 @@
Place holder
diff --git a/debian/tests/README b/debian/tests/README
new file mode 100644
index 00000000000..c74d1c4aef8
--- /dev/null
+++ b/debian/tests/README
@@ -0,0 +1,21 @@
1Scripts placed in this directory get called one at a time by run-parts(8).
2The scripts are expected to perform some sort of sanity checks on the
3finished build. Scripts will be called once for each flavour.
4
5Some environment variables are exported to make life a little easier:
6
7DPKG_ARCH : The dpkg architecture (e.g. "amd64")
8KERN_ARCH : The kernel architecture (e.g. "x86_64")
9FLAVOUR : The specific flavour for this run (e.g. "generic")
10VERSION : The full version of this build (e.g. 2.6.22-1)
11REVISION : The exact revision of this build (e.g. 1.3)
12PREV_REVISION : The revision prior to this one
13ABI_NUM : The specific ABI number for this build (e.g. 2)
14PREV_ABI_NUM : The previous ABI number. Can be the same as ABI_NUM.
15BUILD_DIR : The directory where this build took place
16INSTALL_DIR : The directory where the package is prepared
17SOURCE_DIR : Where the main kernel source is
18
19Scripts are expected to have a zero exit status when no problems occur,
20and non-zero when an error occurs that should stop the build. Scripts
21should print whatever info they deem needed to deduce the problem.
diff --git a/debian/tests/check-aliases b/debian/tests/check-aliases
new file mode 100755
index 00000000000..b85118ff12c
--- /dev/null
+++ b/debian/tests/check-aliases
@@ -0,0 +1,24 @@
1#!/usr/bin/perl -w
2
3my %map;
4
5print "Checking for dupe aliases in $ENV{'FLAVOUR'}...\n";
6
7$aliases =
8 "$ENV{'INSTALL_DIR'}/lib/modules/$ENV{'VERSION'}-$ENV{'FLAVOUR'}/modules.alias";
9
10open(ALIASES, "< $aliases") or die "Could not open $aliases";
11
12while (<ALIASES>) {
13 chomp;
14 my ($junk, $alias, $module) = split;
15
16 if (defined($map{$alias})) {
17 printf("%s %20s / %-20s : %s \n", ("$map{$alias}" eq "$module")
18 ? "INT" : " ", $map{$alias}, $module, $alias);
19 } else {
20 $map{$alias} = $module;
21 }
22}
23
24exit(0);
diff --git a/debian/tools/perf b/debian/tools/perf
new file mode 100644
index 00000000000..ab35fab9f0f
--- /dev/null
+++ b/debian/tools/perf
@@ -0,0 +1,16 @@
1#!/bin/bash
2full_version=`uname -r`
3
4# Removing flavour from version i.e. generic or server.
5flavour_abi=${full_version#*-}
6flavour=${flavour_abi#*-}
7version=${full_version%-$flavour}
8perf="perf_$version"
9
10if ! which "$perf" > /dev/null; then
11 echo "$perf not found" >&2
12 echo "You may need to install linux-tools-$version" >&2
13 exit 2
14fi
15
16exec "$perf" "$@"