]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - debian/control-scripts/headers-postinst
x86/xen: Reset VCPU0 info pointer after shared_info remap
[mirror_ubuntu-artful-kernel.git] / debian / control-scripts / headers-postinst
CommitLineData
fef4fb4a
LO
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__