Merge pull request #487 from marineam/sdk

build_image: fix generation of version.txt
This commit is contained in:
Michael Marineau 2015-12-02 13:03:18 -08:00
commit dca121d83f
2 changed files with 18 additions and 3 deletions

View File

@ -182,10 +182,11 @@ then
fi
# 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
COREOS_BUILD=${COREOS_BUILD}
COREOS_BRANCH=${COREOS_BRANCH}
COREOS_PATCH=${COREOS_PATCH}
COREOS_BUILD=${SPLIT[0]}
COREOS_BRANCH=${SPLIT[1]}
COREOS_PATCH=${SPLIT[2]}
COREOS_VERSION=${COREOS_VERSION_STRING}
COREOS_VERSION_ID=${COREOS_VERSION_ID}
COREOS_BUILD_ID="${COREOS_BUILD_ID}"

View File

@ -172,6 +172,20 @@ cmp_ver() {
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.
CHROOT_TRUNK_DIR="/mnt/host/source"