From b364785ea90e60806aaaec56d15bcc70a74daf6d Mon Sep 17 00:00:00 2001 From: Antoine Ginies Date: Wed, 6 Oct 2010 07:58:18 +0000 Subject: end of the move --- BCD/Isolinux.pm | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 BCD/Isolinux.pm (limited to 'BCD/Isolinux.pm') diff --git a/BCD/Isolinux.pm b/BCD/Isolinux.pm new file mode 100644 index 0000000..41c3d97 --- /dev/null +++ b/BCD/Isolinux.pm @@ -0,0 +1,118 @@ +package BCD::Isolinux; + +use File::Copy::Recursive qw(dircopy pathrm); +use BCD::Common qw(:DEFAULT $isoconf $wd $name $arch $version $based_on $repo $builddir); + +our @ISA = qw(Exporter); +our @EXPORT = qw(main_isolinux); + +my $LOG="ISOLINUX -"; +my $color = "yellow"; + +my $repo_isolinux; +if (!defined($isoconf->{isolinux}{fullpath})) { + $repo_isolinux = "$repo/$based_on/$arch/$isoconf->{isolinux}{defaultpath}/"; +} else { + $repo_isolinux = $isoconf->{isolinux}{fullpath}; +} +my $build_isolinux_dir = "$builddir/isolinux"; + +sub switch_theme { + my $theme = $isoconf->{theme}{bootsplash}; + print_color("$LOG switch to theme $theme", $color); + -d "$isoconf->{theme}{bootsplash_path}/themes/$theme" or die "$LOG cant find the gfxboot theme: $isoconf->{theme}{bootsplash_path}/themes/$theme"; + opendir my $DIR, $build_isolinux_dir or die "$LOG FATAL switch_theme: unable to open $build_isolinux_dir\n"; + foreach my $f (readdir $DIR) { + $f =~ /^\.{1,2}$/ and next; + -d "$build_isolinux_dir/$f" or next; + opendir my $ALT, "$build_isolinux_dir/$f" or die "LOG FATAL switch_theme: unable to open $dir/$f\n"; + foreach my $all (readdir $ALT) { + $all =~ /all.rdz/ or next; + my $initrd = "$build_isolinux_dir/$f/$all"; + my $binary = "/usr/share/bootsplash/scripts/make-boot-splash-raw"; + -x $binary or die "$LOG you need $binary which is available in bootsplash >= 3.2.3\n"; + my $cmd; + if ($isoconf->{based_on} gt "2009.1") { + $cmd = "$binary $initrd $theme"; + } else { + # old script use a resolution parameter + $cmd = "$binary $initrd 800x600 $theme"; + } + print_color("$LOG using $f", $color); + system($cmd) == 0 or die "$LOG FATAL switch_theme: config file for $theme may not exist\n"; + } + closedir $ALT; + } + closedir $DIR; + # syslinux + my $lilo_sys = "$isoconf->{theme}{bootsplash_path}/themes/$theme/lilo/syslinux"; + -f $lilo_sys and system("cp -vf $lilo_sys", "$build_isolinux_dir/boot.msg"); + print_color("$LOG copy $isoconf->{theme}{gfxboot_path}/themes/*.jpg to $build_isolinux_dir/",, $color); + system("cp -vf $isoconf->{theme}{gfxboot_path}/themes/$theme/welcome.jpg $build_isolinux_dir/"); + system("cp -vf $isoconf->{theme}{gfxboot_path}/themes/$theme/back.jpg $build_isolinux_dir/"); +} + +sub add_entry { + my $syslinuxcfg = "$build_isolinux_dir/isolinux.cfg"; + -f $syslinuxcfg or die "$LOG can't path $syslinuxcfg"; + foreach my $syslinux (@{$isoconf->{isolinux}{entry}}) { + $syslinux->{name} or next; + print_color("$LOG add $syslinux->{name} in $syslinuxcfg", $color); + open my $SYS, ">> $syslinuxcfg"; + print $SYS "label $syslinux->{label}\n"; + print $SYS " kernel $syslinux->{kernel}\n"; + print $SYS " append $syslinux->{append}\n"; + close $SYS; + if (-f $syslinux->{bin}) { + system("cp -vf $syslinux->{bin} $build_isolinux_dir/"); + } else { + die "$LOG $syslinux->{bin} is not present on the system !\n"; + } + } +} + +sub use_firmware { + print_color("$LOG copy fw.gz to $build_isolinux_dir/alt0/", $color); + my $syslinuxcfg = "$build_isolinux_dir/isolinux.cfg"; + open (IN, "+<$syslinuxcfg"); + @file = ; + seek IN,0,0; + foreach (@file){ + $_ =~ s|alt0/all.rdz|alt0/all.rdz,alt0/fw.gz|g; + print IN $_; + } + close IN; + system("cp -v /usr/lib*/drakx-installer-images/isolinux/alt0/fw.gz $build_isolinux_dir/alt0/") +} + +sub copy_files { + foreach my $file (@{$isoconf->{isolinux}{tocopy}}) { + $file->{name} or next; + if (-f $file->{file}) { + print_color("$LOG copy $file->{file} in $build_isolinux_dir", $color); + system("cp -avf $file->{file} $build_isolinux_dir/"); + } else { + die "$LOG $file->{file} is not present on the system !\n"; + } + } +} + +sub main_isolinux { + if (! -d $repo_isolinux) { + print_color("$LOG I can't find the isolinux dir $repo_isolinux !", $color); + exit; + } + print_color("$LOG Remove old copy of isolinux", $color); + pathrm("$build_isolinux_dir/isolinux") or die $!; + print_color("$LOG copy $repo_isolinux to $build_isolinux_dir", $color); + dircopy($repo_isolinux, $build_isolinux_dir) or die $!; + add_entry; + if ($isoconf->{isolinux}{firmware} eq "yes") { + use_firmware; + } + copy_files; + switch_theme; +} + +1; + -- cgit v1.2.1