Skip to content

Commit 909e10a

Browse files
committed
cmd-buildextend-metal: drain more code into generate_runvm_osbuild_config()
This only needs to happen when we're generating the config.
1 parent 3d6948e commit 909e10a

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/cmd-buildextend-metal

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,6 @@ fi
116116
# reread these values from the build itself rather than rely on the ones loaded
117117
# by prepare_build since the config might've changed since then
118118
name=$(meta_key name)
119-
ref=$(meta_key ref)
120-
if [ "${ref}" = "None" ]; then
121-
ref=""
122-
fi
123-
commit=$(meta_key ostree-commit)
124-
125-
ostree_repo=${tmprepo}
126-
# Ensure that we have the cached unpacked commit
127-
import_ostree_commit_for_build "${build}"
128-
# Note this overwrote the bits generated in prepare_build
129-
# for image_json. In the future we expect to split prepare_build
130-
# into prepare_ostree_build and prepare_diskimage_build; the
131-
# latter path would only run this.
132-
image_json=${workdir}/tmp/image.json
133119

134120
image_format=raw
135121
if [[ "${image_type}" == "qemu" || "${image_type}" == "qemu-secex" ]]; then
@@ -163,6 +149,23 @@ generate_runvm_osbuild_config() {
163149
fi
164150
rm -f ${workdir}/tmp/runvm-osbuild-config-*.json # clean up any previous configs
165151

152+
# reread these values from the build itself rather than rely on the ones loaded
153+
# by prepare_build since the config might've changed since then
154+
ostree_commit=$(meta_key ostree-commit)
155+
ostree_ref=$(meta_key ref)
156+
if [ "${ostree_ref}" = "None" ]; then
157+
ostree_ref=""
158+
fi
159+
160+
ostree_repo=${tmprepo}
161+
# Ensure that we have the cached unpacked commit
162+
import_ostree_commit_for_build "${build}"
163+
# Note this overwrote the bits generated in prepare_build
164+
# for image_json. In the future we expect to split prepare_build
165+
# into prepare_ostree_build and prepare_diskimage_build; the
166+
# latter path would only run this.
167+
image_json=${workdir}/tmp/image.json
168+
166169
# Grab a few values from $image_json
167170
deploy_via_container=$(getconfig_def "deploy-via-container" "" "${image_json}")
168171
extra_kargs="$(python3 -c 'import sys, json; args = json.load(sys.stdin)["extra-kargs"]; print(" ".join(args))' < "${image_json}")"
@@ -177,7 +180,7 @@ generate_runvm_osbuild_config() {
177180
echo "Estimating disk size..." &>2
178181
# The additional 35% here is obviously a hack, but we can't easily completely fill the filesystem,
179182
# and doing so has apparently negative performance implications.
180-
ostree_size_json="$(/usr/lib/coreos-assembler/estimate-commit-disk-size --repo "$ostree_repo" "$commit" --add-percent 35)"
183+
ostree_size_json="$(/usr/lib/coreos-assembler/estimate-commit-disk-size --repo "$ostree_repo" "$ostree_commit" --add-percent 35)"
181184
rootfs_size_mb="$(jq '."estimate-mb".final' <<< "${ostree_size_json}")"
182185
# The minimum size of a disk image we'll need will be the rootfs_size
183186
# estimate plus the size of the non-root partitions. We'll use this

0 commit comments

Comments
 (0)