absolute path of the directory containing the interpreted novaboot
script.
+Lines starting with C<copy> keyword are similar to C<load> lines. The
+file mentioned there is copied to the same place as in case of C<load>
+(e.g. tftp server), but the file is not used in the bootloader
+configuration. Such a file can be used by the target for other
+purposed than booting, e.g. at OS runtime or for firmware update.
+
Lines starting with C<run> keyword contain shell commands that are run
during file generation phase. This is the same as the "< CMD" syntax
for C<load> keyboard except that the command's output is not
;;; novaboot-mode.el --- Major mode for novaboot scripts
-;; Copyright (C) 2014 Michal Sojka
+;; Copyright (C) 2014, 2015 Michal Sojka
;; Author: Michal Sojka <sojkam1@fel.cvut.cz>
;; Keywords: languages, tools, files
(defvar novaboot-mode-font-lock-keywords)
(setq novaboot-mode-font-lock-keywords
`(("^#.*" . font-lock-comment-face)
- ("^load\\>.*\\(<<EOF\\)\n\\(\\(?:.*\n\\)*?\\)\\(EOF\\)\n"
+ ("^\\(?:load\\|copy\\)\\>.*\\(<<EOF\\)\n\\(\\(?:.*\n\\)*?\\)\\(EOF\\)\n"
(1 font-lock-preprocessor-face)
(2 font-lock-string-face)
(3 font-lock-preprocessor-face))
- ("^\\(load\\)\\s-+\\([^ \n\t]*\\)"
+ ("^\\(load\\|copy\\)\\s-+\\([^ \n\t]*\\)"
(1 font-lock-keyword-face)
(2 font-lock-function-name-face))
- ("^load\\>.*?< \\(.*\\)"
+ ("^\\(?:load\\|copy\\)\\>.*?< \\(.*\\)"
(1 font-lock-string-face))
("^\\(run\\|uboot\\)\\>" . font-lock-keyword-face)
("^\\([A-Z_]+\\)=" (1 font-lock-variable-name-face))
my $file;
my $EOF;
my $last_fn = '';
-my ($modules, $variables, $generated, $continuation) = ([], {}, []);
+my ($modules, $variables, $generated, $copy, $continuation) = ([], {}, [], []);
my $skip_reading = defined($on_opt) || defined($off_opt);
while (!$skip_reading && ($_ = <>)) {
if ($ARGV ne $last_fn) { # New script
push @scripts, { 'filename' => $ARGV,
'modules' => $modules = [],
'variables' => $variables = {},
- 'generated' => $generated = []};
+ 'generated' => $generated = [],
+ 'copy' => $copy = [],
+ };
}
chomp();
push(@exiton, $2) if ($1 eq "EXITON");
next;
}
- if (s/^load *//) { # Load line
+ sub process_load_copy($) {
die("novaboot: '$last_fn' line $.: Missing file name\n") unless /^[^ <]+/;
if (/^([^ ]*)(.*?)[[:space:]]*<<([^ ]*)$/) { # Heredoc start
- push @$modules, "$1$2";
$file = [];
push @$generated, {filename => $1, content => $file};
$EOF = $3;
- next;
+ return "$1$2";
}
if (/^([^ ]*)(.*?)[[:space:]]*< ?(.*)$/) { # Command substitution
- push @$modules, "$1$2";
push @$generated, {filename => $1, command => $3};
- next;
+ return "$1$2";
}
- push @$modules, $_;
+ return $_;
+ }
+ if (s/^load *//) { # Load line
+ push @$modules, process_load_copy($_);
+ next;
+ }
+ if (s/^copy *//) { # Copy line
+ push @$copy, process_load_copy($_);
next;
}
if (/^run (.*)/) { # run line
$path = $hostname;
$hostname = "";
}
- my $files = join(" ", map({ ($file) = m/([^ ]*)/; $file; } ( @$modules, @bootloader_configs)));
+ my $files = join(" ", map({ ($file) = m/([^ ]*)/; $file; } ( @$modules, @bootloader_configs, @$copy)));
map({ my $file = (split)[0]; die "$file: $!" if ! -f $file; } @$modules);
my $istty = -t STDOUT && ($ENV{'TERM'} || 'dumb') ne 'dumb';
my $progress = $istty ? "--progress" : "";
absolute path of the directory containing the interpreted novaboot
script.
+Lines starting with C<copy> keyword are similar to C<load> lines. The
+file mentioned there is copied to the same place as in case of C<load>
+(e.g. tftp server), but the file is not used in the bootloader
+configuration. Such a file can be used by the target for other
+purposed than booting, e.g. at OS runtime or for firmware update.
+
Lines starting with C<run> keyword contain shell commands that are run
during file generation phase. This is the same as the "< CMD" syntax
for C<load> keyboard except that the command's output is not