File: include.postinst

package info (click to toggle)
kernel-package 8.135
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,008 kB
  • ctags: 696
  • sloc: perl: 3,089; makefile: 2,344; sh: 538
file content (128 lines) | stat: -rwxr-xr-x 3,253 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/perl
#                              -*- Mode: Cperl -*- 
# debian.postinst ---
# Author           : Manoj Srivastava ( srivasta@pilgrim.umass.edu )
# Created On       : Sat Apr 27 05:42:43 1996
# Created On Node  : melkor.pilgrim.umass.edu
# Last Modified By : Manoj Srivastava
# Last Modified On : Tue Mar  2 18:41:35 2004
# Last Machine Used: glaurung.internal.golden-gryphon.com
# Update Count     : 44
# Status           : Unknown, Use with caution!
# HISTORY          :
# Description      :
#
#
#
#  arch-tag: 1c716174-2f0a-476d-a626-a1322e62503a
#


$|=1;

# Predefined values:
my $package="=P";
my $version="=V";

# Ignore all invocations uxcept when called on to configure.
exit 0 unless ($ARGV[0] && $ARGV[0] =~ /configure/);

my $architecture;
chomp($architecture = `dpkg --print-installation-architecture`);
$architecture = "ppc" if $architecture eq "powerpc";
$architecture = "parisc" if $architecture eq "hppa";
$architecture = "mips" if $architecture eq "mipsel";
$architecture = "x86_64" if $architecture eq "amd64";

my $stop_and_read     = 0;
my $have_conffile     = "";
my $src_postinst_hook = '';
my $CONF_LOC          = '/etc/kernel-img.conf';

# most of our work is done in /usr/src.
chdir '/usr/src' or die "Could not chdir to /usr/src:$!";

if (-d "$package") {

  chdir "/usr/src/$package/include" ||
    die "Could not chdir to  /usr/src/$package/include:$!";

  if (! -d "asm-$architecture") {
    warn "/usr/src/$package/include/asm-$architecture does not exist.\n";
  }
  elsif (-e 'asm') {
    if (! -l 'asm') {
      warn "/usr/src/$package/include/asm is not a symlink.\n";
      $stop_and_read++;
    }
    else {
      my $target=readlink 'asm';
      if ("$target" ne "asm-$architecture") {
	if (! unlink 'asm') {
	  warn "could not unlink /usr/src/$package/include/asm: $!\n";
	  warn "It points to /usr/src/$package/include/$target\n";
	  warn  "rather than at /usr/src/$package/include/asm-$architecture\n";
	  $stop_and_read++;
	}
	else {
	  if (! symlink "asm-$architecture", 'asm') {
	    warn "Could not link /usr/src/$package/include/asm:$!\n";
	    warn "to /usr/src/$package/include/asm-$architecture\n";
	    $stop_and_read++;
	  }
	}
      }
    }
  }
}

chdir '/usr/src' or die "Could not chdir to /usr/src:$!";

if ($stop_and_read) {
  my $answer;
  print STDERR " Please Hit return to continue.";
  $answer = <STDIN>;
}

if (-r "$CONF_LOC" && -f "$CONF_LOC"  ) {
  if (open(CONF, "$CONF_LOC")) {
    while (<CONF>) {
      chomp;
      s/\#.*$//g;
      next if /^\s*$/;

      $src_postinst_hook      = "$1"  if /src_postinst_hook\s*=\s*(\S+)/ig;
      $header_postinst_hook   = "$1"  if /header_postinst_hook\s*=\s*(\S+)/ig;
    }
    close CONF;
    $have_conffile = "Yes";
  }
}

## Run user hook script here, if any
if (-x "$src_postinst_hook") {
    system ("$src_postinst_hook", $package, $version) &&
	warn "User hook script $src_postinst_hook failed";
}
if (-x "$header_postinst_hook") {
    system ("$header_postinst_hook", $package, $version) &&
	warn "User hook script $header_postinst_hook failed";
}
if (-x "$header_postinst_hook") {
    system ("$header_postinst_hook", $package, $version) &&
	warn "User hook script $header_postinst_hook failed";
}



exit 0;

__END__