]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
Add "copy" keyword to novaboot script syntax
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 8 Sep 2015 08:12:09 +0000 (10:12 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 8 Sep 2015 08:12:09 +0000 (10:12 +0200)
README.pod
contrib/novaboot-mode.el
novaboot

index a309c5fa2ae3cac109a12ba6a17a5d329fc8d5ef..6b6a68c5ec8b38c39a94b9a8cf6e371feaf9fa11 100644 (file)
@@ -703,6 +703,12 @@ that line. The SRCDIR variable in CMD's environment is set to the
 absolute path of the directory containing the interpreted novaboot
 script.
 
 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
 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
index e3b5e402a5f8f44ad9ca3614eb7bdbec6b863bbc..e3e680fe136d6b47e1942e7fb99eab57d215ce5c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; novaboot-mode.el --- Major mode for novaboot scripts
 
 ;;; 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
 
 ;; 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)
 (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))
      (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))
      (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))
      (1 font-lock-string-face))
     ("^\\(run\\|uboot\\)\\>" . font-lock-keyword-face)
     ("^\\([A-Z_]+\\)=" (1 font-lock-variable-name-face))
index dc1640c0351d95e422e5590ef93a2a7e30142a38..01186490dbb4f88ad0db4cac38f5ccde32088c6d 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -296,7 +296,7 @@ my @scripts;
 my $file;
 my $EOF;
 my $last_fn = '';
 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
 my $skip_reading = defined($on_opt) || defined($off_opt);
 while (!$skip_reading && ($_ = <>)) {
     if ($ARGV ne $last_fn) { # New script
@@ -306,7 +306,9 @@ while (!$skip_reading && ($_ = <>)) {
        push @scripts, { 'filename' => $ARGV,
                         'modules' => $modules = [],
                         'variables' => $variables = {},
        push @scripts, { 'filename' => $ARGV,
                         'modules' => $modules = [],
                         'variables' => $variables = {},
-                        'generated' => $generated = []};
+                        'generated' => $generated = [],
+                        'copy' => $copy = [],
+       };
 
     }
     chomp();
 
     }
     chomp();
@@ -339,21 +341,26 @@ while (!$skip_reading && ($_ = <>)) {
        push(@exiton, $2) if ($1 eq "EXITON");
        next;
     }
        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
        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;
            $file = [];
            push @$generated, {filename => $1, content => $file};
            $EOF = $3;
-           next;
+           return "$1$2";
        }
        if (/^([^ ]*)(.*?)[[:space:]]*< ?(.*)$/) { # Command substitution
        }
        if (/^([^ ]*)(.*?)[[:space:]]*< ?(.*)$/) { # Command substitution
-           push @$modules, "$1$2";
            push @$generated, {filename => $1, command => $3};
            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
        next;
     }
     if (/^run (.*)/) {         # run line
@@ -874,7 +881,7 @@ foreach my $script (@scripts) {
            $path = $hostname;
            $hostname = "";
        }
            $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" : "";
        map({ my $file = (split)[0]; die "$file: $!" if ! -f $file; } @$modules);
        my $istty = -t STDOUT && ($ENV{'TERM'} || 'dumb') ne 'dumb';
        my $progress = $istty ? "--progress" : "";
@@ -1902,6 +1909,12 @@ that line. The SRCDIR variable in CMD's environment is set to the
 absolute path of the directory containing the interpreted novaboot
 script.
 
 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
 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