* debian/rules.real:

Support plain image type. This uses the kernel-package templates for now.
* debian/templates/temp.image.plain: Import from kernel-package.

svn path=/dists/trunk/linux-2.6/; revision=7944
This commit is contained in:
Bastian Blank 2006-12-06 10:31:20 +00:00
parent 73170aafb6
commit 641195b4ff
7 changed files with 3360 additions and 11 deletions

72
debian/rules.real vendored
View File

@ -139,11 +139,8 @@ $(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-kernel-package:
cd '$(DIR)'; $(setup_env) $(kpkg_image) configure
touch '$@'
$(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-s390-tape:
$(SETUP_DIR)
cd '$(DIR)'; $(setup_env) make prepare $(JOBS_ARG)
touch '$@'
$(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain \
$(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-s390-tape \
$(STAMPS_DIR)/setup-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-xen:
$(SETUP_DIR)
cd '$(DIR)'; $(setup_env) make prepare $(JOBS_ARG)
@ -157,10 +154,8 @@ $(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-kernel-package:
python2.4 debian/bin/abicheck.py $(DIR) $(ARCH) $(SUBARCH) $(FLAVOUR)
touch '$@'
$(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-s390-tape:
cd '$(DIR)'; $(setup_env) make $(JOBS_ARG) image
touch '$@'
$(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain \
$(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-s390-tape \
$(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-xen:
cd '$(DIR)'; $(setup_env) make $(JOBS_ARG)
python2.4 debian/bin/abicheck.py $(DIR) $(ARCH) $(SUBARCH) $(FLAVOUR)
@ -333,7 +328,8 @@ install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-$(TYPE): REAL_VERSION = $(UPSTREAMVE
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-$(TYPE): PACKAGE_NAME = linux-image-$(REAL_VERSION)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-$(TYPE): PACKAGE_DIR = $(CURDIR)/debian/$(PACKAGE_NAME)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-$(TYPE): INSTALL_DIR = $(PACKAGE_DIR)/boot
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-$(TYPE): DIR=$(BUILD_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-$(TYPE): DIR = $(BUILD_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-$(TYPE): DH_OPTIONS = -p$(PACKAGE_NAME)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-$(TYPE): $(STAMPS_DIR)/build-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-$(TYPE)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-kernel-package:
@ -349,7 +345,31 @@ endif
mv "$(BUILD_DIR)/$$i" ..; \
done
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-s390-tape: DH_OPTIONS = -p$(PACKAGE_NAME)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain:
dh_testdir
dh_testroot
dh_clean -d -k
dh_installdirs 'boot'
$(MAKE) -f debian/rules.real \
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain_image \
DIR='$(DIR)' INSTALL_DIR='$(INSTALL_DIR)' REAL_VERSION='$(REAL_VERSION)'
ifeq ($(MODULES),True)
cd $(DIR); $(setup_env) make modules_install INSTALL_MOD_PATH=$(PACKAGE_DIR)
cp $(DIR)/.config $(PACKAGE_DIR)/boot/config-$(REAL_VERSION)
cp $(DIR)/System.map $(PACKAGE_DIR)/boot/System.map-$(REAL_VERSION)
rm $(PACKAGE_DIR)/lib/modules/$(REAL_VERSION)/{build,source,modules.*}
endif
$(MAKE) -f debian/rules.real \
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain_templates \
PACKAGE_DIR='$(PACKAGE_DIR)' REAL_VERSION='$(REAL_VERSION)'
$(MAKE) -f debian/rules.real install-base
install-image-powerpc-$(SUBARCH)-$(FLAVOUR)-plain_image:
cp '$(DIR)/vmlinux' $(INSTALL_DIR)/vmlinux-$(REAL_VERSION)
install-image-s390-$(SUBARCH)-$(FLAVOUR)-plain_image:
cp '$(DIR)/arch/s390/boot/image' $(INSTALL_DIR)/vmlinuz-$(REAL_VERSION)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-s390-tape:
dh_testdir
dh_testroot
@ -358,6 +378,36 @@ install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-s390-tape:
cp '$(DIR)/arch/s390/boot/image' $(PACKAGE_DIR)/boot/vmlinuz-$(REAL_VERSION)
$(MAKE) -f debian/rules.real install-base
ifneq ($(INITRAMFS),False)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain_templates: ARG_INITRD = YES
endif
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain_templates:
install -d $(PACKAGE_DIR)/DEBIAN
for i in $(notdir $(wildcard debian/templates/temp.image.plain/*)); do \
sed \
-e 's,=D,/boot,g' \
-e 's/=OF/YES/g' \
-e 's/=ST/linux/g' \
-e 's@=A@$(DEB_HOST_ARCH)@g' \
-e 's@=B@$(KERNEL_ARCH)@g' \
-e 's/=I/$(ARG_INITRD)/g' \
-e 's/=L/$(BOOTLOADER)/g' \
-e 's@=MK@$(INITRD_CMD)@g' \
-e 's/=V/$(REAL_VERSION)/g' \
-e 's/=IB//g' \
-e 's/=K//g' \
-e 's/=M//g' \
-e 's/=MD//g' \
-e 's/=R//g' \
-e 's/=S//g' \
'$(CURDIR)'/debian/templates/temp.image.plain/$$i > '$(PACKAGE_DIR)'/DEBIAN/$$i; \
done
chmod 755 '$(PACKAGE_DIR)'/DEBIAN/{config,{pre,post}*}
chmod 644 '$(PACKAGE_DIR)'/DEBIAN/templates
install-image-s390-$(SUBARCH)-$(FLAVOUR)-plain_templates: BOOTLOADER = zipl
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-xen: MODULES_PACKAGE_NAME = linux-modules-$(REAL_VERSION)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-xen: MODULES_PACKAGE_DIR = $(CURDIR)/debian/$(MODULES_PACKAGE_NAME)
install-image-$(ARCH)-$(SUBARCH)-$(FLAVOUR)-plain-xen: DH_OPTIONS = -p$(PACKAGE_NAME) -p$(MODULES_PACKAGE_NAME)

291
debian/templates/temp.image.plain/config vendored Executable file
View File

@ -0,0 +1,291 @@
#! /usr/bin/perl
# -*- Mode: Cperl -*-
# config ---
# Author : Manoj Srivastava ( srivasta@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__

1370
debian/templates/temp.image.plain/postinst vendored Executable file

File diff suppressed because it is too large Load Diff

397
debian/templates/temp.image.plain/postrm vendored Executable file
View File

@ -0,0 +1,397 @@
#! /usr/bin/perl
# -*- Mode: Cperl -*-
# image.postrm ---
# Author : Manoj Srivastava ( srivasta@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__

583
debian/templates/temp.image.plain/preinst vendored Executable file
View File

@ -0,0 +1,583 @@
#! /usr/bin/perl
# -*- Mode: Cperl -*-
# image.preinst ---
# Author : Manoj Srivastava ( srivasta@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 "cant 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__

361
debian/templates/temp.image.plain/prerm vendored Executable file
View File

@ -0,0 +1,361 @@
#! /usr/bin/perl
# -*- Mode: Perl -*-
# image.prerm ---
# Author : root ( root@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__

View File

@ -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}.