@@ -8,18 +8,18 @@ dn=$(dirname "$0")
88# This script is used for creating both the bare metal and the canonical VM
99# image (qemu). `buildextend-qemu` is a symlink to `buildextend-metal`.
1010case " $( basename " $0 " ) " in
11- " cmd-buildextend-metal" ) image_type =metal;;
12- " cmd-buildextend-metal4k" ) image_type =metal4k;;
13- " cmd-buildextend-qemu" ) image_type =qemu;;
14- " cmd-buildextend-qemu-secex" ) image_type =qemu-secex;;
15- " cmd-buildextend-secex" ) image_type =qemu-secex;;
11+ " cmd-buildextend-metal" ) platform =metal;;
12+ " cmd-buildextend-metal4k" ) platform =metal4k;;
13+ " cmd-buildextend-qemu" ) platform =qemu;;
14+ " cmd-buildextend-qemu-secex" ) platform =qemu-secex;;
15+ " cmd-buildextend-secex" ) platform =qemu-secex;;
1616 * ) fatal " called as unexpected name $0 " ;;
1717esac
1818
1919print_help () {
2020 cat 1>&2 << EOF
21- Usage: coreos-assembler buildextend-${image_type } --help
22- coreos-assembler buildextend-${image_type } [--build ID]
21+ Usage: coreos-assembler buildextend-${platform } --help
22+ coreos-assembler buildextend-${platform } [--build ID]
2323
2424 Build a bare metal image.
2525EOF
8080
8181# shellcheck disable=SC2031
8282export LIBGUESTFS_BACKEND=direct
83- export IMAGE_TYPE=" ${image_type } "
83+ export IMAGE_TYPE=" ${platform } "
8484prepare_build
8585
8686if [ -z " ${build} " ]; then
@@ -96,18 +96,18 @@ if [ ! -d "${builddir}" ]; then
9696fi
9797
9898# add building sempahore
99- build_semaphore=" ${builddir} /.${image_type } .building"
99+ build_semaphore=" ${builddir} /.${platform } .building"
100100if [ -e " ${build_semaphore} " ]; then
101- fatal " ${build_semaphore} found: another process is building ${image_type } "
101+ fatal " ${build_semaphore} found: another process is building ${platform } "
102102fi
103103touch " ${build_semaphore} "
104104trap ' rm -f ${build_semaphore}' EXIT
105105
106106# check if the image already exists in the meta.json
107107if [ -z " ${force} " ]; then
108- meta_img=$( meta_key " images.${image_type } .path" )
108+ meta_img=$( meta_key " images.${platform } .path" )
109109 if [ " ${meta_img} " != " None" ]; then
110- echo " ${image_type } image already exists:"
110+ echo " ${platform } image already exists:"
111111 echo " $meta_img "
112112 exit 0
113113 fi
118118name=$( meta_key name)
119119
120120image_format=raw
121- if [[ " ${image_type } " == " qemu" || " ${image_type } " == " qemu-secex" ]]; then
121+ if [[ " ${platform } " == " qemu" || " ${platform } " == " qemu-secex" ]]; then
122122 image_format=qcow2
123123fi
124124
125- imgname=${name} -${build} -${image_type } .${basearch} .${image_format}
125+ imgname=${name} -${build} -${platform } .${basearch} .${image_format}
126126imgpath=${PWD} /${imgname}
127127
128128# Parse the passed config JSON and extract a mandatory value
@@ -224,22 +224,22 @@ EOF
224224# built in parallel, so we need to be able to access the cache by multiple processes,
225225# so for those we'll set `snapshot=on` so that each will get their own disk image.
226226# This is OK because we don't checkpoint (cache) any of those stages.
227- [ " ${image_type } " == " qemu" ] && snapshot=" off" || snapshot=" on"
227+ [ " ${platform } " == " qemu" ] && snapshot=" off" || snapshot=" on"
228228runvm_osbuild_config_json=" $( generate_runvm_osbuild_config) "
229229runvm_with_cache_snapshot " $snapshot " -- /usr/lib/coreos-assembler/runvm-osbuild \
230230 --config " ${runvm_osbuild_config_json} " \
231231 --mpp " /usr/lib/coreos-assembler/osbuild-manifests/coreos.osbuild.${basearch} .mpp.yaml" \
232232 --filepath " ${imgpath} " \
233- --platform " ${image_type } "
233+ --platform " ${platform } "
234234
235- if [[ " ${image_type } " == " qemu-secex" ]]; then
235+ if [[ " ${platform } " == " qemu-secex" ]]; then
236236 if [ ! -f " ${genprotimgvm} " ]; then
237237 fatal " No genprotimgvm provided at ${genprotimgvm} "
238238 fi
239239
240240 # Basic qemu args:
241241 qemu_args=(); blk_size=" 512"
242- [[ $image_type == metal4k ]] && blk_size=" 4096"
242+ [[ $platform == metal4k ]] && blk_size=" 4096"
243243 qemu_args+=(" -drive" " if=none,id=target,format=${image_format} ,file=${imgpath} ,cache=unsafe" \
244244 " -device" " virtio-blk,serial=target,drive=target,physical_block_size=${blk_size} ,logical_block_size=${blk_size} " )
245245
@@ -278,7 +278,7 @@ sha256=$(sha256sum_str < "${imgpath}")
278278cosa meta --workdir " ${workdir} " --build " ${build} " --dump | python3 -c "
279279import sys, json
280280j = json.load(sys.stdin)
281- j['images']['${image_type } '] = {
281+ j['images']['${platform } '] = {
282282 'path': '${imgname} ',
283283 'sha256': '${sha256} ',
284284 'size': $( stat -c ' %s' " ${imgpath} " )
@@ -305,7 +305,7 @@ json.dump(j, sys.stdout, indent=4)
305305fi
306306
307307# and now the crucial bits
308- cosa meta --workdir " ${workdir} " --build " ${build} " --artifact " ${image_type } " --artifact-json " $( readlink -f meta.json.new) "
308+ cosa meta --workdir " ${workdir} " --build " ${build} " --artifact " ${platform } " --artifact-json " $( readlink -f meta.json.new) "
309309/usr/lib/coreos-assembler/finalize-artifact " ${imgpath} " " ${builddir} /${imgname} "
310310
311311# Quiet for the rest of this so the last thing we see is a success message
0 commit comments