Skip to content

Commit

Permalink
sysext_prod_builder: fix build id mismatch
Browse files Browse the repository at this point in the history
This change fixes a version mismatch of FLATCAR_BUILD_ID when performing
a dev build of an existing release tag. The build ID is part of the
version string of dev builds, separated by a "+" from the main version.
If common.sh detects a dev build (COREOS_OFFICIAL != 1) and
FLATCAR_BUILD_ID is empty, common.sh will generate a new ID based on a
timestamp.

For official releases, FLATCAR_BUILD_ID is not set in version.txt. A dev
build of a release tag would make common.sh generate a new ID each time
it is sourced by different processes. build_image sources common.sh
first, and writes the resulting version string the OS image's
os-release file. build_sysext runs later and also sources common.sh,
leading its version check to fail as its own VERSION now differs from
the version of the OS image it's supposed to generate sysexts for.

This change reads BUILD_ID from the OS image rootfs in
sysext_prod_builder and exports FLATCAR_BUILD_ID accordingly before
calling build_sysext. Hence FLATCAR_BUILD_ID is not empty, so common.sh
in build_sysext will not re-generate it.

Signed-off-by: Thilo Fromm <thilofromm@microsoft.com>
  • Loading branch information
t-lo committed Jun 24, 2024
1 parent b765699 commit 4da0276
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion build_library/sysext_prod_builder
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ create_prod_sysext() {

info "${msg}."

sudo "${SCRIPTS_DIR}/build_sysext" \
# Pass the build ID extracted from root FS to build_sysext. This prevents common.sh
# in build_sysext to generate a (timestamp based) build ID during a DEV build of a
# release tag (which breaks its version check).
sudo "FLATCAR_BUILD_ID=$FLATCAR_BUILD_ID" "${SCRIPTS_DIR}/build_sysext" \
--board="${BOARD}" \
--image_builddir="${workdir}/sysext-build" \
--squashfs_base="${base_sysext}" \
Expand Down Expand Up @@ -104,6 +107,13 @@ mkdir "${sysext_workdir}" "${sysext_output_dir}"
info "creating temporary base OS squashfs"
sudo mksquashfs "${root_fs_dir}" "${sysext_base}" -noappend -xattrs-exclude '^btrfs.'

# Set build ID from root fs for later use by create_prod_sysext().
# This prevents common.sh in build_sysext to generate its own build ID which might cause
# its build ID check to fail.
unset FLATCAR_BUILD_ID
FLATCAR_BUILD_ID=$(source "${root_fs_dir}/usr/lib/os-release" && echo -n "$BUILD_ID")
export FLATCAR_BUILD_ID

# Build sysexts on top of root fs and mount sysexts' squashfs + pkginfo squashfs
# for combined overlay later.
prev_pkginfo=""
Expand Down

0 comments on commit 4da0276

Please sign in to comment.