Skip to content

Commit 42025ba

Browse files
committed
only use prepare_build in legacy build path
The new build path being the use of container tools to build CoreOS and the legacy path being the use of `rpm-ostree` directly where prepare_build is leveraged. Let's remove the use of `prepare_build` in all cases that aren't the legacy `cmd-fetch` and `cmd-build`.
1 parent c204c26 commit 42025ba

4 files changed

Lines changed: 19 additions & 15 deletions

File tree

cmd/clean.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ Delete all build artifacts. Use --all to also clean the cache/ directory.
3434
if err != nil {
3535
return err
3636
}
37-
// XXX: why do we need to prepare_build here?
38-
if _, err := sh.PrepareBuild(""); err != nil {
39-
return err
40-
}
4137

4238
if all {
4339
priv, err := sh.HasPrivileges()

src/cmd-osbuild

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,16 @@ postprocess_qemu_secex() {
165165
generate_runvm_osbuild_config() {
166166
local outfile=$1; shift
167167

168-
# reread these values from the build itself rather than rely on the ones loaded
169-
# by prepare_build since the config might've changed since then
170168
ostree_commit=$(meta_key ostree-commit)
171169
ostree_ref=$(meta_key ref)
172170
if [ "${ostree_ref}" = "None" ]; then
173171
ostree_ref=""
174172
fi
175173

176-
ostree_repo=${tmprepo}
174+
ostree_repo=${workdir}/tmp/repo
177175
# Ensure that we have the cached unpacked commit
178176
import_ostree_commit_for_build "${build}"
179-
# Note this overwrote the bits generated in prepare_build
180-
# for image_json. In the future we expect to split prepare_build
181-
# into prepare_ostree_build and prepare_diskimage_build; the
182-
# latter path would only run this.
177+
# Note this extracted the image.json file from the build.
183178
image_json=${workdir}/tmp/image.json
184179

185180
# Grab a few values from $image_json
@@ -342,7 +337,13 @@ main() {
342337
# shellcheck disable=SC2031
343338
export LIBGUESTFS_BACKEND=direct
344339
export IMAGE_TYPE="${platforms[0]}"
345-
prepare_build
340+
export workdir="${PWD}"
341+
export tmp_builddir="${workdir}/tmp/build${IMAGE_TYPE:+.$IMAGE_TYPE}"
342+
rm "${tmp_builddir}" -rf
343+
mkdir "${tmp_builddir}"
344+
345+
# Basic checks for the environment
346+
preflight_checks
346347

347348
if [ -z "${build}" ]; then
348349
build=$(get_latest_build)
@@ -364,8 +365,6 @@ main() {
364365
touch "${build_semaphore}"
365366
trap 'rm -f ${build_semaphore}' EXIT
366367

367-
# reread these values from the build itself rather than rely on the ones loaded
368-
# by prepare_build since the config might've changed since then
369368
name=$(meta_key name)
370369

371370
for platform in "${platforms[@]}"; do

src/cmd-supermin-shell

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ dn=$(dirname "$0")
55
# shellcheck source=src/cmdlib.sh
66
. "${dn}"/cmdlib.sh
77

8-
prepare_build
8+
export workdir="${PWD}"
9+
preflight_checks
910

1011
RUNVM_SHELL=1 runvm_with_cache "$@" -- bash

src/cmdlib.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ preflight_kvm() {
121121
fi
122122
}
123123

124+
preflight_checks() {
125+
preflight
126+
preflight_kvm
127+
}
128+
124129
# Use this for things like disabling fsync.
125130
# For more information, see the docs of `cosa init --transient`.
126131
is_transient() {
@@ -170,6 +175,9 @@ should_build_with_buildah() {
170175
return 1
171176
}
172177

178+
# Only used by legacy (not via container tools) path. Delete when we
179+
# have moved away from legacy building (i.e. delete or overwrite cmd-build
180+
# and delete cmd-fetch)
173181
prepare_build() {
174182
preflight
175183
preflight_kvm

0 commit comments

Comments
 (0)