Browse Source

add the default configuration (mender_convert_config) to the config array at creation

Current logic actually fails when no '-c/--config' options are provided, with this error:

$ MENDER_ARTIFACT_NAME="test-1" ./mender-convert --disk-image input/Armbian_5.95_Tinkerboard_Debian_buster_next_4.19.69_minimal.img
Running mender-convert-extract: --disk-image input/Armbian_5.95_Tinkerboard_Debian_buster_next_4.19.69_minimal.img
2019-10-02 12:46:39 [INFO] [mender-convert-extract] Using configuration file: configs/mender_convert_config
2019-10-02 12:46:39 [INFO] [mender-convert-extract] Using configuration file: ''
modules/config.sh: line 28: '': No such file or directory

The 'configs' array is actually not empty when passed to modules/config.sh
as it will contain "''", which will be translated as a array element and
hence the above failure.

This commit ensures that we set a valid default value to 'configs',
which is the 'mender_convert_config'. This is moved from modules/config.sh,
to the calling scripts that define the array of configs.

Fixes: 9b944615a8 ("configs: Support multiple config files on command line.")

Changelog: None

Signed-off-by: Mirza Krak <mirza.krak@northern.tech>
2.0.x
Mirza Krak 6 years ago
parent
commit
88fe7558c9
  1. 3
      mender-convert-extract
  2. 3
      mender-convert-modify
  3. 3
      mender-convert-package
  4. 1
      modules/config.sh

3
mender-convert-extract

@ -19,7 +19,8 @@ echo "Running $(basename $0): $@"
source modules/bootstrap.sh
source modules/disk.sh
declare -a configs
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
disk_image=""
while (( "$#" )); do

3
mender-convert-modify

@ -39,7 +39,8 @@ source modules/bootstrap.sh
source modules/disk.sh
source modules/probe.sh
declare -a configs
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
while (( "$#" )); do
case "$1" in

3
mender-convert-package

@ -38,7 +38,8 @@ echo "Running $(basename $0): $@"
source modules/bootstrap.sh
source modules/disk.sh
declare -a configs
# The mender_convert_config is always used and provides all the defaults
declare -a configs=("configs/mender_convert_config")
while (( "$#" )); do
case "$1" in

1
modules/config.sh

@ -16,7 +16,6 @@
# Read in the array of config files to process
read -a configs <<< "${@}"
configs=( "configs/mender_convert_config" "${configs[@]}" )
for config in "${configs[@]}"; do
log_info "Using configuration file: ${config}"
source "${config}"

Loading…
Cancel
Save