diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-06-29 04:54:42 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-06-29 04:54:42 +0000 |
commit | c535eabfd26a1927fc87adb9250e277e19a66c3c (patch) | |
tree | 8ce547511eaa626bcf81cea1fc76a6bcb8d6df7a /scripts | |
parent | 74e685503f350d91b3a7f72cc56c2d6b0e73fe52 (diff) | |
download | bootsplash-c535eabfd26a1927fc87adb9250e277e19a66c3c.tar bootsplash-c535eabfd26a1927fc87adb9250e277e19a66c3c.tar.gz bootsplash-c535eabfd26a1927fc87adb9250e277e19a66c3c.tar.bz2 bootsplash-c535eabfd26a1927fc87adb9250e277e19a66c3c.tar.xz bootsplash-c535eabfd26a1927fc87adb9250e277e19a66c3c.zip |
- add scripts/remove-boot-splash so we can modify a bootsplash
from an initrd without having to rebuild it
- make-boot-splash doesn't try to detect the resolution anymore,
it now needs to be given one
- in switch-themes and remove-theme, use bootloader-config to update the bootloader
- remove detect-resolution
- requires new mkinitrd (old mkinitrd used detect-resolution)
- remove "Patch: glibc-fixed-header.tar.bz2" which is unused (and not in CVS)
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile | 2 | ||||
-rwxr-xr-x | scripts/detect-resolution | 143 | ||||
-rwxr-xr-x | scripts/make-boot-splash | 18 | ||||
-rw-r--r-- | scripts/remove-boot-splash | 34 | ||||
-rw-r--r-- | scripts/remove-theme | 15 | ||||
-rwxr-xr-x | scripts/switch-themes | 15 |
6 files changed, 47 insertions, 180 deletions
diff --git a/scripts/Makefile b/scripts/Makefile index c82b9db..6b46046 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1,4 +1,4 @@ -PL=detect-resolution +PL=remove-boot-splash SH=make-boot-splash rewritejpeg switch-themes remove-theme SBIN=splash.sh SYS=bootsplash.sysconfig diff --git a/scripts/detect-resolution b/scripts/detect-resolution deleted file mode 100755 index 3021f95..0000000 --- a/scripts/detect-resolution +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/perl -# -*- Mode: cperl -*- -# Copyright (C) 2002 by Chmouel Boudjnah <chmouel@mandrakesoft.com> -# Redistribution of this file is permitted under the terms of the GNU -# Public License (GPL) -# -# Detect vga resolution we want. -# -# add better detection thanks to Olivier Blin idea to use argument from -# make_boot_splash. - -use strict; -my (%main, %entry, $vga, $initrd); - -if ($ARGV[0]) { - $initrd = -l $ARGV[0] ? readlink($ARGV[0]) : $ARGV[0]; - $initrd =~ s,.*/,, -} else { - $vga = detect_from_cmdline(cat_('/proc/cmdline')); - undef $vga if $vga =~ /x/; #lilo cmdline can't convert -} - -detect_from_loader() if !$vga; -if ($vga) { - chomp $vga; - $vga =~ s/vga=//; - $vga = convert_vgamode(); -} -print $vga, "\n" if $vga; - -sub detect_from_cmdline {return (grep /vga=\d+/, split("[ \t]", shift))[0];} -sub detect_from_loader { - my $loader = `detectloader -q`;chomp $loader; - if ($loader =~ m/lilo/i ) { - parse_lilo_conf(); - } elsif ($loader =~ /grub/i ) { - parse_grub_conf(); - } - if ($initrd) { - $vga = $main{initrd}{$initrd} - } - $vga ||= $entry{$main{default}}{vga}; - $vga ||= $main{vga} -} -sub parse_grub_conf { - my ($title); - my $cnt = 0; - my $grub_conf = "/boot/grub/menu.lst"; - my $vga; - return if not -f $grub_conf; - open F, $grub_conf or die "Can't open $grub_conf\n"; - - while (<F>) { - next if /^\s*#/; - $main{default} = $1 if /^default (\d+)/; - if (/^title\s+(.*)/) { - $vga=0; - $title=$1; - $entry{$title}{cnt} = $cnt; - $main{default} = $title if $entry{$title}{cnt} eq $main{default}; - $cnt++; - } - if (m/kernel\s+\(.*\)[^\s]+/) { - $vga = $1 if /vga=(\w*)/; - $entry{$title}{vga} = $vga if ($title and $vga); - } - if (m,initrd\s+\(.*\)(?:.*/)?([^\s]+),){ - #- TODO: support links - $entry{$title}{initrd} = $1; - $main{initrd}{$1} = $entry{$title}{vga} - } - } - close F; -} - -sub parse_lilo_conf { - my $lilo_conf="/etc/lilo.conf"; - my ($vga, $label, $loc_initrd); - return if not -f $lilo_conf; - open F, $lilo_conf or die "Can't open $lilo_conf\n"; - while (<F>) { - next if /^\s*#/; - $main{default} = remove_quotes($1) if m/^default=(.*)/; - $main{vga} = $1 if m/^vga=(.*)/; - $vga = $1 if /vga=(.*)/; - $label = remove_quotes($1) if /label=(.*)/; - if (/initrd=(.*)/) { - $loc_initrd = -l $1 ? readlink($1) : $1; - $loc_initrd =~ s,.*/,,; - } - $entry{$label}{vga} = $vga if ($label && $vga); - if (/image/) { - if ($loc_initrd && $label && $vga) { - $entry{$label}{initrd} = $loc_initrd; - if (!$main{initrd}{$loc_initrd} || $main{default} eq $label) { - $main{initrd}{$loc_initrd} = $vga - } - } - undef $vga,$label; - } - } - if ($loc_initrd && $label && $vga) { - $entry{$label}{initrd} = $loc_initrd; - if (!$main{initrd}{$loc_initrd} || $main{default} eq $label) { - $main{initrd}{$loc_initrd} = $vga - } - } - close F; -} - -sub convert_vgamode { - my $v; - #From drakx Xconfigurator_consts.pm - my %vgamodes = ( - '640x480x8' => [ '769', '0x301' ], - '800x600x8' => [ '771', '0x303' ], - '1024x768x8' => [ '773', '0x305' ], - '1280x1024x8' => [ '775', '0x307' ], - '1600x1200x8' => [ '777', '0x309' ], - '640x480x15' => [ '784', '0x310' ], - '800x600x15' => [ '787', '0x313' ], - '1024x768x15' => [ '790', '0x316' ], - '1280x1024x15' => [ '793', '0x319' ], - '1600x1200x15' => [ '796', '0x31C' ], - '640x480x16' => [ '785', '0x311' ], - '800x600x16' => [ '788', '0x314' ], - '1024x768x16' => [ '791', '0x317' ], - '1280x1024x16' => [ '794', '0x31A' ], - '1600x1200x16' => [ '797', '0x31D' ], - #- '640xx24' => 786, #- there is a problem with these resolutions since the BIOS may take 24 or 32 planes. - #- '640x480x24' => 786, - #- '800xx24' => 789, - #- '800x600x24' => 789, - #- '1024xx24' => 792, - #- '1024x768x24' => 792, - #- '1280xx24' => 795, - #- '1280x1024x24' => 795, - ); - foreach my $k (keys %vgamodes) { $v = $k if grep { $_ eq $vga } @{$vgamodes{$k}} } - undef $vga if not $v;return $v; -} -sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; my @l = <F>; wantarray ? @l : join '', @l } -sub remove_quotes { local $_ = $_[0]; s/^"(.*)"$/$1/g; s/\\"/"/g; $_ } diff --git a/scripts/make-boot-splash b/scripts/make-boot-splash index ea22423..8cd83e8 100755 --- a/scripts/make-boot-splash +++ b/scripts/make-boot-splash @@ -11,19 +11,11 @@ [[ -f /etc/sysconfig/bootsplash ]] && source /etc/sysconfig/bootsplash [[ -z $THEME ]] && THEME=Mandrake -initrd_file=$1 - -[[ -z $initrd_file ]] && { - echo "You need to specify a initrd file as argument" - exit 1; -} +[ $# = 2 ] || { echo "usage: $0 <initrd> <resolution>"; exit 1; } +initrd_file=$1 vgamode=$2 -if [[ -z $vgamode || $vgamode == auto ]];then - vgamode=$( $splash_dir/scripts/detect-resolution $initrd_file) -fi - if [[ $vgamode == 640* ]];then resolution=640x480 elif [[ $vgamode == 800* ]];then @@ -34,6 +26,10 @@ elif [[ $vgamode == 1280* ]];then resolution=1280x1024 elif [[ $vgamode == 1600* ]];then resolution=1600x1200 +else + echo "unknown resolution \"$vgamode\"" + [ "$vgamode" = "auto" ] && echo 'resolution "auto" is not handled anymore' + exit 1 fi if [[ -f $splash_cfg/themes/$THEME/config/bootsplash-$resolution.cfg ]];then @@ -49,6 +45,8 @@ if [[ -z $config ]];then exit 1; fi +$splash_dir/scripts/remove-splash $initrd_file + if [[ -x /sbin/splash ]]; then /sbin/splash -s -f $config >> $initrd_file fi diff --git a/scripts/remove-boot-splash b/scripts/remove-boot-splash new file mode 100644 index 0000000..e63c3b5 --- /dev/null +++ b/scripts/remove-boot-splash @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +@ARGV == 1 or die "usage: remove-splash <initrd>\n"; + +my $magic = 'BOOTSPL3'; +my $buffer_size = 15; + +my ($initrd) = @ARGV; +open(my $F, "+< $initrd") or die "can't open $initrd: $!\n"; + +while (1) { + my $got = read($F, my $buffer, $buffer_size); + $got > length($magic) or last; + + my $index = index($buffer, $magic); + if ($index >= 0) { + my $offset = $index + tell($F) - $got; + + seek($F, $offset + 12, 0) && read($F, my $tmp, 4) or last; + my $splash_size = unpack("V", $tmp) + 38; + + my $initrd_size = seek($F, 0, 2) && tell($F); + + if ($offset + $splash_size == $initrd_size) { + truncate($F, $offset); + exit 0; + } else { + warn "bootsplash found at offset $offset, but it is not at the end ($offset + $splash_size != $initrd_size)\n"; + } + } + seek($F, -length($magic), 1); # handle the case BOOTSPL3 when overlaps between buffers +} + +warn "bootsplash not found in $initrd\n"; diff --git a/scripts/remove-theme b/scripts/remove-theme index f7b8dde..97b4a05 100644 --- a/scripts/remove-theme +++ b/scripts/remove-theme @@ -31,20 +31,9 @@ function remove_theme () { } function update_boot () { - pushd /boot &> /dev/null - if [[ -x /usr/share/loader/make-initrd ]]; then - /usr/share/loader/make-initrd -n &> /dev/null - if [[ -x /usr/sbin/detectloader ]]; then - LOADER=$(/usr/sbin/detectloader -q) - if [[ $LOADER = "LILO" ]] && [[ -x /sbin/lilo ]];then - /sbin/lilo >/dev/null 2>/dev/null - fi - if [[ $LOADER = "YABOOT" ]] && [[ -x /sbin/ybin ]];then - /sbin/ybin >/dev/null 2>/dev/null - fi - fi + if [[ -x /usr/bin/bootloader-config ]]; then + /usr/bin/bootloader-config --action remove-splash --kernel-version $(uname -r) fi - popd &> /dev/null } function usage () { diff --git a/scripts/switch-themes b/scripts/switch-themes index 7101954..22676e4 100755 --- a/scripts/switch-themes +++ b/scripts/switch-themes @@ -109,20 +109,9 @@ function switch_theme () { } function update_boot () { - pushd /boot &> /dev/null - if [[ -x /usr/share/loader/make-initrd ]]; then - /usr/share/loader/make-initrd -n &> /dev/null - if [[ -x /usr/sbin/detectloader ]]; then - LOADER=$(/usr/sbin/detectloader -q) - if [[ $LOADER = "LILO" ]] && [[ -x /sbin/lilo ]];then - /sbin/lilo >/dev/null 2>/dev/null - fi - if [[ $LOADER = "YABOOT" ]] && [[ -x /sbin/ybin ]];then - /sbin/ybin >/dev/null 2>/dev/null - fi - fi + if [[ -x /usr/bin/bootloader-config ]]; then + /usr/bin/bootloader-config --action update-splash --kernel-version $(uname -r) fi - popd &> /dev/null } function usage () { |