From 644614346eda5b55c382737daee991c04742fab7 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Sun, 19 Jan 2014 14:51:03 +0100 Subject: [PATCH] Move implementation of --chainloader and --bender to where it is documented i.e. Script preprocessing phase. Also move --strip-rom documentation to section "File generation phase", because it is implemented there. --- README.md | 26 +++++++++--------- novaboot | 68 +++++++++++++++++++++++------------------------ tests/Makefile | 2 +- tests/novaboot.wv | 11 -------- tests/parser.wv | 19 +++++++++++++ 5 files changed, 66 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 5162ba3..823474f 100644 --- a/README.md +++ b/README.md @@ -131,9 +131,9 @@ used in the later phases. - \--dump - Print the modules to boot and their parameters. This happens after - parsing the novaboot script, i.e. after evaluating all _\--scriptmod_ - expressions etc. Exit after reading (and dumping) the script. + Print the modules to boot and their parameters after this phase + finishes. Then exit. This is useful for seeing the effect of other + options in this section. - \-k, --kernel=`file` @@ -152,19 +152,14 @@ used in the later phases. is given multiple times all expressions are evaluated in the command line order. -- \--strip-rom - - Strip _rom://_ prefix from command lines and generated config files. - The _rom://_ prefix is used by NUL. For NRE, it has to be stripped. - ## File generation phase In this phase, files needed for booting are generated in a so called -_build directory_ (see TODO). In most cases configuration for a -bootloader is generated automatically by novaboot. It is also possible -to generate other files using _heredoc_ or _"<"_ syntax in novaboot -scripts. Finally, binaries can be generated in this phases by running -`scons` or `make`. +_build directory_ (see [--build-dir](https://metacpan.org/pod/--build-dir)). In most cases configuration +for a bootloader is generated automatically by novaboot. It is also +possible to generate other files using _heredoc_ or _"<"_ syntax in +novaboot scripts. Finally, binaries can be generated in this phases by +running `scons` or `make`. - \--build-dir=_directory_ @@ -244,6 +239,11 @@ scripts. Finally, binaries can be generated in this phases by running Runs `scons` to build files that are not generated by novaboot itself. +- \--strip-rom + + Strip _rom://_ prefix from command lines and generated config files. + The _rom://_ prefix is used by NUL. For NRE, it has to be stripped. + - \--gen-only Exit novaboot after file generation phase. diff --git a/novaboot b/novaboot index ec2a8b3..e3c78d6 100755 --- a/novaboot +++ b/novaboot @@ -291,13 +291,28 @@ while (<>) { # use Data::Dumper; # print Dumper(\@scripts); - foreach my $script (@scripts) { - $$script{modules}[0] =~ s/^[^ ]*/$kernel_opt/ if $kernel_opt; - $$script{modules}[0] .= ' ' . join(' ', @append) if @append; -} - + $modules = $$script{modules}; + @$modules[0] =~ s/^[^ ]*/$kernel_opt/ if $kernel_opt; + @$modules[0] .= ' ' . join(' ', @append) if @append; + my $kernel; + if (exists $variables->{KERNEL}) { + $kernel = $variables->{KERNEL}; + } else { + if ($CFG::hypervisor) { + $kernel = $CFG::hypervisor . " "; + if (exists $variables->{HYPERVISOR_PARAMS}) { + $kernel .= $variables->{HYPERVISOR_PARAMS}; + } else { + $kernel .= $CFG::hypervisor_params; + } + } + } + @$modules = ($kernel, @$modules) if $kernel; + @$modules = (@chainloaders, @$modules); + @$modules = ("bin/boot/bender", @$modules) if ($bender || defined $ENV{'NOVABOOT_BENDER'}); +} if ($dump_opt) { foreach my $script (@scripts) { @@ -574,23 +589,6 @@ foreach my $script (@scripts) { print "novaboot: Entering directory `$builddir'\n"; } - my $kernel; - if (exists $variables->{KERNEL}) { - $kernel = $variables->{KERNEL}; - } else { - if ($CFG::hypervisor) { - $kernel = $CFG::hypervisor . " "; - if (exists $variables->{HYPERVISOR_PARAMS}) { - $kernel .= $variables->{HYPERVISOR_PARAMS}; - } else { - $kernel .= $CFG::hypervisor_params; - } - } - } - @$modules = ($kernel, @$modules) if $kernel; - @$modules = (@chainloaders, @$modules); - @$modules = ("bin/boot/bender", @$modules) if ($bender || defined $ENV{'NOVABOOT_BENDER'}); - my $prefix; ($prefix = $grub_prefix) =~ s/\$NAME/$config_name/ if defined $grub_prefix; $prefix ||= $builddir; @@ -998,9 +996,9 @@ in the novaboot script. E.g. 'bin/boot/bender promisc'. =item --dump -Print the modules to boot and their parameters. This happens after -parsing the novaboot script, i.e. after evaluating all I<--scriptmod> -expressions etc. Exit after reading (and dumping) the script. +Print the modules to boot and their parameters after this phase +finishes. Then exit. This is useful for seeing the effect of other +options in this section. =item -k, --kernel=F @@ -1019,21 +1017,16 @@ from the configuration file, which has the same effect. If this option is given multiple times all expressions are evaluated in the command line order. -=item --strip-rom - -Strip I prefix from command lines and generated config files. -The I prefix is used by NUL. For NRE, it has to be stripped. - =back =head2 File generation phase In this phase, files needed for booting are generated in a so called -I (see TODO). In most cases configuration for a -bootloader is generated automatically by novaboot. It is also possible -to generate other files using I or I<"<"> syntax in novaboot -scripts. Finally, binaries can be generated in this phases by running -C or C. +I (see L<--build-dir>). In most cases configuration +for a bootloader is generated automatically by novaboot. It is also +possible to generate other files using I or I<"<"> syntax in +novaboot scripts. Finally, binaries can be generated in this phases by +running C or C. =over 8 @@ -1115,6 +1108,11 @@ I. Runs C to build files that are not generated by novaboot itself. +=item --strip-rom + +Strip I prefix from command lines and generated config files. +The I prefix is used by NUL. For NRE, it has to be stripped. + =item --gen-only Exit novaboot after file generation phase. diff --git a/tests/Makefile b/tests/Makefile index 5a9f298..bcd9f7d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,7 @@ all: ./wvtestrun $(MAKE) run-all -run-all: novaboot.wv *.wv +run-all: novaboot.wv parser.wv expect.wv *.wv .PHONY: $(wildcard *.wv) diff --git a/tests/novaboot.wv b/tests/novaboot.wv index 0019185..03f8ae4 100755 --- a/tests/novaboot.wv +++ b/tests/novaboot.wv @@ -19,17 +19,6 @@ create_dummy WVPASS ./script --gen-only --pulsar --pulsar-root=ASDF WVPASS grep "root ASDF" config-novaboot -WVSTART Bender -create_dummy -WVPASS ./script --gen-only --bender --pulsar -WVPASS grep "bender" config-novaboot - -WVSTART Chainloader support -create_dummy -WVPASS ./script --gen-only --chainloader=chain1 -chainloader=chain2 --pulsar -WVPASS grep "exec chain1" config-novaboot -WVPASS grep "load chain2" config-novaboot - WVSTART Configuration files create_dummy echo '1;' > .novaboot diff --git a/tests/parser.wv b/tests/parser.wv index 161fecb..ff6384f 100755 --- a/tests/parser.wv +++ b/tests/parser.wv @@ -43,3 +43,22 @@ WVPASS diff -u - dump < dump" +WVPASS diff -u - dump < dump" +WVPASS diff -u - dump <