From: Michal Sojka Date: Fri, 28 Feb 2014 18:41:02 +0000 (+0100) Subject: Implement run keyword X-Git-Tag: 20140513~8 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/novaboot.git/commitdiff_plain/c10fc9ce1c484e83d983b436fe7eccecb257968e Implement run keyword This allows to run arbitrary commands during file generation phase. --- diff --git a/README.md b/README.md index 29fb2df..0910549 100644 --- a/README.md +++ b/README.md @@ -229,8 +229,9 @@ running `scons` or `make`. - \--no-file-gen - Do not generate files on the fly (i.e. "<" syntax) except for the - files generated via "</etc/init.d/S99myapp" Example (NOVA User Land - NUL): diff --git a/examples/linux-test b/examples/linux-test index 5b0dd3c..2b159b5 100755 --- a/examples/linux-test +++ b/examples/linux-test @@ -1,11 +1,8 @@ #!/usr/bin/env novaboot # -*-sh-*- -# Before this example can be run, you need to build the images refered -# to below. Simply run: -# -# git submodule update --init -# make -C build/buildroot. +run git submodule update --init +run make -C build/buildroot load build/buildroot/images/bzImage console=ttyS0,115200 load build/buildroot/images/rootfs.cpio.gz diff --git a/novaboot b/novaboot index 58ff4d3..d9412ad 100755 --- a/novaboot +++ b/novaboot @@ -288,6 +288,10 @@ while (!$skip_reading && ($_ = <>)) { push @$modules, $_; next; } + if (/^run (.*)/) { # run line + push @$generated, {command => $1}; + next; + } die("novaboot: Cannot parse script '$last_fn' line $.. Didn't you forget 'load' keyword?\n"); } @@ -339,7 +343,11 @@ sub generate_configs($$$) { print "novaboot: Created $fn\n"; } elsif (exists $$g{command} && ! $no_file_gen) { $ENV{SRCDIR} = dirname(File::Spec->rel2abs( $filename, $invocation_dir )); - system_verbose("( $$g{command} ) > $$g{filename}"); + if (exists $$g{filename}) { + system_verbose("( $$g{command} ) > $$g{filename}"); + } else { + system_verbose($$g{command}); + } } } } @@ -707,7 +715,7 @@ foreach my $script (@scripts) { { my @files = map({ ($file) = m/([^ ]*)/; $file; } @$modules); # Filter-out generated files - my @to_build = grep({ my $file = $_; !scalar(grep($file eq $$_{filename}, @$generated)) } @files); + my @to_build = grep({ my $file = $_; !scalar(grep($file eq ($$_{filename} || ''), @$generated)) } @files); system_verbose($scons || $CFG::scons." ".join(" ", @to_build)) if (defined $scons); system_verbose($make || $CFG::make ." ".join(" ", @to_build)) if (defined $make); @@ -1202,8 +1210,9 @@ server directory where the boot files are copied to. =item --no-file-gen -Do not generate files on the fly (i.e. "<" syntax) except for the -files generated via "< keyword). This switch does not influence generation of files +specified with "< keyword contain shell commands that are run +during file generation phase. This is the same as the "< CMD" syntax +for C keyboard except that the command's output is not +redirected to a file. The ordering of commands is the same as they +appear in the novaboot script. + Example (Linux): #!/usr/bin/env novaboot load bzImage console=ttyS0,115200 + run make -C buildroot load rootfs.cpio < gen_cpio buildroot/images/rootfs.cpio "myapp->/etc/init.d/S99myapp" Example (NOVA User Land - NUL): diff --git a/tests/parser.wv b/tests/parser.wv index c9e5001..4825d77 100755 --- a/tests/parser.wv +++ b/tests/parser.wv @@ -85,3 +85,7 @@ load < output" +WVPASS grep "^ahoj$" output