From 3b518adf1b2dcc9b8efe433b71c1af68b22881a2 Mon Sep 17 00:00:00 2001 From: Joachim Wiedorn Date: Sun, 15 Apr 2012 13:23:04 +0200 Subject: [PATCH] Use upstream scripts directly --- debian/changelog | 1 + debian/lilo.install | 6 +- .../patches/10_disable-upstream-scripts.patch | 27 - debian/patches/series | 1 - debian/patches/ubuntu.series | 1 - debian/scripts/lilo-uuid-diskid | 467 -------------- debian/scripts/liloconfig | 601 ------------------ debian/{scripts => }/update-lilo | 8 +- 8 files changed, 9 insertions(+), 1103 deletions(-) delete mode 100644 debian/patches/10_disable-upstream-scripts.patch delete mode 100644 debian/scripts/lilo-uuid-diskid delete mode 100644 debian/scripts/liloconfig rename debian/{scripts => }/update-lilo (86%) diff --git a/debian/changelog b/debian/changelog index 247f0a2..5c337bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ lilo (1:23.2-4) unstable; urgency=low * Enable use of linux 3.x in liloconfig script. * Disable creating pdf documentation. (Closes: #666320) * Remove build dependency to texlive-latex-base. + * Use (patched) upstream scripts directly. -- Joachim Wiedorn Sat, 14 Apr 2012 22:56:42 +0200 diff --git a/debian/lilo.install b/debian/lilo.install index 025d36f..27f0639 100644 --- a/debian/lilo.install +++ b/debian/lilo.install @@ -1,13 +1,13 @@ sbin/lilo usr/sbin/mkrescue usr/sbin/keytab-lilo +usr/sbin/liloconfig +usr/sbin/lilo-uuid-diskid etc/kernel/post* etc/initramfs/post* boot/*.bmp usr/share/lilo/ boot/*.dat usr/share/lilo/ -debian/scripts/liloconfig usr/sbin/ -debian/scripts/lilo-uuid-diskid usr/sbin/ -debian/scripts/update-lilo usr/sbin/ +debian/update-lilo usr/sbin/ debian/lilo-term.xpm usr/share/pixmaps/ debian/floppy/Makefile usr/lib/lilo/ src/bootsect.b usr/lib/lilo/ diff --git a/debian/patches/10_disable-upstream-scripts.patch b/debian/patches/10_disable-upstream-scripts.patch deleted file mode 100644 index f519f54..0000000 --- a/debian/patches/10_disable-upstream-scripts.patch +++ /dev/null @@ -1,27 +0,0 @@ -Package: lilo -Subject: disable upstream scripts -Author: Joachim Wiedorn -Forwarded: no -Last-Update: 2011-05-07 - ---- - -diff -urN s09/Makefile s10/Makefile ---- s09/Makefile 2011-05-06 17:45:57.304713832 +0200 -+++ s10/Makefile 2011-05-07 12:09:45.181057197 +0200 -@@ -109,7 +109,7 @@ - $(MAKE) -C images install - $(MAKE) -C hooks install - $(MAKE) -C sample install -- $(MAKE) -C scripts install -+ #$(MAKE) -C scripts install - $(MAKE) -C man install - $(MAKE) -C dos install - -@@ -138,5 +138,5 @@ - $(MAKE) -C images uninstall - $(MAKE) -C hooks uninstall - $(MAKE) -C sample uninstall -- $(MAKE) -C scripts uninstall -+ #$(MAKE) -C scripts uninstall - $(MAKE) -C man uninstall diff --git a/debian/patches/series b/debian/patches/series index 5958587..dd2c824 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -7,7 +7,6 @@ 07_bad-partition-warn.patch 08_install-also-dat-files.patch 09_use-of-newer-debhelper.patch -10_disable-upstream-scripts.patch 11_update-lilo-conf-manpage1.patch 12_update-lilo-conf-manpage2.patch 13_lilo-conf-append-info.patch diff --git a/debian/patches/ubuntu.series b/debian/patches/ubuntu.series index 633109b..e21bfeb 100644 --- a/debian/patches/ubuntu.series +++ b/debian/patches/ubuntu.series @@ -7,7 +7,6 @@ 07_bad-partition-warn.patch 08_install-also-dat-files.patch 09_use-of-newer-debhelper.patch -10_disable-upstream-scripts.patch 11_update-lilo-conf-manpage1.patch 12_update-lilo-conf-manpage2.patch 13_lilo-conf-append-info.patch diff --git a/debian/scripts/lilo-uuid-diskid b/debian/scripts/lilo-uuid-diskid deleted file mode 100644 index ab03744..0000000 --- a/debian/scripts/lilo-uuid-diskid +++ /dev/null @@ -1,467 +0,0 @@ -#!/usr/bin/perl -w - -# lilo-uuid-diskid - convert boot and root options to diskid -# and uuid in /etc/lilo.conf -# -# Copyright 2010-2011 Joachim Wiedorn -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. - -#---- some modules -use strict; -use warnings; -use Getopt::Std; -use Pod::Usage; -use File::Copy; - - -#---- global variables -my $prog = $0; -$prog =~ s#.*/##; -my $version = "0.3"; - -#---- parameter check -our $opt_h = 0; -our $opt_v = 0; -getopts('hv'); -# define perldoc usage -pod2usage(1) if $opt_h; - -#---- other variables -our $liloconf = "/etc/lilo.conf"; -our $liloconfold = ''; -our $fstabconf = "/etc/fstab"; -our $idpath = "/dev/disk/by-id"; -our $uuidpath = "/dev/disk/by-uuid"; -our $labpath = "/dev/disk/by-label"; - -our $bootready = 0; -our $boot_id = ''; -our $root_id = ''; -our $optboot = 0; # -1 = only ^#boot, 0 = nothing, 1 = ^boot exist - -#-------------------- main program -------------------- - -sub main { - - my $exit = 0; - - if (@ARGV == 1) { - $liloconf = "$ARGV[0]"; - } - - if (-f $liloconf) { - $liloconfold = $liloconf . "_old"; - $exit = convert_lilo_conf(); - } - else { - print "cannot open $liloconf: file not found!\n"; - $exit = 1; - } - return $exit; -} - -#-------------------- subroutines -------------------- - -sub convert_lilo_conf { - - my @sellines; - my $exit = 0; - my $line = ''; - my $bootline = ''; - - # at first read lilo.conf and search for 'boot' - my $ok = 0; - open(MYFH, "<$liloconf") or die ("cannot open $liloconf: $!"); - @sellines = grep(/^#?boot/, readline(MYFH)); - close(MYFH); - - # analyse the boot option in config file - foreach $line (@sellines) { - if ($line =~ /^boot/) { - # activated boot option found - $bootline = $line; - chomp $bootline; - $optboot = 1; - } - if ($optboot == 0) { - # commented boot option found - if ($line =~ /^#boot/) { $optboot = -1; } - } - } - - if ($optboot != 0) { - - if($opt_v) { print "++++++++++ write options into $liloconf ++++++++++\n\n"; } - - if ( detect_boot_device($bootline) == 0) { - # found diskid or uuid for boot device: $boot_id - if (-l $boot_id) { - write_boot_option(); - } - else { - if($opt_v) { print "cannot open $boot_id: link does not exist!\n"; } - $exit = 1; - } - } - else { - if($opt_v) { print "\n"; } - } - } - else { - print "cannot use $liloconf: uncomplete configuration!\n"; - $exit = 1; - } - - return $exit; -} - - -sub detect_boot_device { - - my $boot_line = $_[0]; - my $boot_disk = ''; - my $searchpath; - my $_part; - my $exit = 0; - - if ($optboot == 1) { - # the usual case: found ^boot in lilo.conf - $boot_disk = ($boot_line =~ /^boot *= *(\/dev\/.*)/) ? ($1) : (); - - # check if the found partition is a raid volume - if($boot_disk =~ /\/dev\/md/) { - $boot_disk = check_raid($boot_disk); - } - } - elsif ($optboot == -1) { - # found only ^#boot in lilo.conf, then /etc/fstab is needed - if (-f $fstabconf) { - if($opt_v) { - print "no boot option in $liloconf: selecting from $fstabconf\n"; - } - $boot_disk = read_fstab($fstabconf); - } - else { - print "no boot option in $liloconf and no file $fstabconf found!\n"; - $exit = 1; - } - } - - if (-b $boot_disk) { - if($boot_disk =~ /$idpath/ - or $boot_disk =~ /$uuidpath/ - or $boot_disk =~ /$labpath/) { - print "boot option is already updated to $boot_disk\n"; - $bootready = 1; $exit = 1; - } - else { - if($opt_v) { print "convert boot option $boot_disk into new ID\n"; } - - # is it a block device name ? - $_part = $boot_disk; - $_part =~ s/\d+$//; - $searchpath = ($_part eq $boot_disk) ? $idpath : $uuidpath; - - $boot_id = $searchpath . "/" . find_id_link($boot_disk,$searchpath); - if(not -l "$boot_id") { $exit = 1; } - } - } - else { - if($opt_v) { print "cannot read $boot_disk: link does not exist!\n"; } - $exit = 1; - } - return $exit; -} - -sub read_fstab { - - my $ffile = $_[0]; - my $root_line; - my $root_part; - my $_item; - - $root_line = `awk '{ if (\$2=="/") print \$1}' <$ffile`; - - # search for the last valid entry in /etc/fstab about root partition - foreach $_item (split("\n", $root_line)) { - if(not $_item =~ /#/) { - $root_part = $_item; - } - } - # check if the found partition is a raid volume - if($root_part =~ /\/dev\/md/) { - } - unless ($root_part =~ /^UUID/) { - # now find the right block device name - $root_part =~ s/\d+$//; - } - - return $root_part; -} - -sub check_raid { - - my $part = $_[0]; - my $mdname; - my $md; - my @devices; - - # check if the found partition is a raid volume - if($part =~ /\/dev\/md/) - { - $mdname = $part; - $mdname =~ s/\/dev\///; - $mdname =~ s/\///; - $md = `grep $mdname /proc/mdstat`; - - @devices = split(" ", $md); - @devices = sort(@devices[4..$#devices]); - $part = "/dev/" . $devices[0]; - $part =~ s/\[.*$//; - - } - return $part; -} - -sub detect_root_device { - - my $root_line = $_[0]; - my $root_disk = ''; - my $root_link = ''; - my $exit = 0; - - if (not $exit) { - # extract the root device name - $root_disk = ( $root_line =~ /^\t?root *= *(.*)/ ) ? ($1) : (); - chomp $root_disk; - - # check if the found partition is a raid volume - if($root_disk =~ /\/dev\/md/) { - $root_disk = check_raid($root_disk); - } - } - - # check if root device exist / also for raid volume - if (-b $root_disk) { - if($opt_v) { print "convert root option $root_disk into new UUID\n"; } - $root_id = find_id_link($root_disk,$uuidpath); - if (not -l "$uuidpath/$root_id") { $exit = 1; } - } - else { - # nothing to do but perhaps give a message - $exit = 1; - $root_link = $root_disk; - $root_link =~ s{\"}{}g; - $root_link =~ s{^LABEL=}{/dev/disk/by-label/}; - $root_link =~ s{^UUID=}{/dev/disk/by-uuid/}; - if (not -l $root_link) { - if($opt_v) { print "cannot check $root_link: link does not exist!\n"; } - } - } - return $exit; -} - -sub find_id_link { - - my $olddev = $_[0]; - my $path_id = $_[1]; - my @sellinks; - my $_idlink; - my $_actlink; - my $newdevid = ''; - my $ok = 0; - - opendir(MYDH, "$path_id") or die("cannot open $path_id: $! \n"); - @sellinks = grep(!/\-part\d\d?$/, grep(!/^\.\.?$/, readdir(MYDH))); - @sellinks = sort(@sellinks); - closedir(MYDH); - - foreach $_idlink (@sellinks) { - if(not $_idlink =~ /^usb/ and length($_idlink) > 10 and $ok == 0) { - $_actlink = readlink("$path_id/$_idlink"); - $_actlink =~ s/^\.\.\/\.\.\//\/dev\//; - if($opt_v) { print "** try: $_actlink => $_idlink \n"; } - - if($_actlink eq $olddev) { - $newdevid = $_idlink; - if($opt_v) { print "** convert: $_actlink => $path_id/$_idlink \n"; } - # run only one time - $ok = 1; - } - } - } - - if($opt_v and not $ok) { print "$olddev not converted: link not useful\n\n"; } - - return ($newdevid); -} - -sub write_boot_option { - - my $oldline = ''; - my $comline = ''; - my $newline = ''; - my @status; - my $_preold; - my $_prenew; - - if (-f $liloconf) { - # move old lilo.conf to lilo.conf_old - @status = stat($liloconf); - move ($liloconf, $liloconfold); - utime ($status[9],$status[9],$liloconfold); - chmod (0600,$liloconfold); - - # copy all lines from lilo.conf_old into - # new lilo.conf and add 'boot=' line - my $ok = 0; - open(MYFH_NEW, "> $liloconf") or die("cannot open $liloconf: $!"); - open(MYFH_OLD, "< $liloconfold") or die ("cannot open $liloconfold: $!"); - - while () { - # line read from MYFH_OLD - $oldline = $_; - - if (/^boot/ and $ok == 0) { - $newline = "boot = $boot_id\n"; - print MYFH_NEW "#" . $oldline; - print MYFH_NEW $newline; - if($opt_v) { print "+ #" . $oldline; } - print "+ " . $newline; - if($opt_v) { print "\n"; } - # convert only one time - $ok = 1; - } - elsif (/^#boot/ and $optboot == -1 and $ok == 0) { - # found a line with boot option commented out - $newline = "boot = $boot_id\n"; - print MYFH_NEW $oldline; - print MYFH_NEW $newline; - if($opt_v) { print "+ " . $oldline; } - print "+ " . $newline; - if($opt_v) { print "\n"; } - # convert only one time - $ok = 1; - } - elsif (/^root/ or /^\troot/) { - # found a line with root option - if (detect_root_device($oldline) == 0) { - $comline = comment_root_line($oldline); - $newline = modern_root_line($oldline,$root_id); - print MYFH_NEW $comline; - print MYFH_NEW $newline; - if($opt_v) { print '+ ' . $comline; } - print '+ ' . $newline; - if($opt_v) { print "\n"; } - } - else { - print MYFH_NEW $oldline; - } - } - else { - print MYFH_NEW $oldline; - } - } - close(MYFH_OLD); - close(MYFH_NEW); - chmod (0600,$liloconf); - } - else { - print "file $liloconf does not exist: nothing changed\n"; - } -} - -sub comment_root_line { - - my $rootline = $_[0]; - - if( $rootline =~ /root/) { - $rootline =~ s/root/#root/; - } - return $rootline; -} - -sub modern_root_line { - - my $oldline = $_[0]; - my $newline = $_[0]; - my $rootid = $_[1]; - my $indent = ''; - - if($oldline =~ /root/) { - $indent = $oldline; - chomp $indent; - $indent =~ s/^(\t?)root.*/$1/; - $newline = $indent . "root = \"UUID=$rootid\"\n"; - } - return $newline; -} - - -main(); - - -__END__ - - -=head1 NAME - -lilo-uuid-diskid - convert boot / root options to diskid and uuid in lilo.conf - -=head1 SYNOPSIS - -lilo-uuid-diskid [-h] [-v] [lilo.conf] - -=head1 DESCRIPTION - -This script looks for the boot block device or boot partition and create the -right diskid or uuid as boot option. Then it looks for all root partitions -and create the right uuids as root options. - -These conversions are necessary for use with newer kernel (>= 2.6.26) if it -use the libata module for parallel and serial ATA interfaces of block devices -(i. e. hard disks with IDE or SATA interface, usbsticks). - -=head1 EXAMPLES - -Lines in the configuration file /etc/lilo.conf: - - #boot = /dev/sda - boot = /dev/disk/by-id/ata-SAMSUNG_SV1604N_S01FJ10X999999 - - #root = /dev/sda1 - root = "UUID=18843936-00f9-4df0-a373-000d05a5dd44" - -=head1 OPTIONS - -=over 4 - -=item B<-h> - -Print a brief help. - -=item B<-v> - -Print verbose messages. - -=back - -=head1 AUTHOR - -B was written by Joachim Wiedorn. - -=cut diff --git a/debian/scripts/liloconfig b/debian/scripts/liloconfig deleted file mode 100644 index 46a83f5..0000000 --- a/debian/scripts/liloconfig +++ /dev/null @@ -1,601 +0,0 @@ -#!/usr/bin/perl -w - -# liloconfig - creating a new lilo.conf file -# -# Copyright 2011 Joachim Wiedorn -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, -# MA 02110-1301, USA. - -#---- some modules -use strict; -use warnings; -use Getopt::Std; -use Pod::Usage; -use File::Copy; - - -#---- global variables -my $prog = $0; -$prog =~ s#.*/##; -my $version = "0.1"; - -#---- parameter check -# h: help, v: verbose, f: force -our $opt_h = 0; -our $opt_v = 0; -our $opt_f = 0; -getopts('hvf'); -# define perldoc usage -pod2usage(1) if $opt_h; - -#---- other variables -our $liloconf = "/etc/lilo.conf"; -our $conftmp_1 = "/tmp/lilotmp1"; -our $conftmp_2 = "/tmp/lilotmp2"; -our $liloconfold = $liloconf . ".old"; -our $liloconfnew = $liloconf . ".new"; -our $fstabconf = "/etc/fstab"; - -our $idpath = "/dev/disk/by-id"; -our $uuidpath = "/dev/disk/by-uuid"; -our $lblpath = "/dev/disk/by-label"; -our $template = "/usr/share/doc/lilo/examples/lilo.example.conf.gz"; - -our $rootpart; # found root part -our $root_dev; # /dev/hdX9, /dev/sdX9, /dev/md/* -our $root_id; # UUID, LABEL, ID -our $boot_dev; # /dev/hdX, /dev/sdX, /dev/md -our $boot_id; # DISK-ID - -#-------------------- main program -------------------- - -sub main { - - my $exit = 0; - - if (@ARGV == 1) { - $liloconf = "$ARGV[0]"; - $liloconfold = $liloconf . ".old"; - $liloconfnew = $liloconf . ".new"; - } - if (-f $liloconf and not $opt_f) { - print "$prog: $liloconf already exist! Please use '-f' for overwriting.\n"; - $exit = 1; - } - else { - $exit = create_lilo_conf() - } - return $exit; -} - -#-------------------- subroutines -------------------- - -sub create_lilo_conf { - - my $found = 0; - my $exit = 1; - - # search for root device in fstab and convert it - $found = detect_root_device(); - - # convert root device to boot device - if ($found) { $found = convert_boot_device(); } - - # finally write new lilo.conf file - if ($found) { $exit = write_lilo_conf(); } - - return $exit; -} - -sub detect_root_device { - - # read fstab and find root device; - my $found = read_fstab(); - - # identify root device: root_dev and root_id - if ($found) { $found = convert_root_device(); } - - return $found; -} - -sub read_fstab { - - my $root_part; - my $mountpoint; - my $broken_fstab = 1; - my $base_fstab = 0; - my $found = 1; - - # check fstab for root device - if (-f $fstabconf) { - # Parsing fstab for the root partition - open(FSTAB, "<$fstabconf") or die "$prog: couldn't open $fstabconf: $!\n"; - - while () { - # Search magic string which indicates a base filesystem - $base_fstab = 1 if /^# UNCONFIGURED FSTAB FOR BASE SYSTEM/; - next if /^#/; # ignore comment lines - - s/^[ \t]+//; # remove space or tab at begin of the line - ($root_part,$mountpoint) = split(/[ \t]+/); - next unless defined $mountpoint; # ignore empty lines too - - # stop if we found the root device... - if ($mountpoint eq '/') { - $broken_fstab = 0; - last; - } - } - close(FSTAB) or die "$prog: couldn't close $fstabconf: $!\n"; - } - - if ($base_fstab) { - print "E: It seems you want configure the base filesystem \n" . - "and I'm therefore simply going to exit successfully \n" . - "without trying to actually configure LILO properly. \n"; - $found = 0; - } - if ($broken_fstab) { - print "E: It seems the file /etc/fstab is not properly \n" . - "configured: no root partition '/' found! \n"; - $found = 0; - } - # save the found root device - $rootpart = $root_part; - - return $found; -} - -sub convert_root_device { - - my $found = 1; - my $root_disk = ''; - my $root_link; - # global variables: $root_dev, $root_id - - if ($rootpart =~ /\/dev\//) { - $root_disk = $rootpart; - - if (-b $root_disk) { - $root_dev = $root_disk; - if($opt_v) { print "Convert root option $root_disk into UUID\n"; } - $root_id = find_id_link($root_disk,$uuidpath); - - if (not -l "$uuidpath/$root_id") { - if($opt_v) { print "W: could not find UUID for $root_disk!\n"; } - ## than we want use root_dev in lilo.conf - #$found = 0; - } - else { - # finally add uuid label - $root_id = "UUID=" . $root_id; - } - } - else { - if($opt_v) { print "E: cannot check $root_disk: device does not exist!\n"; } - $found = 0; - } - } - elsif ($rootpart =~ /^UUID/ or $rootpart =~ /^LABEL/) { - $root_link = $rootpart; - $root_link =~ s{\"}{}g; - $root_link =~ s{^LABEL=}{/dev/disk/by-label/}; - $root_link =~ s{^UUID=}{/dev/disk/by-uuid/}; - - if (-l $root_link) { - $root_id = $rootpart; - $root_disk = readlink($root_link); - $root_disk =~ s{\.\./\.\./}{/dev/}; - - if (-b $root_disk) { $root_dev = $root_disk; } - else { - if($opt_v) { print "E: cannot check $root_link: link does not exist!\n"; } - $found = 0; - } - } - else { - print "E: cannot check $root_link: link does not exist!\n"; - $found = 0; - } - } - else { - print "E: cannot use uncommon $rootpart found as root device!\n"; - $found = 0; - } - - return $found; -} - -sub find_id_link { - - my $olddev = $_[0]; - my $path_id = $_[1]; - my @sellinks; - my $_idlink; - my $_actlink; - my $newdevid = ''; - - opendir(MYDH, "$path_id") or die("cannot open $path_id: $! \n"); - @sellinks = grep(!/\-part\d\d?$/, grep(!/^\.\.?$/, readdir(MYDH))); - @sellinks = sort(@sellinks); - closedir(MYDH); - - foreach $_idlink (@sellinks) { - chomp $_idlink; - if(not $_idlink =~ /^usb/ and length($_idlink) > 10) { - $_actlink = readlink("$path_id/$_idlink"); - $_actlink =~ s{\.\./\.\./}{/dev/}; - if($opt_v) { print "** try: $_actlink => $_idlink \n"; } - - # stop if we find the right link... - if($_actlink eq $olddev) { - $newdevid = $_idlink; - if($opt_v) { print "** convert: $_actlink => $path_id/$_idlink \n\n"; } - last; - } - } - } - - if(not $newdevid) { - if($opt_v) { print "W: $olddev not converted: link not useful\n\n"; } - } - - return ($newdevid); -} - -sub convert_boot_device { - - my $found = 1; - my $boot_disk = ''; - my $boot_link; - # global variables: $boot_dev, $boot_id - - if (-b $root_dev) { - if ($root_dev =~ /\/dev\/md/) { - # search if the found partition is a raid volume - $boot_disk = check_raid($root_dev); - } - else { - # find the right block device name - $boot_disk = $root_dev; - $boot_disk =~ s/\d+$//; - } - - if (-b $boot_disk) { - # set global variable boot_dev - $boot_dev = $boot_disk; - } - else { - print "E: boot device $boot_disk does not exist! \n"; - $found = 0; - } - } - else { - print "E: could not find root device $root_dev! \n"; - $found = 0; - } - - if ($found) { - if($opt_v) { print "Convert boot option $boot_disk into DISK ID\n"; } - $boot_id = $idpath . "/" . find_id_link($boot_disk,$idpath); - - if(not -l "$boot_id") { - if($opt_v) { print "W: could not find DISK ID for $boot_disk!\n"; } - ## not so important, than using boot_dev in lilo.conf - #$found = 0; - } - } - - return $found; -} - -sub check_raid { - - my $part = $_[0]; - my $mdname; - my $md; - my @devices; - - # check if the found partition is a raid volume - if($part =~ /\/dev\/md/) - { - $mdname = $part; - $mdname =~ s/\/dev\///; - $mdname =~ s/\///; - $md = `grep $mdname /proc/mdstat`; - - @devices = split(" ", $md); - @devices = sort(@devices[4..$#devices]); - $part = "/dev/" . $devices[0]; - $part =~ s/\[.*$//; - - } - return $part; -} - -sub write_lilo_conf { - - my @status; - my $exit = copy_template(); - - if (not $exit) { - # create lilo.conf.new - write_boot_option(); - write_image_config(); - } - - if (-f $liloconf and not -f $liloconfold) { - # move old lilo.conf to lilo.conf.old - @status = stat($liloconf); - move ($liloconf, $liloconfold) or die "Cannot rename file: $!\n"; - utime ($status[9],$status[9],$liloconfold); - chmod (0600,$liloconfold); - print "Old file moved to: $liloconfold \n"; - } - if (-f $liloconfnew) { - move ($liloconfnew, $liloconf) or die "Cannot move file: $!\n"; - chmod (0600,$liloconf); - print "New file created as: $liloconf \n"; - print "Now you must execute '/sbin/lilo' to " . - "activate this new configuation!\n\n"; - } - else { - print "E: Cannot find temporary file $conftmp_1!\n"; - $exit = 1; - } - - return $exit; -} - -sub copy_template { - - my $endreached = 0; - my $exit = 0; - - # copy template config - if (-f $template) { - system("gzip -d -c $template >$conftmp_1") if ($template =~ /\.gz$/); - system("cat $template >$conftmp_1") if ($template =~ /\.conf$/); - - open(CONFTMP1, "<$conftmp_1") or die "$prog: couldn't open $conftmp_1: $!\n"; - open(CONFTMP2, ">$conftmp_2") or die "$prog: couldn't open $conftmp_2: $!\n"; - - while () { - if (/first\ example/) { - $endreached = 1; - } - unless ($endreached) { - print CONFTMP2 $_; - } - } - close(CONFTMP1) or die "$prog: couldn't close $conftmp_1: $!\n";; - close(CONFTMP2) or die "$prog: couldn't close $conftmp_2: $!\n";; - } - else { - open(CONFTMP2, ">$conftmp_2") or die "$prog: couldn't open $conftmp_2: $!\n"; - print CONFTMP2 "# /etc/lilo.conf - -### LILO global section ### - -#large-memory -lba32 -boot = /dev/sda -map = /boot/map -install = menu -menu-scheme = Wb:Yr:Wb:Wb -prompt -timeout = 100 -vga = normal -#default = Linux - -### LILO per-image section ### - -"; - close(CONFTMP2) or die "$prog: couldn't close $conftmp_2: $!\n";; - } - - return $exit; -} - -sub write_boot_option { - - my $oldline = ''; - my $newline = ''; - my $ok = 0; - - open(MYFH_NEW, "> $liloconfnew") or die "Cannot open file: $!"; - open(MYFH_TMP, "< $conftmp_2") or die "Cannot read file: $!"; - - while () { - # line read from MYFH_TMP - $oldline = $_; - - if (/^boot/ and $ok == 0) { - if ($boot_id) { - $oldline = "#boot = $boot_dev\n"; - $newline = "boot = $boot_id\n"; - print MYFH_NEW $oldline; - if($opt_v) { print $oldline; } - } - else { - $oldline = "boot = $boot_dev\n"; - } - print MYFH_NEW $newline; - if($opt_v) { print $newline; } - if($opt_v) { print "\n"; } - - # convert only one time - $ok = 1; - } - else { - print MYFH_NEW $oldline; - } - } - close(MYFH_TMP); - close(MYFH_NEW); -} - -sub write_image_config { - - my $image; - my $initrd; - my $nr; - my $nr2; - - # search for kernel image files - my @vmlinuz = readpipe("/bin/ls -t -1 /boot/vmlinuz-2* 2>/dev/null"); - - # append to new lilo.conf - open(MYFH_NEW, ">> $liloconfnew") or die "Cannot open file: $!"; - - # create some line for each kernel image - $nr = 0; - foreach $image (@vmlinuz) { - # search for kernel initrd file - chomp $image; - $initrd = $image; - $initrd =~ s/vmlinuz/initrd\.img/; - $nr2 = $nr + 1; - - print MYFH_NEW 'image = ' . $image . "\n"; - if($opt_v) { print 'image = ' . $image . "\n"; } - if ($nr == 0) { - print MYFH_NEW "\t" . 'label = "Linux"' . "\n"; - if($opt_v) { print "\t" . 'label = "Linux"' . "\n"; } - } - elsif ($nr == 1) { - print MYFH_NEW "\t" . 'label = "Linux Old"' . "\n"; - if($opt_v) { print "\t" . 'label = "Linux Old"' . "\n"; } - } - if ($root_id) { - print MYFH_NEW "\t" . '#root = ' . $root_dev . "\n"; - if($opt_v) { print "\t" . '#root = ' . $root_dev . "\n"; } - print MYFH_NEW "\t" . 'root = "' . $root_id . '"' . "\n"; - if($opt_v) { print "\t" . 'root = "' . $root_id . '"' . "\n"; } - } - else { - print MYFH_NEW "\t" . 'root = ' . $root_dev . "\n"; - if($opt_v) { print "\t" . 'root = ' . $root_dev . "\n"; } - } - print MYFH_NEW "\t" . 'read-only' . "\n"; - if($opt_v) { print "\t" . 'read-only' . "\n"; } - print MYFH_NEW "#\t" . 'restricted' . "\n"; - if($opt_v) { print "#\t" . 'restricted' . "\n"; } - print MYFH_NEW "#\t" . 'alias = ' . "$nr2" . "\n"; - if($opt_v) { print "#\t" . 'alias = ' . "$nr2" . "\n"; } - print MYFH_NEW "#\t" . 'optional' . "\n"; - if($opt_v) { print "#\t" . 'optional' . "\n"; } - if (-f $initrd) { - print MYFH_NEW "\t" . 'initrd = ' . $initrd . "\n"; - if($opt_v) { print "\t" . 'initrd = ' . $initrd . "\n"; } - } - print MYFH_NEW "\n"; - if($opt_v) { print "\n"; } - - $nr++; - last if ($nr > 1); - } - - close(MYFH_NEW); -} - - -main(); - -__END__ - - -=head1 NAME - -liloconfig - create new lilo.conf file (with diskid and uuid) - -=head1 SYNOPSIS - -liloconfig [-h] [-v] [-f] [lilo.conf] - -=head1 DESCRIPTION - -liloconfig is an simple program for creating a new lilo.conf file. -After creating the new configuration file you must execute '/sbin/lilo'. - -liloconfig use the lilo.example.conf file as template. In the final -lilo.conf file you find many useful comments for custom changes. - -=head1 EXAMPLES - -Lines in the configuration file /etc/lilo.conf: - - ### LILO global section ### - - #large-memory - lba32 - boot = /dev/sda - map = /boot/map - install = menu - menu-scheme = Wb:Yr:Wb:Wb - prompt - timeout = 100 - vga = normal - #default = Linux - - ### LILO per-image section ### - - #boot = /dev/sda - boot = /dev/disk/by-id/ata-SAMSUNG_SV1604N_S01FJ10X999999 - - image = /boot/vmlinuz-2.6.32-5book-686 - label = "Linux" - #root = /dev/sda1 - root = "UUID=18843936-00f9-4df0-a373-000d05a5dd44" - read-only - # restricted - # alias = 1 - # optional - initrd = /boot/initrd.img-2.6.32-5book-686 - - image = /boot/vmlinuz-2.6.32-5-686 - label = "Linux Old" - #root = /dev/sda1 - root = "UUID=18843936-00f9-4df0-a373-000d05a5dd44" - read-only - # restricted - # alias = 2 - # optional - initrd = /boot/initrd.img-2.6.32-5-686 - -=head1 OPTIONS - -=over 4 - -=item B<-h> - -Print a brief help. - -=item B<-v> - -Print verbose messages. - -=item B<-f> - -Force overriding existing lilo.conf. - -=back - -=head1 AUTHOR - -B was written by Joachim Wiedorn. - -=cut diff --git a/debian/scripts/update-lilo b/debian/update-lilo similarity index 86% rename from debian/scripts/update-lilo rename to debian/update-lilo index f8c5e29..0f1351a 100644 --- a/debian/scripts/update-lilo +++ b/debian/update-lilo @@ -2,7 +2,7 @@ # update-lilo - execute lilo in special debconf mode # -# Copyright 2010-2011 Joachim Wiedorn +# Copyright 2010-2012 Joachim Wiedorn # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,9 +21,11 @@ set -e -# Run the boot loader installer. Sending STDOUT to STDERR +# Run the boot loader installer. Sending STDOUT to STDERR # to avoid confusing debconf, which has redirected STDOUT. -if [ -f /etc/lilo.conf ];then + +if [ -f /etc/lilo.conf ] +then lilo >&2 fi -- 2.39.2