build_image: fix generation of version.txt

The generation of version.txt was the only thing depending on sourcing
the deprecated BUILD, BRANCH, and PATCH values from version.txt which
common.sh no longer does since 0b6acf86. Derive them instead.
This commit is contained in:
Michael Marineau 2015-12-02 12:31:01 -08:00
parent ec58813496
commit f6064d52e8
2 changed files with 18 additions and 3 deletions

View File

@ -182,10 +182,11 @@ then
fi fi
# Write out a version.txt file, this will be used by image_to_vm.sh # Write out a version.txt file, this will be used by image_to_vm.sh
split_ver "${COREOS_VERSION_ID}" SPLIT
tee "${BUILD_DIR}/version.txt" <<EOF tee "${BUILD_DIR}/version.txt" <<EOF
COREOS_BUILD=${COREOS_BUILD} COREOS_BUILD=${SPLIT[0]}
COREOS_BRANCH=${COREOS_BRANCH} COREOS_BRANCH=${SPLIT[1]}
COREOS_PATCH=${COREOS_PATCH} COREOS_PATCH=${SPLIT[2]}
COREOS_VERSION=${COREOS_VERSION_STRING} COREOS_VERSION=${COREOS_VERSION_STRING}
COREOS_VERSION_ID=${COREOS_VERSION_ID} COREOS_VERSION_ID=${COREOS_VERSION_ID}
COREOS_BUILD_ID="${COREOS_BUILD_ID}" COREOS_BUILD_ID="${COREOS_BUILD_ID}"

View File

@ -172,6 +172,20 @@ cmp_ver() {
return $? return $?
} }
# Split a semver into a 3 item array (major minor patch)
# Usage: split_ver 1.2.3 NAME
split_ver() {
local v="$1" n="$2"
v="${v%%-*}" # strip off pre-release suffix
v="${v%%+*}" # strip off build id suffix
v="${v//./ }"
local -a a="(${v})"
if [[ ${#a[@]} -ne 3 ]]; then
die "Invalid version string '$1'"
fi
declare -g -a ${n}="(${v})"
}
# repo source root inside the chroot, usually mounted from the outside. # repo source root inside the chroot, usually mounted from the outside.
CHROOT_TRUNK_DIR="/mnt/host/source" CHROOT_TRUNK_DIR="/mnt/host/source"