summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/MGA/DrakISO/BuildBoot.pm61
-rwxr-xr-xlib/MGA/DrakISO/BuildISO.pm70
-rw-r--r--lib/MGA/DrakISO/Config.pm12
-rw-r--r--lib/MGA/DrakISO/ISOBuild.pm5
-rw-r--r--lib/MGA/DrakISO/LiveBuild.pm7
-rw-r--r--lib/MGA/DrakISO/Media.pm7
-rw-r--r--lib/MGA/DrakISO/Storage.pm1
7 files changed, 100 insertions, 63 deletions
diff --git a/lib/MGA/DrakISO/BuildBoot.pm b/lib/MGA/DrakISO/BuildBoot.pm
index 2038538..bfa6042 100755
--- a/lib/MGA/DrakISO/BuildBoot.pm
+++ b/lib/MGA/DrakISO/BuildBoot.pm
@@ -159,7 +159,7 @@ sub prepare_iso_bootloader {
build_grub2_eltorito_img($grub2_dir . '/eltorito.img');
}
- my $label = $build->{media}->get_media_label;
+ my $label = $build->{media}{label};
# If the user has supplied a top-level grub2 configuration file, copy that
# (replacing the "VOLUME_LABEL" template with the actual label for the ISO
@@ -175,12 +175,13 @@ sub prepare_iso_bootloader {
}
my $title = $build->{media}{bootloader_title} // $label =~ s/-/ /gr;
+ my $mode = $build->{settings}{arch} eq 'x86_64' ? '64-bit' : '32-bit';
# If we have a theme, replace the menu title with the name of the ISO
# (extracted from the disk label).
my $base_theme_txt = $grub2_dir . "/themes/$theme_name/theme.txt";
if (-e $base_theme_txt) {
- run_('sed', '-i', qq(s/title-text:.*/title-text: "$title"/), $base_theme_txt);
+ run_('sed', '-i', qq(s/title-text:.*/title-text: "$title ($mode)"/), $base_theme_txt);
}
# If we are building a 32-bit ISO, we are done, as we don't support
@@ -230,8 +231,9 @@ sub prepare_iso_bootloader {
sub build_grub2_eltorito_img {
my ($output) = @_;
- my @modules = qw(biosdisk iso9660 fat part_msdos all_video font png gfxterm gfxmenu linux
- keylayouts at_keyboard usb_keyboard configfile echo gettext ls search test);
+ my @modules = qw(biosdisk iso9660 fat part_msdos all_video font png gfxterm gfxmenu
+ keylayouts at_keyboard usb_keyboard configfile echo gettext
+ linux linux16 ls search test);
run_('grub2-mkimage',
'--output', $output,
@@ -244,8 +246,9 @@ sub build_grub2_eltorito_img {
sub build_grub2_bootx64_efi {
my ($output) = @_;
- my @modules = qw(iso9660 fat part_msdos all_video font png gfxterm gfxmenu linux
- keylayouts at_keyboard usb_keyboard configfile echo gettext ls search test);
+ my @modules = qw(iso9660 fat part_msdos all_video font png gfxterm gfxmenu
+ keylayouts at_keyboard usb_keyboard configfile echo gettext
+ linux linux16 ls search test);
run_('grub2-mkimage',
'--output', $output,
@@ -267,7 +270,7 @@ sub build_grub2_cfg {
join("\n",
"if [ -z \$initialised ] ; then",
- " search --no-floppy --set=root -l '" . $build->{media}->get_media_label . "'",
+ " search --no-floppy --set=root -l '" . $build->{media}{label} . "'",
" set prefix=(\$root)/boot/grub2",
"",
" if loadfont \$prefix/fonts/unicode.pf2 ; then",
@@ -302,12 +305,27 @@ sub build_grub2_cfg {
"",
),
(map {
- my ($name, $cmdline) = @$_;
+ my ($name, $options) = @$_;
+ my $command = $options->{command} // 'linux';
+ my $image = $options->{image} // get_default_image($build, $name);
+ my $initrd = $options->{initrd} // get_default_initrd($build);
+ my $append = $options->{append};
+
+ my $initrd_command = $command eq 'linux16 ' ? 'initrd16' : 'initrd';
+
join("\n",
+ if_($command eq 'linux16',
+ "if [ x\$uefi != 'xtrue' ] ; then", # UEFI doesn't support 16-bit
+ ),
"menuentry $gettext\"$name\" {",
- " linux /boot/vmlinuz " . get_default_append($build) . if_($cmdline, " $cmdline"),
- " initrd /boot/initrd.gz",
- "}"
+ " $command $image " . join(' ', get_default_append($build), $append),
+ if_($initrd,
+ " $initrd_command $initrd",
+ ),
+ "}",
+ if_($command eq 'linux16',
+ "fi",
+ ),
);
} group_by2(@{$build->{media}{bootloader_entries}})),
if_($add_lang_menu || $add_kbd_menu,
@@ -340,15 +358,24 @@ sub get_bootloader_timeout {
defined $build->{media}{bootloader_timeout} ? $build->{media}{bootloader_timeout} : 4;
}
+sub get_default_image {
+ my ($build, $name) = @_;
+ -e ($build->get_builddir('boot') . '/vmlinuz') && '/boot/vmlinuz'
+ or die "ERROR: no boot image found for '$name' boot entry\n";
+}
+
+sub get_default_initrd {
+ my ($build) = @_;
+ -e ($build->get_builddir('boot') . '/initrd,gz') && '/boot/initrd.gz' ||
+ -e ($build->get_builddir('boot') . '/all.rdz') && '/boot/all.rdz';
+}
+
sub get_default_append {
my ($build) = @_;
- my $append = $build->{system}{append};
join(" ",
- "root=mgalive:LABEL=" . $build->{media}->get_media_label,
"lang=\$lang kbd=\$kbd",
- if_($append, $append),
- if_($build->{system}{vga_mode} && $append !~ /\bvga=\b/,
- "vga=" . $build->{system}{vga_mode}),
+ if_($build->{system}{append}, $build->{system}{append}),
+ if_($build->{system}{vga_mode}, "vga=" . $build->{system}{vga_mode}),
);
}
@@ -407,7 +434,7 @@ sub build_kbd_menu_cfg {
sub build_uefi_grub2_cfg {
my ($build) = @_;
join("\n",
- "search --no-floppy --set=root -l '" . $build->{media}->get_media_label . "'",
+ "search --no-floppy --set=root -l '" . $build->{media}{label} . "'",
"set prefix=(\$root)/boot/grub2",
"",
"set uefi=true",
diff --git a/lib/MGA/DrakISO/BuildISO.pm b/lib/MGA/DrakISO/BuildISO.pm
index eb28c6c..a3b7851 100755
--- a/lib/MGA/DrakISO/BuildISO.pm
+++ b/lib/MGA/DrakISO/BuildISO.pm
@@ -17,6 +17,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# SYNOPSIS
+# --------
+# This module provides a function to build the ISO image. All the files
+# to go on the ISO should be stored in or linked into the build directory
+# before performing this step.
+
package MGA::DrakISO::BuildISO;
use strict;
@@ -24,7 +30,7 @@ use strict;
use MDK::Common;
use common;
-use MGA::DrakISO::LiveBuild;
+use MGA::DrakISO::ISOBuild;
use MGA::DrakISO::Loopback;
use MGA::DrakISO::Utils;
@@ -32,16 +38,17 @@ use MGA::DrakISO::BuildLoop;
use Exporter;
our @ISA = qw(Exporter);
-our @EXPORT = qw(build_live_iso);
-
-###############################################################################
-# Live System
-###############################################################################
+our @EXPORT = qw(build_iso);
-sub build_live_iso {
+sub build_iso {
my ($build) = @_;
- my $label = $build->{media}->get_media_label or die "the source device must be described by a label\n";
+ my $arch = $build->{settings}{arch};
+ my $label = $build->{media}{label};
+
+ my $arch_dir = $build->get_builddir($arch);
+ my $dosutils = $build->get_builddir('dosutils');
+ my $loopbacks = $build->get_builddir('loopbacks');
my $mbr_image = $build->get_absolute_path($build->{media}{mbr_boot_img}) // '/usr/lib/grub/i386-pc/boot_hybrid.img';
-e $mbr_image or die "cannot find MBR boot image $mbr_image\n";
@@ -62,9 +69,15 @@ sub build_live_iso {
if_($build->{settings}{arch} eq 'x86_64',
'/EFI=' . $build->get_builddir('EFI'),
),
- (
+ if_(-d $dosutils,
+ "dosutils=" . $dosutils,
+ ),
+ if_(-d $arch_dir,
+ "$arch=" . $arch_dir,
+ ),
+ if_(-d $loopbacks,
map {
- '/loopbacks' . $_ . '=' . $build->get_builddir('loopbacks') . $_;
+ '/loopbacks' . $_ . '=' . $loopbacks . $_;
} list_selected_loopbacks($build)
),
if_($build->{media}{files},
@@ -83,10 +96,6 @@ sub list_selected_loopbacks {
(map { '/modules/' . $_->{name} . $loop_types{$_->{type}}{extension} } @pack_modules);
}
-###############################################################################
-# Generic
-###############################################################################
-
# This builds a hybrid ISO capable of both legacy and UEFI boot. The
# ISO contains a primary iso9660 partition (which is the only thing
# visible when booting from DVD) and a secondary ESP partition (which
@@ -109,9 +118,15 @@ sub list_selected_loopbacks {
sub build_iso_image {
my ($build, $dest, $label, $mbr_image, $esp_image, @opts) = @_;
+ my $dir = dirname($dest);
+
+ my $date_file = $dir . '/DATE.txt';
+ run_('date', '>', $date_file);
+
run_('xorrisofs',
'-pad', '-l', '-R', '-J',
'-V', $label,
+ '-follow-links',
'-graft-points',
'-hide-rr-moved',
'--sort-weight', 0, '/',
@@ -133,24 +148,21 @@ sub build_iso_image {
'-iso_mbr_part_type', '0x00',
'-append_partition', 2, '0xef', $esp_image,
),
- if_($dest, '-o', $dest),
+ '-o', $dest,
@opts,
+ '/DATE.txt=' . $date_file,
) or die "unable to run xorrisofs\n";
- if ($dest) {
- my $dir = dirname($dest);
- my $filename = basename($dest);
- run_('mgaiso-addmd5', '>', '/dev/null', '2>', '/dev/null', $dest);
- run_({ chdir => $dir }, 'md5sum', '>', $dest . '.md5', $filename);
- run_({ chdir => $dir }, 'sha1sum', '>', $dest . '.sha1', $filename);
- run_({ chdir => $dir }, 'sha512sum', '>', $dest . '.sha512', $filename);
- run_({ chdir => $dir }, 'date', '>', $dir . '/DATE.txt');
- if (my $suffix = $build->get_set_suffix) {
- if (my ($prefix, $ext) = $dest =~ /(.*)(\.[^.]+)$/) {
- my $link = $prefix . $suffix . $ext;
- linkf($dest, $link);
- print "linked as $link\n";
- }
+ my $filename = basename($dest);
+ run_('mgaiso-addmd5', '>', '/dev/null', '2>', '/dev/null', $dest);
+ run_({ chdir => $dir }, 'md5sum', '>', $dest . '.md5', $filename);
+ run_({ chdir => $dir }, 'sha1sum', '>', $dest . '.sha1', $filename);
+ run_({ chdir => $dir }, 'sha512sum', '>', $dest . '.sha512', $filename);
+ if (my $suffix = $build->get_set_suffix) {
+ if (my ($prefix, $ext) = $dest =~ /(.*)(\.[^.]+)$/) {
+ my $link = $prefix . $suffix . $ext;
+ linkf($dest, $link);
+ print "linked as $link\n";
}
}
}
diff --git a/lib/MGA/DrakISO/Config.pm b/lib/MGA/DrakISO/Config.pm
index f3cb706..2d7de1f 100644
--- a/lib/MGA/DrakISO/Config.pm
+++ b/lib/MGA/DrakISO/Config.pm
@@ -42,14 +42,14 @@ sub read_config {
if ($config_path && -e getcwd() . '/' . $config_path) {
$config_root = getcwd();
}
- print "using $config_root as directory root\n";
+ print "Using $config_root as directory root\n";
add2hash($build->{settings} ||= {}, { getVarsFromSh($config_root . '/' . $settings_path) }) if $settings_path;
if ($config_path) {
#- don't use do(), since it can't see lexicals in the enclosing scope
my $cfg = eval(cat_($config_root . '/' . $config_path)) or die "unable to load $config_path: $@\n";
put_in_hash($build, $cfg);
- print "loaded $config_path as config file\n";
+ print "Loaded $config_path as config file\n";
}
$build->{settings}{config_root} = $config_root;
}
@@ -61,8 +61,12 @@ sub check_config {
Pod::Usage::pod2usage();
}
#- check for minimum requirements
- ref $build->{media} && $build->{media}{storage} or die "no media storage definition\n";
- ref $build->{system} or die "no system definition\n";
+ $build->{settings}{arch}
+ or die "ERROR: you must specify an architecture\n";
+ ref $build->{media} && $build->{media}{storage}
+ or die "ERROR: you must specify the media storage type.\n";
+ $build->{media}{label}
+ or die "ERROR: you must supply a media label\n";
}
sub complete_config {
diff --git a/lib/MGA/DrakISO/ISOBuild.pm b/lib/MGA/DrakISO/ISOBuild.pm
index 16fa36e..2f4bce9 100644
--- a/lib/MGA/DrakISO/ISOBuild.pm
+++ b/lib/MGA/DrakISO/ISOBuild.pm
@@ -52,6 +52,11 @@ sub get_builddir {
$build->{settings}{builddir} . '/' . $build->get_name . $build->get_set_suffix . if_($o_subdir, '/' . $o_subdir);
}
+sub get_system_root {
+ my ($build) = @_;
+ $build->{settings}{chroot} . '/' . $build->get_name . $build->get_set_suffix;
+}
+
sub get_absolute_path {
my ($build, $path) = @_;
if (defined $path && substr($path, 0, 1) ne '/') {
diff --git a/lib/MGA/DrakISO/LiveBuild.pm b/lib/MGA/DrakISO/LiveBuild.pm
index 67561d2..7a0c006 100644
--- a/lib/MGA/DrakISO/LiveBuild.pm
+++ b/lib/MGA/DrakISO/LiveBuild.pm
@@ -41,7 +41,7 @@ sub new {
sub default_name_fields {
my ($build) = @_;
- [ qw(name version product desktop),
+ [ qw(distro version product desktop),
if_($build->{settings}{region} ne 'all', $build->{settings}{region}),
qw(arch media)
];
@@ -55,11 +55,6 @@ sub get_langs {
);
}
-sub get_system_root {
- my ($build) = @_;
- $build->{settings}{chroot} . '/' . $build->get_name . $build->get_set_suffix;
-}
-
sub find_kernel {
my ($build) = @_;
require bootloader;
diff --git a/lib/MGA/DrakISO/Media.pm b/lib/MGA/DrakISO/Media.pm
index f821a6c..41fa3d5 100644
--- a/lib/MGA/DrakISO/Media.pm
+++ b/lib/MGA/DrakISO/Media.pm
@@ -37,7 +37,7 @@ sub new {
foreach my $mntpoint (qw(/ OEM_RESCUE)) {
my $part = find { $_->{mntpoint} eq $mntpoint } @{$media->{partitions}};
$part->{fs_type} ||= $media->get_media_setting('fs');
- if (my $label = $mntpoint eq '/' && $media->get_media_label) {
+ if (my $label = $mntpoint eq '/' && $media->{label}) {
$part->{device_LABEL} ||= $label;
}
}
@@ -58,9 +58,4 @@ sub get_media_setting {
$media->{$setting} || $media->get_storage_setting($setting);
}
-sub get_media_label {
- my ($media) = @_;
- first($media->get_media_setting('source') =~ /^LABEL=(.*)$/);
-}
-
1;
diff --git a/lib/MGA/DrakISO/Storage.pm b/lib/MGA/DrakISO/Storage.pm
index 34f7c4a..8c08862 100644
--- a/lib/MGA/DrakISO/Storage.pm
+++ b/lib/MGA/DrakISO/Storage.pm
@@ -25,7 +25,6 @@ our %storage_types = (
iso => {
fs => 'iso9660',
read_only => 1,
- source => 'LABEL=MGAISOROOT',
},
);