fix(common): Define VERSION_ID and BUILD_ID

Scripts can now use COREOS_VERSION_ID to get the base version instead of
having to strip off the BUILD_ID that is appended for unofficial builds.
This commit is contained in:
Michael Marineau 2014-02-09 13:56:41 -08:00
parent 50e54cea85
commit 5524a7ce9a
3 changed files with 7 additions and 10 deletions

View File

@ -90,14 +90,12 @@ EOF
# Aaaannd for the new systemd world order
# os-release provides a separate build-id field, so split it from version
OS_ID=$(tr '[:upper:]' '[:lower:]' <<<"$COREOS_VERSION_NAME")
OS_VERSION_ID="${COREOS_VERSION_STRING%%+*}"
OS_BUILD_ID="${COREOS_VERSION_STRING#*+}"
sudo_clobber "${ROOT_FS_DIR}/etc/os-release" <<EOF
NAME=$COREOS_VERSION_NAME
ID=$OS_ID
VERSION=$COREOS_VERSION_STRING
VERSION_ID=$OS_VERSION_ID
BUILD_ID=$OS_BUILD_ID
VERSION_ID=$COREOS_VERSION_ID
BUILD_ID=$COREOS_BUILD_ID
PRETTY_NAME="$COREOS_VERSION_NAME $COREOS_VERSION_DESCRIPTION"
ANSI_COLOR="1;32"
HOME_URL="http://www.coreos.com/"

View File

@ -314,13 +314,15 @@ source "$COREOS_VERSION_FILE" || die "Cannot source version.txt"
# Official builds must set COREOS_OFFICIAL=1 to use an official version.
# Unofficial builds always appended the date/time as a build identifier.
# Also do not alter the version if using an alternate version.txt path.
COREOS_BUILD_ID=""
if [[ ${COREOS_OFFICIAL:-0} -ne 1 &&
"${COREOS_VERSION_FILE}" =~ /\.repo/manifests/version.txt ]]; then
COREOS_PATCH="${COREOS_PATCH}+$(date +%Y-%m-%d-%H%M)"
COREOS_BUILD_ID=$(date +%Y-%m-%d-%H%M)
fi
# Full version string.
COREOS_VERSION_STRING="${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}"
COREOS_VERSION_ID="${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}"
COREOS_VERSION_STRING="${COREOS_VERSION_ID}${COREOS_BUILD_ID++}${COREOS_BUILD_ID}"
# Calculate what today's build version should be, used by release
# scripts to provide a reasonable default value. The value is the number

View File

@ -7,15 +7,12 @@
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1
# Default to the current release for the new SDK version (minus dev build id)
DEFAULT_SDK="${COREOS_VERSION_STRING%+*}"
DEFINE_integer build "${TODAYS_VERSION}" \
"Branch name (aka 'build'), should be days since 2013-7-1"
DEFINE_integer branch 0 "Branch revision, normally 0"
DEFINE_integer patch 0 "Branch patch id, normally 0"
DEFINE_string track "dev-channel" "Set the given track to this new branch"
DEFINE_string sdk_version "${DEFAULT_SDK}" \
DEFINE_string sdk_version "${COREOS_VERSION_ID}" \
"Set the SDK version to use. (current: ${COREOS_SDK_VERSION})"
DEFINE_boolean push ${FLAGS_FALSE} "Push to public manifest repository."
DEFINE_string remote "origin" "Remote name or URL to push to."