From 50546c463b7c66d124095e0fa0a46db49574692a Mon Sep 17 00:00:00 2001 From: Steffen Winterfeldt Date: Wed, 8 Jul 2009 12:02:59 +0200 Subject: - improved gfxtest script; removed old test script - added --version option to gfxboot --- 2hl | 74 --------- Changelog | 2 + Makefile | 7 +- bin/2hl | 74 +++++++++ doc/gfxboot.8 | 20 ++- gfxboot | 170 +++++++++++++++++++-- gfxtest | 181 +++------------------- test/cdrom/gfxtest.config | 15 +- test/grub/gfxtest.config | 13 ++ test/lilo/gfxtest.config | 13 ++ test/syslinux/gfxtest.config | 15 ++ tst | 356 ------------------------------------------- 12 files changed, 338 insertions(+), 602 deletions(-) delete mode 100755 2hl create mode 100755 bin/2hl create mode 100644 test/syslinux/gfxtest.config delete mode 100755 tst diff --git a/2hl b/2hl deleted file mode 100755 index d6f65c4..0000000 --- a/2hl +++ /dev/null @@ -1,74 +0,0 @@ -#! /usr/bin/perl - -# replace identical files with hard links - -use Getopt::Long; -use File::stat; - -$md5_0 = "d41d8cd98f00b204e9800998ecf8427e"; - -$opt_link = 0; -$opt_quiet = 0; - -GetOptions( - link => \$opt_link, - quiet => \$opt_quiet, -); - -for $dir (@ARGV) { - for (`find '$dir' -type f -print0 | xargs -0r md5sum`) { - chomp; - if(/^(\S+) (.*)/) { - $m = $1; - $f = $2; - push @{$md5{$m}}, $f; - } - } -} - -$total_size = 0; -$empty_files = 0; - -for $m (sort keys %md5) { - if(@{$md5{$m}} > 1) { - $size = 0; - $cnt = 0; - undef %ino; - undef @buf; - for $f (@{$md5{$m}}) { - $sb = stat $f; - die "oops: stat failed on \"$f\"\n" unless defined $sb; - $size = $sb->size; - $cnt++ unless $ino{$sb->ino}; - $ino{$sb->ino} = 1; - push @buf, sprintf(" %04o %04d:%04d %5d %6d \"%s\"\n", - $sb->mode & 07777, $sb->uid, $sb->gid, $sb->ino, $sb->size, $f); - } - if(!$opt_quiet) { - printf "%s: %d (%d)\n", $m, ($cnt - 1) * $size, $cnt - 1; - print @buf; - } - - $total_size += ($cnt - 1) * $size; - - if($opt_link && $m ne $md5_0) { - $ref = undef; - for $f (@{$md5{$m}}) { - if($ref) { - unlink $f; - link $ref, $f; - } - else { - $ref = $f; - } - } - } - } -} - -$empty_files = @{$md5{$md5_0}}; - -print "\n" unless $opt_quiet; -printf "total saved size: %d\n", $total_size; -printf " empty files: %d\n", $empty_files; - diff --git a/Changelog b/Changelog index 33b280e..82d0df1 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,8 @@ - allow empty menus - added new gfxtest script - support qemu-kvm + - improved gfxtest script; removed old test script + - added --version option to gfxboot 8/4/2009: v4.1.21 - Ilyas Bakirov: added Kirghiz support diff --git a/Makefile b/Makefile index a7d8c0b..c292850 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ -ARCH := $(shell uname -m) +ARCH := $(shell uname -m) +GFXBOOT_VERSION := $(shell cat VERSION) CC = gcc CFLAGS = -g -Wall -Wno-pointer-sign -O2 -fomit-frame-pointer @@ -42,7 +43,9 @@ jpeg.o: jpeg.S install: all install -d -m 755 $(DESTDIR)/usr/sbin - install -m 755 gfxboot gfxboot-compile gfxboot-font $(DESTDIR)/usr/sbin + perl -p -e 's//$(GFXBOOT_VERSION)/' gfxboot >gfxboot~ + install -m 755 gfxboot~ $(DESTDIR)/usr/sbin/gfxboot + install -m 755 gfxboot-compile gfxboot-font $(DESTDIR)/usr/sbin @for i in $(THEMES) ; do \ install -d -m 755 $(DESTDIR)/etc/bootsplash/$$i/{bootloader,cdrom} ; \ cp $$i/bootlogo $(DESTDIR)/etc/bootsplash/$$i/cdrom ; \ diff --git a/bin/2hl b/bin/2hl new file mode 100755 index 0000000..d6f65c4 --- /dev/null +++ b/bin/2hl @@ -0,0 +1,74 @@ +#! /usr/bin/perl + +# replace identical files with hard links + +use Getopt::Long; +use File::stat; + +$md5_0 = "d41d8cd98f00b204e9800998ecf8427e"; + +$opt_link = 0; +$opt_quiet = 0; + +GetOptions( + link => \$opt_link, + quiet => \$opt_quiet, +); + +for $dir (@ARGV) { + for (`find '$dir' -type f -print0 | xargs -0r md5sum`) { + chomp; + if(/^(\S+) (.*)/) { + $m = $1; + $f = $2; + push @{$md5{$m}}, $f; + } + } +} + +$total_size = 0; +$empty_files = 0; + +for $m (sort keys %md5) { + if(@{$md5{$m}} > 1) { + $size = 0; + $cnt = 0; + undef %ino; + undef @buf; + for $f (@{$md5{$m}}) { + $sb = stat $f; + die "oops: stat failed on \"$f\"\n" unless defined $sb; + $size = $sb->size; + $cnt++ unless $ino{$sb->ino}; + $ino{$sb->ino} = 1; + push @buf, sprintf(" %04o %04d:%04d %5d %6d \"%s\"\n", + $sb->mode & 07777, $sb->uid, $sb->gid, $sb->ino, $sb->size, $f); + } + if(!$opt_quiet) { + printf "%s: %d (%d)\n", $m, ($cnt - 1) * $size, $cnt - 1; + print @buf; + } + + $total_size += ($cnt - 1) * $size; + + if($opt_link && $m ne $md5_0) { + $ref = undef; + for $f (@{$md5{$m}}) { + if($ref) { + unlink $f; + link $ref, $f; + } + else { + $ref = $f; + } + } + } + } +} + +$empty_files = @{$md5{$md5_0}}; + +print "\n" unless $opt_quiet; +printf "total saved size: %d\n", $total_size; +printf " empty files: %d\n", $empty_files; + diff --git a/doc/gfxboot.8 b/doc/gfxboot.8 index 10de696..d4dba07 100644 --- a/doc/gfxboot.8 +++ b/doc/gfxboot.8 @@ -26,6 +26,9 @@ Increase verbosity. \fB--save-temp\fR Keep temporary files. .TP +\fB--version\fR +Show gfxboot version. +.TP \fB--help\fR Print usage. .SS Switching themes @@ -89,8 +92,14 @@ Use isolinux from DIRECTORY or RPM (default is /). \fB--password\fR \fIPASSWORD\fR Create test config with PASSWORD for preview. .TP +\fB--32\fR +Create 32 bit test image. +.TP +\fB--64\fR +Create 64 bit test image. +.TP \fB--biarch\fR -Create biarch test image. +Create biarch test image (same as using --32 and --64). .TP \fB--cdrom\fR, \fB--dvd\fR Create iso image for preview. @@ -103,6 +112,12 @@ Create floppy image for preview. .TP \fB--save-image\fR \fIFILE\fR Copy preview image to FILE. +.TP +\fB--test-add-files\fR \fIFILE1\fR \fIFILE2\fR ... +Add files to test directory. +.TP +\fB--test-rm-files\fR \fIFILE1\fR \fIFILE2\fR ... +Delete files from test directory. .SS Adding/removing files from gfxboot archive .TP \fB--ls\fR, \fB--list-files\fR @@ -111,6 +126,9 @@ List gfxboot archive files. \fB--add-files\fR \fIFILE1\fR \fIFILE2\fR ... Add files to gfxboot archive. .TP +\fB--rm-files\fR \fIFILE1\fR \fIFILE2\fR ... +Delete files from gfxboot archive. +.TP \fB--extract-files\fR \fIFILE1\fR \fIFILE2\fR ... Copy files from gfxboot archive to current working directory. .TP diff --git a/gfxboot b/gfxboot index aa669c6..2d0de12 100755 --- a/gfxboot +++ b/gfxboot @@ -872,6 +872,7 @@ sub fake_menu; sub prepare_grub; sub prepare_lilo; sub prepare_isolinux; +sub prepare_syslinux; sub prepare_qemu; sub run_qemu; sub prepare_vbox; @@ -925,6 +926,8 @@ my $opt_test = 0; my $opt_ls = 0; my @opt_addfiles; my @opt_rmfiles; +my @opt_test_addfiles; +my @opt_test_rmfiles; my @opt_extractfiles; my $opt_showfile; my $opt_theme; @@ -935,7 +938,8 @@ my $opt_defaultlanguage; my $opt_gfxboot_cfg; my $opt_expand_archive; my $opt_pack_archive; -my $opt_biarch; +my $opt_32; +my $opt_64; my $opt_media; my $opt_save_image; my $opt_help_create; @@ -983,6 +987,7 @@ usage 0 if !@ARGV; GetOptions( 'help' => sub { usage 0 }, + 'version' => sub { print "\n" ; exit 0 }, 'archive|a=s' => \$opt_gfxarchive, 'config-file=s' => \$opt_gfxboot_cfg, 'verbose|v+' => \$opt_verbose, @@ -1003,6 +1008,8 @@ GetOptions( 'list-files|ls' => \$opt_ls, 'add-files=s{1,}' => \@opt_addfiles, 'rm-files=s{1,}' => \@opt_rmfiles, + 'test-add-files=s{1,}' => \@opt_test_addfiles, + 'test-rm-files=s{1,}' => \@opt_test_rmfiles, 'extract-files=s{1,}' => \@opt_extractfiles, 'show-file=s' => \$opt_showfile, 'new-theme=s' => sub { $opt_theme = $_[1]; $opt_theme_update = 0 }, @@ -1015,7 +1022,9 @@ GetOptions( 'cdrom|dvd' => sub { $opt_media = 'cdrom' }, 'disk' => sub { $opt_media = 'disk' }, 'floppy' => sub { $opt_media = 'floppy' }, - 'biarch' => \$opt_biarch, + 'biarch' => sub { $opt_32 = $opt_64 = 1 }, + '32' => \$opt_32, + '64' => \$opt_64, 'save-image=s' => \$opt_save_image, 'help-create=s' => \$opt_help_create, 'help-show=s' => \$opt_help_show, @@ -1233,6 +1242,7 @@ General options: (see --expand-archive option below). -v, --verbose Increase verbosity. --save-temp Keep temporary files. + --version Show gfxboot version. --help Write this help text. Switching themes: @@ -1275,17 +1285,25 @@ Preview/test gfxboot setup: --syslinux DIRECTORY|RPM Use syslinux from DIRECTORY or RPM (default is /). --isolinux DIRECTORY|RPM Use isolinux from DIRECTORY or RPM (default is /). --password PASSWORD Create test config with PASSWORD for preview. - --biarch Create biarch test image. + --32 Create 32 bit test image. + --64 Create 64 bit test image. + --biarch Create biarch test image (same as using --32 and --64). --cdrom, --dvd Create iso image for preview. --disk Create harddisk image for preview. --floppy Create floppy image for preview. --save-image FILE Copy preview image to FILE. + --test-add-files FILE1 FILE2 ... + Add files to test directory. + --test-rm-files FILE1 FILE2 ... + Delete files from test directory. Adding/removing files from gfxboot archive: --ls, --list-files List gfxboot archive files. --add-files FILE1 FILE2 ... Add files to gfxboot archive. + --rm-files FILE1 FILE2 ... + Delete files from gfxboot archive. --extract-files FILE1 FILE2 ... Copy files from gfxboot archive to current working directory. @@ -1371,6 +1389,11 @@ sub preview $vm_env->{boot} = 'cd'; $preview_image = $vm_env->{cd0}{image_name}; } + elsif($bootloader eq 'syslinux') { + $vm_env->{hd0} = prepare_syslinux $file; + $vm_env->{boot} = 'hd'; + $preview_image = $vm_env->{hd0}{image_name}; + } else { return; } @@ -1555,6 +1578,15 @@ sub prepare_grub } close F; + for (@opt_test_addfiles) { + system "cp $_ $dst/boot" and die "error copying file: $_\n"; + } + + for (@opt_test_rmfiles) { + s#^/+##; + system "cd $dst/boot ; rm -f $_" and die "error deleting file: $_\n"; + } + my $img_size = `du -s --apparent-size --block-size 1k $dst 2>/dev/null`; $img_size = $img_size =~ /^(\d+)/ ? $1 * 2 + 2 * 200 : 0; # add 200k @@ -1664,6 +1696,15 @@ sub prepare_lilo } close F; + for (@opt_test_addfiles) { + system "cp $_ $dst/boot" and die "error copying file: $_\n"; + } + + for (@opt_test_rmfiles) { + s#^/+##; + system "cd $dst/boot ; rm -f $_" and die "error deleting file: $_\n"; + } + my $msg_size = `du -s --apparent-size --block-size 1k $dst/boot/message 2>/dev/null`; $msg_size = $msg_size =~ /^(\d+)/ ? $1 * 2 : 0; my $img_size = `du -s --apparent-size --block-size 1k $dst 2>/dev/null`; @@ -1700,6 +1741,7 @@ sub prepare_isolinux local $_; my $file = shift; my $cdimage; + my $arch_dir; die "Can't setup isolinux on $opt_media.\n" if $opt_media && $opt_media ne 'cdrom'; @@ -1707,6 +1749,9 @@ sub prepare_isolinux die "error: isolinux not found\n" unless -f "$opt_syslinux/$bl_list{isolinux}"; + $arch_dir = 'i386'; + $arch_dir = 'x86_64' if $opt_64 && !$opt_32; + my $menu = fake_menu 'install'; if($opt_verbose) { @@ -1719,16 +1764,16 @@ sub prepare_isolinux my $loader = ""; if(-x "$opt_syslinux/usr/bin/isolinux-config") { - $loader = "boot/i386/loader/"; + $loader = "boot/$arch_dir/loader/"; mkdir "$dst/boot", 0755; - mkdir "$dst/boot/i386", 0755; - mkdir "$dst/boot/i386/loader", 0755; + mkdir "$dst/boot/$arch_dir", 0755; + mkdir "$dst/boot/$arch_dir/loader", 0755; } system "cp $opt_syslinux/usr/share/syslinux/isolinux.bin $dst/$loader" and die "error: no isolinux\n"; if($loader ne "") { - system "isolinux-config --base=/boot/i386/loader $dst/${loader}isolinux.bin" . + system "isolinux-config --base=/boot/$arch_dir/loader $dst/${loader}isolinux.bin" . ($opt_verbose ? "" : " >/dev/null"); } @@ -1762,7 +1807,7 @@ sub prepare_isolinux print F " kernel memtest\n\n"; } else { - print F " kernel linux\n append initrd=initrd splash=silent showopts\n\n"; + print F " kernel linux\n append initrd=initrd splash=silent showopts\n\n"; } } @@ -1776,7 +1821,16 @@ sub prepare_isolinux close F; } - if($opt_biarch) { + for (@opt_test_addfiles) { + system "cp $_ $dst/${loader}" and die "error copying file: $_\n"; + } + + for (@opt_test_rmfiles) { + s#^/+##; + system "cd $dst/${loader} ; rm -f $_" and die "error deleting file: $_\n"; + } + + if($opt_32 && $opt_64) { symlink "i386", "$dst/boot/x86_64" if -d "$dst/boot/i386"; } @@ -1791,6 +1845,104 @@ sub prepare_isolinux } +sub prepare_syslinux +{ + local $_; + my $file = shift; + + die "Can't setup syslinux on $opt_media.\n" if $opt_media && $opt_media ne 'disk'; + + $opt_syslinux = unpack_rpm $opt_syslinux if -f $opt_syslinux; + + die "error: isolinux not found\n" unless -f "$opt_syslinux/$bl_list{syslinux}"; + + my $menu = fake_menu 'install'; + + if($opt_verbose) { + print "menu items (default $menu->{default}):\n"; + print " $_\n" for (@{$menu->{list}}); + } + + my $dst = $gfxboot_tmp->dir('syslinux'); + my $img = $gfxboot_tmp->file('syslinux.img'); + + my $bl_unpacked; + ( $bl_unpacked ) = unpack_archive $file; + my $bl_packed = pack_archive $bl_unpacked, 'bootlogo'; + + system "cp -a $bl_packed/* $dst"; + + system "cp /boot/vmlinuz $dst/linux" if -f "/boot/vmlinuz"; + system "cp /boot/initrd $dst/initrd" if -f "/boot/initrd"; + + if(! -f "$dst/message") { + open F, ">$dst/message"; + print F "\x0cgfxboot didn't work? Try one of those:\n"; + print F " $_\n" for (@{$menu->{list}}); + print F "\n"; + close F; + } + + if(! -f "$dst/syslinux.cfg") { + open F, ">$dst/syslinux.cfg"; + print F "default $menu->{list}[$menu->{default}]\n\n"; + + for (@{$menu->{list}}) { + print F "label $_\n"; + if($_ eq 'harddisk') { + print F " localboot 0x80\n\n"; + } + elsif($_ eq 'memtest' && -f("$dst/memtest")) { + print F " kernel memtest\n\n"; + } + else { + print F " kernel linux\n append initrd=initrd splash=silent showopts\n\n"; + } + } + + print F + "implicit 1\n" . + "gfxboot bootlogo\n" . + "display message\n" . + "prompt 1\n" . + "timeout 600\n"; + + close F; + } + + for (@opt_test_addfiles) { + system "cp $_ $dst" and die "error copying file: $_\n"; + } + + for (@opt_test_rmfiles) { + s#^/+##; + system "cd $dst ; rm -f $_" and die "error deleting file: $_\n"; + } + + my $img_size = `du -s --apparent-size --block-size 1k $dst 2>/dev/null`; + $img_size = $img_size =~ /^(\d+)/ ? $1 * 2 + 2 * 200 : 0; # add 200k + + my $hdimage = HDImage::new; + $hdimage->verbose($opt_verbose); + $hdimage->chs(0, 4, 16); + $hdimage->size($img_size); + $hdimage->type(1); + $hdimage->label('GFXBOOT'); + $hdimage->fs('fat'); + $hdimage->mbr('/usr/lib/boot/master-boot-code'); + $hdimage->add_files(<$dst/*>); + $hdimage->write($img); + + my $log = $gfxboot_tmp->file('syslinux.log'); + + system "$opt_syslinux/$bl_list{syslinux} -o " . $hdimage->partition_ofs * 512 . " $img >$log 2>&1"; + + print `cat $log`, "\n" if $opt_verbose >= 2; + + return $hdimage; +} + + sub prepare_qemu { } diff --git a/gfxtest b/gfxtest index 766182c..9f185d0 100755 --- a/gfxtest +++ b/gfxtest @@ -15,184 +15,45 @@ function switch_disk { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function gfxtest_cdrom { +function gfxtest_isolinux { set -f - ./gfxboot --test --preview --archive $opt_archive -b isolinux --cdrom $gfxboot_args $gfxboot_x_args + ./gfxboot -b isolinux --cdrom \ + --test --preview --archive $opt_archive $gfxboot_args \ + --test-add-files $add_files --test-rm-files gfxtest.config $rm_files $gfxboot_x_args set +f } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function gfxtest_grub { +function gfxtest_syslinux { set -f - ./gfxboot --test --preview --archive $opt_archive -b grub $gfxboot_args $gfxboot_x_args + ./gfxboot -b syslinux \ + --test --preview --archive $opt_archive $gfxboot_args \ + --test-add-files $add_files --test-rm-files gfxtest.config $rm_files $gfxboot_x_args set +f } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function gfxtest_lilo { +function gfxtest_grub { set -f - ./gfxboot --test --preview --archive $opt_archive -b lilo $gfxboot_args $gfxboot_x_args + ./gfxboot -b grub \ + --test --preview --archive $opt_archive $gfxboot_args \ + --test-add-files $add_files --test-rm-files gfxtest.config $rm_files $gfxboot_x_args set +f } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function tst_lilo { - bin="test/lilo.rpm" - src="test/$1" - dst="$tmp/$1" - img="$tmp/$1.img" - vm_src=test/vm - vm_tmp=tmp/$1.vm - - rm -rf $dst $vm_tmp - rm -f $img - - mkdir -p $dst/boot - cp -a $src/* $dst/boot - cp -a $logo $dst/boot/message - - for i in /boot/vmlinuz /boot/initrd ; do - [ -f $i ] && cp --parents $i $dst - done - - test/hdimg $img - - sw 0 mount -oloop=/dev/loop7,offset=32256 $img /mnt - sw 0 cp -r $dst/* /mnt - sw 0 losetup /dev/loop6 $img - sw 0 $bin/sbin/lilo -w -C /mnt/boot/lilo.conf -m /mnt/boot/map - sw 0 losetup -d /dev/loop6 - sw 0 umount /mnt - - if [ "$program" = vmware ] ; then - # vmware - cp -a $vm_src $vm_tmp - perl -pi -e "s/^\s*#\s*(ide1:0.startConnected)/\$1/" $vm_tmp/gfxboot.vmx - perl -pi -e "s::`pwd`/$img:g" $vm_tmp/gfxboot.vmx - vmware -qx $vm_tmp/gfxboot.vmx - elif [ "$program" = qemu ] ; then - # qemu - $qemu -boot c -hda $img - elif [ "$program" = bd ] ; then - # bochs debug wrapper - bd $img - elif [ "$program" = bochs ] ; then - # bochs - bochs -q 'boot: a' "floppya: image=$img, status=inserted" 'log: /dev/null' 'ata0-master: type=disk, path=/dev/null' 'parport1: enabled=0' - else - echo -e "\n*** Error: $program not supported ***\n" - fi -} - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function tst_grub { - bin="test/grub.rpm" - src="test/$1" - dst="$tmp/$1" - img="$tmp/$1.img" - vm_src=test/vm - vm_tmp=tmp/$1.vm - - rm -rf $dst $vm_tmp - rm -f $img - - mkdir -p $dst/boot - cp -a $src/* $dst/boot - cp $bin/usr/lib/grub/{fat_stage1_5,stage1,stage2} $dst/boot/grub - cp -a $logo $dst/boot/message - for i in /boot/vmlinuz /boot/initrd ; do - [ -f $i ] && cp --parents $i $dst - done - - sh -c "echo '(hd0) $img' >$dst/boot/grub/device.map" - - test/hdimg $img - - sw 0 mount -oloop,offset=32256 "$img" /mnt - sw 0 cp -r $dst/* /mnt - sw 0 umount /mnt - - echo "setup --prefix=/boot/grub (hd0,0) (hd0,0)" | \ - $bin/usr/sbin/grub --batch --config-file=$dst/boot/grub/menu.lst --device-map=$dst/boot/grub/device.map - echo - - if [ "$program" = vmware ] ; then - # vmware - #cp -a $vm_src $vm_tmp - #perl -pi -e "s/^\s*#\s*(ide1:0.startConnected)/\$1/" $vm_tmp/gfxboot.vmx - #perl -pi -e "s::`pwd`/$img:g" $vm_tmp/gfxboot.vmx - #vmplayer $vm_tmp/gfxboot.vmx - vm --vm vmplayer --disk $img - elif [ "$program" = qemu ] ; then - # qemu - $qemu -boot c -hda $img - elif [ "$program" = bd ] ; then - # bochs debug wrapper - bd $img - elif [ "$program" = bochs ] ; then - # bochs - bochs -q 'boot: a' "floppya: image=$img, status=inserted" 'log: /dev/null' 'ata0-master: type=disk, path=/dev/null' 'parport1: enabled=0' - else - echo -e "\n*** Error: $program not supported \n" - fi -} - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function tst_syslinux { - bin="test/syslinux.rpm" - src="test/$1" - dst="$tmp/$1" - img="$tmp/$1.img" - vm_src=test/vm - vm_tmp=tmp/$1.vm - syslx=$bin/usr/bin/syslinux-nomtools - - rm -rf $dst $vm_tmp - rm -f $img* - - mkdir -p $dst - cp -a $src/* $dst - cp -a $logo $dst/bootlogo - - rm -f $dst/*~ - bin/unpack_bootlogo $dst - - sw 0 test/mkbootdisk --syslinux=$syslx --out=${img}_ $dst - - sw 0 chown --reference=tmp $img* - - cp $dst.img_01 $img - - if [ "$program" = vmware ] ; then - # vmware - cp -a $vm_src $vm_tmp - perl -pi -e "s/^\s*#\s*(ide1:0.startConnected)/\$1/" $vm_tmp/gfxboot.vmx - perl -pi -e "s::`pwd`/$img:g" $vm_tmp/gfxboot.vmx - vmware -qx $vm_tmp/gfxboot.vmx - elif [ "$program" = qemu ] ; then - # qemu - $qemu -boot a -fda $img - elif [ "$program" = bd ] ; then - # bochs debug wrapper - bd $img - elif [ "$program" = bochs ] ; then - # bochs - bochs -q 'boot: a' "floppya: image=$img, status=inserted" 'log: /dev/null' 'ata0-master: type=disk, path=/dev/null' 'parport1: enabled=0' - else - echo -e "\n*** Error: $program not supported ***\n" - fi +function gfxtest_lilo { + set -f + ./gfxboot -b lilo \ + --test --preview --archive $opt_archive $gfxboot_args \ + --test-add-files $add_files --test-rm-files gfxtest.config $rm_files $gfxboot_x_args + set +f } - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function usage { @@ -254,8 +115,6 @@ case "$1" in *) what="$1" ; shift ;; esac -gfxboot_x_args="$@" - if [ ! -d "$test_dir/$what" ] ; then echo "config directory missing: $what" exit 1 @@ -263,6 +122,8 @@ else [ -f "$test_dir/$what/gfxtest.config" ] && . "$test_dir/$what/gfxtest.config" fi +gfxboot_x_args="$args $@" + opt_theme=${opt_theme:-openSUSE} if [ ! -d "themes/$opt_theme" ] ; then echo "no such theme: $opt_theme" @@ -277,6 +138,8 @@ case "$opt_type" in *) echo "unsupported type: $opt_type" ; exit 1 ;; esac +add_files=`echo $test_dir/$what/*` + [ -x gfxboot-compile ] || { echo "error: gfxboot-compile missing. Run 'make' first." exit 2 diff --git a/test/cdrom/gfxtest.config b/test/cdrom/gfxtest.config index 931cfe5..2590441 100644 --- a/test/cdrom/gfxtest.config +++ b/test/cdrom/gfxtest.config @@ -1,2 +1,15 @@ +# all files in this directory ex this config file are added +# to the bootloader directory + +# archive file name in theme directory archive=bootlogo -setup=cdrom + +# setup function name in 'gfxtest' script +setup=isolinux + +# list of files to remove in bootloader directory +rm_files="" + +# additional 'gfxboot' args +args="" + diff --git a/test/grub/gfxtest.config b/test/grub/gfxtest.config index 76d6c0d..639f8af 100644 --- a/test/grub/gfxtest.config +++ b/test/grub/gfxtest.config @@ -1,2 +1,15 @@ +# all files in this directory ex this config file are added +# to the bootloader directory + +# archive file name in theme directory archive=message + +# setup function name in 'gfxtest' script setup=grub + +# list of files to remove in bootloader directory +rm_files="" + +# additional 'gfxboot' args +args="" + diff --git a/test/lilo/gfxtest.config b/test/lilo/gfxtest.config index dd51439..e03ab6e 100644 --- a/test/lilo/gfxtest.config +++ b/test/lilo/gfxtest.config @@ -1,2 +1,15 @@ +# all files in this directory ex this config file are added +# to the bootloader directory + +# archive file name in theme directory archive=message + +# setup function name in 'gfxtest' script setup=lilo + +# list of files to remove in bootloader directory +rm_files="" + +# additional 'gfxboot' args +args="" + diff --git a/test/syslinux/gfxtest.config b/test/syslinux/gfxtest.config new file mode 100644 index 0000000..6b0aafc --- /dev/null +++ b/test/syslinux/gfxtest.config @@ -0,0 +1,15 @@ +# all files in this directory ex this config file are added +# to the bootloader directory + +# archive file name in theme directory +archive=bootlogo + +# setup function name in 'gfxtest' script +setup=syslinux + +# list of files to remove in bootloader directory +rm_files="" + +# additional 'gfxboot' args +args="" + diff --git a/tst b/tst deleted file mode 100755 index a7da2d8..0000000 --- a/tst +++ /dev/null @@ -1,356 +0,0 @@ -#! /bin/sh - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function switch_disk { - disk=$1 - tmp=tmp - - if [ -z "$disk" -o ! -f "$tmp/syslinux.img_$disk" ] ; then - echo "usage:" - echo " tst -d disk_number" - exit 1 - fi - - dd if="$tmp/syslinux.img_$disk" of="$tmp/syslinux.img" conv=notrunc status=noxfer -} - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function tst_isolinux { - bin="test/syslinux.rpm" - src="test/$1" - dst="$tmp/$1" - img="$tmp/$1.iso" - vm_src=test/vm - vm_tmp=tmp/$1.vm - isolx=$bin/usr/share/syslinux/isolinux.bin - - rm -rf $dst $vm_tmp - rm -f $img - - isodir32=boot/i386/loader - isodir64=boot/x86_64/loader - mkdir -p $dst/$isodir32 $dst/$isodir64 - cp $isolx $dst/$isodir32/isolinux.bin - cp $isolx $dst/$isodir64/isolinux.bin - test/syslinux.rpm/usr/bin/isolinux-config --base=$isodir32 $dst/$isodir32/isolinux.bin - test/syslinux.rpm/usr/bin/isolinux-config --base=$isodir64 $dst/$isodir64/isolinux.bin - - cp -a $src/* $dst/$isodir32 - rm -f $dst/$isodir32/{linux,initrd}64 - cp -a $logo $dst/$isodir32/bootlogo - bin/unpack_bootlogo $dst/$isodir32 - - cp -a $src/* $dst/$isodir64 - [ -f $dst/$isodir64/linux64 ] && mv $dst/$isodir64/linux64 $dst/$isodir64/linux - [ -f $dst/$isodir64/initrd64 ] && mv $dst/$isodir64/initrd64 $dst/$isodir64/initrd - cp -a $logo $dst/$isodir64/bootlogo - bin/unpack_bootlogo $dst/$isodir64 - - test/2hl --link --quiet $dst - - echo "$dst/$isodir32/isolinux.bin 1" >$tmp/cd_sort - echo "$dst/$isodir64/isolinux.bin 1" >>$tmp/cd_sort - - rm -f `find $dst/boot -name \*~` - - # rm -r $dst/boot/x86_64 - - mkisofs -o $img -J -r -sort $tmp/cd_sort \ - -b $isodir32/isolinux.bin -c $isodir32/boot.catalog \ - -publisher "Tester" \ - -no-emul-boot -boot-load-size 4 -boot-info-table $dst - - tagmedia --check --md5 $img - - rm -f $tmp/cd_sort - - if [ "$program" = vmware ] ; then - # vmware - cp -a $vm_src $vm_tmp - perl -pi -e "s/^\s*#\s*(floppy0.startConnected)/\$1/" $vm_tmp/gfxboot.vmx - perl -pi -e "s::`pwd`/$img:g" $vm_tmp/gfxboot.vmx - vmplayer $vm_tmp/gfxboot.vmx - elif [ "$program" = qemu ] ; then - # qemu - $qemu -cdrom $img -serial pty - elif [ "$program" = bd ] ; then - # bochs debug wrapper - bd $img - elif [ "$program" = bochs ] ; then - # bochs - bochs -q 'boot: cdrom' "ata0-master: type=cdrom, path=$img, status=inserted" 'log: /dev/null' 'parport1: enabled=0' - else - echo -e "\n*** Error: $program not supported ***\n" - fi -} - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function tst_lilo { - bin="test/lilo.rpm" - src="test/$1" - dst="$tmp/$1" - img="$tmp/$1.img" - vm_src=test/vm - vm_tmp=tmp/$1.vm - - rm -rf $dst $vm_tmp - rm -f $img - - mkdir -p $dst/boot - cp -a $src/* $dst/boot - cp -a $logo $dst/boot/message - - for i in /boot/vmlinuz /boot/initrd ; do - [ -f $i ] && cp --parents $i $dst - done - - test/hdimg $img - - sw 0 mount -oloop=/dev/loop7,offset=32256 $img /mnt - sw 0 cp -r $dst/* /mnt - sw 0 losetup /dev/loop6 $img - sw 0 $bin/sbin/lilo -w -C /mnt/boot/lilo.conf -m /mnt/boot/map - sw 0 losetup -d /dev/loop6 - sw 0 umount /mnt - - if [ "$program" = vmware ] ; then - # vmware - cp -a $vm_src $vm_tmp - perl -pi -e "s/^\s*#\s*(ide1:0.startConnected)/\$1/" $vm_tmp/gfxboot.vmx - perl -pi -e "s::`pwd`/$img:g" $vm_tmp/gfxboot.vmx - vmware -qx $vm_tmp/gfxboot.vmx - elif [ "$program" = qemu ] ; then - # qemu - $qemu -boot c -hda $img - elif [ "$program" = bd ] ; then - # bochs debug wrapper - bd $img - elif [ "$program" = bochs ] ; then - # bochs - bochs -q 'boot: a' "floppya: image=$img, status=inserted" 'log: /dev/null' 'ata0-master: type=disk, path=/dev/null' 'parport1: enabled=0' - else - echo -e "\n*** Error: $program not supported ***\n" - fi -} - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function tst_grub { - bin="test/grub.rpm" - src="test/$1" - dst="$tmp/$1" - img="$tmp/$1.img" - vm_src=test/vm - vm_tmp=tmp/$1.vm - - rm -rf $dst $vm_tmp - rm -f $img - - mkdir -p $dst/boot - cp -a $src/* $dst/boot - cp $bin/usr/lib/grub/{fat_stage1_5,stage1,stage2} $dst/boot/grub - cp -a $logo $dst/boot/message - for i in /boot/vmlinuz /boot/initrd ; do - [ -f $i ] && cp --parents $i $dst - done - - sh -c "echo '(hd0) $img' >$dst/boot/grub/device.map" - - test/hdimg $img - - sw 0 mount -oloop,offset=32256 "$img" /mnt - sw 0 cp -r $dst/* /mnt - sw 0 umount /mnt - - echo "setup --prefix=/boot/grub (hd0,0) (hd0,0)" | \ - $bin/usr/sbin/grub --batch --config-file=$dst/boot/grub/menu.lst --device-map=$dst/boot/grub/device.map - echo - - if [ "$program" = vmware ] ; then - # vmware - #cp -a $vm_src $vm_tmp - #perl -pi -e "s/^\s*#\s*(ide1:0.startConnected)/\$1/" $vm_tmp/gfxboot.vmx - #perl -pi -e "s::`pwd`/$img:g" $vm_tmp/gfxboot.vmx - #vmplayer $vm_tmp/gfxboot.vmx - vm --vm vmplayer --disk $img - elif [ "$program" = qemu ] ; then - # qemu - $qemu -boot c -hda $img - elif [ "$program" = bd ] ; then - # bochs debug wrapper - bd $img - elif [ "$program" = bochs ] ; then - # bochs - bochs -q 'boot: a' "floppya: image=$img, status=inserted" 'log: /dev/null' 'ata0-master: type=disk, path=/dev/null' 'parport1: enabled=0' - else - echo -e "\n*** Error: $program not supported \n" - fi -} - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function tst_syslinux { - bin="test/syslinux.rpm" - src="test/$1" - dst="$tmp/$1" - img="$tmp/$1.img" - vm_src=test/vm - vm_tmp=tmp/$1.vm - syslx=$bin/usr/bin/syslinux-nomtools - - rm -rf $dst $vm_tmp - rm -f $img* - - mkdir -p $dst - cp -a $src/* $dst - cp -a $logo $dst/bootlogo - - rm -f $dst/*~ - bin/unpack_bootlogo $dst - - sw 0 test/mkbootdisk --syslinux=$syslx --out=${img}_ $dst - - sw 0 chown --reference=tmp $img* - - cp $dst.img_01 $img - - if [ "$program" = vmware ] ; then - # vmware - cp -a $vm_src $vm_tmp - perl -pi -e "s/^\s*#\s*(ide1:0.startConnected)/\$1/" $vm_tmp/gfxboot.vmx - perl -pi -e "s::`pwd`/$img:g" $vm_tmp/gfxboot.vmx - vmware -qx $vm_tmp/gfxboot.vmx - elif [ "$program" = qemu ] ; then - # qemu - $qemu -boot a -fda $img - elif [ "$program" = bd ] ; then - # bochs debug wrapper - bd $img - elif [ "$program" = bochs ] ; then - # bochs - bochs -q 'boot: a' "floppya: image=$img, status=inserted" 'log: /dev/null' 'ata0-master: type=disk, path=/dev/null' 'parport1: enabled=0' - else - echo -e "\n*** Error: $program not supported ***\n" - fi -} - - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function usage { - echo "usage: tst [-b] [-d floppy_nr] [-i] [-l language] [-p program] [-s test_src_dir] [-t theme] what" - exit 1 -} - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -qemu=qemu - -while getopts bd:hil:p:s:t:x opt ; do - case $opt in - \:|\?|h) usage - ;; - - b) logo=boot - ;; - - d) disk=$OPTARG - ;; - - i) logo=install - ;; - - l) lang="DEFAULT_LANG=$OPTARG" - ;; - - p) program=$OPTARG - ;; - - s) src=$OPTARG - ;; - - t) theme=$OPTARG - ;; - - x) qemu=qemu-system-x86_64 - ;; - esac -done -shift $(($OPTIND - 1)) - -if [ "$disk" ] ; then - switch_disk $disk - exit -fi - -theme=${theme:-openSUSE} - -program=${program:-qemu} - -what=$1 -what=${what:-cdrom} - -[ "$what" = cdrom ] && what=isolinux -[ "$what" = cd ] && what=isolinux -[ "$what" = floppy ] && what=syslinux - -if [ ! "$logo" ] ; then - logo=boot - [ "$what" = syslinux -o "$what" = isolinux ] && logo=install -fi - -[ "$logo" = "boot" ] && logo="themes/$theme/message" -[ "$logo" = "install" ] && logo="themes/$theme/bootlogo" - -[ "$BOOTLOGO" ] && logo=$BOOTLOGO - -[ -x gfxboot-compile ] || { - echo "error: gfxboot-compile missing. Try make." - exit 2 -} - -if [ ! "$what" ] ; then - echo "What is "\""$what"\""?" - usage -fi - -# make BINDIR=../../ -C themes/$theme prep -make -C themes/$theme $lang || exit - -[ -f "$logo" ] || logo="themes/$theme/bootlogo" - -if [ ! -f "$logo" ] ; then - echo "no such file: $logo" - usage -fi - -tmp=tmp -mkdir -p "$tmp" || exit - -if [ -z "$src" ] ; then - src=$what - [ $what = isolinux ] && src=syslinux -fi - -if [ ! -d test/$src ] ; then - echo "no such directory: $src" - usage -fi - -if [ "`type -t tst_$what`" = function ] ; then - tst_$what $src -else - echo "What is "\""$what"\""?" - usage -fi - -- cgit v1.2.3