]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
Use syslinux bootloader to create bootable ISO images
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 13 May 2014 10:45:16 +0000 (12:45 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 13 May 2014 10:45:16 +0000 (12:45 +0200)
Previously, we used Grub 1, which was problematic, because it is not
available on modern distributions.

README.md
novaboot

index 4a6ebcbce241e498b01020246a37c1a3bc69a820..cabf0f4ae53415fb6ee0b50bbb0c56858620d077 100644 (file)
--- a/README.md
+++ b/README.md
@@ -4,11 +4,11 @@ novaboot - A tool for booting various operating systems on various hardware or i
 
 # SYNOPSIS
 
-__novaboot__ --help
+**novaboot** --help
 
-__novaboot__ \[option\]... \[--\] script...
+**novaboot** \[option\]... \[--\] script...
 
-__./script__ \[option\]...
+**./script** \[option\]...
 
 # DESCRIPTION
 
@@ -63,7 +63,7 @@ host from it. E.g.
     configurations.
 
 Note that the options needed for a specific target can be stored in a
-["CONFIGURATION FILE"](#configuration-file). Then it is sufficient to use only the __-t__
+["CONFIGURATION FILE"](#configuration-file). Then it is sufficient to use only the **-t**
 option to specify the name of the target.
 
 # PHASES AND OPTIONS
@@ -102,7 +102,7 @@ for configuration file search.
 
 - -h, --help
 
-    Print short (__-h__) or long (__--help__) help.
+    Print short (**-h**) or long (**--help**) help.
 
 - -t, --target=_target_
 
@@ -180,7 +180,7 @@ running `scons` or `make`.
 
     Generates grub bootloader menu file. If the _filename_ is not
     specified, `menu.lst` is used. The _filename_ is relative to the
-    build directory (see __--build-dir__).
+    build directory (see **--build-dir**).
 
 - --grub-preamble=_prefix_
 
@@ -194,14 +194,14 @@ running `scons` or `make`.
     `menu.lst`. The default value is the absolute path to the build directory.
 
     If the _prefix_ contains string $NAME, it will be replaced with the
-    name of the novaboot script (see also __--name__).
+    name of the novaboot script (see also **--name**).
 
 - --grub2\[=_filename_\]
 
     Generate GRUB2 menuentry in _filename_. If _filename_ is not
     specified `grub.cfg` is used. The content of the menuentry can be
-    customized with __--grub-preable__, __--grub2-prolog__ or
-    __--grub\_prefix__ options.
+    customized with **--grub-preable**, **--grub2-prolog** or
+    **--grub\_prefix** options.
 
     In order to use the the generated menuentry on your development
     machine that uses GRUB2, append the following snippet to
@@ -287,7 +287,7 @@ user/instance.
 - --stty=_settings_
 
     Specifies settings passed to `stty` invoked on the serial line
-    specified with __--serial__ option. If this option is not given,
+    specified with **--serial** option. If this option is not given,
     `stty` is called with `raw -crtscts -onlcr 115200` settings.
 
 - --remote-cmd=_cmd_
@@ -324,21 +324,21 @@ to a particular location, e.g. to a TFTP boot server or to the
 
     Generates the ISO image that boots NOVA system via GRUB. If no filename
     is given, the image is stored under _NAME_.iso, where _NAME_ is the name
-    of the novaboot script (see also __--name__).
+    of the novaboot script (see also **--name**).
 
 - --server\[=\[\[user@\]server:\]path\]
 
-    Copy all files needed for booting to another location (implies __-g__
-    unless __--grub2__ is given). The files will be copied (by __rsync__
+    Copy all files needed for booting to another location (implies **-g**
+    unless **--grub2** is given). The files will be copied (by **rsync**
     tool) to the directory _path_. If the _path_ contains string $NAME,
     it will be replaced with the name of the novaboot script (see also
-    __--name__).
+    **--name**).
 
 - --concat
 
-    If __--server__ is used and its value ends with $NAME, then after
+    If **--server** is used and its value ends with $NAME, then after
     copying the files, a new bootloader configuration file (e.g. menu.lst)
-    is created at _path-wo-name_, i.e. the path specified by __--server__
+    is created at _path-wo-name_, i.e. the path specified by **--server**
     with $NAME part removed. The content of the file is created by
     concatenating all files of the same name from all subdirectories of
     _path-wo-name_ found on the "server".
@@ -353,8 +353,8 @@ to a particular location, e.g. to a TFTP boot server or to the
 - --on, --off
 
     Switch on/off the target machine and exit. The script (if any) is
-    completely ignored. Currently it works only with __--iprelay__ or
-    __--amt__.
+    completely ignored. Currently it works only with **--iprelay** or
+    **--amt**.
 
 - -Q, --qemu\[=_qemu-binary_\]
 
@@ -400,7 +400,7 @@ interactive work with the target.
     When _string_ is sent by the target, novaboot exits. This option can
     be specified multiple times.
 
-    If _string_ is `-re`, then the next __--exiton__'s _string_ is
+    If _string_ is `-re`, then the next **--exiton**'s _string_ is
     treated as regular expression. For example:
 
         --exiton -re --exiton 'error:.*failed'
@@ -417,12 +417,12 @@ interactive work with the target.
 - --expect=_string_
 
     When _string_ is received from the target, send the string specified
-    with the subsequent __--send\*__ option to the target.
+    with the subsequent **--send\*** option to the target.
 
 - --expect-re=_regex_
 
     When target's output matches regular expression _regex_, send the
-    string specified with the subsequent __--send\*__ option to the target.
+    string specified with the subsequent **--send\*** option to the target.
 
 - --expect-raw=_perl-code_
 
@@ -431,7 +431,7 @@ interactive work with the target.
 - --send=_string_
 
     Send _string_ to the target after the previously specified
-    __--expect\*__ was matched in the target's output. The _string_ may
+    **--expect\*** was matched in the target's output. The _string_ may
     contain escape sequences such as "\\n".
 
     Note that _string_ is actually interpreted by Perl, so it can contain
@@ -442,7 +442,7 @@ interactive work with the target.
 
 - --sendcont=_string_
 
-    Similar to __--send__ but continue expecting more input.
+    Similar to **--send** but continue expecting more input.
 
     Example: `--expect='Continue?' --sendcont='yes\n'`
 
@@ -462,7 +462,7 @@ section.
 
 Lines starting with `load` keyword represent modules to boot. The
 word after `load` is a file name (relative to the build directory
-(see __--build-dir__) of the module to load and the remaining words are
+(see **--build-dir**) of the module to load and the remaining words are
 passed to it as the command line parameters.
 
 When the `load` line ends with "<<WORD" then the subsequent lines
@@ -535,14 +535,14 @@ The following variables are interpreted in the novaboot script:
 
 - QEMU
 
-    Use a specific qemu binary (can be overridden with __-Q__) and flags
+    Use a specific qemu binary (can be overridden with **-Q**) and flags
     when booting this script under qemu. If QEMU\_FLAGS variable is also
     specified flags specified in QEMU variable are replaced by those in
     QEMU\_FLAGS.
 
 - QEMU\_FLAGS
 
-    Use specific qemu flags (can be overridden with __-q__).
+    Use specific qemu flags (can be overridden with **-q**).
 
 - WVDESC
 
@@ -560,10 +560,10 @@ The following variables are interpreted in the novaboot script:
 Novaboot can read its configuration from one or more files. By
 default, novaboot looks for files named `.novaboot` as described in
 ["Configuration reading phase"](#configuration-reading-phase). Alternatively, its location can be
-specified with the __-c__ switch or with the NOVABOOT\_CONFIG
+specified with the **-c** switch or with the NOVABOOT\_CONFIG
 environment variable. The configuration file has perl syntax and
 should set values of certain Perl variables. The current configuration
-can be dumped with the __--dump-config__ switch. Some configuration
+can be dumped with the **--dump-config** switch. Some configuration
 variables can be overridden by environment variables (see below) or by
 command line switches.
 
@@ -577,11 +577,11 @@ Supported configuration variables include:
 - $default\_target
 
     Default target (see below) to use when no target is explicitly
-    specified on command line with the __--target__ option.
+    specified on command line with the **--target** option.
 
 - %targets
 
-    Hash of shortcuts to be used with the __--target__ option. If the hash
+    Hash of shortcuts to be used with the **--target** option. If the hash
     contains, for instance, the following pair of values
 
         'mybox' => '--server=boot:/tftproot --serial=/dev/ttyUSB0 --grub',
@@ -605,7 +605,7 @@ override the environment variables.
 
 - NOVABOOT\_BENDER
 
-    Defining this variable has the same meaning as __--bender__ option.
+    Defining this variable has the same meaning as **--bender** option.
 
 # AUTHORS
 
index ddb2192d592d68b06ee5f73afe27ee576dc70a10..f932d35a77d2759d0b4a06f81bac58e01e9668d7 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -377,6 +377,29 @@ sub generate_grub_config($$$$;$)
     return $filename;
 }
 
+sub generate_syslinux_config($$$$)
+{
+    my ($filename, $title, $base, $modules_ref) = @_;
+    if ($base && $base !~ /\/$/) { $base = "$base/"; };
+    open(my $fg, '>', $filename) or die "$filename: $!";
+    print $fg "LABEL $title\n";
+    #TODO print $fg "MENU LABEL $human_readable_title\n";
+    print $fg "KERNEL mboot.c32\n";
+
+    my @append;
+    foreach (@$modules_ref) {
+       s|\brom://([^ ]*)|$rom_prefix$base$1|g; # Translate rom:// files - needed for vdisk parameter of sigma0
+       push @append, "$base$_";
+    }
+    print $fg "APPEND ".join(' --- ', @append)."\n";
+    #TODO print $fg "TEXT HELP\n";
+    #TODO print $fg "some help here\n";
+    #TODO print $fg "ENDTEXT\n";
+    close($fg);
+    print("novaboot: Created $builddir/$filename\n");
+    return $filename;
+}
+
 sub generate_grub2_config($$$$;$$)
 {
     my ($filename, $title, $base, $modules_ref, $preamble, $prolog) = @_;
@@ -745,7 +768,7 @@ foreach my $script (@scripts) {
     if (defined $iso_image) {
        generate_configs("(cd)", $generated, $filename);
        my $menu;
-       generate_grub_config(\$menu, $config_name, "(cd)", $modules);
+       generate_syslinux_config(\$menu, $config_name, "/", $modules);
        $menu_iso .= "$menu\n";
        map { ($file,undef) = split; $files_iso{$file} = 1; } @$modules;
     }
@@ -753,12 +776,26 @@ foreach my $script (@scripts) {
 
 ## Generate ISO image
 if (defined $iso_image) {
-    open(my $fh, ">menu-iso.lst");
-    print $fh "timeout 5\n\n$menu_iso";
+    system_verbose("mkdir -p isolinux");
+    system_verbose('cp /usr/lib/syslinux/isolinux.bin /usr/lib/syslinux/mboot.c32 /usr/lib/syslinux/menu.c32 isolinux');
+    open(my $fh, ">isolinux/isolinux.cfg");
+    if ($#scripts) {
+       print $fh "TIMEOUT 50\n";
+       print $fh "DEFAULT menu\n";
+    } else {
+       print $fh "DEFAULT $config_name\n";
+    }
+    print $fh "$menu_iso";
     close($fh);
-    my $files = "boot/grub/menu.lst=menu-iso.lst " . join(" ", map("$_=$_", keys(%files_iso)));
+
+    my $files = join(" ", map("$_=$_", (keys(%files_iso), 'isolinux/isolinux.bin', 'isolinux/isolinux.cfg', 'isolinux/mboot.c32', 'isolinux/menu.c32')));
     $iso_image ||= "$config_name.iso";
-    system_verbose("$CFG::genisoimage -R -b stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -hide-rr-moved -J -joliet-long -o $iso_image -graft-points bin/boot/grub/ $files");
+
+    # Note: We use -U flag below to "Allow 'untranslated' filenames,
+    # completely violating the ISO9660 standards". Without this
+    # option, isolinux is not able to read files names for example
+    # bzImage-3.0.
+    system_verbose("$CFG::genisoimage -R -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -hide-rr-moved -U -o $iso_image -graft-points $files");
     print("ISO image created: $builddir/$iso_image\n");
 }