diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2022-11-25 13:42:50 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2022-11-29 14:54:56 +0000 |
commit | cae61649be98393925ff04cde9c1882e88c64475 (patch) | |
tree | 3051e9dfe7039fe7b79dae55a900d862feb14a74 | |
parent | 80140b97d42b851983f2353ccb56d04ae8b1cdb6 (diff) |
jenkins-helpers.sh: Add @@artifacts_var artifacts_dir
... to convert_args_to_variables(). This is useful for reproducing
builds from the manifests.
Change-Id: I871e3a8c36aff0dab066553e79593abb5db029e1
-rw-r--r-- | jenkins-helpers.sh | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh index cb9a107..68e2abd 100644 --- a/jenkins-helpers.sh +++ b/jenkins-helpers.sh @@ -886,9 +886,11 @@ __manifest_filename=("/dev/null") # Set new file name for manifest # $1: File name +# $2: Optional true/false on whether start a new manifest manifest_push () { local filename="$1" + local clean="${2-true}" # Resolve absolute path to manifest. local dir @@ -897,7 +899,9 @@ manifest_push () dir=$(cd "$dir"; pwd) __manifest_filename=("$dir/$(basename "$filename")" "${__manifest_filename[@]}") - rm -f "${__manifest_filename[0]}" + if $clean; then + rm -f "${__manifest_filename[0]}" + fi } # Return to previous manifest filename @@ -955,6 +959,8 @@ EOF convert_arg_source () { + assert_with_msg "ERROR: manifest/include does not exist: $1" \ + [ -f "$1" ] # shellcheck disable=SC1090 source "$1" echo "# Start of include $1" | manifest_out @@ -971,6 +977,9 @@ convert_arg_source () # "==arr[key] value" defines shell associative array "$arr[@]" and sets # "${arr[key]}" to "value". # "@@ file" sources file. +# "@@artifacts_var dir" defines artifacts directory and sources the manifest in +# from dir/manifest.sh. This is useful for reproducing +# builds. # "%%artifacts_var dir" defines artifacts directory and starts manifest in # dir/manifest.sh. Also see "^^ true". # "^^ true/false %%artifacts_var dir" whether to reproduce the build using manifest. @@ -1025,6 +1034,21 @@ convert_args_to_variables () convert_arg_source "$2" num=2 ;; + "@@"*) + # TODO: It should be possible to simplify handling of "^^" + # now that we have @@artifacts dir. + assert_with_msg "ERROR: Parameter value not provided for $1." \ + [ $# -ge 2 ] + convert_arg_source "$2/manifest.sh" + manifest_push "$2/manifest.sh" false + + name="${1#@@}" + case "$name" in + *"["*"]") convert_arg_assarr "$name" "$2" ;; + *) convert_arg_var "$name" "$2" ;; + esac + num=2 + ;; "%%"*) assert_with_msg "ERROR: Parameter value not provided for $1." \ [ $# -ge 2 ] @@ -1048,8 +1072,6 @@ EOF assert_with_msg "ERROR: Parameter value not provided for $1." \ [ $# -ge 4 ] if [ x"$2" = x"true" ]; then - assert_with_msg "ERROR: manifest does not exist: $4/manifest.sh" \ - [ -f $4/manifest.sh ] name="${3#%%}" case "$name" in *"["*"]") convert_arg_assarr "$name" "$4" ;; |