From f6f36f70633b7cc604ef0add77eb6efe6039d1b6 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 8 Sep 2015 10:58:45 +0200 Subject: [PATCH] Add "<" syntax for uboot lines in novaboot script --- README.pod | 28 ++++++++++++++++++++-------- novaboot | 45 +++++++++++++++++++++++++++++---------------- 2 files changed, 49 insertions(+), 24 deletions(-) diff --git a/README.pod b/README.pod index f32f33f..d0c6e6f 100644 --- a/README.pod +++ b/README.pod @@ -728,14 +728,26 @@ appear in the novaboot script. =item C -Lines starting with C represent U-Boot commands that are sent -to the target if B<--uboot> option is given. Having a U-Boot line in -the novaboot script is the same as passing an equivalent -B<--uboot-init> option to novaboot. The C keyword can be -suffixed with timeout specification. The syntax is C, where -C is the whole number of seconds. If the U-Boot command prompt does -not appear before the timeout, novaboot fails. The default timeout is -10 seconds. +These lines represent U-Boot commands that are sent to the target if +B<--uboot> option is given. Having a U-Boot line in the novaboot +script is the same as giving B<--uboot-init> option to novaboot. The +following syntax variants are supported: + + + uboot[:] + uboot[:] < + +C is the literal U-Boot command. + +The C keyword can be suffixed with timeout specification. The +syntax is C, where C is the whole number of seconds. If +the U-Boot command prompt does not appear before the timeout, novaboot +fails. The default timeout is 10 seconds. + +In the second variant with the C<<> character the shell code is +executed and its standard output is sent to U-Boot. Example: + + uboot < printf "mmc write \$loadaddr 1 %x" $(($(/usr/bin/stat -c%s rootfs.ext4) / 512)) =back diff --git a/novaboot b/novaboot index 49f8469..d6b17fe 100755 --- a/novaboot +++ b/novaboot @@ -367,15 +367,12 @@ while (!$skip_reading && ($_ = <>)) { push @$generated, {command => $1}; next; } - if (/^uboot(?::([0-9]+)s)? (.*)/) { # uboot line + if (/^uboot(?::([0-9]+)s)? +(< *)?(.*)/) { # uboot line # TODO: If U-Boot supports some interactive menu, it might # make sense to store uboot lines per novaboot script. - if ($1) { # Command with explicit timeout - push @uboot_init, { command => $2, - timeout => $1 }; - } else { # Command without explicit timeout - push @uboot_init, $2; - } + push @uboot_init, { command => $2 ? "" : $3, + system => $2 ? $3 : "", + timeout => $1 // 10 }; next; } @@ -1088,7 +1085,11 @@ if (defined $uboot) { foreach my $cmdspec (@uboot_init) { my ($cmd, $timeout); if (ref($cmdspec) eq "HASH") { - $cmd = $cmdspec->{command}; + if ($cmdspec->{system}) { + $cmd = `$cmdspec->{system}`; + } else { + $cmd = $cmdspec->{command}; + } $timeout = $cmdspec->{timeout}; } else { $cmd = $cmdspec; @@ -1934,14 +1935,26 @@ appear in the novaboot script. =item C -Lines starting with C represent U-Boot commands that are sent -to the target if B<--uboot> option is given. Having a U-Boot line in -the novaboot script is the same as passing an equivalent -B<--uboot-init> option to novaboot. The C keyword can be -suffixed with timeout specification. The syntax is C, where -C is the whole number of seconds. If the U-Boot command prompt does -not appear before the timeout, novaboot fails. The default timeout is -10 seconds. +These lines represent U-Boot commands that are sent to the target if +B<--uboot> option is given. Having a U-Boot line in the novaboot +script is the same as giving B<--uboot-init> option to novaboot. The +following syntax variants are supported: + + + uboot[:] + uboot[:] < + +C is the literal U-Boot command. + +The C keyword can be suffixed with timeout specification. The +syntax is C, where C is the whole number of seconds. If +the U-Boot command prompt does not appear before the timeout, novaboot +fails. The default timeout is 10 seconds. + +In the second variant with the C<<> character the shell code is +executed and its standard output is sent to U-Boot. Example: + + uboot < printf "mmc write \$loadaddr 1 %x" $(($(/usr/bin/stat -c%s rootfs.ext4) / 512)) =back -- 2.39.2