Add global option --setenv
Allow to set environment variables in the caller environment via the commandline, e.g --setenv SOURCE_DATE_EPOCH=42
This commit is contained in:
parent
8038ccfbef
commit
f9fb77e93e
@ -12,6 +12,7 @@ SYNOPSIS
|
||||
|
||||
kiwi-ng -h | --help
|
||||
kiwi-ng [--profile=<name>...]
|
||||
[--setenv=<variable=value>...]
|
||||
[--temp-dir=<directory>]
|
||||
[--type=<build_type>]
|
||||
[--logfile=<filename>]
|
||||
@ -32,6 +33,7 @@ SYNOPSIS
|
||||
[--config=<configfile>]
|
||||
result <command> [<args>...]
|
||||
kiwi-ng [--profile=<name>...]
|
||||
[--setenv=<variable=value>...]
|
||||
[--shared-cache-dir=<directory>]
|
||||
[--temp-dir=<directory>]
|
||||
[--target-arch=<name>]
|
||||
@ -143,6 +145,11 @@ GLOBAL OPTIONS
|
||||
XML description. The option can be specified multiple times to
|
||||
allow a combination of profiles.
|
||||
|
||||
--setenv=<variable=value>
|
||||
|
||||
export environment variable and its value into the caller
|
||||
environment. This option can be specified multiple times
|
||||
|
||||
--shared-cache-dir=<directory>
|
||||
|
||||
Specify an alternative shared cache directory. The directory
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
"""
|
||||
usage: kiwi-ng -h | --help
|
||||
kiwi-ng [--profile=<name>...]
|
||||
[--setenv=<variable=value>...]
|
||||
[--temp-dir=<directory>]
|
||||
[--target-arch=<name>]
|
||||
[--type=<build_type>]
|
||||
@ -39,6 +40,7 @@ usage: kiwi-ng -h | --help
|
||||
[--config=<configfile>]
|
||||
result <command> [<args>...]
|
||||
kiwi-ng [--profile=<name>...]
|
||||
[--setenv=<variable=value>...]
|
||||
[--shared-cache-dir=<directory>]
|
||||
[--temp-dir=<directory>]
|
||||
[--target-arch=<name>]
|
||||
@ -89,6 +91,9 @@ global options for services: image, system
|
||||
--profile=<name>
|
||||
profile name, multiple profiles can be selected by passing
|
||||
this option multiple times
|
||||
--setenv=<variable=value>
|
||||
export environment variable and its value into the caller
|
||||
environment. This option can be specified multiple times
|
||||
--shared-cache-dir=<directory>
|
||||
specify an alternative shared cache directory. The directory
|
||||
is shared via bind mount between the build host and image
|
||||
|
||||
@ -139,6 +139,12 @@ class CliTask:
|
||||
if self.global_args['--color-output']:
|
||||
log.set_color_format()
|
||||
|
||||
if self.global_args['--setenv']:
|
||||
for setenv in self.global_args['--setenv']:
|
||||
(variable, value) = self.attr_token(setenv)
|
||||
log.info(f'--> Set Env[{variable}]="{value}"')
|
||||
os.environ[format(variable)] = format(value)
|
||||
|
||||
# initialize runtime configuration
|
||||
# import RuntimeConfig late to make sure the logging setup applies
|
||||
from kiwi.runtime_config import RuntimeConfig
|
||||
|
||||
@ -38,6 +38,7 @@ class TestCli:
|
||||
'--debug-run-scripts-in-screen': False,
|
||||
'result': False,
|
||||
'--profile': [],
|
||||
'--setenv': [],
|
||||
'--shared-cache-dir': '/var/cache/kiwi',
|
||||
'--temp-dir': '/var/tmp',
|
||||
'--target-arch': None,
|
||||
|
||||
@ -45,6 +45,7 @@ class TestCliTask:
|
||||
'--loglevel': None,
|
||||
'--color-output': True,
|
||||
'--profile': ['vmxFlavour'],
|
||||
'--setenv': ['SOURCE_DATE_EPOCH=42'],
|
||||
'--type': None
|
||||
}
|
||||
mock_command_args.return_value = {
|
||||
@ -78,6 +79,7 @@ class TestCliTask:
|
||||
'--loglevel': None,
|
||||
'--color-output': True,
|
||||
'--profile': ['vmxFlavour'],
|
||||
'--setenv': [],
|
||||
'--type': None
|
||||
}
|
||||
self.task = CliTask()
|
||||
@ -120,6 +122,7 @@ class TestCliTask:
|
||||
'--debug-run-scripts-in-screen': None,
|
||||
'--color-output': None,
|
||||
'--loglevel': '10',
|
||||
'--setenv': []
|
||||
}
|
||||
self.task = CliTask()
|
||||
mock_setLogLevel.assert_called_once_with(10)
|
||||
@ -141,6 +144,7 @@ class TestCliTask:
|
||||
'--debug-run-scripts-in-screen': None,
|
||||
'--color-output': None,
|
||||
'--loglevel': 'bogus',
|
||||
'--setenv': []
|
||||
}
|
||||
self.task = CliTask()
|
||||
mock_setLogLevel.assert_called_once_with(20)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user