[kernel] r7904 -
people/waldi/linux-2.6/debian/templates/temp.image.plain
Bastian Blank
waldi at alioth.debian.org
Sat Dec 2 14:40:35 CET 2006
Author: waldi
Date: Sat Dec 2 14:40:34 2006
New Revision: 7904
Added:
people/waldi/linux-2.6/debian/templates/temp.image.plain/
people/waldi/linux-2.6/debian/templates/temp.image.plain/config (contents, props changed)
people/waldi/linux-2.6/debian/templates/temp.image.plain/postinst (contents, props changed)
people/waldi/linux-2.6/debian/templates/temp.image.plain/postrm (contents, props changed)
people/waldi/linux-2.6/debian/templates/temp.image.plain/preinst (contents, props changed)
people/waldi/linux-2.6/debian/templates/temp.image.plain/prerm (contents, props changed)
people/waldi/linux-2.6/debian/templates/temp.image.plain/templates
Log:
debian/templates/temp.image.plain:
Add a temporary copy of the kernel-package templates.
Added: people/waldi/linux-2.6/debian/templates/temp.image.plain/config
==============================================================================
--- (empty file)
+++ people/waldi/linux-2.6/debian/templates/temp.image.plain/config Sat Dec 2 14:40:34 2006
@@ -0,0 +1,291 @@
+#! /usr/bin/perl
+# -*- Mode: Cperl -*-
+# config ---
+# Author : Manoj Srivastava ( srivasta at glaurung.internal.golden-gryphon.com )
+# Created On : Thu Nov 3 09:11:38 2005
+# Created On Node : glaurung.internal.golden-gryphon.com
+# Last Modified By : Manoj Srivastava
+# Last Modified On : Thu Nov 3 09:11:38 2005
+# Last Machine Used: glaurung.internal.golden-gryphon.com
+# Update Count : 0
+# Status : Unknown, Use with caution!
+# HISTORY :
+# Description :
+#
+# arch-tag: 9a70bb3a-30d4-4f4c-96e7-d3feb9a9752e
+#
+
+use Debconf::Client::ConfModule qw(:all);
+version('2.0');
+$|=1;
+
+# Predefined values:
+my $version = "=V";
+my $link_in_boot = "=IB"; # Should be empty, mostly
+my $no_symlink = "=S"; # Should be empty, mostly
+my $reverse_symlink = "=R"; # Should be empty, mostly
+my $do_symlink = "Yes"; # target machine defined
+my $do_boot_enable = "Yes"; # target machine defined
+my $do_bootfloppy = "Yes"; # target machine defined
+my $do_bootloader = "Yes"; # target machine defined
+my $move_image = ''; # target machine defined
+my $kimage = "=K"; # Should be empty, mostly
+my $loader = "=L"; # lilo, silo, quik, palo, vmelilo, nettrom, arcboot or delo
+my $image_dir = "=D"; # where the image is located
+my $clobber_modules = ''; # target machine defined
+my $relative_links = ""; # target machine defined
+my $initrd = "=I"; # initrd kernel
+my $mkimage = "=M"; # command to generate the initrd image
+my $do_initrd = ''; # Normally we do not
+my $warn_initrd = 'YES'; # Normally we do
+my $use_hard_links = ''; # hardlinks do not work across fs boundaries
+my $postinst_hook = ''; #Normally we do not
+my $postrm_hook = ''; #Normally we do not
+my $preinst_hook = ''; #Normally we do not
+my $prerm_hook = ''; #Normally we do not
+my $minimal_swap = ''; # Do not swap symlinks
+my $ignore_depmod_err = ''; # normally we do not
+my $relink_src_link = 'YES'; # There is no harm in checking the link
+my $relink_build_link = 'YES'; # There is no harm in checking the link
+my $force_build_link = ''; # There is no harm in checking the link
+my $official_image = "=OF"; # only true for official images
+my $arch = "=A"; # should be same as dpkg --print-installation-architecture
+my $kernel_arch = "=B";
+my $ramdisk = "=MK"; # List of tools to create initial ram fs.
+my $initrddep = "=MD"; # List of dependencies for such tools
+my $package_name = "=ST-image-$version";
+
+my $Loader = "NoLOADER"; #
+$Loader = "LILO" if $loader =~ /^lilo/io;
+$Loader = "SILO" if $loader =~ /^silo/io;
+$Loader = "QUIK" if $loader =~ /^quik/io;
+$Loader = "yaboot" if $loader =~ /^yaboot/io;
+$Loader = "PALO" if $loader =~ /^palo/io;
+$Loader = "NETTROM" if $loader =~ /^nettrom/io;
+$Loader = "VMELILO" if $loader =~ /^vmelilo/io;
+$Loader = "ZIPL" if $loader =~ /^zipl/io;
+$Loader = "ELILO" if $loader =~ /^elilo/io;
+$Loader = "ARCBOOT" if $loader =~ /^arcboot/io;
+$Loader = "DELO" if $loader =~ /^delo/io;
+
+#known variables
+my $image_dest = "/";
+my $realimageloc = "/$image_dir/";
+my $have_conffile = "";
+my $silent_modules = '';
+my $silent_loader = '';
+my $modules_base = '/lib/modules';
+my $CONF_LOC = '/etc/kernel-img.conf';
+
+# Ignore all invocations except when called on to configure.
+exit 0 unless $ARGV[0] =~ /configure/;
+chdir('/') or die "could not chdir to /:$!\n";
+
+# remove multiple leading slashes; make sure there is at least one.
+$realimageloc =~ s|^/*|/|o;
+$realimageloc =~ s|/+|/|o;
+
+if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
+ if (open(CONF, "$CONF_LOC")) {
+ while (<CONF>) {
+ chomp;
+ s/\#.*$//g;
+ next if /^\s*$/;
+
+ $do_symlink = "" if /do_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $no_symlink = "" if /no_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $reverse_symlink = "" if /reverse_symlink\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /image_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /link_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $move_image = "" if /move_image\s*=\s*(no|false|0)\s*$/ig;
+ $clobber_modules = '' if /clobber_modules\s*=\s*(no|false|0)\s*$/ig;
+ $do_boot_enable = '' if /do_boot_enable\s*=\s*(no|false|0)\s*$/ig;
+ $do_bootfloppy = '' if /do_bootfloppy\s*=\s*(no|false|0)\s*$/ig;
+ $relative_links = '' if /relative_links \s*=\s*(no|false|0)\s*$/ig;
+ $do_bootloader = '' if /do_bootloader\s*=\s*(no|false|0)\s*$/ig;
+ $do_initrd = '' if /do_initrd\s*=\s*(no|false|0)\s*$/ig;
+ $warn_initrd = '' if /warn_initrd\s*=\s*(no|false|0)\s*$/ig;
+ $use_hard_links = '' if /use_hard_links\s*=\s*(no|false|0)\s*$/ig;
+ $silent_modules = '' if /silent_modules\s*=\s*(no|false|0)\s*$/ig;
+ $silent_loader = '' if /silent_loader\s*=\s*(no|false|0)\s*$/ig;
+ $minimal_swap = '' if /minimal_swap\s*=\s*(no|false|0)\s*$/ig;
+ $ignore_depmod_err = '' if /ignore_depmod_err\s*=\s*(no|false|0)\s*$/ig;
+ $relink_src_link = '' if /relink_src_link\s*=\s*(no|false|0)\s*$/ig;
+ $relink_build_link = '' if /relink_build_link\s*=\s*(no|false|0)\s*$/ig;
+ $force_build_link = '' if /force_build_link\s*=\s*(no|false|0)\s*$/ig;
+
+ $do_symlink = "Yes" if /do_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $no_symlink = "Yes" if /no_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $reverse_symlink = "Yes" if /reverse_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /image_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /link_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $move_image = "Yes" if /move_image\s*=\s*(yes|true|1)\s*$/ig;
+ $clobber_modules = "Yes" if /clobber_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $do_boot_enable = "Yes" if /do_boot_enable\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootfloppy = "Yes" if /do_bootfloppy\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootloader = "Yes" if /do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
+ $relative_links = "Yes" if /relative_links\s*=\s*(yes|true|1)\s*$/ig;
+ $do_initrd = "Yes" if /do_initrd\s*=\s*(yes|true|1)\s*$/ig;
+ $warn_initrd = "Yes" if /warn_initrd\s*=\s*(yes|true|1)\s*$/ig;
+ $use_hard_links = "Yes" if /use_hard_links\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_modules = 'Yes' if /silent_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_loader = 'Yes' if /silent_loader\s*=\s*(yes|true|1)\s*$/ig;
+ $minimal_swap = 'Yes' if /minimal_swap\s*=\s*(yes|true|1)\s*$/ig;
+ $ignore_depmod_err = 'Yes' if /ignore_depmod_err\s*=\s*(yes|true|1)\s*$/ig;
+ $relink_src_link = 'Yes' if /relink_src_link\s*=\s*(yes|true|1)\s*$/ig;
+ $relink_build_link = 'Yes' if /relink_build_link\s*=\s*(yes|true|1)\s*$/ig;
+ $force_build_link = 'Yes' if /force_build_link\s*=\s*(yes|true|1)\s*$/ig;
+
+ $image_dest = "$1" if /image_dest\s*=\s*(\S+)/ig;
+ $postinst_hook = "$1" if /postinst_hook\s*=\s*(\S+)/ig;
+ $postrm_hook = "$1" if /postrm_hook\s*=\s*(\S+)/ig;
+ $preinst_hook = "$1" if /preinst_hook\s*=\s*(\S+)/ig;
+ $prerm_hook = "$1" if /prerm_hook\s*=\s*(\S+)/ig;
+ $mkimage = "$1" if /mkimage\s*=\s*(.+)$/ig;
+ $ramdisk = "$1" if /ramdisk\s*=\s*(.+)$/ig;
+ }
+ close CONF;
+ $have_conffile = "Yes";
+ }
+}
+
+# For some versions of kernel-package, we had this warning in the
+# postinst, but the rules did not really interpolate the value in.
+# Here is a sanity check.
+my $pattern = "=" . "I";
+$initrd=~ s/^$pattern$//;
+
+if ($link_in_boot) {
+ $image_dest = "/$image_dir/";
+ $image_dest =~ s|^/*|/|o;
+}
+
+$image_dest = "$image_dest/";
+$image_dest =~ s|/+$|/|o;
+
+# Official powerpc images may silently upgrade
+if ($official_image =~ /^\s*YES\s*$/o && $arch =~ m/powerpc/) {
+ $silent_modules = 'Yes';
+}
+$ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
+
+# Paranoid check to make sure that the correct value is put in there
+if (! $kimage) { $kimage = "vmlinuz"; } # Hmm. empty
+elsif ($kimage =~ m/^b?zImage$/o) { $kimage = "vmlinuz"; } # these produce vmlinuz
+elsif ($kimage =~ m/^[iI]mage$/o) { my $nop = $kimage; }
+elsif ($kimage =~ m/^vmlinux$/o) { my $nop = $kimage; }
+else { $kimage = "vmlinuz"; } # Default
+
+# search for the boot loader in the path
+my $loader_exec;
+($loader_exec = $loader) =~ s|.*/||;
+my ($loaderloc) = grep -x, map "$_/$loader_exec",
+ map { length($_) ? $_ : "." } split /:/, $ENV{PATH};
+
+if (-d "$kimage" ) {
+ my $ret;
+ my $seen;
+ my $note = "${package_name}/postinst/kimage-is-a-directory";
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'kimage', "$kimage");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'image_dest', "$image_dest");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$note");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf note $note: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $note: $seen";
+ }
+}
+
+if (! -e "$kimage" && ! $no_symlink && ! $reverse_symlink &&
+ ! $have_conffile ) {
+ my $ret;
+ my $seen;
+ my $question = "${package_name}/postinst/create-kimage-link-$version";
+
+ $ret = subst("$question", 'kimage', "$kimage");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+ if ($ret == 30) {
+ }
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+}
+
+if ($initrd && -l "$image_dest/initrd" ) {
+ my $ret;
+ my $seen;
+ my $question = "${package_name}/postinst/old-initrd-link-$version";
+
+ ($ret,$seen) = input('medium', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+}
+
+if ($initrd && -l "$image_dir/initrd" && ! $link_in_boot) {
+ my $ret;
+ my $seen;
+ my $question = "${package_name}/postinst/old-dir-initrd-link-$version";
+
+ $ret = subst("$question", 'image_dir', "$image_dir");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ $ret = subst("$question", 'image_dest', "$image_dest");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ ($ret,$seen) = input('medium', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+}
+
+
+# We used to have System.* files in /
+if (-e "/System.map" || -e "/System.old") {
+ my $ret;
+ my $seen;
+ my $question = "${package_name}/postinst/old-dir-initrd-link-$version";
+
+ ($ret,$seen) = input('medium', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+}
+
+
+exit 0;
+
+__END__
+
Added: people/waldi/linux-2.6/debian/templates/temp.image.plain/postinst
==============================================================================
--- (empty file)
+++ people/waldi/linux-2.6/debian/templates/temp.image.plain/postinst Sat Dec 2 14:40:34 2006
@@ -0,0 +1,1370 @@
+#! /usr/bin/perl
+# -*- Mode: Cperl -*-
+# debian.postinst ---
+# Author : Manoj Srivastava ( srivasta at pilgrim.umass.edu )
+# Created On : Sat Apr 27 05:55:26 1996
+# Created On Node : melkor.pilgrim.umass.edu
+# Last Modified By : Manoj Srivastava
+# Last Modified On : Fri Sep 29 10:08:18 2006
+# Last Machine Used: glaurung.internal.golden-gryphon.com
+# Update Count : 357
+# Status : Unknown, Use with caution!
+# HISTORY :
+# Description :
+#
+# $Id: image.postinst,v 1.125 2003/10/07 16:24:20 srivasta Exp $
+#
+
+#
+#use strict; #for debugging
+use Cwd 'abs_path';
+use Debconf::Client::ConfModule qw(:all);
+version('2.0');
+my $capb=capb("backup");
+
+$|=1;
+
+# Predefined values:
+my $version = "=V";
+my $link_in_boot = "=IB"; # Should be empty, mostly
+my $no_symlink = "=S"; # Should be empty, mostly
+my $reverse_symlink = "=R"; # Should be empty, mostly
+my $do_symlink = "Yes"; # target machine defined
+my $do_boot_enable = "Yes"; # target machine defined
+my $do_bootfloppy = "Yes"; # target machine defined
+my $do_bootloader = "Yes"; # target machine defined
+my $move_image = ''; # target machine defined
+my $kimage = "=K"; # Should be empty, mostly
+my $loader = "=L"; # lilo, silo, quik, palo, vmelilo, nettrom, arcboot or delo
+my $image_dir = "=D"; # where the image is located
+my $clobber_modules = ''; # target machine defined
+my $relative_links = ""; # target machine defined
+my $initrd = "=I"; # initrd kernel
+my $mkimage = "=M"; # command to generate the initrd image
+my $do_initrd = ''; # Normally we do not
+my $warn_initrd = 'YES'; # Normally we do
+my $use_hard_links = ''; # hardlinks do not work across fs boundaries
+my $postinst_hook = ''; #Normally we do not
+my $postrm_hook = ''; #Normally we do not
+my $preinst_hook = ''; #Normally we do not
+my $prerm_hook = ''; #Normally we do not
+my $minimal_swap = ''; # Do not swap symlinks
+my $ignore_depmod_err = ''; # normally we do not
+my $relink_src_link = 'YES'; # There is no harm in checking the link
+my $relink_build_link = 'YES'; # There is no harm in checking the link
+my $force_build_link = ''; # There is no harm in checking the link
+my $official_image = "=OF"; # only true for official images
+my $arch = "=A"; # should be same as dpkg --print-installation-architecture
+my $kernel_arch = "=B";
+my $ramdisk = "=MK"; # List of tools to create initial ram fs.
+my $initrddep = "=MD"; # List of dependencies for such tools
+my $package_name = "=ST-image-$version";
+my $explicit_do_loader = '';
+
+my $Loader = "NoLOADER"; #
+$Loader = "LILO" if $loader =~ /^lilo/io;
+$Loader = "SILO" if $loader =~ /^silo/io;
+$Loader = "QUIK" if $loader =~ /^quik/io;
+$Loader = "yaboot" if $loader =~ /^yaboot/io;
+$Loader = "PALO" if $loader =~ /^palo/io;
+$Loader = "NETTROM" if $loader =~ /^nettrom/io;
+$Loader = "VMELILO" if $loader =~ /^vmelilo/io;
+$Loader = "ZIPL" if $loader =~ /^zipl/io;
+$Loader = "ELILO" if $loader =~ /^elilo/io;
+$Loader = "ARCBOOT" if $loader =~ /^arcboot/io;
+$Loader = "DELO" if $loader =~ /^delo/io;
+
+# This should not point to /tmp, because of security risks.
+my $temp_file_name = "/var/log/$loader" . "_log.$$";
+
+#known variables
+my $image_dest = "/";
+my $realimageloc = "/$image_dir/";
+my $have_conffile = "";
+my $silent_modules = '';
+my $silent_loader = '';
+my $warn_reboot = 'Yes'; # Warn that we are installing a version of
+ # the kernel we are running
+
+my $modules_base = '/lib/modules';
+my $CONF_LOC = '/etc/kernel-img.conf';
+
+# Ignore all invocations except when called on to configure.
+exit 0 unless $ARGV[0] =~ /configure/;
+
+my $DEBUG = 0;
+
+# Do some preliminary sanity checks here to ensure we actually have an
+# valid image dir
+chdir('/') or die "could not chdir to /:$!\n";
+die "Internal Error: ($image_dir) is not a directory!\n"
+ unless -d $image_dir;
+
+# remove multiple leading slashes; make sure there is at least one.
+$realimageloc =~ s|^/*|/|o;
+$realimageloc =~ s|/+|/|o;
+die "Internal Error: ($realimageloc) is not a directory!\n"
+ unless -d $realimageloc;
+
+if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
+ if (open(CONF, "$CONF_LOC")) {
+ while (<CONF>) {
+ chomp;
+ s/\#.*$//g;
+ next if /^\s*$/;
+
+ $do_symlink = "" if /do_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $no_symlink = "" if /no_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $reverse_symlink = "" if /reverse_symlink\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /image_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /link_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $move_image = "" if /move_image\s*=\s*(no|false|0)\s*$/ig;
+ $clobber_modules = '' if /clobber_modules\s*=\s*(no|false|0)\s*$/ig;
+ $do_boot_enable = '' if /do_boot_enable\s*=\s*(no|false|0)\s*$/ig;
+ $do_bootfloppy = '' if /do_bootfloppy\s*=\s*(no|false|0)\s*$/ig;
+ $relative_links = '' if /relative_links \s*=\s*(no|false|0)\s*$/ig;
+ $do_bootloader = '' if /do_bootloader\s*=\s*(no|false|0)\s*$/ig;
+ $do_initrd = '' if /do_initrd\s*=\s*(no|false|0)\s*$/ig;
+ $warn_initrd = '' if /warn_initrd\s*=\s*(no|false|0)\s*$/ig;
+ $use_hard_links = '' if /use_hard_links\s*=\s*(no|false|0)\s*$/ig;
+ $silent_modules = '' if /silent_modules\s*=\s*(no|false|0)\s*$/ig;
+ $silent_loader = '' if /silent_loader\s*=\s*(no|false|0)\s*$/ig;
+ $warn_reboot = '' if /warn_reboot\s*=\s*(no|false|0)\s*$/ig;
+ $minimal_swap = '' if /minimal_swap\s*=\s*(no|false|0)\s*$/ig;
+ $ignore_depmod_err = '' if /ignore_depmod_err\s*=\s*(no|false|0)\s*$/ig;
+ $relink_src_link = '' if /relink_src_link\s*=\s*(no|false|0)\s*$/ig;
+ $relink_build_link = '' if /relink_build_link\s*=\s*(no|false|0)\s*$/ig;
+ $force_build_link = '' if /force_build_link\s*=\s*(no|false|0)\s*$/ig;
+
+ $do_symlink = "Yes" if /do_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $no_symlink = "Yes" if /no_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $reverse_symlink = "Yes" if /reverse_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /image_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /link_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $move_image = "Yes" if /move_image\s*=\s*(yes|true|1)\s*$/ig;
+ $clobber_modules = "Yes" if /clobber_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $do_boot_enable = "Yes" if /do_boot_enable\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootfloppy = "Yes" if /do_bootfloppy\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootloader = "Yes" if /do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
+ $explicit_do_loader = "YES" if /do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
+ $relative_links = "Yes" if /relative_links\s*=\s*(yes|true|1)\s*$/ig;
+ $do_initrd = "Yes" if /do_initrd\s*=\s*(yes|true|1)\s*$/ig;
+ $warn_initrd = "Yes" if /warn_initrd\s*=\s*(yes|true|1)\s*$/ig;
+ $use_hard_links = "Yes" if /use_hard_links\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_modules = 'Yes' if /silent_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_loader = 'Yes' if /silent_loader\s*=\s*(yes|true|1)\s*$/ig;
+ $warn_reboot = 'Yes' if /warn_reboot\s*=\s*(yes|true|1)\s*$/ig;
+ $minimal_swap = 'Yes' if /minimal_swap\s*=\s*(yes|true|1)\s*$/ig;
+ $ignore_depmod_err = 'Yes' if /ignore_depmod_err\s*=\s*(yes|true|1)\s*$/ig;
+ $relink_src_link = 'Yes' if /relink_src_link\s*=\s*(yes|true|1)\s*$/ig;
+ $relink_build_link = 'Yes' if /relink_build_link\s*=\s*(yes|true|1)\s*$/ig;
+ $force_build_link = 'Yes' if /force_build_link\s*=\s*(yes|true|1)\s*$/ig;
+
+ $image_dest = "$1" if /image_dest\s*=\s*(\S+)/ig;
+ $postinst_hook = "$1" if /postinst_hook\s*=\s*(\S+)/ig;
+ $postrm_hook = "$1" if /postrm_hook\s*=\s*(\S+)/ig;
+ $preinst_hook = "$1" if /preinst_hook\s*=\s*(\S+)/ig;
+ $prerm_hook = "$1" if /prerm_hook\s*=\s*(\S+)/ig;
+ $mkimage = "$1" if /mkimage\s*=\s*(.+)$/ig;
+ $ramdisk = "$1" if /ramdisk\s*=\s*(.+)$/ig;
+ }
+ close CONF;
+ $have_conffile = "Yes";
+ }
+}
+
+
+
+# For some versions of kernel-package, we had this warning in the
+# postinst, but the rules did not really interpolate the value in.
+# Here is a sanity check.
+my $pattern = "=" . "I";
+$initrd=~ s/^$pattern$//;
+
+if ($link_in_boot) {
+ $image_dest = "/$image_dir/"; # same as realimageloc
+}
+
+# Tack on at least one trainling /
+$image_dest = "$image_dest/";
+$image_dest =~ s|^/*|/|o;
+$image_dest =~ s|/+$|/|o;
+
+if (! -d "$image_dest") {
+ die "Expected Image Destination dir ($image_dest) to be a valid directory!\n";
+}
+
+# sanity
+if (!($do_bootfloppy || $do_bootloader)) {
+ $do_boot_enable = '';
+}
+if ($do_symlink && $no_symlink) {
+ warn "Both do_symlinks and no_symlinks options enabled; disabling no_symlinks\n";
+ $no_symlink = 0;
+}
+
+# most of our work is done in $image_dest (nominally /)
+chdir("$image_dest") or die "could not chdir to $image_dest:$!\n";
+
+# Paranoid check to make sure that the correct value is put in there
+if (! $kimage) { $kimage = "vmlinuz"; } # Hmm. empty
+elsif ($kimage =~ m/^b?zImage$/o) { $kimage = "vmlinuz"; } # these produce vmlinuz
+elsif ($kimage =~ m/^[iI]mage$/o) { my $nop = $kimage; }
+elsif ($kimage =~ m/^vmlinux$/o) { my $nop = $kimage; }
+else { $kimage = "vmlinuz"; } # Default
+
+$ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
+
+
+die "Internal Error: Could not find image (" . $realimageloc
+ . "$kimage-$version)\n" unless -e $realimageloc
+ . "$kimage-$version";
+
+# search for the boot loader in the path
+my $loader_exec;
+($loader_exec = $loader) =~ s|.*/||;
+my ($loaderloc) = grep -x, map "$_/$loader_exec",
+ map { length($_) ? $_ : "." } split /:/, $ENV{PATH};
+
+
+######################################################################
+## Fix the build link
+######################################################################
+sub fix_build_link {
+ return unless -d "$modules_base/$version";
+ # if we saved a build link in preinst, restore the link
+ if (! -e "$modules_base/$version/build" &&
+ -l "$modules_base/$version/build.save" ) {
+ rename("$modules_base/$version/build.save", "$modules_base/$version/build") ||
+ die "failed to move $modules_base/$version/build:$!";
+ }
+ if ($relink_build_link || $force_build_link) {
+ my $build_target;
+ my $real_target = '';
+ if (-l "$modules_base/$version/build") {
+ $build_target = readlink "$modules_base/$version/build";
+ } else {
+ return;
+ }
+ # Determine what the real file name is, and test that for existence
+ $real_target = abs_path($build_target) if defined($build_target);
+ if (!defined($build_target) || ! -d "$real_target") { # Danglink link
+ warn qq(
+ Hmm. There is a symbolic link $modules_base/$version/build
+ However, I can not read it: $!
+ Therefore, I am deleting $modules_base/$version/build\n
+);
+ my $num = unlink "$modules_base/$version/build";
+ if ($num != 1) {
+ warn "error unlinking $modules_base/$version/build";
+ } else {
+ if ($force_build_link || -d "/usr/src/=ST-headers-$version") {
+ my $result = symlink ("/usr/src/=ST-headers-$version",
+ "$modules_base/$version/build");
+ if (! $result) {
+ warn "Could not link /usr/src/=ST-headers-$version to $modules_base/$version/build:$!"
+ }
+ }
+ }
+ }
+ }
+}
+
+if ($relink_build_link || $force_build_link) {
+ &fix_build_link();
+}
+######################################################################
+## Fix the source link
+######################################################################
+sub fix_source_link {
+ return unless -d "$modules_base/$version";
+ if ($relink_src_link) {
+ my $source_target;
+ my $real_target = '';
+
+ if (-l "$modules_base/$version/source") {
+ $source_target = readlink "$modules_base/$version/source";
+ } else {
+ return;
+ }
+ # Determine what the real file name is, and test that for existence
+ $real_target = abs_path($source_target) if defined($source_target);
+ if (!defined($source_target) || ! -d "$real_target") { # Danglink link
+ warn qq(
+ Hmm. The package shipped with a symbolic link $modules_base/$version/source
+ However, I can not read the target: $!
+ Therefore, I am deleting $modules_base/$version/source\n
+);
+ my $num = unlink "$modules_base/$version/source";
+ if ($num != 1) {
+ warn "error unlinking $modules_base/$version/source";
+ }
+ }
+ }
+}
+
+if ($relink_src_link) {
+ &fix_source_link();
+}
+######################################################################
+######################################################################
+########### Test whether a relative symlinkwould be OK #######
+######################################################################
+######################################################################
+sub test_relative {
+ my %params = @_;
+ my $cwd;
+
+ die "Internal Error: Missing Required paramater 'Old Dir' "
+ unless $params{'Old Dir'};
+ die "Internal Error: Missing Required paramater New Dir' "
+ unless $params{'New Dir'};
+
+
+ die "Internal Error: No such dir $params{'Old Dir'} "
+ unless -d $params{'Old Dir'};
+ die "Internal Error: No such dir $params{'New Dir'} "
+ unless -d $params{'New Dir'};
+
+ warn "Test relative: testing $params{'Old Dir'} -> $params{'New Dir'}"
+ if $DEBUG;
+ chomp($cwd = `pwd`);
+ chdir ($params{'New Dir'}) or die "Could not chdir to $params{'New Dir'}:$!";
+ my $ok = 0;
+ $params{'Old Dir'} =~ s|^/*||o;
+ if (-d $params{'Old Dir'} ) {
+ if (defined $params{'Test File'}) {
+ if (-e $params{'Old Dir'} . $params{'Test File'}) {
+ $ok = 1;
+ }
+ } else {
+ $ok = 1; # well, backward compatibility
+ }
+ }
+ chdir ($cwd) or die "Could not chdir to $params{'New Dir'}:$!";
+ return $ok;
+}
+
+######################################################################
+######################################################################
+############
+######################################################################
+######################################################################
+# sub CanonicalizePath {
+# my $path = join '/', @_;
+# my @work = split '/', $path;
+# my @out;
+# my $is_absolute;
+
+# if (@work && $work[0] eq "") {
+# $is_absolute = 1; shift @work;
+# }
+
+# while (@work) {
+# my $seg = shift @work;
+# if ($seg eq "." || $seg eq "") {
+# }
+# elsif ($seg eq "..") {
+# if (@out && $out[-1] ne "..") {
+# pop @out;
+# }
+# else {
+# # Leading "..", or "../..", etc.
+# push @out, $seg;
+# }
+# }
+# else {
+# push @out, $seg;
+# }
+# }
+
+# unshift @out, "" if $is_absolute;
+# return join('/', @out);
+# }
+######################################################################
+######################################################################
+############
+######################################################################
+######################################################################
+
+sub spath {
+ my %params = @_;
+
+ die "Missing Required paramater 'Old'" unless $params{'Old'};
+ die "Missing Required paramater 'New'" unless $params{'New'};
+
+ my @olddir = split '/', `readlink -q -m $params{'Old'}`;
+ my @newdir = split '/', `readlink -q -m $params{'New'}`;
+ my @outdir = @olddir;
+
+ my $out = '';
+ my $i;
+ for ($i = 0; $i <= $#olddir && $i <= $#newdir; $i++) {
+ $out++ if ($olddir[$i] ne $newdir[$i]);
+ shift @outdir unless $out;
+ unshift @outdir, ".." if $out;
+ }
+ if ($#newdir > $#olddir) {
+ for ($i=0; $i < $#newdir; $i++) {
+ unshift @outdir, "..";
+ }
+ }
+ return join ('/', @outdir);
+}
+######################################################################
+######################################################################
+############
+######################################################################
+######################################################################
+
+
+# This routine actually moves the kernel image
+# From: $realimageloc/$kimage-$version (/boot/vmlinuz-2.6.12)
+# To: $image_dest/$kimage-$version (/vmlinuz-2.6.12)
+# Note that the image is moved to a versioned destination, but ordinary
+# symlinks we create otherwise are not normally versioned
+sub really_move_image {
+ my $src_dir = $_[0];
+ my $target = $_[1];
+ my $dest_dir = $_[2];
+
+ warn "Really move image: src_dir=$src_dir, target=$target,\n destdir=$dest_dir"
+ if $DEBUG;
+ if (-e "$target") {
+ # we should be in dir $dest_dir == $image_dest /, normally
+ rename("$target", "$target.$$") ||
+ die "failed to move " . $dest_dir . "$target:$!";
+ warn "mv $target $target.$$" if $DEBUG;
+ }
+ warn "mv -f $src_dir$target $target" if $DEBUG;
+ my $ret = system("mv -f " . $src_dir . "$target " .
+ " $target");
+ if ($ret) {
+ die("Failed to move " . $src_dir . "$target to "
+ . $dest_dir . "$target.\n");
+ }
+ # Ok, now we may clobber the previous .old files
+ if (-e "$target.$$") {
+ rename("$target.$$", "$target.old") ||
+ die "failed to move " . $dest_dir . "$target:$!";
+ warn "mv $target.$$ $target " if $DEBUG;
+ }
+}
+
+# Normally called after really_move_image; and only called if we asked for
+# reversed link this routine reverses the symbolic link that is notmally
+# created. Since the real kernel image has been moved over to
+# $image_dest/$kimage-$version. So, this routine links
+# From: $image_dest/$kimage-$version (/vmlinuz-2.6.12)
+# To: $realimageloc/$kimage-$version (/boot/vmlinuz-2.6.12)
+sub really_reverse_link {
+ my $src_dir = $_[0];
+ my $link_name = $_[1];
+ my $dest_dir = $_[2];
+ warn "Really reverse link: src_dir=$src_dir, link name=$link_name\n" .
+ "\tdestdir=$dest_dir" if $DEBUG;
+
+ my $Old = $dest_dir;
+ if (test_relative ('Old Dir' => $Old, 'New Dir' => $src_dir,
+ 'Test File' => "$link_name")) {
+ $Old =~ s|^/*||o;
+ }
+ # Special case is they are in the same dir
+ my $rel_path = spath('Old' => "$Old", 'New' => "$src_dir" );
+ $Old ="" if $rel_path =~ m/^\s*$/o;
+
+ if ($use_hard_links =~ m/YES/i) {
+ link($Old . "$link_name", $src_dir . "$link_name") ||
+ die("Failed to symbolic-link " . $dest_dir . "$link_name to " . $src_dir
+ . "$link_name .\n");
+ warn "ln " . $Old . "$link_name " . $src_dir . "$link_name" if $DEBUG;
+ }
+ else {
+ symlink($Old . "$link_name", $src_dir . "$link_name") ||
+ die("Failed to link " . $dest_dir . "$link_name to " . $src_dir .
+ "$link_name .\n");
+ warn "ln -s " . $Old . "$link_name " . $src_dir . "$link_name" if $DEBUG;
+ }
+}
+
+# This routine is invoked if there is a symbolic link in place
+# in $image_dest/$kimage -- so a symlink exists in the destination.
+# What we are trying to determine is if we need to move the symbolic link over
+# to the the .old location
+sub move_p {
+ my $kimage = $_[0]; # Name of the symbolic link
+ my $image_dest = $_[1]; # The directory the links goes into
+ my $image_name = $_[2];
+ my $src_dir = $_[3];
+ my $force_move = 0;
+ warn "Move?: kimage=$kimage, image_dest=$image_dest, \n" .
+ "\timage_name=$image_name, src_dir=$src_dir" if $DEBUG;
+
+ if ($no_symlink || $reverse_symlink) {
+ # we do not want links, yet we have a symbolic link here!
+ warn "found a symbolic link in " . $image_dest . "$kimage \n" .
+ "even though no_symlink is defined\n" if $no_symlink;
+ warn "found a symbolic link in " . $image_dest . "$kimage \n" .
+ "even though reverse_symlink is defined\n" if $reverse_symlink;
+ # make sure we change this state of affairs
+ $force_move = 1;
+ return $force_move;
+ }
+
+ warn "DEBUG: OK. We found symlink, and we should have a symlink here.\n"
+ if $DEBUG;
+ my $vmlinuz_target = readlink "$kimage";
+ my $real_target = '';
+ my $target = `readlink -q -m "${realimageloc}${kimage-$version}"`;
+ $real_target = abs_path($vmlinuz_target) if defined($vmlinuz_target);
+
+ if (!defined($vmlinuz_target) || ! -f "$real_target") {
+ # what, a dangling symlink?
+ warn "The link " . $image_dest . "$kimage is a dangling link" .
+ "to $real_target\n";
+ $force_move = 1;
+ return $force_move;
+ }
+
+
+ warn "DEBUG: The link $kimage points to ($vmlinuz_target)\n" if $DEBUG;
+ warn "DEBUG: ($vmlinuz_target) is really ($real_target)\n" if $DEBUG;
+ my $cwd;
+ chomp ($cwd=`pwd`);
+ if ($vmlinuz_target !~ m|^/|o) {
+ $vmlinuz_target = $cwd . "/" . $vmlinuz_target;
+ $vmlinuz_target =~ s|/+|/|o;
+ }
+ $vmlinuz_target = `readlink -q -m $vmlinuz_target`;
+
+ if ("$vmlinuz_target" ne "$target") {
+ warn "DEBUG: We need to handle this.\n" if $DEBUG;
+ if ($minimal_swap) {
+ warn "DEBUG: Minimal swap.\n" if $DEBUG;
+ if (-l "$kimage.old") {
+ warn "DEBUG: There is an old link at $kimage.old\n" if $DEBUG;
+ my $old_target = readlink "$kimage.old";
+ my $real_old_target = '';
+ $real_old_target=abs_path($old_target) if defined ($old_target);
+
+ if ($real_old_target && -f "$real_old_target") {
+ if ($old_target !~ m|^/|o) {
+ $old_target = $cwd . "/" . $old_target;
+ $old_target =~ s|/+|/|o;
+ }
+ $old_target = `readlink -q -m $old_target`;
+ if ("$old_target" ne "$target") {
+ $force_move = 1;
+ warn "DEBUG: Old link ($old_target) does not point to us ($target)\n"
+ if $DEBUG;
+ }
+ else { # The .old points to the current
+ warn "$kimage.old --> $target -- doing nothing";
+ $force_move = 0;
+ }
+ }
+ else {
+ warn "DEBUG: Well, the old link does not exist -- so we move\n"
+ if $DEBUG;
+ $force_move = 1;
+ }
+ }
+ else {
+ warn "DEBUG: No .old link -- OK to move\n"
+ if $DEBUG;
+ $force_move = 1;
+ }
+ }
+ else {
+ warn "DEBUG: ok, minimal swap is no-- so we move.\n"
+ if $DEBUG;
+ $force_move = 1;
+ }
+ }
+ else { # already have proper link
+ warn "$kimage($vmlinuz_target) points to $target ($real_target) -- doing nothing";
+ $force_move = 0;
+ }
+ return $force_move;
+}
+
+
+# This routine moves the symbolic link around (/vmlinuz -> /vmlinuz.old)
+# It pays attention to whether we should the fact whether we should be using
+# hard links or not.
+sub really_move_link {
+ my $kimage = $_[0]; # Name of the symbolic link
+ my $image_dest = $_[1]; # The directory the links goes into
+ my $image_name = $_[2];
+ my $src_dir = $_[3];
+ warn "really_move_link: kimage=$kimage, image_dest=$image_dest\n" .
+ "\t image_name=$image_name, src_dir=$src_dir" if $DEBUG;
+
+ # don't clobber $kimage.old quite yet
+ rename("$kimage", "$kimage.$$") ||
+ die "failed to move " . $image_dest . "$kimage:$!";
+ warn "mv $kimage $kimage.$$" if $DEBUG;
+ my $Old = $src_dir;
+ my $cwd;
+
+ chomp($cwd=`pwd`);
+ if (test_relative ('Old Dir' => $Old, 'New Dir' => $cwd,
+ 'Test File' => "$image_name")) {
+ $Old =~ s|^/*||o;
+ }
+ # Special case is they are in the same dir
+ my $rel_path = spath('Old' => "$Old", 'New' => "$cwd" );
+ $Old ="" if $rel_path =~ m/^\s*$/o;
+
+ if ($use_hard_links =~ m/YES/i) {
+ warn "ln ${Old}${image_name} $kimage" if $DEBUG;
+ if (! link("${Old}${image_name}", "$kimage")) {
+ rename("$kimage.$$", "$kimage");
+ die("Failed to link ${Old}${image_name} to " .
+ "${image_dest}${kimage}.\n");
+ }
+ }
+ else {
+ warn "ln -s ${Old}${image_name} $kimage" if $DEBUG;
+ if (! symlink("${Old}${image_name}", "$kimage")) {
+ rename("$kimage.$$", "$kimage");
+ die("Failed to symbolic-link ${Old}${image_name} to " .
+ "${image_dest}${kimage}.\n");
+ }
+ }
+
+ # Ok, now we may clobber the previous .old file
+ if (-l "$kimage.old" || ! -e "$kimage.old" ) {
+ rename("$kimage.$$", "$kimage.old");
+ warn "mv $kimage.$$ $kimage.old" if $DEBUG;
+ }
+ else {
+ warn "$kimage.old is not a symlink, not clobbering\n";
+ warn "rm $kimage.$$";
+ unlink "$kimage.$$" if $DEBUG;
+ }
+}
+
+# This routine handles a request to do symlinks, but there is no
+# symlink file already there. Either we are supposed to use copy, or we are
+# installing on a pristine system, or the user does not want symbolic links at
+# all. We use a configuration file to tell the last two cases apart, creating
+# a config file if needed.
+sub handle_missing_link {
+ my $kimage = $_[0]; # Name of the symbolic link
+ my $image_dest = $_[1]; # The directory the links goes into
+ my $image_name = $_[2];
+ my $src_dir = $_[3];
+ warn "handle_missing_link: kimage=$kimage, image_dest=$image_dest\n" .
+ "\t image_name=$image_name, src_dir=$src_dir" if $DEBUG;
+
+ if ($no_symlink) {
+ warn "cp -a --backup=t $realimageloc$image_name $kimage" if $DEBUG;
+ my $ret = system("cp -a --backup=t " . $realimageloc .
+ "$image_name " . " $kimage");
+ if ($ret) {
+ die("Failed to copy " . $realimageloc . "$image_name to "
+ . $image_dest . "$kimage .\n");
+ }
+ }
+ elsif ($reverse_symlink) {
+ warn "mv -f $realimageloc$image_name $kimage" if $DEBUG;
+ my $ret = system("mv -f " . $realimageloc . "$image_name "
+ . "$kimage");
+ if ($ret) {
+ die("Failed to move " . $realimageloc . "$image_name to "
+ . $image_dest . "$kimage .\n");
+ }
+ }
+ else {
+ if (! $have_conffile) {
+ my $ret;
+ my $answer='';
+ $do_symlink = "Yes";
+ my $question = "${package_name}/postinst/create-kimage-link-$version";
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ $answer =~ s/^\s+//;
+ $answer =~ s/\s+$//;
+ $do_symlink = "No" if $answer =~ /^(f|n)/i;
+
+ if (open(CONF, ">$CONF_LOC")) {
+ print CONF "# Kernel Image management overrides\n";
+ print CONF "# See kernel-img.conf(5) for details\n";
+ if ($loader =~ /palo/i) {
+ print CONF "link_in_boot = Yes\n";
+ print CONF "do_symlinks = Yes\n";
+ print CONF "relative_links = Yes\n";
+ print CONF "do_bootloader = No\n";
+ } else {
+ print CONF "do_symlinks = $do_symlink\n";
+ }
+ close CONF;
+ }
+ $have_conffile = "Yes";
+ }
+ }
+
+ if (! $no_symlink && $do_symlink =~ /Yes/i) {
+ my $Old = $realimageloc;
+ my $New = $image_dest;
+ my $Name = "$image_name";
+ my $Link_Dest = "$kimage";
+
+ if ($reverse_symlink) {
+ $Old = $image_dest;
+ $New = $realimageloc;
+ $Name = "$kimage";
+ $Link_Dest = $realimageloc . "$image_name";
+ }
+ if (test_relative ('Old Dir' => $Old,
+ 'New Dir' => $New,
+ 'Test File' => $Name)) {
+ $Old =~ s|^/*||o;
+ }
+ # Special case is they are in the same dir
+ my $rel_path = spath('Old' => "$Old", 'New' => "$New" );
+ $Old ="" if $rel_path =~ m/^\s*$/o;
+
+ symlink($Old . "$Name", "$Link_Dest") ||
+ die("Failed to symbolic-link ${Old}$Name to $Link_Dest.\n");
+ warn "ln -s ${Old}$Name $Link_Dest" if $DEBUG;
+
+ }
+}
+
+# This routine handles the rest of the cases, where the user has requested
+# non-traditional handling, like using cp, or reverse symlinks, or hard links.
+sub handle_non_symlinks {
+ my $kimage = $_[0]; # Name of the symbolic link
+ my $image_dest = $_[1]; # The directory the links goes into
+ my $image_name = $_[2];
+ my $src_dir = $_[3];
+ warn "handle_non_link: kimage=$kimage, image_dest=$image_dest\n" .
+ "\t image_name=$image_name, src_dir=$src_dir" if $DEBUG;
+
+ # Save the current image. We do this in all four cases
+ rename("$kimage", "$kimage.$$") ||
+ die "failed to move " . $image_dest . "$kimage:$!";
+ warn "mv $kimage $kimage.$$" if $DEBUG;
+
+ ##,####
+ # case One
+ #`####
+ if ($no_symlink) {
+ # Maybe /$image_dest is on a dos system?
+ warn "cp -a --backup=t $realimageloc$image_name $kimage" if $DEBUG;
+ my $ret = system("cp -a --backup=t " . $realimageloc
+ . "$image_name " . "$kimage");
+ if ($ret) {
+ if (-e "$kimage.$$") {
+ rename("$kimage.$$", "$kimage");
+ warn "mv $kimage.$$ $kimage" if $DEBUG;
+ }
+ die("Failed to copy " . $realimageloc . "$image_name to "
+ . $image_dest . "$kimage .\n");
+ }
+ }
+ ##,####
+ # case Two
+ #`####
+ elsif ($reverse_symlink) { # Maybe /$image_dest is on a dos system?
+ warn "mv -f $realimageloc$image_name $kimage" if $DEBUG;
+ my $ret = system("mv -f " . $realimageloc . "$image_name "
+ . $image_dest . "$kimage");
+ if ($ret) {
+ if (-e "$kimage.$$") {
+ rename("$kimage.$$", "$kimage");
+ warn "mv $kimage.$$ $kimage" if $DEBUG;
+ }
+ die("Failed to move " . $realimageloc . "$image_name to "
+ . $image_dest . "$kimage .\n");
+ }
+ my $Old = $image_dest;
+ if (test_relative ('Old Dir' => $Old, 'New Dir' => $realimageloc,
+ 'Test File' => "$kimage")) {
+ $Old =~ s|^/*||o;
+ }
+ # Special case is they are in the same dir
+ my $rel_path = spath('Old' => "$Old", 'New' => "$realimageloc" );
+ $Old ="" if $rel_path =~ m/^\s*$/o;
+
+ if ($use_hard_links =~ m/YES/i) {
+ warn "ln " . $Old . "$kimage " . $realimageloc . "$image_name" if $DEBUG;
+ if (! link($Old . "$kimage", $realimageloc . "$image_name")) {
+ warn "Could not link " . $image_dest .
+ "$kimage to $image_name :$!";
+ }
+ }
+ else {
+ warn "ln -s " . $Old . "$kimage " . $realimageloc . "$image_name" if $DEBUG;
+ if (! symlink($Old . "$kimage", $realimageloc . "$image_name")) {
+ warn "Could not symlink " . $image_dest .
+ "$kimage to $image_name :$!";
+ }
+ }
+ }
+ ##,####
+ # case Three
+ #`####
+ elsif ($use_hard_links =~ m/YES/i ) {
+ # Ok then. this ought to be a hard link, and hence fair game
+ # don't clobber $kimage.old quite yet
+ my $Old = $realimageloc;
+ my $cwd;
+ chomp($cwd=`pwd`);
+ if (test_relative ('Old Dir' => $Old, 'New Dir' => $cwd,
+ 'Test File' => "$image_name")) {
+ $Old =~ s|^/*||o;
+ }
+ # Special case is they are in the same dir
+ my $rel_path = spath('Old' => "$Old", 'New' => "$cwd" );
+ $Old ="" if $rel_path =~ m/^\s*$/o;
+
+ warn "ln " . $Old . "$image_name " . "$kimage" if $DEBUG;
+ if (! link($Old . "$image_name", "$kimage")) {
+ warn "mv $kimage.$$ $kimage" if $DEBUG;
+ rename("$kimage.$$", "$kimage");
+ die("Failed to link " . $realimageloc . "$image_name to "
+ . $image_dest . "$kimage .\n");
+ }
+ }
+ ##,####
+ # case Four
+ #`####
+ else {
+ # We just use cp
+ warn "cp -a --backup=t $realimageloc$image_name $kimage" if $DEBUG;
+ my $ret = system("cp -a --backup=t " . $realimageloc
+ . "$image_name " . "$kimage");
+ if ($ret) {
+ if (-e "$kimage.$$") {
+ warn "mv $kimage.$$ $kimage" if $DEBUG;
+ rename("$kimage.$$", "$kimage");
+ }
+ die("Failed to copy " . $realimageloc . "$image_name to "
+ . $image_dest . "$kimage .\n");
+ }
+ }
+ # Ok, now we may clobber the previous .old file
+ warn "mv $kimage.$$ $kimage.old if -e $kimage.$$" if $DEBUG;
+ rename("$kimage.$$", "$kimage.old") if -e "$kimage.$$";
+}
+
+# This routine is responsible for setting up the symbolic links
+# So, the actual kernel image lives in
+# $realimageloc/$image_name (/boot/vmlinuz-2.6.12).
+# This routine creates symbolic links in $image_dest/$kimage (/vmlinuz)
+sub image_magic {
+ my $kimage = $_[0]; # Name of the symbolic link
+ my $image_dest = $_[1]; # The directory the links goes into
+ my $image_name = "$kimage-$version";
+ my $src_dir = $realimageloc;
+ warn "image_magic: kimage=$kimage, image_dest=$image_dest\n" .
+ "\t image_name=$image_name, src_dir=$src_dir" if $DEBUG;
+
+ # Well, in any case, if the destination (the symlink we are trying
+ # to create) is a directory, we should do nothing, except throw a
+ # diagnostic.
+ if (-d "$kimage" ) {
+ die ("Hmm. $kimage is a directory, which I did not expect. I am\n" .
+ "trying to create a symbolic link with that name linked to \n" .
+ "$image_dest . Since a directory exists here, my assumptions \n" .
+ "are way off, and I am aborting.\n" );
+ exit (3);
+ }
+
+ if ($move_image) { # Maybe $image_dest is in on dos, or something?
+ # source dir, link name, dest dir
+ really_move_image( $realimageloc, $image_name, $image_dest);
+ really_reverse_link($realimageloc, $image_name, $image_dest)
+ if $reverse_symlink;
+ return;
+ }
+
+ if (-l "$kimage") { # There is a symbolic link
+ warn "DEBUG: There is a symlink for $kimage\n" if $DEBUG;
+ my $force_move = move_p($kimage, $image_dest, $image_name, $src_dir);
+
+ if ($force_move) {
+ really_move_link($kimage, $image_dest, $image_name, $src_dir);
+ }
+ }
+ elsif (! -e "$kimage") {
+ # Hmm. Pristine system? How can that be? Installing from scratch?
+ # Or maybe the user does not want a symbolic link here.
+ # Possibly they do not want a link here. (we should be in /
+ # here[$image_dest, really]
+ handle_missing_link($kimage, $image_dest, $image_name, $src_dir);
+ }
+ elsif (-e "$kimage" ) {
+ # OK, $kimage exists -- but is not a link
+ handle_non_symlinks($kimage, $image_dest, $image_name, $src_dir);
+ }
+}
+
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+
+# We may not have any modules installed
+if ( -d "$modules_base/$version" ) {
+ print STDERR "Running depmod.\n";
+ my $ret = system("depmod -a -F $realimageloc/System.map-$version $version");
+ my $exit_value = $? >> 8;
+ my $signal_num = $? & 127;
+ my $dumped_core = $? & 128;
+ if ($ret) {
+ if ( -f "$modules_base/$version/modules.dep") {
+ unlink "$modules_base/$version/modules.dep" unless $initrd;
+ }
+ my $seen;
+ my $answer;
+ my $question = "${package_name}/postinst/depmod-error-$version";
+ if ($initrd) {
+ $question = "${package_name}/postinst/depmod-error-initrd-$version";
+ }
+ ($ret,$seen) = fset ("$question", 'seen', 'false');
+ die "Error setting debconf flags in $question: $seen" if $ret;
+
+ $ret = subst("$question", 'modules_base', "$modules_base");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ $ret = subst("$question", 'SIGNAL', ", and got a signal $signal_num");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ if ($dumped_core) {
+ $ret = subst("$question", 'CORE', ", and dumped core");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+ }
+ else {
+ $ret = subst("$question", 'CORE', " ");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+ }
+
+ ($ret,$seen) = input('medium', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ if (! $ignore_depmod_err) {
+ if ($answer =~ /^(y|t)/i) {
+ exit(1);
+ }
+ else {
+ print STDERR "Ok, continuing as directed\n";
+ }
+ }
+ }
+}
+
+
+
+sub find_inird_tool {
+ my $hostversion = shift;
+ my $version = shift;
+ print STDERR "Finding valid ramdisk creators.\n";
+ my @ramdisks =
+ grep {
+ my $args =
+ "$_ " .
+ "--supported-host-version=$hostversion " .
+ "--supported-target-version=$version " .
+ "1>/dev/null 2>&1"
+ ;
+ system($args) == 0;
+ }
+ split (/[:,\s]+/, $ramdisk);
+}
+
+# The initrd symlink should probably be in the same dir that the
+# symlinks are in
+if ($initrd) {
+ chomp (my $hostversion = `uname -r`);
+ my @ramdisklist;
+ @ramdisklist = find_inird_tool($hostversion, $version, $ramdisk) if $ramdisk;
+ die "Failed to find suitable ramdisk generation tool for kernel version \n" .
+ "$version on running kernel $hostversion in $ramdisk\n"
+ if $#ramdisklist < 0;
+ my $success = 0;
+ for $ramdisk_cmd (@ramdisklist) {
+ print STDERR "Using $ramdisk_cmd to build the ramdisk.\n";
+ print STDERR "Other valid candidates: @ramdisklist\n" if $#ramdisklist > 0;
+
+ my $initrd_path = $realimageloc . "initrd.img-$version";
+ my $ret = system("$ramdisk_cmd " .
+ ($mkimage ? "-m '$mkimage' " : "") .
+ "-o $initrd_path.new $modules_base/$version");
+ if ($ret) {
+ warn "$ramdisk_cmd failed to create initrd image.\n";
+ }
+ else {
+ rename("$initrd_path.new", "$initrd_path")
+ or die("Failed to rename initrd ($initrd_path)\n");
+ $success = 1;
+ last;
+ }
+ }
+ die "Failed to create initrd image.\n" unless $success;
+ if (! defined $ARGV[1] || ! $ARGV[1] || $ARGV[1] =~ m/<unknown>/og) {
+ image_magic("initrd.img", $image_dest);
+ }
+ else {
+ if (! -e "initrd.img") {
+ handle_missing_link("initrd.img", $image_dest, "initrd.img-$version",
+ $realimageloc);
+ }
+ else {
+ print STDERR
+ "Not updating initrd symbolic links since we are being updated/reinstalled \n";
+ print STDERR
+ "($ARGV[1] was configured last, according to dpkg)\n";
+ }
+ }
+
+ if ($initrd && -l "initrd" ) {
+ my $ret;
+ my $seen;
+ my $answer;
+ my $question = "${package_name}/postinst/old-initrd-link-$version";
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ $answer =~ s/^\s+//;
+ $answer =~ s/\s+$//;
+ if ($answer =~ /^(y|t)/i) {
+ unlink "initrd";
+ }
+ }
+
+ if ($initrd && -l "$image_dir/initrd" && ! $link_in_boot) {
+ my $ret;
+ my $seen;
+ my $answer;
+ my $question = "${package_name}/postinst/old-dir-initrd-link-$version";
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ $answer =~ s/^\s+//;
+ $answer =~ s/\s+$//;
+ if ($answer =~ /^(y|t)/i) {
+ unlink "$image_dir/initrd";
+ }
+ }
+}
+else { # Not making an initrd emage
+ if (-l "initrd.img") {
+ # Ooh, last image was an initrd image? in any case, we should move it.
+ my $target = readlink "initrd.img";
+ my $real_target = '';
+ $real_target = abs_path($target) if defined ($target);
+
+ if (!defined($target) || ! -f "$real_target") {
+ # Eh. dangling link. can safely be removed.
+ unlink("initrd.img");
+ } else {
+ if (-l "initrd.img.old" || ! -e "initrd.img.old" ) {
+ rename("initrd.img", "initrd.img.old");
+ } else {
+ warn "initrd.img.old is not a symlink, not clobbering\n";
+ unlink("initrd.img");
+ }
+ }
+ }
+}
+
+# Only change the symlinks if we are not being upgraded
+if (! defined $ARGV[1] || ! $ARGV[1] || $ARGV[1] =~ m/<unknown>/og) {
+ image_magic($kimage, $image_dest);
+}
+else {
+ if (! -e "$kimage") {
+ handle_missing_link($kimage, $image_dest, "$kimage-$version",
+ $realimageloc);
+ }
+ else {
+ print STDERR
+ "Not updating image symbolic links since we are being updated/reinstalled \n";
+ print STDERR
+ "($ARGV[1] was configured last, according to dpkg)\n";
+ }
+}
+
+# We used to have System.* files in /
+if (-e "/System.map" || -e "/System.old") {
+ my $ret;
+ my $answer;
+ my $question = "${package_name}/postinst/old-system-map-link-$version";
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ $answer =~ s/^\s+//;
+ $answer =~ s/\s+$//;
+ if ($answer =~ /^(y|t)/i) {
+ unlink '/System.map' if -e '/System.map';
+ unlink '/System.old' if -e '/System.old';
+ print STDERR "Obsolete links removed.\n";
+ }
+}
+
+# creating some info about kernel and initrd
+if ($DEBUG) {
+ my $ksize=sprintf("%.0f",(stat($realimageloc .
+ "$kimage-$version"))[7]/1024)."kB";
+ my $initrdsize='';
+ if ($initrd) {
+ $initrdsize=sprintf("%.0f",(stat($realimageloc .
+ "initrd.img-$version"))[7]/1024)."kB";
+ }
+
+ print STDERR <<"EOMSG";
+A new kernel image has been installed at $realimageloc$kimage-$version
+ (Size: $ksize)
+
+Symbolic links, unless otherwise specified, can be found in $image_dest
+
+EOMSG
+ ;
+
+ if ($initrd) {
+ print STDERR <<"EOMSGA";
+
+ Initial rootdisk image: ${realimageloc}initrd.img-$version (Size: $initrdsize)
+EOMSGA
+ ;
+ }
+}
+
+# set the env var stem
+$ENV{'STEM'} = "=ST";
+sub exec_script {
+ my $type = shift;
+ my $script = shift;
+ print STDERR "Running $type hook script $script.\n";
+ system ("$script $version $realimageloc$kimage-$version") &&
+ print STDERR "User $type hook script [$script] ";
+ if ($?) {
+ if ($? == -1) {
+ print STDERR "failed to execute: $!\n";
+ }
+ elsif ($? & 127) {
+ printf STDERR "died with signal %d, %s coredump\n",
+ ($? & 127), ($? & 128) ? 'with' : 'without';
+ }
+ else {
+ printf STDERR "exited with value %d\n", $? >> 8;
+ }
+ exit $? >> 8;
+ }
+}
+sub run_hook {
+ my $type = shift;
+ my $script = shift;
+ if ($script =~ m,^/,) {
+ # Full path provided for the hook script
+ if (-x "$script") {
+ &exec_script($type,$script);
+ }
+ else {
+ die "The provided $type hook script [$script] could not be run.\n";
+ }
+ }
+ else {
+ # Look for it in a safe path
+ for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
+ if (-x "$path/$script") {
+ &exec_script($type, "$path/$script");
+ return 0;
+ }
+ }
+ # No luck
+ print STDERR "Could not find $type hook script [$script].\n";
+ die "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
+ }
+}
+
+## Run user hook script here, if any
+if ($postinst_hook) {
+ &run_hook("postinst", $postinst_hook);
+}
+
+if (-d "/etc/kernel/postinst.d") {
+ print STDERR "Examining /etc/kernel/postinst.d.\n";
+ system ("run-parts --verbose --exit-on-error --arg=$version " .
+ "--arg=$realimageloc$kimage-$version " .
+ "/etc/kernel/postinst.d") &&
+ die "Failed to process /etc/kernel/postinst.d";
+}
+
+if (-d "/etc/kernel/postinst.d/$version") {
+ print STDERR "Examining /etc/kernel/postinst.d/$version.\n";
+ system ("run-parts --verbose --exit-on-error --arg=$version " .
+ "--arg=$realimageloc$kimage-$version " .
+ "/etc/kernel/postinst.d/$version") &&
+ die "Failed to process /etc/kernel/postinst.d/$version";
+}
+
+LOADER: {
+ last unless $do_boot_enable; # Exit if explicitly asked to
+
+ last if $loader =~ /silo/i; # SILO does not have to be executed.
+ last if $loader =~ /yaboot/i; # yaboot does not have to be executed.
+ last if $loader =~ /milo/i; # MILO does not have to be executed.
+ last if $loader =~ /nettrom/i; # NETTROM does not have to be executed.
+ last if $loader =~ /arcboot/i; # ARCBOOT does not have to be executed.
+ last if $loader =~ /delo/i; # DELO does not have to be executed.
+ if ($official_image =~ /^\s*YES\s*$/o) {
+ last if $loader =~ /quik/i; # maintainer asked quik invocation to be ignored
+ }
+
+ last unless $loaderloc;
+ last unless -x $loaderloc;
+ last unless $do_bootloader;
+
+ if (-T "/etc/$loader.conf") {
+ # Trust and use the existing lilo.conf.
+ print STDERR "You already have a $Loader configuration in /etc/$loader.conf\n";
+ my $ret = &run_lilo();
+ exit $ret if $ret;
+ }
+}
+
+
+sub run_lilo (){
+ my $ret;
+ # Try and figure out if the user really wants lilo to be run --
+ # since the default is to run the boot laoder, which is ! grub -- but
+ # the user may be using grub now, and not changed the default.
+
+ # So, if the user has explicitly asked for the loader to be run, or
+ # if there is no postinst hook, or if there is no grub installed --
+ # we are OK. Or else, we ask.
+ if ($explicit_do_loader || (! ($postinst_hook && -x '/sbin/grub'))) {
+ print STDERR "Running boot loader as requested\n";
+ }
+ else {
+ # Ask the user
+ my $seen;
+ my $question = "shared/kernel-image/really-run-bootloader";
+
+ print STDERR "Do we really want to run bootloader $loader?\n";
+
+ ($ret,$seen) = fset ("$question", 'seen', 'false');
+ die "Error setting debconf flags in $question: $seen" if $ret;
+
+ $ret = subst("$question", 'loader', "$loader");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ if ($answer =~ /^(y|t)/i) {
+ print STDERR "Ok, not running $loader\n";
+ return 0;
+ }
+ else {
+ print STDERR "Ok, continuing as directed.\n";
+ }
+
+ }
+ if ($loader =~ /^lilo/io or $loader =~ /vmelilo/io) {
+ print STDERR "Testing $loader.conf ... \n";
+ unlink $temp_file_name; # security
+ $ret = system("$loaderloc -t >$temp_file_name 2>&1");
+ if ($ret) {
+ my $seen;
+ my $note = "${package_name}/postinst/bootloader-test-error-$version";
+
+ print STDERR "Failed test for bootloader $loader\n";
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'loader', "$loader");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'temp_file_name', "$temp_file_name");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$note");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf note $note: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error showing debconf note $note: $seen";
+ }
+ return $ret;
+ }
+ unlink "$temp_file_name";
+ print STDERR "Testing successful.\n";
+ print STDERR "Installing the ";
+ print STDERR "partition " if $loader =~ /^lilo/io;
+ print STDERR "boot sector... \n";
+ }
+
+ print STDERR "Running $loaderloc ... \n";
+ if ($loader =~ /^elilo/io) {
+ $ret = system("$loaderloc 2>&1 | tee $temp_file_name");
+ } else {
+ $ret = system("$loaderloc >$temp_file_name 2>&1");
+ }
+ if ($ret) {
+ my $ret;
+ my $seen;
+ my $note = "${package_name}/postinst/bootloader-error-$version";
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'locader', "$loader");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'temp_file_name', "$temp_file_name");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$note");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf note $note: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $note: $seen";
+ }
+ return $ret;
+ }
+ unlink $temp_file_name;
+ print STDERR "Installation successful.\n";
+ return 0;
+}
+
+exit 0;
+
+__END__
+
Added: people/waldi/linux-2.6/debian/templates/temp.image.plain/postrm
==============================================================================
--- (empty file)
+++ people/waldi/linux-2.6/debian/templates/temp.image.plain/postrm Sat Dec 2 14:40:34 2006
@@ -0,0 +1,397 @@
+#! /usr/bin/perl
+# -*- Mode: Cperl -*-
+# image.postrm ---
+# Author : Manoj Srivastava ( srivasta at glaurung.green-gryphon.com )
+# Created On : Sat May 15 11:05:13 1999
+# Created On Node : glaurung.green-gryphon.com
+# Last Modified By : Manoj Srivastava
+# Last Modified On : Wed Sep 13 11:26:19 2006
+# Last Machine Used: glaurung.internal.golden-gryphon.com
+# Update Count : 57
+# Status : Unknown, Use with caution!
+# HISTORY :
+# Description :
+#
+# $Id: image.postrm,v 1.31 2003/10/07 16:24:20 srivasta Exp $
+#
+
+
+#
+#use strict; #for debugging
+use Cwd 'abs_path';
+
+# Debconf may not be around here.
+my $have_debconf = 0;
+my $capb;
+
+eval {require Debconf::Client::ConfModule;};
+if ( ! $@ )
+{
+ $have_debconf++;
+ import Debconf::Client::ConfModule ':all';
+ version('2.0');
+ $capb=capb("backup");
+}
+
+$|=1;
+# Predefined values:
+my $version = "=V";
+my $link_in_boot = "=IB"; # Should be empty, mostly
+my $no_symlink = "=S"; # Should be empty, mostly
+my $reverse_symlink = "=R"; # Should be empty, mostly
+my $do_symlink = "Yes"; # target machine defined
+my $do_boot_enable = "Yes"; # target machine defined
+my $do_bootfloppy = "Yes"; # target machine defined
+my $do_bootloader = "Yes"; # target machine defined
+my $move_image = ''; # target machine defined
+my $kimage = "=K"; # Should be empty, mostly
+my $loader = "=L"; # lilo, silo, quik, palo, vmelilo, or nettrom
+my $image_dir = "=D"; # where the image is located
+my $clobber_modules = ''; # target machine defined
+my $initrd = "=I"; # initrd kernel
+my $mkimage = "=M"; # command to generate the initrd image
+my $do_initrd = ''; # Normally, we don't
+my $warn_initrd = 'YES'; # Normally we do
+my $use_hard_links = ''; # hardlinks do not work across fs boundaries
+my $postinst_hook = ''; #Normally we do not
+my $postrm_hook = ''; #Normally we do not
+my $preinst_hook = ''; #Normally we do not
+my $prerm_hook = ''; #Normally we do not
+my $minimal_swap = ''; # Do not swap symlinks
+my $ignore_depmod_err = ''; # normally we do not
+my $relink_build_link = 'YES'; # There is no harm in checking the link
+my $force_build_link = ''; # we shall not create a dangling link
+my $official_image = "=OF"; # only true for official images
+my $arch = "=A"; # should be same as dpkg --print-installation-architecture
+my $kernel_arch = "=B";
+my $ramdisk = "=MK"; # List of tools to create initial ram fs.
+my $initrddep = "=MD"; # List of dependencies for such tools
+my $package_name = "=ST-image-$version";
+
+my $Loader = "NoLOADER"; #
+$Loader = "LILO" if $loader =~ /^lilo/io;
+$Loader = "SILO" if $loader =~ /^silo/io;
+$Loader = "QUIK" if $loader =~ /^quik/io;
+$Loader = "yaboot" if $loader =~ /^yaboot/io;
+$Loader = "PALO" if $loader =~ /^palo/io;
+$Loader = "NETTROM" if $loader =~ /^nettrom/io;
+$Loader = "VMELILO" if $loader =~ /^vmelilo/io;
+$Loader = "ZIPL" if $loader =~ /^zipl/io;
+$Loader = "ELILO" if $loader =~ /^elilo/io;
+
+
+# This should not point to /tmp, because of security risks.
+my $temp_file_name = "/var/log/$loader" . "_log.$$";
+
+#known variables
+my @boilerplate = ();
+my @silotemplate = ();
+my @quiktemplate = ();
+my @palotemplate = ();
+my @vmelilotemplate = ();
+my $bootdevice = '';
+my $rootdevice = '';
+my $rootdisk = '';
+my $rootpartition = '';
+my $image_dest = "/";
+my $realimageloc = "/$image_dir/";
+my $have_conffile = "";
+my $CONF_LOC = '/etc/kernel-img.conf';
+my $relative_links = '';
+my $silent_modules = '';
+my $silent_loader = '';
+my $warn_reboot = 'Yes'; # Warn that we are installing a version of
+ # the kernel we are running
+
+chdir('/') or die "could not chdir to /:$!\n";
+# remove multiple leading slashes; make sure there is at least one.
+$realimageloc =~ s|^/*|/|o;
+$realimageloc =~ s|/+|/|o;
+
+
+if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
+ if (open(CONF, "$CONF_LOC")) {
+ while (<CONF>) {
+ chomp;
+ s/\#.*$//g;
+ next if /^\s*$/;
+
+ $do_symlink = "" if /do_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $no_symlink = "" if /no_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $reverse_symlink = "" if /reverse_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /image_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /link_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $move_image = "" if /move_image\s*=\s*(no|false|0)\s*$/ig;
+ $clobber_modules = '' if /clobber_modules\s*=\s*(no|false|0)\s*$/ig;
+ $do_boot_enable = '' if /do_boot_enable\s*=\s*(no|false|0)\s*$/ig;
+ $do_bootfloppy = '' if /do_bootfloppy\s*=\s*(no|false|0)\s*$/ig;
+ $relative_links = '' if /relative_links \s*=\s*(no|false|0)\s*$/ig;
+ $do_bootloader = '' if /do_bootloader\s*=\s*(no|false|0)\s*$/ig;
+ $do_initrd = '' if /do_initrd\s*=\s*(no|false|0)\s*$/ig;
+ $warn_initrd = '' if /warn_initrd\s*=\s*(no|false|0)\s*$/ig;
+ $use_hard_links = '' if /use_hard_links\s*=\s*(no|false|0)\s*$/ig;
+ $silent_modules = '' if /silent_modules\s*=\s*(no|false|0)\s*$/ig;
+ $silent_loader = '' if /silent_loader\s*=\s*(no|false|0)\s*$/ig;
+ $warn_reboot = '' if /warn_reboot\s*=\s*(no|false|0)\s*$/ig;
+ $minimal_swap = '' if /minimal_swap\s*=\s*(no|false|0)\s*$/ig;
+ $ignore_depmod_err = '' if /ignore_depmod_err\s*=\s*(no|false|0)\s*$/ig;
+ $relink_build_link = '' if /relink_build_link\s*=\s*(no|false|0)\s*$/ig;
+ $force_build_link = '' if /force_build_link\s*=\s*(no|false|0)\s*$/ig;
+
+ $do_symlink = "Yes" if /do_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $no_symlink = "Yes" if /no_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $reverse_symlink = "Yes" if /reverse_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /image_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /link_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $move_image = "Yes" if /move_image\s*=\s*(yes|true|1)\s*$/ig;
+ $clobber_modules = "Yes" if /clobber_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $do_boot_enable = "Yes" if /do_boot_enable\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootfloppy = "Yes" if /do_bootfloppy\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootloader = "Yes" if /do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
+ $relative_links = "Yes" if /relative_links\s*=\s*(yes|true|1)\s*$/ig;
+ $do_initrd = "Yes" if /do_initrd\s*=\s*(yes|true|1)\s*$/ig;
+ $warn_initrd = "Yes" if /warn_initrd\s*=\s*(yes|true|1)\s*$/ig;
+ $use_hard_links = "Yes" if /use_hard_links\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_modules = 'Yes' if /silent_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_loader = 'Yes' if /silent_loader\s*=\s*(yes|true|1)\s*$/ig;
+ $warn_reboot = 'Yes' if /warn_reboot\s*=\s*(yes|true|1)\s*$/ig;
+ $minimal_swap = 'Yes' if /minimal_swap\s*=\s*(yes|true|1)\s*$/ig;
+ $ignore_depmod_err = 'Yes' if /ignore_depmod_err\s*=\s*(yes|true|1)\s*$/ig;
+ $relink_build_link = 'Yes' if /relink_build_link\s*=\s*(yes|true|1)\s*$/ig;
+ $force_build_link = 'Yes' if /force_build_link\s*=\s*(yes|true|1)\s*$/ig;
+
+ $image_dest = "$1" if /image_dest\s*=\s*(\S+)/ig;
+ $postinst_hook = "$1" if /postinst_hook\s*=\s*(\S+)/ig;
+ $postrm_hook = "$1" if /postrm_hook\s*=\s*(\S+)/ig;
+ $preinst_hook = "$1" if /preinst_hook\s*=\s*(\S+)/ig;
+ $prerm_hook = "$1" if /prerm_hook\s*=\s*(\S+)/ig;
+ $mkimage = "$1" if /mkimage\s*=\s*(.+)$/ig;
+ $ramdisk = "$1" if /ramdisk\s*=\s*(.+)$/ig;
+ }
+ close CONF;
+ $have_conffile = "Yes";
+ }
+}
+
+if ($link_in_boot) {
+ $image_dest = "/$image_dir/";
+ $image_dest =~ s|^/*|/|o;
+}
+
+$image_dest = "$image_dest/";
+$image_dest =~ s|/+$|/|o;
+
+# The destdir may be gone by now.
+if (-d "$image_dest") {
+ chdir("$image_dest") or die "could not chdir to $image_dest:$!\n";
+}
+
+# Paranoid check to make sure that the correct value is put in there
+if (! $kimage) {$kimage = "vmlinuz"} # Hmm. empty
+elsif ($kimage =~ m/^b?zImage$/o) {$kimage = "vmlinuz"} # these produce vmlinuz
+elsif ($kimage =~ m/^[iI]mage$/o) { my $nop = $kimage;}
+elsif ($kimage =~ m/^vmlinux$/o) { my $nop = $kimage;}
+else {$kimage = "vmlinuz"} # default
+
+$ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
+
+
+######################################################################
+######################################################################
+############
+######################################################################
+######################################################################
+sub remove_sym_link {
+ my $bad_image = $_[0];
+
+ warn "Removing symbolic link $bad_image \n";
+ if ($loader =~ /lilo/i)
+ {
+ warn "Unless you used the optional flag in lilo, \n";
+ }
+ warn " you may need to re-run your boot loader" . ($loader ? "[$loader]":"")
+ . "\n";
+ # Remove the dangling link
+ unlink "$bad_image";
+}
+
+######################################################################
+######################################################################
+############
+######################################################################
+######################################################################
+sub CanonicalizePath {
+ my $path = join '/', @_;
+ my @work = split '/', $path;
+ my @out;
+ my $is_absolute;
+
+ if (@work && $work[0] eq "") { $is_absolute = 1; shift @work; }
+
+ while (@work) {
+ my $seg = shift @work;
+ if ($seg eq "." || $seg eq "") {
+ } elsif ($seg eq "..") {
+ if (@out && $out[-1] ne "..") {
+ pop @out;
+ } else {
+ # Leading "..", or "../..", etc.
+ push @out, $seg;
+ }
+ } else {
+ push @out, $seg;
+ }
+ }
+
+ unshift @out, "" if $is_absolute;
+ return join('/', @out);
+}
+
+######################################################################
+######################################################################
+############
+######################################################################
+######################################################################
+# This removes dangling symlinks. What do we do about hard links? Surely a
+# something with the nane $image_dest . "$kimage" ought not to be left behind?
+sub image_magic {
+ my $kimage = $_[0];
+ my $image_dest = $_[1];
+
+ if (-l "$kimage") {
+ # There is a symbolic link
+ my $force_move = 0;
+ my $vmlinuz_target = readlink "$kimage";
+ my $real_target = '';
+ $real_target = abs_path($vmlinuz_target) if defined ($vmlinuz_target);
+ if (!defined($vmlinuz_target) || ! -f "$real_target") {
+ # what, a dangling symlink?
+ warn "The link " . $image_dest . "$kimage is a damaged link\n";
+ # Remove the dangling link
+ &remove_sym_link("$kimage");
+ }
+ else {
+ my $canonical_target = CanonicalizePath("$vmlinuz_target");
+ if (! -e $canonical_target) {
+ warn "The link " . $image_dest . "$kimage is a dangling link\n";
+ &remove_sym_link("$kimage");
+ }
+ }
+ }
+}
+
+# set the env var stem
+$ENV{'STEM'} = "=ST";
+
+sub exec_script {
+ my $type = shift;
+ my $script = shift;
+ print STDERR "Running $type hook script $script.\n";
+ system ("$script $version $realimageloc$kimage-$version") &&
+ print STDERR "User $type hook script [$script] ";
+ if ($?) {
+ if ($? == -1) {
+ print STDERR "failed to execute: $!\n";
+ }
+ elsif ($? & 127) {
+ printf STDERR "died with signal %d, %s coredump\n",
+ ($? & 127), ($? & 128) ? 'with' : 'without';
+ }
+ else {
+ printf STDERR "exited with value %d\n", $? >> 8;
+ }
+ }
+}
+sub run_hook {
+ my $type = shift;
+ my $script = shift;
+ if ($script =~ m,^/,) {
+ # Full path provided for the hook script
+ if (-x "$script") {
+ &exec_script($type,$script);
+ }
+ else {
+ warn "The provided $type hook script [$script] could not be run.\n";
+ }
+ }
+ else {
+ # Look for it in a safe path
+ for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
+ if (-x "$path/$script") {
+ &exec_script($type, "$path/$script");
+ return 0;
+ }
+ }
+ # No luck
+ print STDERR "Could not find $type hook script [$script].\n";
+ warn "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
+ }
+}
+
+## Run user hook script here, if any
+if ($postrm_hook) {
+ &run_hook("postrm", $postrm_hook);
+}
+if (-d "/etc/kernel/postrm.d") {
+ warn "Examining /etc/kernel/postrm.d .\n";
+ system ("run-parts --verbose --exit-on-error --arg=$version " .
+ "--arg=$realimageloc$kimage-$version " .
+ "/etc/kernel/postrm.d") &&
+ die "Failed to process /etc/kernel/postrm.d";
+}
+if (-d "/etc/kernel/postrm.d/$version") {
+ warn "Examining /etc/kernel/postrm.d/$version .\n";
+ system ("run-parts --verbose --exit-on-error --arg=$version " .
+ "--arg=$realimageloc$kimage-$version " .
+ "/etc/kernel/postrm.d/$version") &&
+ die "Failed to process /etc/kernel/postrm.d/$version";
+}
+
+# check and remove damaged and dangling symlinks
+if ($ARGV[0] !~ /upgrade/) {
+ if (-f $realimageloc . "initrd.img-$version") {
+ unlink $realimageloc . "initrd.img-$version";
+ }
+ if (-f $realimageloc . "initrd.img-$version.bak") {
+ unlink $realimageloc . "initrd.img-$version.bak";
+ }
+ image_magic($kimage, $image_dest);
+ image_magic($kimage . ".old", $image_dest);
+ image_magic("initrd.img", $image_dest) if $initrd;
+ image_magic("initrd.img.old", $image_dest) if $initrd;
+}
+
+
+# Ignore all invocations except when called on to purge.
+exit 0 unless $ARGV[0] =~ /purge/;
+
+my $ret = purge();
+
+my @files_to_remove = qw{
+ modules.dep modules.isapnpmap modules.pcimap
+ modules.usbmap modules.parportmap
+ modules.generic_string modules.ieee1394map
+ modules.ieee1394map modules.pnpbiosmap
+ modules.alias modules.ccwmap modules.inputmap
+ modules.symbols build source modules.ofmap
+ };
+
+foreach my $extra_file (@files_to_remove) {
+ if (-f "/lib/modules/$version/$extra_file") {
+ unlink "/lib/modules/$version/$extra_file";
+ }
+}
+
+if (-d "/lib/modules/$version" ) {
+ system ("rmdir", "/lib/modules/$version");
+}
+
+exit 0;
+
+__END__
+
+
+
+
+
+
Added: people/waldi/linux-2.6/debian/templates/temp.image.plain/preinst
==============================================================================
--- (empty file)
+++ people/waldi/linux-2.6/debian/templates/temp.image.plain/preinst Sat Dec 2 14:40:34 2006
@@ -0,0 +1,583 @@
+#! /usr/bin/perl
+# -*- Mode: Cperl -*-
+# image.preinst ---
+# Author : Manoj Srivastava ( srivasta at tiamat.datasync.com )
+# Created On : Sun Jun 14 03:38:02 1998
+# Created On Node : tiamat.datasync.com
+# Last Modified By : Manoj Srivastava
+# Last Modified On : Sun Sep 24 14:04:42 2006
+# Last Machine Used: glaurung.internal.golden-gryphon.com
+# Update Count : 99
+# Status : Unknown, Use with caution!
+# HISTORY :
+# Description :
+#
+#
+
+#
+#use strict; #for debugging
+
+use Debconf::Client::ConfModule qw(:all);
+version('2.0');
+my $capb=capb("backup");
+
+$|=1;
+
+# Predefined values:
+my $version = "=V";
+my $link_in_boot = "=IB"; # Should be empty, mostly
+my $no_symlink = "=S"; # Should be empty, mostly
+my $reverse_symlink = "=R"; # Should be empty, mostly
+my $do_symlink = "Yes"; # target machine defined
+my $do_boot_enable = "Yes"; # target machine defined
+my $do_bootfloppy = "Yes"; # target machine defined
+my $do_bootloader = "Yes"; # target machine defined
+my $move_image = ''; # target machine defined
+my $mkimage = "=M"; # command to generate the initrd image
+my $do_initrd = ''; # target machine defined
+my $warn_initrd = 'YES'; # target machine defined
+my $kimage = "=K"; # Should be empty, mostly
+my $loader = "=L"; # lilo, silo, quik, palo, vmelilo, nettrom
+ # or elilo
+my $image_dir = "=D"; # where the image is located
+my $clobber_modules = ''; # target machine defined
+my $initrd = "=I"; # initrd kernel
+my $use_hard_links = ''; # hardlinks do not wirk across fs boundaries
+my $postinst_hook = ''; #Normally we do not
+my $postrm_hook = ''; #Normally we do not
+my $preinst_hook = ''; #Normally we do not
+my $prerm_hook = ''; #Normally we do not
+my $minimal_swap = ''; # Do not swap symlinks
+my $ignore_depmod_err = ''; # normally we do not
+my $relink_src_link = 'YES'; # There is no harm in checking the link
+my $relink_build_link = 'YES'; # There is no harm in checking the link
+my $force_build_link = ''; # There is no harm in checking the link
+my $official_image = "=OF"; # only true for official images
+my $arch = "=A"; # should be same as dpkg --print-installation-architecture
+my $kernel_arch = "=B";
+my $ramdisk = "=MK"; # List of tools to create initial ram fs.
+my $initrddep = "=MD"; # List of dependencies for such tools
+my $package_name = "=ST-image-$version";
+
+my $Loader = "NoLOADER"; #
+$Loader = "LILO" if $loader =~ /^lilo/io;
+$Loader = "SILO" if $loader =~ /^silo/io;
+$Loader = "QUIK" if $loader =~ /^quik/io;
+$Loader = "yaboot" if $loader =~ /^yaboot/io;
+$Loader = "PALO" if $loader =~ /^palo/io;
+$Loader = "NETTROM" if $loader =~ /^nettrom/io;
+$Loader = "VMELILO" if $loader =~ /^vmelilo/io;
+$Loader = "ZIPL" if $loader =~ /^zipl/io;
+$Loader = "ELILO" if $loader =~ /^elilo/io;
+
+
+#known variables
+my @boilerplate = ();
+my @silotemplate = ();
+my @quiktemplate = ();
+my @palotemplate = ();
+my @vmelilotemplate = ();
+my $bootdevice = '';
+my $rootdevice = '';
+my $rootdisk = '';
+my $rootpartition = '';
+my $image_dest = "/";
+my $realimageloc = "/$image_dir/";
+my $have_conffile = "";
+my $CONF_LOC = '/etc/kernel-img.conf';
+my $relative_links = '';
+my $silent_modules = '';
+my $silent_loader = '';
+my $warn_reboot = 'Yes'; # Warn that we are installing a version of
+ # the kernel we are running
+
+my $modules_base = '/lib/modules';
+
+die "Pre inst Internal error. Aborting." unless $version;
+
+exit 0 if $ARGV[0] =~ /abort-upgrade/;
+exit 1 unless $ARGV[0] =~ /(install|upgrade)/;
+
+# Official images may silently upgrade
+if ($official_image =~ /^\s*YES\s*$/o && ($ARGV[0] =~ /upgrade/)) {
+ $silent_modules = 'Yes';
+ }
+
+# remove multiple leading slashes; make sure there is at least one.
+$realimageloc =~ s|^/*|/|o;
+$realimageloc =~ s|/+|/|o;
+
+if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
+ if (open(CONF, "$CONF_LOC")) {
+ while (<CONF>) {
+ chomp;
+ s/\#.*$//g;
+ next if /^\s*$/;
+
+ $do_symlink = "" if /do_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $no_symlink = "" if /no_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $reverse_symlink = "" if /reverse_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /image_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /link_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $move_image = "" if /move_image\s*=\s*(no|false|0)\s*$/ig;
+ $clobber_modules = '' if /clobber_modules\s*=\s*(no|false|0)\s*$/ig;
+ $do_boot_enable = '' if /do_boot_enable\s*=\s*(no|false|0)\s*$/ig;
+ $do_bootfloppy = '' if /do_bootfloppy\s*=\s*(no|false|0)\s*$/ig;
+ $do_bootloader = '' if /do_bootloader\s*=\s*(no|false|0)\s*$/ig;
+ $do_initrd = '' if /do_initrd\s*=\s*(no|false|0)\s*$/ig;
+ $warn_initrd = '' if /warn_initrd\s*=\s*(no|false|0)\s*$/ig;
+ $relative_links = '' if /relative_links \s*=\s*(no|false|0)\s*$/ig;
+ $use_hard_links = '' if /use_hard_links\s*=\s*(no|false|0)\s*$/ig;
+ $silent_modules = '' if /silent_modules\s*=\s*(no|false|0)\s*$/ig;
+ $silent_loader = '' if /silent_loader\s*=\s*(no|false|0)\s*$/ig;
+ $warn_reboot = '' if /warn_reboot\s*=\s*(no|false|0)\s*$/ig;
+ $minimal_swap = '' if /minimal_swap\s*=\s*(no|false|0)\s*$/ig;
+ $ignore_depmod_err = '' if /ignore_depmod_err\s*=\s*(no|false|0)\s*$/ig;
+ $relink_src_link = '' if /relink_src_link\s*=\s*(no|false|0)\s*$/ig;
+ $relink_build_link = '' if /relink_build_link\s*=\s*(no|false|0)\s*$/ig;
+ $force_build_link = '' if /force_build_link\s*=\s*(no|false|0)\s*$/ig;
+
+ $do_symlink = "Yes" if /do_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $no_symlink = "Yes" if /no_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $reverse_symlink = "Yes" if /reverse_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /image_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /link_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $move_image = "Yes" if /move_image\s*=\s*(yes|true|1)\s*$/ig;
+ $clobber_modules = "Yes" if /clobber_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $do_boot_enable = "Yes" if /do_boot_enable\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootfloppy = "Yes" if /do_bootfloppy\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootloader = "Yes" if /do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
+ $relative_links = "Yes" if /relative_links\s*=\s*(yes|true|1)\s*$/ig;
+ $do_initrd = "Yes" if /do_initrd\s*=\s*(yes|true|1)\s*$/ig;
+ $warn_initrd = "Yes" if /warn_initrd\s*=\s*(yes|true|1)\s*$/ig;
+ $use_hard_links = "Yes" if /use_hard_links\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_modules = 'Yes' if /silent_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_loader = 'Yes' if /silent_loader\s*=\s*(yes|true|1)\s*$/ig;
+ $warn_reboot = 'Yes' if /warn_reboot\s*=\s*(yes|true|1)\s*$/ig;
+ $minimal_swap = 'Yes' if /minimal_swap\s*=\s*(yes|true|1)\s*$/ig;
+ $ignore_depmod_err = 'Yes' if /ignore_depmod_err\s*=\s*(yes|true|1)\s*$/ig;
+ $relink_src_link = 'Yes' if /relink_src_link\s*=\s*(yes|true|1)\s*$/ig;
+ $relink_build_link = 'Yes' if /relink_build_link\s*=\s*(yes|true|1)\s*$/ig;
+ $force_build_link = 'Yes' if /force_build_link\s*=\s*(yes|true|1)\s*$/ig;
+
+ $image_dest = "$1" if /image_dest\s*=\s*(\S+)/ig;
+ $postinst_hook = "$1" if /postinst_hook\s*=\s*(\S+)/ig;
+ $postrm_hook = "$1" if /postrm_hook\s*=\s*(\S+)/ig;
+ $preinst_hook = "$1" if /preinst_hook\s*=\s*(\S+)/ig;
+ $prerm_hook = "$1" if /prerm_hook\s*=\s*(\S+)/ig;
+ $mkimage = "$1" if /mkimage\s*=\s*(.+)$/ig;
+ $ramdisk = "$1" if /ramdisk\s*=\s*(.+)$/ig;
+ }
+ close CONF;
+ $have_conffile = "Yes";
+ $have_conffile = "Yes"; # stop perl complaining
+ }
+}
+
+if ($do_initrd) { $warn_initrd = ''; }
+if (!$warn_initrd) { $do_initrd = "YES";}
+
+$ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
+
+# About to upgrade this package from version $2 TO THIS VERSION.
+# "prerm upgrade" has already been called for the old version of
+# this package.
+
+sub find_inird_tool {
+ my $hostversion = shift;
+ my $version = shift;
+ my @ramdisks =
+ grep {
+ my $args =
+ "$_ " .
+ "--supported-host-version=$hostversion " .
+ "--supported-target-version=$version " .
+ "1>/dev/null 2>&1"
+ ;
+ system($args) == 0;
+ }
+ split (/[:,\s]+/, $ramdisk);
+}
+
+# For some versions of kernel-package, we had this warning in the
+# postinst, but the rules did not really interpolate the value in.
+# Here is a sanity check.
+my $pattern = "=" . "I";
+$initrd=~ s/^$pattern$//;
+
+if ($initrd) {
+ chomp (my $hostversion = `uname -r`);
+ my @ramdisklist;
+ @ramdisklist = find_inird_tool($hostversion, $version, $ramdisk) if $ramdisk;
+ if ($#ramdisklist < 0) {
+ my $ret;
+ my $seen;
+ my $text = "${package_name}/preinst/initrd-$version";
+ ($ret,$seen) = fset ("$text", 'seen', 'false');
+ die "Error setting debconf flags in $text: $seen" if $ret;
+
+ ($ret,$seen) = subst("$text", 'hostversion', "$hostversion");
+ die "Error setting debconf substitutions in $text: $seen" if $ret;
+
+ ($ret,$seen) = subst("$text", 'ramdisk', "$ramdisk");
+ die "Error setting debconf substitutions in $text: $seen" if $ret;
+
+ ($ret,$seen) = subst("$text", 'initrddep', "$initrddep");
+ die "Error setting debconf substitutions in $text: $seen" if $ret;
+
+ ($ret,$seen) = input('medium', "$text");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $text: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $text: $seen";
+ }
+ # I no longer claim this question
+ ($ret,$seen) = unregister("$text");
+ die "Error unregistering debconf question $text: $seen" if $ret;
+ warn "Could not find $ramdisk.";
+ }
+}
+
+
+if ($initrd && !$do_initrd) {
+ my $ret;
+ my $seen;
+ my $answer;
+ my $invisible = 0;
+ my $question = "${package_name}/preinst/bootloader-initrd-$version";
+ if ($loader =~ m/^lilo/i) {
+ $question = "${package_name}/preinst/lilo-initrd-$version";
+ }
+ elsif ($loader =~ m/^elilo/i) {
+ $question = "${package_name}/preinst/elilo-initrd-$version";
+ }
+ ($ret,$seen) = fset ("$question", 'seen', 'false');
+ die "Error setting debconf flags in $question: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+ $invisible = $ret if $ret == 30;
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ my $note = "${package_name}/preinst/lilo-has-ramdisk";
+ if (-f "/etc/lilo.conf"){
+ my $ramdisk_found = 0;
+ open (CONF, "/etc/lilo.conf") or warn "Can't open /etc/lilo.conf: $!";
+ while (<CONF>) {
+ chomp;
+ if (m/^(\s*ramdisk\s*=\s*0)/g) {
+ my $line = $1;
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'LINE', "$line");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ ($ret,$seen) = input('medium', "$note");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf note $note: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $note: $seen";
+ }
+ last;
+ }
+ }
+ close CONF;
+ }
+ $answer =~ s/^\s+//;
+ $answer =~ s/\s+$//;
+ print STDERR "Ok, Aborting\n" unless $answer =~ /^(f|n)/i;
+ if ($answer !~ /^(f|n)/i && $invisible) {
+ my $note = "${package_name}/preinst/abort-install-$version";
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$note");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf note $note: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $note: $seen";
+ }
+ }
+ exit 1 unless $answer =~ /^(f|n)/i;
+}
+
+
+sub check {
+ my $version = shift;
+ my $lib_modules="$modules_base/$version";
+ my $message = '';
+
+ if (-d "$lib_modules") {
+ opendir(DIR, $lib_modules) || die "can’t opendir $lib_modules: $!";
+ my @children = readdir(DIR);
+ if ($#children > 1) {
+ my @dirs = grep { -d "$lib_modules/$_" } @children;
+ if ($#dirs > 1) { # we have subdirs
+ my $dir_message='';
+ for my $dir (@dirs) {
+ if ($dir =~/kernel$/) {
+ $dir_message="An older install was detected.\n";
+ }
+ else {
+ $dir_message="Module sub-directories were detected.\n"
+ unless $dir_message;
+ }
+ }
+ $message += $dir_message if $dir_message;
+ }
+
+ my @links = grep { -l "$lib_modules/$_" } @children;
+ if ($#links > -1) {
+ my $links_message = '';
+ for my $link (@links) {
+ next if ($link =~ /^build$/);
+ next if ($link =~ /^source$/);
+ $links_message = "Symbolic links were detected in $modules_base/$version.\n";
+ }
+ $message += $links_message if $links_message;
+ }
+ my @files = grep { -f "$lib_modules/$_" } @children;
+ $message += "Additional files also exist in $modules_base/$version.\n"
+ if ($#files > -1);
+ }
+ }
+ else { $message .= "$lib_modules does not exist. ";}
+ return $message;
+}
+
+if (-d "$modules_base/$version") {
+ my $errors=check($version);
+ warn "Info:\n$errors\n" if $errors;
+}
+
+# If this is an official image, and only a build symlink exists, allow
+# it to be clobbered.
+if ($official_image =~ /^\s*YES\s*$/o ) {
+ if (-d "$modules_base/$version" && -l "$modules_base/$version/build" ) {
+ rename("$modules_base/$version/build", "$modules_base/$version/build.save") ||
+ die "failed to move $modules_base/$version/build:$!";
+ }
+}
+
+if (-d "$modules_base/$version/kernel") {
+ if ($clobber_modules) {
+ my $ret =
+ system("mv $modules_base/$version/kernel $modules_base/${version}_kernel_$$");
+ my $seen;
+ if ($ret) {
+ my $note = "${package_name}/preinst/failed-to-move-modules-$version";
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'modules_base', "$modules_base");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'dest', "${version}/kernel_$$");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$note");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf note $note: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $note: $seen";
+ }
+ exit 1;
+ }
+ }
+ elsif ($silent_modules !~ m/YES/i) {
+ my $ret;
+ my $seen;
+ my $answer;
+ my $question = "${package_name}/preinst/overwriting-modules-$version";
+
+ ($ret,$seen) = fset ("$question", 'seen', 'false');
+ die "Error setting debconf flags in $question: $seen" if $ret;
+
+ $ret = subst("$question", 'modules_base', "$modules_base");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ $ret = subst("$question", 'package', "$package_name");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+ $invisible = $ret if $ret == 30;
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ $answer =~ s/^\s+//;
+ $answer =~ s/\s+$//;
+ print STDERR "Ok, Aborting\n" unless $answer =~ /^(f|n)/i;
+ if ($answer !~ /^(f|n)/i && $invisible) {
+ my $note = "${package_name}/preinst/abort-overwrite-$version";
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$note");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf note $note: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $note: $seen";
+ }
+ }
+ exit 1 unless $answer =~ /^(f|n)/i;
+ }
+ else {
+ print STDERR <<EOF;
+The directory $modules_base/$version still exists. Continuing as directed.
+EOF
+ ;
+ }
+}
+
+if ( -f "$modules_base/$version/modules.dep" && $warn_reboot) {
+ my $running = '';
+ chop($running=`uname -r`);
+ if ($running eq $version) {
+ my $note = "${package_name}/preinst/already-running-this-$version";
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ ($ret,$seen) = fset ("$note", 'seen', 'false');
+ die "Error setting debconf flags in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'modules_base', "$modules_base");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ $ret = subst("$note", 'running', "$running");
+ die "Error setting debconf substitutions in $note: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$note");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf note $note: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $note: $seen";
+ }
+ }
+}
+
+# set the env var stem
+$ENV{'STEM'} = "=ST";
+
+sub exec_script {
+ my $type = shift;
+ my $script = shift;
+ print STDERR "Running $type hook script $script.\n";
+ system ("$script $version $realimageloc$kimage-$version") &&
+ print STDERR "User $type hook script [$script] ";
+ if ($?) {
+ if ($? == -1) {
+ print STDERR "failed to execute: $!\n";
+ }
+ elsif ($? & 127) {
+ printf STDERR "died with signal %d, %s coredump\n",
+ ($? & 127), ($? & 128) ? 'with' : 'without';
+ }
+ else {
+ printf STDERR "exited with value %d\n", $? >> 8;
+ }
+ exit $? >> 8;
+ }
+}
+sub run_hook {
+ my $type = shift;
+ my $script = shift;
+ if ($script =~ m,^/,) {
+ # Full path provided for the hook script
+ if (-x "$script") {
+ &exec_script($type,$script);
+ }
+ else {
+ die "The provided $type hook script [$script] could not be run.\n";
+ }
+ }
+ else {
+ # Look for it in a safe path
+ for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
+ if (-x "$path/$script") {
+ &exec_script($type, "$path/$script");
+ return 0;
+ }
+ }
+ # No luck
+ print STDERR "Could not find $type hook script [$script].\n";
+ die "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
+ }
+}
+
+
+## Run user hook script here, if any
+if (-x "$preinst_hook") {
+ &run_hook("preinst", $preinst_hook);
+}
+if (-d "/etc/kernel/preinst.d") {
+ print STDERR "Examining /etc/kernel/preinst.d/\n";
+ system ("run-parts --verbose --exit-on-error --arg=$version" .
+ " --arg=$realimageloc$kimage-$version" .
+ " /etc/kernel/preinst.d") &&
+ die "Failed to process /etc/kernel/preinst.d";
+}
+if (-d "/etc/kernel/preinst.d/$version") {
+ print STDERR "Examining /etc/kernel/preinst.d/$version.\n";
+ system ("run-parts --verbose --exit-on-error --arg=$version" .
+ " --arg=$realimageloc$kimage-$version" .
+ " /etc/kernel/preinst.d/$version") &&
+ die "Failed to process /etc/kernel/preinst.d/$version";
+}
+print STDERR "Done.\n";
+
+exit 0;
+
+__END__
+
+
Added: people/waldi/linux-2.6/debian/templates/temp.image.plain/prerm
==============================================================================
--- (empty file)
+++ people/waldi/linux-2.6/debian/templates/temp.image.plain/prerm Sat Dec 2 14:40:34 2006
@@ -0,0 +1,361 @@
+#! /usr/bin/perl
+# -*- Mode: Perl -*-
+# image.prerm ---
+# Author : root ( root at melkor.pilgrim.umass.edu )
+# Created On : Fri May 17 03:28:59 1996
+# Created On Node : melkor.pilgrim.umass.edu
+# Last Modified By : Manoj Srivastava
+# Last Modified On : Sat Aug 5 13:14:17 2006
+# Last Machine Used: glaurung.internal.golden-gryphon.com
+# Update Count : 85
+# Status : Unknown, Use with caution!
+# HISTORY :
+# Description :
+#
+#
+# $Id: image.prerm,v 1.22 2003/10/07 16:24:20 srivasta Exp $
+#
+#
+#use strict;
+use Debconf::Client::ConfModule qw(:all);
+version('2.0');
+my $capb=capb("backup");
+
+$|=1;
+# Predefined values:
+my $version = "=V";
+my $link_in_boot = "=IB"; # Should be empty, mostly
+my $no_symlink = "=S"; # Should be empty, mostly
+my $reverse_symlink = "=R"; # Should be empty, mostly
+my $do_symlinks = "Yes"; # target machine defined
+my $do_boot_enable = "Yes"; # target machine defined
+my $do_bootfloppy = "Yes"; # target machine defined
+my $do_bootloader = "Yes"; # target machine defined
+my $move_image = ''; # target machine defined
+my $kimage = "=K"; # Should be empty, mostly
+my $loader = "=L"; # lilo, silo, quik, palo, vmelilo, or nettrom
+my $image_dir = "=D"; # where the image is located
+my $clobber_modules = ''; # target machine defined
+my $mkimage = "=M"; # command to generate the initrd image
+my $initrd = "=I"; # initrd kernel
+my $use_hard_links = ''; # hardlinks do not wirk across fs boundaries
+my $postinst_hook = ''; #Normally we do not
+my $postrm_hook = ''; #Normally we do not
+my $preinst_hook = ''; #Normally we do not
+my $prerm_hook = ''; #Normally we do not
+my $minimal_swap = ''; # Do not swap symlinks
+my $ignore_depmod_err = ''; # normally we do not
+my $relink_build_link = 'YES'; # There is no harm in checking the link
+my $force_build_link = ''; # There is no harm in checking the link
+my $official_image = "=OF"; # only true for official images
+my $arch = "=A"; # should be same as dpkg --print-installation-architecture
+my $kernel_arch = "=B";
+my $ramdisk = "=MK"; # List of tools to create initial ram fs.
+my $initrddep = "=MD"; # List of dependencies for such tools
+my $package_name = "=ST-image-$version";
+
+my $Loader = "NoLOADER"; #
+$Loader = "LILO" if $loader =~ /^lilo/io;
+$Loader = "SILO" if $loader =~ /^silo/io;
+$Loader = "QUIK" if $loader =~ /^quik/io;
+$Loader = "yaboot" if $loader =~ /^yaboot/io;
+$Loader = "PALO" if $loader =~ /^palo/io;
+$Loader = "NETTROM" if $loader =~ /^nettrom/io;
+$Loader = "VMELILO" if $loader =~ /^vmelilo/io;
+$Loader = "ZIPL" if $loader =~ /^zipl/io;
+$Loader = "ELILO" if $loader =~ /^elilo/io;
+
+
+# This should not point to /tmp, because of security risks.
+my $temp_file_name = "/var/log/$loader" . "_log.$$";
+
+#known variables
+my $image_dest = "/";
+my $realimageloc = "/$image_dir/";
+my $have_conffile = "";
+my $CONF_LOC = '/etc/kernel-img.conf';
+my $relative_links = '';
+my $silent_modules = '';
+my $silent_loader = '';
+my $warn_reboot = 'Yes'; # Warn that we are installing a version of
+ # the kernel we are running
+
+# remove multiple leading slashes; make sure there is at least one.
+$realimageloc =~ s|^/*|/|o;
+$realimageloc =~ s|/+|/|o;
+
+my $DEBUG = 0;
+
+# Variables used
+my $image='';
+my $ret=0;
+my $seen='';
+my $answer='';
+my $running = '';
+my $WouldInvalidate = 0;
+
+if ($ARGV[0] && ($ARGV[0] =~ /remove/ || $ARGV[0] =~ /upgrade/)) {
+ if (-l "/usr/doc/=ST-image-$version") {
+ unlink "/usr/doc/=ST-image-$version";
+ }
+}
+
+# Ignore all invocations uxcept when called on to remove
+exit 0 unless ($ARGV[0] && $ARGV[0] =~ /remove/) ;
+
+# Paranoid check to make sure that the correct value is put in there
+if (! $kimage) { $kimage = "vmlinuz";} # Hmm. empty
+elsif ($kimage =~ m/^b?zImage$/o) { $kimage = "vmlinuz";} # these produce vmlinuz
+elsif ($kimage =~ m/^[iI]mage$/o) { my $nop = $kimage; }
+elsif ($kimage =~ m/^vmlinux$/o) { my $nop = $kimage; }
+else { $kimage = "vmlinuz";} # Default
+
+if (-r "$CONF_LOC" && -f "$CONF_LOC" ) {
+ if (open(CONF, "$CONF_LOC")) {
+ while (<CONF>) {
+ chomp;
+ s/\#.*$//g;
+ next if /^\s*$/;
+
+ $do_symlink = "" if /do_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $no_symlink = "" if /no_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $reverse_symlink = "" if /reverse_symlinks\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /image_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $link_in_boot = "" if /link_in_boot\s*=\s*(no|false|0)\s*$/ig;
+ $move_image = "" if /move_image\s*=\s*(no|false|0)\s*$/ig;
+ $clobber_modules = '' if /clobber_modules\s*=\s*(no|false|0)\s*$/ig;
+ $do_boot_enable = '' if /do_boot_enable\s*=\s*(no|false|0)\s*$/ig;
+ $do_bootfloppy = '' if /do_bootfloppy\s*=\s*(no|false|0)\s*$/ig;
+ $relative_links = '' if /relative_links \s*=\s*(no|false|0)\s*$/ig;
+ $do_bootloader = '' if /do_bootloader\s*=\s*(no|false|0)\s*$/ig;
+ $do_initrd = '' if /do_initrd\s*=\s*(no|false|0)\s*$/ig;
+ $use_hard_links = '' if /use_hard_links\s*=\s*(no|false|0)\s*$/ig;
+ $silent_modules = '' if /silent_modules\s*=\s*(no|false|0)\s*$/ig;
+ $silent_loader = '' if /silent_loader\s*=\s*(no|false|0)\s*$/ig;
+ $warn_reboot = '' if /warn_reboot\s*=\s*(no|false|0)\s*$/ig;
+ $minimal_swap = '' if /minimal_swap\s*=\s*(no|false|0)\s*$/ig;
+ $ignore_depmod_err = '' if /ignore_depmod_err\s*=\s*(no|false|0)\s*$/ig;
+ $relink_build_link = '' if /relink_build_link\s*=\s*(no|false|0)\s*$/ig;
+ $force_build_link = '' if /force_build_link\s*=\s*(no|false|0)\s*$/ig;
+
+
+ $do_symlink = "Yes" if /do_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $no_symlink = "Yes" if /no_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $reverse_symlink = "Yes" if /reverse_symlinks\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /image_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $link_in_boot = "Yes" if /link_in_boot\s*=\s*(yes|true|1)\s*$/ig;
+ $move_image = "Yes" if /move_image\s*=\s*(yes|true|1)\s*$/ig;
+ $clobber_modules = "Yes" if /clobber_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $do_boot_enable = "Yes" if /do_boot_enable\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootfloppy = "Yes" if /do_bootfloppy\s*=\s*(yes|true|1)\s*$/ig;
+ $do_bootloader = "Yes" if /do_bootloader\s*=\s*(yes|true|1)\s*$/ig;
+ $relative_links = "Yes" if /relative_links\s*=\s*(yes|true|1)\s*$/ig;
+ $do_initrd = "Yes" if /do_initrd\s*=\s*(yes|true|1)\s*$/ig;
+ $use_hard_links = "Yes" if /use_hard_links\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_modules = 'Yes' if /silent_modules\s*=\s*(yes|true|1)\s*$/ig;
+ $silent_loader = 'Yes' if /silent_loader\s*=\s*(yes|true|1)\s*$/ig;
+ $warn_reboot = 'Yes' if /warn_reboot\s*=\s*(yes|true|1)\s*$/ig;
+ $minimal_swap = 'Yes' if /minimal_swap\s*=\s*(yes|true|1)\s*$/ig;
+ $ignore_depmod_err = 'Yes' if /ignore_depmod_err\s*=\s*(yes|true|1)\s*$/ig;
+ $relink_build_link = 'Yes' if /relink_build_link\s*=\s*(yes|true|1)\s*$/ig;
+ $force_build_link = 'Yes' if /force_build_link\s*=\s*(yes|true|1)\s*$/ig;
+
+ $image_dest = "$1" if /image_dest\s*=\s*(\S+)/ig;
+ $postinst_hook = "$1" if /postinst_hook\s*=\s*(\S+)/ig;
+ $postrm_hook = "$1" if /postrm_hook\s*=\s*(\S+)/ig;
+ $preinst_hook = "$1" if /preinst_hook\s*=\s*(\S+)/ig;
+ $prerm_hook = "$1" if /prerm_hook\s*=\s*(\S+)/ig;
+ $mkimage = "$1" if /mkimage\s*=\s*(.+)$/ig;
+ $ramdisk = "$1" if /ramdisk\s*=\s*(.+)$/ig;
+ }
+ close CONF;
+ $have_conffile = "Yes";
+ }
+}
+
+
+$ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
+
+#check to see if we are trying to remove a running kernel
+# if so we abort right now.
+chop($running=`uname -r`);
+if ($running eq $version) {
+ my $question = "${package_name}/prerm/removing-running-kernel-$version";
+
+ ($ret,$seen) = fset ("$question", 'seen', 'false');
+ die "Error setting debconf flags in $question: $seen" if $ret;
+
+ $ret = subst("$question", 'running', "$running");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ if ($answer =~ /^(y|t)/i) {
+ exit 1; #Operation not permitted
+ }
+ else {
+ print STDERR "Ok, proceeding with removing running kernel image.\n";
+ }
+}
+
+#Now, they have an alternate kernel which they are currently running
+
+# This is just us being nice to lilo users.
+
+chdir("/") or die "could not chdir to /:$!\n";
+
+if (-f "/etc/$loader.conf") { #I know, could be a link, but ..
+ open (LILO, "/etc/$loader.conf") || &success(); # this is not critical
+ while (<LILO>) {
+ chop;
+ s/\#.*//; # nix the comments
+ next unless /^\s*image\s*=\s(\S+)/o;
+ $image = $1;
+ if ($image && -e $image) {
+ while (defined($image) && -l $image) {
+ $image = readlink ($image);
+ }
+ if (defined($image) && -e $image) {
+ $WouldInvalidate |= $image =~ /$kimage-$version/;
+ }
+ else {
+ &success(); # invalid $loader.conf file
+ }
+ }
+ else {
+ &success(); # invalid $loader.conf file
+ }
+ }
+ close (LILO);
+ if ($WouldInvalidate) {
+ my $question = "${package_name}/prerm/would-invalidate-boot-loader-$version";
+
+ ($ret,$seen) = fset ("$question", 'seen', 'false');
+ die "Error setting debconf flags in $question: $seen" if $ret;
+
+ $ret = subst("$question", 'loader', "$loader");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ $ret = subst("$question", 'kimage', "$kimage");
+ die "Error setting debconf substitutions in $question: $seen" if $ret;
+
+ ($ret,$seen) = input('critical', "$question");
+ if ($ret && $ret != 30 ) {
+ die "Error setting debconf question $question: $seen";
+ }
+
+ ($ret,$seen) = go ();
+ if ($ret && $ret != 30 ) {
+ die "Error asking debconf question $question: $seen";
+ }
+
+ ($ret,$answer) = get("$question");
+ die "Error retreiving answer for $question: $answer" if $ret;
+
+ if ($answer =~ /^(y|t)/i) {
+ print STDERR "\nNot removing =ST-image-$version.\n";
+ exit 1; #Operation not permitted
+ }
+ else {
+ print STFERR "Ok, proceeding with removing running kernel image.\n";
+ &success();
+ }
+ }
+}
+
+
+# set the env var stem
+$ENV{'STEM'} = "=ST";
+
+sub exec_script {
+ my $type = shift;
+ my $script = shift;
+ print STDERR "Running $type hook script $script.\n";
+ system ("$script $version $realimageloc$kimage-$version") &&
+ print STDERR "User $type hook script [$script] ";
+ if ($?) {
+ if ($? == -1) {
+ print STDERR "failed to execute: $!\n";
+ }
+ elsif ($? & 127) {
+ printf STDERR "died with signal %d, %s coredump\n",
+ ($? & 127), ($? & 128) ? 'with' : 'without';
+ }
+ else {
+ printf STDERR "exited with value %d\n", $? >> 8;
+ }
+ exit $? >> 8;
+ }
+}
+sub run_hook {
+ my $type = shift;
+ my $script = shift;
+ if ($script =~ m,^/,) {
+ # Full path provided for the hook script
+ if (-x "$script") {
+ &exec_script($type,$script);
+ }
+ else {
+ die "The provided $type hook script [$script] could not be run.\n";
+ }
+ }
+ else {
+ # Look for it in a safe path
+ for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
+ if (-x "$path/$script") {
+ &exec_script($type, "$path/$script");
+ return 0;
+ }
+ }
+ # No luck
+ print STDERR "Could not find $type hook script [$script].\n";
+ die "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
+ }
+}
+
+
+## Run user hook script here, if any
+if (-x "$prerm_hook") {
+ &run_hook("prerm", $prerm_hook);
+}
+if (-d "/etc/kernel/prerm.d") {
+ print STDERR "Examining /etc/kernel/prerm.d.\n";
+ system ("run-parts --verbose --exit-on-error --arg=$version " .
+ "--arg=$realimageloc$kimage-$version /etc/kernel/prerm.d") &&
+ die "Failed to process /etc/kernel/prerm.d";
+}
+if (-d "/etc/kernel/prerm.d/$version") {
+ print STDERR "Examining /etc/kernel/prerm.d/$version.\n";
+ system ("run-parts --verbose --exit-on-error --arg=$version" .
+ " --arg=$realimageloc$kimage-$version " .
+ "/etc/kernel/prerm.d/$version") &&
+ die "Failed to process /etc/kernel/prerm.d/$version";
+}
+
+sub success () {
+ -f "/lib/modules/$version/modules.dep" &&
+ unlink "/lib/modules/$version/modules.dep";
+ exit 0;
+}
+
+
+
+&success();
+exit 0;
+__END__
+
+
+
+
+
Added: people/waldi/linux-2.6/debian/templates/temp.image.plain/templates
==============================================================================
--- (empty file)
+++ people/waldi/linux-2.6/debian/templates/temp.image.plain/templates Sat Dec 2 14:40:34 2006
@@ -0,0 +1,297 @@
+Template: =ST-image-=V/preinst/initrd-=V
+Type: text
+Description: You are installing a kernel with an initrd image
+ You are attempting to install an initrd kernel image (version
+ =V) on a machine currently running kernel version
+ ${hostversion}.
+ .
+ I have been unable to find a suitable tool for generating initrd images
+ (I looked at the list "${ramdisk}")
+ This will break the installation, unless such tools are also being installed
+ right now in the same run. (This means, one from the following list
+ ${initrddep})
+
+Template: =ST-image-=V/preinst/bootloader-initrd-=V
+Type: boolean
+Default: true
+Description: Do you want to abort now?
+ You are attempting to install an initrd kernel image (version =V)
+ This will not work unless you have configured your boot loader to use
+ initrd. (An initrd image is a kernel image that expects to use an INITial
+ Ram Disk to mount a minimal root file system into RAM and use that for
+ booting).
+ .
+ I repeat, You need to configure your boot loader -- please read your
+ bootloader documentation for details on how to add initrd images.
+ .
+ If you have already done so, and you wish to get rid of this message,
+ please put
+ "do_initrd = Yes"
+ in /etc/kernel-img.conf. Note that this is optional, but if you do not,
+ you will continue to see this message whenever you install a kernel
+ image using initrd.
+
+Template: =ST-image-=V/preinst/lilo-initrd-=V
+Type: boolean
+Default: true
+Description: Do you want to abort now?
+ You are attempting to install an initrd kernel image (version =V)
+ This will not work unless you have configured your boot loader to use
+ initrd. (An initrd image is a kernel image that expects to use an INITial
+ Ram Disk to mount a minimal root file system into RAM and use that for
+ booting).
+ .
+ As a reminder, in order to configure LILO, you need to add an
+ 'initrd=/initrd.img' to the image=/vmlinuz stanza of your /etc/lilo.conf
+ .
+ I repeat, You need to configure your boot loader -- please read your
+ bootloader documentation for details on how to add initrd images.
+ .
+ If you have already done so, and you wish to get rid of this message,
+ please put
+ "do_initrd = Yes"
+ in /etc/kernel-img.conf. Note that this is optional, but if you do not,
+ you will continue to see this message whenever you install a kernel
+ image using initrd.
+
+Template: =ST-image-=V/preinst/elilo-initrd-=V
+Type: boolean
+Default: true
+Description: Do you want to abort now?
+ You are attempting to install an initrd kernel image (version =V)
+ This will not work unless you have configured your boot loader to use
+ initrd. (An initrd image is a kernel image that expects to use an INITial
+ Ram Disk to mount a minimal root file system into RAM and use that for
+ booting).
+ .
+ As a reminder, in order to configure ELILO, you need to add an
+ 'initrd=/initrd.img' to the image=/vmlinuz stanza of your /etc/elilo.conf
+ .
+ I repeat, You need to configure your boot loader -- please read your
+ bootloader documentation for details on how to add initrd images.
+ .
+ If you have already done so, and you wish to get rid of this message,
+ please put
+ "do_initrd = Yes"
+ in /etc/kernel-img.conf. Note that this is optional, but if you do not,
+ you will continue to see this message whenever you install a kernel
+ image using initrd.
+
+Template: =ST-image-=V/preinst/lilo-has-ramdisk
+Type: text
+Description: Lilo has a ramdisk line, which should be commented or removed
+ I have found a line
+ ${LINE}
+ in /etc/lilo.conf that should be removed or commented out, since you are using
+ initrd/initramfs.
+
+Template: =ST-image-=V/preinst/abort-install-=V
+Type: note
+Description: Aborting install since loading an initrd kernel image
+ You are attempting to install an initrd kernel image (version
+ =V) This will not work unless you have configured your boot
+ loader to use initrd. (An initrd image is a kernel image that expects
+ to use an INITial Ram Disk to mount a minimal root file system into
+ RAM and use that for booting). Unfortunately, since this Question
+ pertaining to this was not shown, and the default action is to abort
+ the install. =ST-image-=V aborted.
+
+
+Template: =ST-image-=V/preinst/failed-to-move-modules-=V
+Type: note
+Description: Failed to move modules out of the way, aborting
+ You are attempting to install a kernel image (version =V)
+ However, the directory ${modules_base}/=V/kernel still exists.
+ .
+ As you have instructed, an attempt was made to move the directory out
+ of the way. Unfortunately, There was a problem moving
+ ${modules_base}/=V to ${modules_base}/${dest}.
+ .
+ I suggest you move $modules_base/$version out of the way manually,
+ and then try re-installing this image.
+ .
+ I am aborting.
+
+Template: =ST-image-=V/preinst/overwriting-modules-=V
+Type: boolean
+Default: true
+Description: Stop install since the kernel-image is already installed?
+ You are attempting to install a kernel image (version =V)
+ However, the directory ${modules_base}/=V/kernel still exists. If this
+ directory belongs to a previous ${package} package, and if
+ you have deselected some modules, or installed standalone modules
+ packages, this could be bad.
+ .
+ If ${modules_base}/=V/kernel belongs to a old install of
+ ${package}, then this is your last chance to abort the
+ installation of this kernel image (nothing has been changed yet).
+ .
+ If you know what you are doing, and if you feel that this
+ image should be installed despite this anomaly, Please answer n to the
+ question.
+ .
+ Otherwise, I suggest you move ${modules_base}/=V/kernel out of the way,
+ perhaps to ${modules_base}/=V.kernel.old or something, and then try
+ re-installing this image.
+
+Template: =ST-image-=V/preinst/abort-overwrite-=V
+Type: note
+Description: Aborting install since modules exist
+ You are attempting to install an initrd kernel image (version
+ =V). However, the corresponding kernel modules directory exists,
+ and there was no permission given to silently delete the modules
+ directory. Unfortunately, since this Question
+ pertaining to this was not shown, and the default action is to abort
+ the install. =ST-image-=V aborted.
+
+
+Template: =ST-image-=V/preinst/already-running-this-=V
+Type: note
+Description: The kernel version running is the same as the one being installed
+ You are attempting to install a kernel version that is the same as
+ the version you are currently running (version ${running}). The modules
+ list is quite likely to have been changed, and the modules dependency
+ file ${modules_base}/=V/modules.dep needs to be re-built. It can
+ not be built correctly right now, since the module list for the
+ running kernel are likely to be different from the kernel installed.
+ I am creating a new modules.dep file, but that may not be
+ correct. It shall be regenerated correctly at next reboot.
+ .
+ I repeat: you have to reboot in order for the modules file to be
+ created correctly. Until you reboot, it may be impossible to load
+ some modules. Reboot as soon as this install is finished (Do not
+ reboot right now, since you may not be able to boot back up until
+ installation is over, but boot immediately after). I can not stress
+ that too much. You need to reboot soon.
+
+Template: =ST-image-=V/postinst/create-kimage-link-=V
+Type: boolean
+Default: true
+Description: Create a symbolic link to the current kernel image?
+ I notice that you do not have ${kimage} symbolic link. I can create one
+ for you, and it shall be updated by newer kernel image packages. This is
+ useful if you use a boot loader like lilo.
+
+Template: =ST-image-=V/postinst/kimage-is-a-directory
+Type: note
+Description: Image symbolic link destination is a directory, aborting
+ ${kimage} is a directory, which I did not expect. I am trying to create a
+ symbolic link with that name linked to ${image_dest}. Since a directory
+ exists here, my assumptions are way off, and I am aborting.
+
+Template: =ST-image-=V/postinst/depmod-error-=V
+Type: boolean
+Default: false
+Description: Do you want to abort now?
+ This may be benign, (You may have versioned symbol names, for instance).
+ Or this could be an error. depmod exited with return value ${exit_value}
+ ${SIGNAL}${CORE}.
+ I am deleting the file ${modules_base}/=V/modules.dep. However,
+ since depmod is run at install time, we could just defer running depmod.
+
+Template: =ST-image-=V/postinst/depmod-error-initrd-=V
+Type: boolean
+Default: false
+Description: Do you want to abort now?
+ This may be benign, (You may have versioned symbol names, for instance).
+ Or this could be an error. depmod exited with return value ${exit_value}
+ . ${SIGNAL} ${CORE}
+ Since this image uses initrd, I am not deleting the file
+ ${modules_base}/=V/modules.dep. However, there is no guarantee that the
+ file is valid. I would strongly advice you to either abort and fix the
+ errors in depmod, or regenerate the initrd image with a known good
+ modules.dep file. I repeat, an initrd kernel image with a bad modules.dep
+ shall fail to boot.
+
+Template: =ST-image-=V/postinst/old-initrd-link-=V
+Type: boolean
+Default: true
+Description: Should the old initrd link be deleted now?
+ I note that you have an old initrd symbolic link in place. The name of
+ the symbolic link is being changed to initrd.img. If the old link is
+ deleted, you may have to update the boot loader. If the link is left in
+ place, it will point to the wrong image.
+
+Template: =ST-image-=V/postinst/old-dir-initrd-link-=V
+Type: boolean
+Default: true
+Description: Should the old initrd link be deleted now?
+ I note that you have an old ${image_dir}/initrd symbolic link in
+ place. The location of the symbolic link is now the same location as
+ the kernel image symbolic links, namely, in ${image_dest}. If the old
+ link is deleted, you may have to update the boot loader. If the link
+ is left in place, it will point to the wrong image.
+
+Template: =ST-image-=V/postinst/old-system-map-link-=V
+Type: boolean
+Default: true
+Description: Should the old /System.map link be deleted now?
+ You have /System.map symbolic link. These were installed by ancient
+ kernel image packages. However, all the programs that look at the
+ information in the map files (including top, ps, and klogd)
+ also will look at /boot/System.map-=V
+ Having the symbolic link in / is technically detrimental
+ (apart from cluttering up /); many programs, though looking in /boot,
+ still allow /System.map to override. If you install multiple kernels
+ on this machine, then the /System.map symbolic link only
+ applies to one such kernel, for all other choices the symbols loaded
+ will be wrong. Not having /System.map at all prevents this.
+
+Template: shared/kernel-image/really-run-bootloader
+Type: boolean
+Default: true
+Description: Run the default bootloader?
+ The default boot loader for this architecture is $loader, which is
+ present. However, you have not explicitly requested the boot loader
+ $loader should be run in the configuration file /etc/kernel-img.conf,
+ and you seem to have grub installed, and have set a postinst hook
+ (which is used to hook in grub after a kernel image installation). At
+ this point, it is perfectly likely that this system is using grub as a
+ bootloader, and not the builtin default of $loader. If that is the case,
+ running $loader instead of grub might make the machine unbootable. I need
+ to know whether to run the default bootloader $loader, or just let the
+ postinst hook script update grub later. The default is to run $loader.
+
+
+Template: =ST-image-=V/postinst/bootloader-test-error-=V
+Type: note
+Description: Error running the boot loader in test mode.
+ An error occurred while running the boot loader ${loader} in test mode.
+ A log is available in ${temp_file_name}. Please edit /etc/${loader}.conf
+ manually and re-run ${loader}, or make other arrangements to boot your machine.
+
+Template: =ST-image-=V/postinst/bootloader-error-=V
+Type: note
+Description: Error running the boot loader in test mode.
+ An error occurred while running the boot loader ${loader}.
+ A log is available in ${temp_file_name}. Please edit /etc/${loader}.conf
+ manually and re-run ${loader}, or make other arrangements to boot your machine.
+
+Template: =ST-image-=V/prerm/removing-running-kernel-=V
+Type: boolean
+Default: true
+Description: Do you want to abort removal now?
+ You are running a kernel (version ${running}) and attempting to remove
+ the same version. This is a potentially disastrous action. Not only
+ will /boot/vmlinuz-${running} be removed, making it impossible to boot
+ it, (you will have to take action to change your boot loader to boot
+ a new kernel), it will also remove all modules under the directory
+ /lib/modules/${running}. Just having a copy of the kernel image is not
+ enough, you will have to replace the modules too.
+ .
+ I repeat, this is very dangerous. If at all in doubt, answer Yes. If
+ you know exactly what you are doing, and are prepared to hose your
+ system, then answer No.
+
+Template: =ST-image-=V/prerm/would-invalidate-boot-loader-=V
+Type: boolean
+Default: true
+Description: Do you want to abort removal now?
+ You have a valid /etc/${loader}.conf file that mentions
+ ${kimage}-=V. Removing =ST-image-=V would invalidate
+ that file. (you will have to edit /etc/${loader}.conf or re-target
+ symbolic links mentioned there (typically, /vmlinuz and /vmlinuz.old)
+ to not refer to ${kimage}-=V and will have to re-run ${loader}).
+ .
+ I repeat: you shall have to make changes to your boot loader setup
+ and will have to re-run ${loader}.
More information about the Kernel-svn-changes
mailing list