pax_global_header00006660000000000000000000000064107643570100014515gustar00rootroot0000000000000052 comment=d48bc815581db8ecd8d59ff6d936e720a6a47c61 bootloader-utils-0.3.3-alt1/000075500000000000000000000000001076435701000156455ustar00rootroot00000000000000bootloader-utils-0.3.3-alt1/.gear-rules000064400000000000000000000000611076435701000177110ustar00rootroot00000000000000tar: . name=bootloader-utils-@version@-@release@ bootloader-utils-0.3.3-alt1/FILES000064400000000000000000000002221076435701000164260ustar00rootroot00000000000000bootloader_utils.pm bootloader-utils.spec detectloader detectloader.8 FILES grub installkernel lilo Makefile rebootin rebootin.8 skiplist test.pl bootloader-utils-0.3.3-alt1/Makefile000064400000000000000000000020461076435701000173070ustar00rootroot00000000000000NAME = bootloader-utils FILES = $(shell cat FILES) root = $(RPM_BUILD_ROOT) prefix = $(root)/usr sbindir = $(prefix)/sbin datadir = $(prefix)/share mandir = $(prefix)/share/man perl_libdir = $(root)$(shell eval `perl -V:installsitelib`; echo $$installsitelib) INSTALL = install -p all: build build: detectloader.8 detectloader.8: detectloader pod2man --section 8 detectloader > detectloader.8 test: perl test.pl install: $(INSTALL) -d $(sbindir) $(datadir) $(mandir)/man8 $(perl_libdir) $(root)/sbin $(datadir)/loader $(INSTALL) -m644 *.pm $(perl_libdir) $(INSTALL) -m644 *.8 $(mandir)/man8 $(INSTALL) -m755 lilo grub $(datadir)/loader $(INSTALL) -m755 detectloader $(sbindir) $(INSTALL) -m755 rebootin $(sbindir) $(INSTALL) -m755 installkernel $(root)/sbin tar $(NAME).tar.gz: $(FILES) mkdir $(NAME) ; \ tar cf - `cat FILES` | ( cd $(NAME) ; tar xfBp - ) ; \ tar cf $(NAME).tar $(NAME) ; \ rm -rf $(NAME) ; \ gzip -9f $(NAME).tar rpm: $(NAME).tar.gz rpm -ta $(NAME).tar.gz clean: rm -fv *[~-] .PHONY: all build install tar rpm clean bootloader-utils-0.3.3-alt1/bootloader-utils.spec000064400000000000000000000071501076435701000220140ustar00rootroot00000000000000Name: bootloader-utils Version: 0.3.3 Release: alt1 Summary: Bootloader utilities License: GPL Group: System/Base URL: http://www.altlinux.ru Packager: Alexey Tourbin BuildArch: noarch Source: %name-%version-%release.tar Requires: fdisk getopt Provides: %_sbindir/detectloader /sbin/installkernel # Automatically added by buildreq on Thu Feb 22 2007 BuildRequires: perl-devel %description This package contains utilities used to manipulate bootloaders. %prep %setup -q -n %name-%version-%release %build %make_build %make test %install %makeinstall perl_libdir=%buildroot%perl_vendor_privlib ln -s `relative %perl_vendor_privlib/bootloader_utils.pm %_datadir/loader/bootloader_utils.pm` \ %buildroot%_datadir/loader/bootloader_utils.pm %files /sbin/installkernel %_sbindir/detectloader %_sbindir/rebootin %_datadir/loader/ %perl_vendor_privlib/*.pm %_man8dir/*.* %changelog * Fri Mar 07 2008 Dmitry V. Levin 0.3.3-alt1 - grub: Fixed memtest removal (Alexey Tourbin). - installkernel: + Do not discard /sbin/lilo stdout (Alexey Tourbin). + Do not run detectloader in nolaunch mode. + Do not invoke "cp" by absolute pathname. + Do not touch files in DURING_INSTALL mode, thus reverting the change made in 0.3.1-alt2. + Replaced non-portable "realpath" with "readlink -e". + Fixed xen kernels install (Aleksey Avdeev, #13672). * Thu Feb 22 2007 Alexey Tourbin 0.3.2-alt1 - fixed accidental Windows(tm) removal from lilo.conf (#6102) - fixed lilo.conf quoting issues (#10903) * Mon Feb 12 2007 Alexey Gladkov 0.3.1-alt2 - Update symlinks in /boot if DURING_INSTALL specified. * Fri Feb 09 2007 Alexey Gladkov 0.3.1-alt1.1.1 - NMU: - quote lilo parameters. * Thu Feb 09 2006 Anton Farygin 0.3.1-alt1.1 - NMU: - fstab parser fixes (#3318, #8615) - installkernel fixes (#4811, #7386) * Tue Aug 17 2004 Alexey Tourbin 0.3.1-alt1 - fixed skiplist processing (Sergey Vlasov, #4254) - create backup (.old) copies of lilo.conf and grub/menu.lst (#4395) - installkernel: run mkinitrd(8) without --ifneeded (should hopefully fix #4234 and #4643) * Fri Jun 11 2004 Alexey Tourbin 0.3-alt1 - added support for LABEL and UUID volumes (via /etc/mtab) - installkernel: save entry for /boot/vmlinuz before upgrade - installkernel: added support for memtest86 - grub: fix for separate /boot partition, by Sergey Vlasov (#4234) - started test suite (test.pl) * Fri May 07 2004 Alexey Tourbin 0.2-alt1 - here goes my first major revision; highlights: + common.pm -> bootloader_utils.pm, reworked + detectloader(1) reworked + helpers for lilo(1) and grub(1) configuration files reworked + installkernel reworked, /etc/sysconfig/installkernel disappeared * Wed Mar 19 2003 Peter Novodvorsky 0.1-alt7 - Updated label shorten algorithm in lilo installer script. * Mon Dec 09 2002 Dmitry V. Levin 0.1-alt6 - Fixed perl dependencies (#0001679). * Fri Nov 15 2002 Stanislav Ievlev 0.1-alt5 - rebuild - more features: + skiplist for mhz (#0001015) + advanced skiping of cdroms (#0001014) * Fri Mar 15 2002 Dmitry V. Levin 0.1-alt4 - Fixed configuration options parsing (imz, #0000507). * Thu Feb 14 2002 Stanislav Ievlev 0.1-alt3 - added new signature for the GRUB * Fri Nov 23 2001 Dmitry V. Levin 0.1-alt2 - Added %%build section, autogenerated buildrequires. * Wed Nov 14 2001 Dmitry V. Levin 0.1-alt1 - Imported MDK code (to be rewritten). bootloader-utils-0.3.3-alt1/bootloader_utils.pm000064400000000000000000000077631076435701000215720ustar00rootroot00000000000000package bootloader_utils; # $Id: bootloader_utils.pm,v 1.4 2004/06/11 11:09:45 at Exp $ #-------------------------------------------------------------------- # Copyright (C) 2000, 2001, 2002 by MandrakeSoft. # Chmouel Boudjnah . # # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) #-------------------------------------------------------------------- # Copyright (C) 2003 by ALT Linux Team, # Alexey Tourbin . #-------------------------------------------------------------------- require Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(mnt2dev partitions typeOfMBR getroot); use strict; sub gettab ($) { my $fname = shift; open my $fh, $fname or do { warn "$0: $fname: $!"; return; }; my @tab; local $_; local $/ = "\n"; while (<$fh>) { next unless /\S/; next if /^\s*#/; my @ent = split; push @tab, \@ent; } return @tab; } sub mnt2dev ($;$$) { my $mnt = shift; my $fstab_file = shift || "/etc/fstab"; my $mtab_file = shift || "/etc/mtab"; my @fstab = gettab $fstab_file; my @mtab = gettab $mtab_file; foreach my $fsent (@fstab) { if ($$fsent[0] =~ /^(LABEL|UUID)=/) { foreach my $ment (@mtab) { if ($$ment[1] eq $$fsent[1]) { $$fsent[0] = $$ment[0]; } } } return $$fsent[0] if $$fsent[1] eq $mnt; } return; } my @MBR_signatures = ( [ 'empty', 0, "\0\0\0\0" ], [ 'grub', 0, "\xEBG", 0x17d, "stage1 \0" ], [ 'grub', 0, "\xEBH", 0x17e, "stage1 \0" ], [ 'grub', 0, "\xEBH", 0x18a, "stage1 \0" ], [ 'grub', 0, "\xEBH", 0x181, "GRUB \0" ], [ 'lilo', 0x2, "LILO" ], [ 'lilo', 0x6, "LILO" ], [ 'grub', 0x6, "GRUB" ], [ 'osbs', 0x2, "OSBS" ], #- http://www.prz.tu-berlin.de/~wolf/os-bs.html [ 'pqmagic', 0xef, "PQV" ], [ 'BootStar', 0x130, "BootStar:" ], [ 'DocsBoot', 0x148, 'DocsBoot' ], [ 'system_commander', 0x1ad, "SYSCMNDRSYS" ], [ 'Be Os', 0x24, 'Boot Manager' ], [ 'os2', 0, "\xFA\xB8\x30\x00", 0xfA, "OS/2" ], [ 'TimO', 0, 'IBM Thinkpad hibernation partition' ], [ 'dos', 0xa0, "\x25\x03\x4E\x02\xCD\x13" ], [ 'dos', 0xa0, "\x00\xB4\x08\xCD\x13\x72" ], #- nt2k's [ 'dos', 0x60, "\xBB\x00\x7C\xB8\x01\x02\x57\xCD\x13\x5F\x73\x0C\x33\xC0\xCD\x13" ], #- nt's [ 'dos', 0x70, "\x0C\x33\xC0\xCD\x13\x4F\x75\xED\xBE\xA3" ], [ 'freebsd', 0xC0, "\x00\x30\xE4\xCD\x16\xCD\x19\xBB\x07\x00\xB4" ], [ 'freebsd', 0x160, "\x6A\x10\x89\xE6\x48\x80\xCC\x40\xCD\x13" ], [ 'dummy', 0xAC, "\x0E\xB3\x07\x56\xCD\x10\x5E\xEB" ], #- caldera? [ 'ranish', 0x100, "\x6A\x10\xB4\x42\x8B\xF4\xCD\x13\x8B\xE5\x73" ], [ 'os2', 0x1c2, "\x0A" ], [ 'Acronis', 0, "\xE8\x12\x01" ], ); sub typeFromMagic { my $fname = shift; sysopen my $fh, $fname, 0 or do { warn "$0: $fname: $!"; return; }; set: foreach my $set (@_) { my ($type, %magic) = @$set; while (my ($offset, $signature) = each %magic) { sysseek($fh, $offset, 0) or next set; my $n = length $signature; sysread($fh, my $buf, $n) == $n or next set; $buf eq $signature or next set; } return $type; } return; } use File::Temp qw(tempdir); use sigtrap qw(die normal-signals); sub typeOfMBR($) { my $disk = shift; my $dev = "/dev/$$disk{dev}"; unless (-b $dev) { my $dir = tempdir("bootloader.XXXXXXXXXX", CLEANUP => 1, TMPDIR => 1); $dev = "$dir/$$disk{dev}"; system "mknod", $dev, "b", $$disk{major}, $$disk{minor}; die "$0: cannot create block special file $dev\n" unless $? == 0 && -b $dev; } return typeFromMagic($dev, @MBR_signatures); } sub media_type { my $dev = shift; open my $fh, "/proc/ide/$dev/media" or return; my $type = <$fh>; chomp $type; return $type; } sub partitions { open my $fh, "/proc/partitions" or return; my @all; local $_; while (<$fh>) { next unless /\d/; my %ent; @ent{qw(major minor size dev)} = split; $ent{media} = media_type $ent{dev}; push @all, \%ent; } return @all; } sub getroot { if (open my $fh, "/proc/cmdline") { return $1 if <$fh> =~ /root=(\/\S+)/; } my $root = mnt2dev("/"); return $root if $root; return $& if `/usr/sbin/rdev` =~ /\/\S+/; return; } 1; bootloader-utils-0.3.3-alt1/detectloader000064400000000000000000000042361076435701000202340ustar00rootroot00000000000000#!/usr/bin/perl # $Id: detectloader,v 1.5 2004/06/24 00:19:22 at Exp $ =head1 NAME detectloader - detect what type of loader you have on your disk =head1 DESCRIPTION detectloader detects the type of the boot loader you have on your MBR. It finds the first disk via /proc/partitions and looks via the magic serial what kind of boot loader you have installed. If neither LILO nor GRUB is found on MBR, try partitions too. =head1 LIMITATION Supports only grub and lilo. Patches welcome for other boot loaders. =head1 COPYRIGHT Copyright (C) 2003 by ALT Linux Team, Alexey Tourbin . Copyright (C) 2000, 2001, 2002 by MandrakeSoft, Pixel and others MandrakeSoft folks. Redistribution of this file is permitted under the terms of the GNU Public License (GPL). =cut use bootloader_utils qw(partitions typeOfMBR); use strict; use Getopt::Long qw(GetOptions); GetOptions "q|quiet" => \my $quiet or die "usage: $0 [-q|--quiet]\n"; sub warning { warn "@_\n" unless $quiet; } sub read_skiplist { open my $fh, "/etc/bootloader/skiplist" or return; my @list; local $_; while (<$fh>) { next if /^#/; /\S+/ and push @list, $&; } return @list; } sub detect { my %known_loaders = map { $_ => 1 } qw(grub lilo); my %skiplist = map { $_ => 1 } read_skiplist(); my (@disks, @partitions); foreach (partitions()) { next if $skiplist{$$_{dev}}; next if $$_{media} eq "cdrom"; $$_{dev} =~ /\d$/ ? push @partitions, $_ : push @disks, $_ ; } foreach my $disk (@disks) { my $loader = typeOfMBR($disk); if ($known_loaders{$loader}) { warning "$0: $$disk{dev}: $loader"; return $loader; } } warning "no bootloader on MBR, trying partitions!"; open my $pipe, "-|", "fdisk", "-l", or warning "$0: fdisk not available" and return; while (<$pipe>) { next unless m#^/dev/(\w+\d+)\s+\*\s+#; next if $skiplist{$1}; my ($partition) = grep { $$_{dev} eq $1 } @partitions; next unless $partition; my $loader = typeOfMBR($partition); if ($known_loaders{$loader}) { warning "$0: $$partition{dev}: $loader"; return $loader; } } return; } my $loader = $ENV{DEFAULT_LOADER} || detect(); print uc($loader) . "\n"; bootloader-utils-0.3.3-alt1/detectloader.8000064400000000000000000000110271076435701000203760ustar00rootroot00000000000000.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DETECTLOADER 8" .TH DETECTLOADER 8 "2004-06-24" "perl v5.8.4" "User Contributed Perl Documentation" .SH "NAME" detectloader \- detect what type of loader you have on your disk .SH "DESCRIPTION" .IX Header "DESCRIPTION" detectloader detects the type of the boot loader you have on your \s-1MBR\s0. It finds the first disk via /proc/partitions and looks via the magic serial what kind of boot loader you have installed. If neither \s-1LILO\s0 nor \s-1GRUB\s0 is found on \&\s-1MBR\s0, try partitions too. .SH "LIMITATION" .IX Header "LIMITATION" Supports only grub and lilo. Patches welcome for other boot loaders. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2003 by \s-1ALT\s0 Linux Team, Alexey Tourbin . .PP Copyright (C) 2000, 2001, 2002 by MandrakeSoft, Pixel and others MandrakeSoft folks. .PP Redistribution of this file is permitted under the terms of the \s-1GNU\s0 Public License (\s-1GPL\s0). bootloader-utils-0.3.3-alt1/grub000064400000000000000000000054541076435701000165370ustar00rootroot00000000000000#!/usr/bin/perl # $Id: grub,v 1.7 2004/08/17 02:03:39 at Exp $ #-------------------------------------------------------------------- # Copyright (C) 2000, 2001, 2002 by MandrakeSoft. # Chmouel Boudjnah . # # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) #-------------------------------------------------------------------- # Copyright (C) 2003 by ALT Linux Team, # Alexey Tourbin . #-------------------------------------------------------------------- # description: Add/remove entry for grub bootloader. use strict; use bootloader_utils qw(getroot mnt2dev); use Getopt::Long qw(GetOptions); GetOptions "r|R|remove" => \my $remove, "m|memtest" => \my $memtest and (my $version = shift) and (@ARGV == 0) or die "usage: $0 [-r|-R|--remove] [-m|--memtest] version\n"; sub dev2grub { my $dev = shift; my ($disk, $part) = $dev =~ /([^\d\s]+)(\d+)/ or return; # Sample device.map entry: # (hd0) /dev/hda # Sample convertion: # /dev/hda5 => (hd0,4) $part--; my $map = $ENV{GRUB_DEVICE_MAP} || "/boot/grub/device.map"; open my $fh, $map or return; my $grub_part; while (<$fh>) { if (/\((\w+d\d+)\)\s+\Q$disk\E$/) { $grub_part = "($1,$part)"; last; } } return $grub_part; } my $bootdev = mnt2dev("/boot"); my $boot = $bootdev ? "" : "/boot"; my $root = getroot; my $grub_part = dev2grub($bootdev ? $bootdev : $root); die "Can't convert grub partition\n" unless $grub_part; sub add_memtest { local $_ = shift; /\/memtest-\Q$version.bin\E\b/ or $_ .= < @sections; } sub add_kernel { local $_ = shift; /\/vmlinuz-\Q$version\E\s/ or $_ .= < @sections; } { # open menu.lst for update my $menu_lst = $ENV{GRUB_MENU_LST} || "/boot/grub/menu.lst"; open my $fh, "+<", $menu_lst or die "Cannot open $menu_lst\n"; my $content = do { local $/ = undef; <$fh> }; # modify the content if ($memtest && $remove) { $content = remove_memtest($content); } elsif ($memtest) { $content = add_memtest($content); } elsif ($remove) { $content = remove_kernel($content); } else { $content = add_kernel($content); } # neat $content =~ s/\n{3,}/\n\n/g; # debug # print $content; # exit 0; # do the update seek $fh, 0, 0; print $fh $content; truncate $fh, tell $fh; # autoclosed } bootloader-utils-0.3.3-alt1/installkernel000064400000000000000000000072731076435701000204500ustar00rootroot00000000000000#!/bin/sh # $Id: installkernel,v 1.7 2004/08/17 02:08:27 at Exp $ #-------------------------------------------------------------------- # Copyright (C) 2000, 2002 by MandrakeSoft, # Chmouel Boudjnah , # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) #-------------------------------------------------------------------- # Copyright (C) 2003, 2004 by ALT Linux Team, # Alexey Tourbin . #-------------------------------------------------------------------- # description: Install a kernel to /boot and add an entry for grub and lilo : ${INSTALLKERNEL_CONFIG:=/etc/sysconfig/installkernel} if [ -f "$INSTALLKERNEL_CONFIG" ]; then . "$INSTALLKERNEL_CONFIG" fi usage() { cat <&2 Usage: $0 [options] KERNEL_VERSION -n, --nolaunch don't launch lilo; -r, -R, --remove remove bootloader entry and prepare to remove kernel; -m, --memtest it's all about memtest86, not Linux kernel; -h, --help this help. EOF [ -n "$1" ] && exit "$1" || exit 2 } LEGACY=algyNdsSCiLc ARGV=`getopt -n "$0" -o nrRmh$LEGACY -l nolaunch,remove,memtest,help -- "$@"` || usage eval set -- "$ARGV" while :; do case "$1" in -n|--nolaunch) NOLAUNCH=$1; shift ;; -r|-R|--remove) REMOVE=$1; shift ;; -m|--memtest) MEMTEST=$1; shift ;; -h|--help) shift; usage 0 ;; --) shift; break ;; -[$LEGACY]) echo "$0: legacy option $1 ignored (probably harmless)" >&2; shift ;; *) echo "$0: unrecognized option: $1" >&2; exit 1 ;; esac done [ -z "${0##*memtest*}" ] && MEMTEST=--memtest VERSION="$1" [ -n "$VERSION" ] || usage if [ -n "$DURING_INSTALL" ]; then echo "$0: DURING_INSTALL=$DURING_INSTALL; supposed to run later" >&2 exit 0 fi : ${BOOTDIR:=/boot} : ${MKINITRD:=/sbin/mkinitrd} if OLD_KERNEL=`readlink -e -- "$BOOTDIR/vmlinuz"`; then OLD_VERSION="${OLD_KERNEL##*/vmlinuz-}" fi cd "$BOOTDIR" if [ -z "$REMOVE" -a -z "$MEMTEST" ]; then "$MKINITRD" $MKINITRD_OPTIONS -f "$BOOTDIR/initrd-$VERSION.img" "$VERSION" if [ -z "${VERSION##*-xen-*}" ]; then ln -snf "vmlinuz-$VERSION" vmlinuz-xen ln -snf "initrd-$VERSION.img" initrd-xen.img else ln -snf "vmlinuz-$VERSION" vmlinuz ln -snf "initrd-$VERSION.img" initrd.img if [ -z "${VERSION##*-up-*}" ]; then ln -snf "vmlinuz-$VERSION" vmlinuz-up ln -snf "initrd-$VERSION.img" initrd-up.img fi if [ -z "${VERSION##*-smp-*}" ]; then ln -snf "vmlinuz-$VERSION" vmlinuz-smp ln -snf "initrd-$VERSION.img" initrd-smp.img fi fi elif [ -z "$MEMTEST" ]; then rm -f "initrd-$VERSION.img" fi cd - : ${LILO_CONF:=/etc/lilo.conf} : ${GRUB_MENU_LST:=$BOOTDIR/grub/menu.lst} : ${GRUB_DEVICE_MAP:=$BOOTDIR/grub/device.map} : ${PERL:=/usr/bin/perl} : ${LILO:=/sbin/lilo} : ${DETECTLOADER:=/usr/sbin/detectloader} : ${SHARFILE:=/usr/share/loader} # check perl if [ ! -x "$PERL" ] && ! type "$PERL" >/dev/null 2>&1; then echo "$0: warning: PERL=$PERL not available; supposed to run manually..." PERL="echo $PERL" fi # modify lilo config if [ -f "$LILO_CONF" -a -x "$SHARFILE/lilo" ]; then cp -pf "$LILO_CONF" "$LILO_CONF.old" if [ -z "$REMOVE" -a -z "$MEMTEST" -a -n "$OLD_VERSION" ]; then $PERL "$SHARFILE/lilo" "$OLD_VERSION" fi $PERL "$SHARFILE/lilo" $MEMTEST $REMOVE "$VERSION" fi # modify grub config if [ -f "$GRUB_MENU_LST" -a -f "$GRUB_DEVICE_MAP" -a -x "$SHARFILE/grub" ]; then cp -pf "$GRUB_MENU_LST" "$GRUB_MENU_LST.old" if [ -z "$REMOVE" -a -z "$MEMTEST" -a -n "$OLD_VERSION" ]; then $PERL "$SHARFILE/grub" "$OLD_VERSION" fi $PERL "$SHARFILE/grub" $MEMTEST $REMOVE "$VERSION" fi # launch lilo if [ -z "$NOLAUNCH" ]; then if [ -z "$LOADER" -a -x "$DETECTLOADER" ]; then LOADER=`$PERL $DETECTLOADER -q` fi if [ "$LOADER" = LILO ]; then "$LILO" ||: fi fi exit 0 bootloader-utils-0.3.3-alt1/lilo000064400000000000000000000047311076435701000165340ustar00rootroot00000000000000#!/usr/bin/perl # $Id: lilo,v 1.4 2004/08/17 02:03:39 at Exp $ #-------------------------------------------------------------------- # Copyright (C) 2000, 2001 by MandrakeSoft. # Chmouel Boudjnah . # # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) #-------------------------------------------------------------------- # Copyright (C) 2003 by ALT Linux Team, # Alexey Tourbin . #-------------------------------------------------------------------- # description: Add/remove entry for lilo bootloader. use strict; use bootloader_utils qw(getroot); use Getopt::Long qw(GetOptions); # --nolaunch is legacy option GetOptions "n|nolaunch" => \my $nolaunch, "r|R|remove" => \my $remove, "m|memtest" => \my $memtest and (my $version = shift) and (@ARGV == 0) or die "usage: $0 [-n|--nolaunch] [-r|-R|--remove] [-m|--memtest] version\n"; sub add_memtest { local $_ = shift; /\/memtest-\Q$version.bin\E\b/ or $_ .= < @sections; } sub kernel_label { local $_ = shift; s/\.//g; s/mdk|alt//; s/secure/sec/; s/enterprise/ent/; s/vanilla/vnl/; return $_; } sub add_kernel { local $_ = shift; my $label = kernel_label($version); my $root = getroot(); /\/vmlinuz-\Q$version\E[\s"]/ or $_ .= < @sections; } { # open lilo.conf for update my $lilo_conf = $ENV{LILO_CONF} || "/etc/lilo.conf"; open my $fh, "+<", $lilo_conf or die "Cannot open $lilo_conf\n"; my $content = do { local $/ = undef; <$fh> }; # modify the content if ($memtest && $remove) { $content = remove_memtest($content); } elsif ($memtest) { $content = add_memtest($content); } elsif ($remove) { $content = remove_kernel($content); } else { $content = add_kernel($content); } # neat $content =~ s/\n{3,}/\n\n/g; # debug # print $content; # exit 0; # do the update seek $fh, 0, 0; print $fh $content; truncate $fh, tell $fh; # autoclosed } bootloader-utils-0.3.3-alt1/rebootin000064400000000000000000000047711076435701000174220ustar00rootroot00000000000000#!/usr/bin/perl #-------------------------------------------------------------------- # Copyright (C) 2000, 2001 by MandrakeSoft, # Pixel , # Chmouel Boudjnah , # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) #-------------------------------------------------------------------- # $Id: rebootin,v 1.1.1.1 2003/11/26 19:11:38 at Exp $ #-------------------------------------------------------------------- ## description: # Reboot once on a specified image for grub or lilo use strict; my $lilo_conf = "/etc/lilo.conf"; my $grub_menu = "/boot/grub/menu.lst"; my $grub_once = "/boot/grub/menu.once"; my @entries; my $bootloader = `/usr/sbin/detectloader -q` or die "Can't detect your bootloader\n";chomp $bootloader; my ($fastboot, $noreboot); while ( $ARGV[0] =~ /^-/ ) { $_ = shift; if (/^-f/) { $fastboot++; } elsif (/^-n/) { $noreboot++; } else { die "Unknow switch $_\n"; } } if ($bootloader =~ /GRUB/) { grub_conf(); } elsif ( $bootloader =~ /LILO/) { lilo_conf(); } else { die "Can't detect your bootloader\n"; } sub lilo_conf { open F, $lilo_conf or die "lilo is not installed ($lilo_conf is missing)\n"; @entries = map { /=(\S.*)/ } grep { /\s*label=\S*/ } ; @entries > 0 or die "Bad lilo.conf (no entry found)\n"; usage() unless $ARGV[0]; grep /^$ARGV[0]$/, @entries or usage(); write_fast_boot() if $fastboot; system("lilo -R @ARGV"); die "error while wanting to reboot on $ARGV[0]\n" if $?; exec "reboot" unless $noreboot; } sub grub_conf { open F, $grub_menu or die "grub is not installed ($grub_menu is missing)\n"; @entries = map { /\s(\S.*)/ } grep { /^title\s/ } my @l = ; grep { m|^altconfigfile\s.*grub/menu\.once| } @l or die "rebootin is of no use without altconfigfile\n"; @entries > 0 or die "bad menu.lst (no entry found)\n"; @ARGV == 1 or usage(); for (my $i = 0; $i < @entries; $i++) { $ARGV[0] eq $entries[$i] and set_grub($i); } print STDERR "$ARGV[0] not found\n"; usage(); # not found } sub set_grub { open F, ">$grub_once" or die "can't write rebootin file ($grub_once), verify the rights\n"; print F "default $_[0]\ntimeout 0\n"; write_fast_boot() if $fastboot; exec "reboot" unless $noreboot; } sub usage { die "usage: rebootin