@@ -36,36 +36,28 @@ function image_changes() (
36
36
local arch what
37
37
38
38
arch=${1} ; shift
39
- what=${1} ; shift
39
+ # make nightly and release from last-nightly and last-release, respectively
40
+ mode=${1# last-} ; shift
40
41
41
- local -a package_diff_env package_diff_params
42
- local -a size_changes_env size_changes_params
43
- local -a show_changes_env show_changes_params
44
- local version_description
45
- local -a var_names=(
46
- package_diff_env package_diff_params
47
- size_changes_env size_changes_params
48
- show_changes_env show_changes_params
49
- version_description
50
- )
51
-
52
- case ${what} in
53
- last-release)
54
- local git_tag
55
- git_tag_for_release . git_tag
56
- prepare_env_vars_and_params_for_release " ${arch} " " ${git_tag} " " ${var_names[@]} "
57
- ;;
58
- last-nightly)
59
- local git_tag
60
- git_tag_for_nightly . git_tag
61
- prepare_env_vars_and_params_for_bincache " ${arch} " " ${git_tag} " " ${var_names[@]} "
62
- ;;
63
- * )
64
- echo " invalid argument '${what} ', expected 'last-nightly' or 'last-release'" >&2
65
- exit 1
66
- ;;
67
- esac
42
+ local fbs_repo=' ../flatcar-build-scripts'
43
+ rm -rf " ${fbs_repo} "
44
+ git clone \
45
+ --depth 1 \
46
+ --single-branch \
47
+ " https://github.com/flatcar/flatcar-build-scripts" \
48
+ " ${fbs_repo} "
49
+ if [[ -z " ${BUILDCACHE_SERVER:- } " ]]; then
50
+ local BUILDCACHE_SERVER=$( source ci-automation/ci-config.env; echo " ${BUILDCACHE_SERVER} " )
51
+ fi
52
+ echo " Image URL: http://${BUILDCACHE_SERVER} /images/${arch} /${version} /flatcar_production_image.bin.bz2"
53
+ echo
54
+ run_image_changes_job " ${arch} " " ${mode} " ' -' " ${fbs_repo} " ricj_callback
55
+ )
56
+ # --
68
57
58
+ # Callback invoked by run_image_changes_job, read its docs to learn
59
+ # about the details about the callback.
60
+ function ricj_callback() {
69
61
local ic_head_tag version
70
62
head_git_tag . ic_head_tag
71
63
version=$( source sdk_container/.repo/manifests/version.txt; echo " ${FLATCAR_VERSION} " )
@@ -94,29 +86,75 @@ function image_changes() (
94
86
# here instead of the vernum variable.
95
87
" NEW_VERSION=${ic_head_tag} "
96
88
)
89
+ }
90
+ # --
91
+
92
+ # Runs the whole image changes job for given arch and mode. The report
93
+ # is written to the given file. The reports will be done using tools
94
+ # from the passed path to the flatcar build scripts repository. The
95
+ # parameters and environment of the tools should will be partially set
96
+ # up depending on mode, but the further setup should be done by the
97
+ # passed callback.
98
+ #
99
+ # The callback takes no parameters. It should assume that array
100
+ # variables 'package_diff_env', 'package_diff_params',
101
+ # 'size_changes_env', 'size_changes_params', 'show_changes_env' and
102
+ # 'show_changes_params' are already defined, so it can append
103
+ # necessary data into them.
104
+ #
105
+ # 1 - arch
106
+ # 2 - mode
107
+ # 3 - report file name ('-' for standard output)
108
+ # 4 - path to the flatcar-build-scripts repository
109
+ # 5 - name of a callback function
110
+ function run_image_changes_job() {
111
+ arch=${1} ; shift
112
+ mode=${1} ; shift
113
+ report_file_name=${1} ; shift
114
+ fbs_repo=${1} ; shift
115
+ cb=${1} ; shift
116
+
117
+ case ${mode} in
118
+ release|nightly)
119
+ :
120
+ ;;
121
+ * )
122
+ echo " invalid mode ${mode@ Q} , expected 'nightly' or 'release'" >&2
123
+ exit 1
124
+ ;;
125
+ esac
126
+
127
+ local -a package_diff_env package_diff_params
128
+ local -a size_changes_env size_changes_params
129
+ local -a show_changes_env show_changes_params
130
+ local version_description
131
+ local -a var_names=(
132
+ package_diff_env package_diff_params
133
+ size_changes_env size_changes_params
134
+ show_changes_env show_changes_params
135
+ version_description
136
+ )
137
+ local git_tag_for_mode prepare_env_vars_and_params_for_mode
138
+ git_tag_for_mode=" git_tag_for_${mode} "
139
+ prepare_env_vars_and_params_for_mode=" prepare_env_vars_and_params_for_${mode} "
140
+
141
+ local git_tag
142
+ " ${git_tag_for_mode} " . git_tag
143
+ " ${prepare_env_vars_and_params_for_mode} " " ${arch} " " ${git_tag} " " ${var_names[@]} "
144
+
145
+ # invoke callback that should append necessary info to env and params variables
146
+ " ${cb} "
97
147
98
- local fbs_repo=' ../flatcar-build-scripts'
99
- rm -rf " ${fbs_repo} "
100
- git clone \
101
- --depth 1 \
102
- --single-branch \
103
- " https://github.com/flatcar/flatcar-build-scripts" \
104
- " ${fbs_repo} "
105
- if [[ -z " ${BUILDCACHE_SERVER:- } " ]]; then
106
- local BUILDCACHE_SERVER=$( source ci-automation/ci-config.env; echo " ${BUILDCACHE_SERVER} " )
107
- fi
108
- echo " Image URL: http://${BUILDCACHE_SERVER} /images/${arch} /${version} /flatcar_production_image.bin.bz2"
109
- echo
110
148
local -a oemids base_sysexts
111
149
get_oem_id_list . " ${arch} " oemids
112
150
get_base_sysext_list . " ${arch} " base_sysexts
113
151
generate_image_changes_report \
114
- " ${version_description} " ' - ' " ${fbs_repo} " \
152
+ " ${version_description} " " ${report_file_name} " " ${fbs_repo} " \
115
153
" ${package_diff_env[@]} " --- " ${package_diff_params[@]} " -- \
116
154
" ${size_changes_env[@]} " --- " ${size_changes_params[@]} " -- \
117
155
" ${show_changes_env[@]} " --- " ${show_changes_params[@]} " -- \
118
156
" ${oemids[@]} " -- " ${base_sysexts[@]} "
119
- )
157
+ }
120
158
# --
121
159
122
160
# Gets a git tag that can be passed to
@@ -180,7 +218,7 @@ function head_git_tag() {
180
218
}
181
219
182
220
# Gets a git tag of a previous nightly that can be passed to
183
- # prepare_env_vars_and_params_for_bincache .
221
+ # prepare_env_vars_and_params_for_nightly .
184
222
#
185
223
# 1 - scripts repo
186
224
# 2 - name of a variable to store the result in
@@ -357,7 +395,7 @@ function prepare_env_vars_and_params_for_release() {
357
395
# nightly relative to the git tag. The git tag should be in form of
358
396
# <channel>-<version id>-<build id>, which is the usual format used in
359
397
# scripts repo.
360
- function prepare_env_vars_and_params_for_bincache () {
398
+ function prepare_env_vars_and_params_for_nightly () {
361
399
local arch git_tag
362
400
arch=${1} ; shift
363
401
git_tag=${1} ; shift
0 commit comments