[shellprocess] Migrate towards 'standard' variable substitutions
This commit is contained in:
parent
3bf0a93b86
commit
bb278c7ba9
@ -146,14 +146,14 @@ script:
|
||||
QVariant plainScript = CalamaresUtils::yamlMapToVariant( doc ).value( "script" );
|
||||
QVariant rootScript = CalamaresUtils::yamlMapToVariant( YAML::Load( R"(---
|
||||
script:
|
||||
- "ls @@ROOT@@"
|
||||
- "ls ${ROOT}"
|
||||
)" ) )
|
||||
.value( "script" );
|
||||
QVariant userScript = CalamaresUtils::yamlMapToVariant( YAML::Load( R"(---
|
||||
script:
|
||||
- mktemp -d @@ROOT@@/calatestXXXXXXXX
|
||||
- "chown @@USER@@ @@ROOT@@/calatest*"
|
||||
- rm -rf @@ROOT@@/calatest*
|
||||
- mktemp -d ${ROOT}/calatestXXXXXXXX
|
||||
- "chown ${USER} ${ROOT}/calatest*"
|
||||
- rm -rf ${ROOT}/calatest*
|
||||
)" ) )
|
||||
.value( "script" );
|
||||
|
||||
@ -167,13 +167,13 @@ script:
|
||||
|
||||
qDebug() << "Expect WARNING, ERROR, WARNING";
|
||||
|
||||
// Doesn't use @@ROOT@@, so no failures
|
||||
// Doesn't use ${ROOT}, so no failures
|
||||
QVERIFY( bool( CommandList( plainScript, false, 10s ).run() ) );
|
||||
|
||||
// Doesn't use @@ROOT@@, but does chroot, so fails
|
||||
// Doesn't use ${ROOT}, but does chroot, so fails
|
||||
QVERIFY( !bool( CommandList( plainScript, true, 10s ).run() ) );
|
||||
|
||||
// Does use @@ROOT@@, which is not set, so fails
|
||||
// Does use ${ROOT}, which is not set, so fails
|
||||
QVERIFY( !bool( CommandList( rootScript, false, 10s ).run() ) );
|
||||
// .. fails for two reasons
|
||||
QVERIFY( !bool( CommandList( rootScript, true, 10s ).run() ) );
|
||||
|
@ -31,7 +31,7 @@ private Q_SLOTS:
|
||||
void testProcessFromObject();
|
||||
// Create from a complex YAML list
|
||||
void testProcessListFromObject();
|
||||
// Check @@ROOT@@ substitution
|
||||
// Check variable substitution
|
||||
void testRootSubstitution();
|
||||
};
|
||||
|
||||
|
@ -7,11 +7,13 @@
|
||||
# If the top-level key *dontChroot* is true, then the commands
|
||||
# are executed in the context of the live system, otherwise
|
||||
# in the context of the target system. In all of the commands,
|
||||
# the following substitutions will take place:
|
||||
# - `@@ROOT@@` is replaced by the root mount point of the **target**
|
||||
# system from the point of view of the command (for chrooted
|
||||
# commands, that will be */*).
|
||||
# - `@@USER@@` is replaced by the username, set on the user page.
|
||||
# the following variable expansions will take place:
|
||||
# - `ROOT` is replaced by the root mount point of the **target**
|
||||
# system from the point of view of the command (when run in the target
|
||||
# system, e.g. when *dontChroot* is false, that will be `/`).
|
||||
# - `USER` is replaced by the username, set on the user page.
|
||||
#
|
||||
# Variables are written as `${var}`, e.g. `${ROOT}`.
|
||||
#
|
||||
# The (global) timeout for the command list can be set with
|
||||
# the *timeout* key. The value is a time in seconds, default
|
||||
@ -72,7 +74,7 @@ dontChroot: false
|
||||
# ignored; the slowloris command has a different timeout from the
|
||||
# other commands in the list):
|
||||
script:
|
||||
- "-touch @@ROOT@@/tmp/thingy"
|
||||
- "-touch ${ROOT}/tmp/thingy"
|
||||
- "/usr/bin/true"
|
||||
- command: "/usr/local/bin/slowloris"
|
||||
timeout: 3600
|
||||
|
Loading…
Reference in New Issue
Block a user