mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
fix(scripts): Cleanup build version handling.
A few things here: - Source manifests/version.txt directly instead of coreos-version.sh - Remove Chrome branch from target image directory names. - Use proper version instead of timestap for catalyst builds. - Move lsb_release script from coreos-overlay to build_library.
This commit is contained in:
parent
be2bdaaecf
commit
2482291e7d
@ -58,9 +58,6 @@ eval set -- "${FLAGS_ARGV}"
|
|||||||
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
|
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
|
||||||
switch_to_strict_mode
|
switch_to_strict_mode
|
||||||
|
|
||||||
# Determine build version.
|
|
||||||
OVERLAY_CHROMEOS_DIR="${SRC_ROOT}/third_party/coreos-overlay/coreos"
|
|
||||||
. "${OVERLAY_CHROMEOS_DIR}/config/coreos_version.sh" || exit 1
|
|
||||||
# N.B. Ordering matters for some of the libraries below, because
|
# N.B. Ordering matters for some of the libraries below, because
|
||||||
# some of the files contain initialization used by later files.
|
# some of the files contain initialization used by later files.
|
||||||
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
|
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
|
||||||
|
@ -90,9 +90,6 @@ eval set -- "${FLAGS_ARGV}"
|
|||||||
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
|
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
|
||||||
switch_to_strict_mode
|
switch_to_strict_mode
|
||||||
|
|
||||||
# Determine build version.
|
|
||||||
OVERLAY_CHROMEOS_DIR="${SRC_ROOT}/third_party/coreos-overlay/coreos"
|
|
||||||
. "${OVERLAY_CHROMEOS_DIR}/config/coreos_version.sh" || exit 1
|
|
||||||
# N.B. Ordering matters for some of the libraries below, because
|
# N.B. Ordering matters for some of the libraries below, because
|
||||||
# some of the files contain initialization used by later files.
|
# some of the files contain initialization used by later files.
|
||||||
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
|
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
|
||||||
|
@ -181,7 +181,7 @@ create_base_container() {
|
|||||||
emerge_to_image --root="${root_fs_dir}" ${BASE_PACKAGE}
|
emerge_to_image --root="${root_fs_dir}" ${BASE_PACKAGE}
|
||||||
|
|
||||||
# Set /etc/lsb-release on the image.
|
# Set /etc/lsb-release on the image.
|
||||||
"${OVERLAY_CHROMEOS_DIR}/scripts/cros_set_lsb_release" \
|
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
|
||||||
--root="${root_fs_dir}" \
|
--root="${root_fs_dir}" \
|
||||||
--board="${BOARD}"
|
--board="${BOARD}"
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ create_base_image() {
|
|||||||
"${root_fs_dir}/var"
|
"${root_fs_dir}/var"
|
||||||
|
|
||||||
# Set /etc/lsb-release on the image.
|
# Set /etc/lsb-release on the image.
|
||||||
"${OVERLAY_CHROMEOS_DIR}/scripts/cros_set_lsb_release" \
|
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
|
||||||
--root="${root_fs_dir}" \
|
--root="${root_fs_dir}" \
|
||||||
--board="${BOARD}"
|
--board="${BOARD}"
|
||||||
|
|
||||||
|
@ -11,12 +11,10 @@
|
|||||||
|
|
||||||
# Use canonical path since some tools (e.g. mount) do not like symlinks.
|
# Use canonical path since some tools (e.g. mount) do not like symlinks.
|
||||||
# Append build attempt to output directory.
|
# Append build attempt to output directory.
|
||||||
IMAGE_SUBDIR="R${CHROME_BRANCH}"
|
|
||||||
if [ -z "${FLAGS_version}" ]; then
|
if [ -z "${FLAGS_version}" ]; then
|
||||||
IMAGE_SUBDIR="${IMAGE_SUBDIR}-${CHROMEOS_VERSION_STRING}-a\
|
IMAGE_SUBDIR="${COREOS_VERSION_STRING}-a${FLAGS_build_attempt}"
|
||||||
${FLAGS_build_attempt}"
|
|
||||||
else
|
else
|
||||||
IMAGE_SUBDIR="${IMAGE_SUBDIR}-${FLAGS_version}"
|
IMAGE_SUBDIR="${FLAGS_version}"
|
||||||
fi
|
fi
|
||||||
BUILD_DIR="${FLAGS_output_root}/${BOARD}/${IMAGE_SUBDIR}"
|
BUILD_DIR="${FLAGS_output_root}/${BOARD}/${IMAGE_SUBDIR}"
|
||||||
OUTSIDE_OUTPUT_DIR="../build/images/${BOARD}/${IMAGE_SUBDIR}"
|
OUTSIDE_OUTPUT_DIR="../build/images/${BOARD}/${IMAGE_SUBDIR}"
|
||||||
|
76
build_library/set_lsb_release
Executable file
76
build_library/set_lsb_release
Executable file
@ -0,0 +1,76 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
||||||
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
# Script to set /etc/lsb-release on the root file system. This script is run by
|
||||||
|
# build_image inside chroot.
|
||||||
|
|
||||||
|
SCRIPT_ROOT=$(readlink -f $(dirname "$0")/..)
|
||||||
|
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
||||||
|
|
||||||
|
# Flags
|
||||||
|
DEFINE_string board "" "The board to build an image for."
|
||||||
|
DEFINE_string root "" "The root file system to write /etc/lsb-release to."
|
||||||
|
|
||||||
|
# Parse command line
|
||||||
|
FLAGS "$@" || exit 1
|
||||||
|
eval set -- "${FLAGS_ARGV}"
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ROOT_FS_DIR="$FLAGS_root"
|
||||||
|
[ -n "$ROOT_FS_DIR" ] || die "--root is required."
|
||||||
|
[ -d "$ROOT_FS_DIR" ] || die "Root FS does not exist? ($ROOT_FS_DIR)"
|
||||||
|
|
||||||
|
COREOS_VERSION_NAME="CoreOS"
|
||||||
|
COREOS_VERSION_AUSERVER=\
|
||||||
|
${COREOS_VERSION_AUSERVER:-"http://$(hostname --fqdn):8080/update"}
|
||||||
|
COREOS_VERSION_DEVSERVER=\
|
||||||
|
${COREOS_VERSION_DEVSERVER:-"http://$(hostname --fqdn):8080"}
|
||||||
|
|
||||||
|
# Official builds must set COREOS_OFFICIAL=1.
|
||||||
|
if [ ${COREOS_OFFICIAL:-0} = 1 ]; then
|
||||||
|
# Official builds (i.e., buildbot)
|
||||||
|
COREOS_VERSION_TRACK="dev-channel"
|
||||||
|
COREOS_VERSION_NAME="CoreOS"
|
||||||
|
COREOS_VERSION_DESCRIPTION="${COREOS_VERSION_STRING} (Official Build) \
|
||||||
|
${COREOS_VERSION_TRACK} $FLAGS_board test"
|
||||||
|
COREOS_VERSION_AUSERVER="https://api.core-os.net/v1/update/"
|
||||||
|
COREOS_VERSION_DEVSERVER=""
|
||||||
|
elif [ "$USER" = "chrome-bot" ]; then
|
||||||
|
# Continuous builder
|
||||||
|
COREOS_VERSION_TRACK="buildbot-build"
|
||||||
|
COREOS_VERSION_DESCRIPTION="${COREOS_VERSION_STRING} (Continuous Build \
|
||||||
|
- Builder: ${BUILDBOT_BUILD:-"N/A"}) $FLAGS_board"
|
||||||
|
else
|
||||||
|
# Developer hand-builds
|
||||||
|
COREOS_VERSION_TRACK=${COREOS_VERSION_TRACK:-"developer-build"}
|
||||||
|
COREOS_VERSION_DESCRIPTION="${COREOS_VERSION_STRING} (Developer Build \
|
||||||
|
- $USER) ${COREOS_VERSION_TRACK} $FLAGS_board"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set coreos-specific version numbers:
|
||||||
|
# COREOS_RELEASE_BOARD is the target board identifier.
|
||||||
|
# COREOS_RELEASE_DESCRIPTION is the version displayed by Chrome; see
|
||||||
|
# chrome/browser/chromeos/chromeos_version_loader.cc.
|
||||||
|
# COREOS_RELEASE_NAME is a human readable name for the build.
|
||||||
|
# COREOS_RELEASE_TRACK and COREOS_RELEASE_VERSION are used by the software
|
||||||
|
# update service.
|
||||||
|
sudo_append "${ROOT_FS_DIR}/etc/lsb-release" <<EOF
|
||||||
|
COREOS_RELEASE_BOARD=$FLAGS_board
|
||||||
|
COREOS_RELEASE_DESCRIPTION=$COREOS_VERSION_DESCRIPTION
|
||||||
|
COREOS_RELEASE_NAME=$COREOS_VERSION_NAME
|
||||||
|
COREOS_RELEASE_TRACK=$COREOS_VERSION_TRACK
|
||||||
|
COREOS_RELEASE_VERSION=$COREOS_VERSION_STRING
|
||||||
|
COREOS_AUSERVER=$COREOS_VERSION_AUSERVER
|
||||||
|
COREOS_DEVSERVER=$COREOS_VERSION_DEVSERVER
|
||||||
|
CHROMEOS_RELEASE_BOARD=$FLAGS_board
|
||||||
|
CHROMEOS_RELEASE_DESCRIPTION=$COREOS_VERSION_DESCRIPTION
|
||||||
|
CHROMEOS_RELEASE_NAME=$COREOS_VERSION_NAME
|
||||||
|
CHROMEOS_RELEASE_TRACK=$COREOS_VERSION_TRACK
|
||||||
|
CHROMEOS_RELEASE_VERSION=$COREOS_VERSION_STRING
|
||||||
|
CHROMEOS_AUSERVER=$COREOS_VERSION_AUSERVER
|
||||||
|
CHROMEOS_DEVSERVER=$COREOS_VERSION_DEVSERVER
|
||||||
|
EOF
|
12
common.sh
12
common.sh
@ -303,6 +303,18 @@ SRC_INTERNAL="${GCLIENT_ROOT}/src-internal"
|
|||||||
SCRIPTS_DIR="${SRC_ROOT}/scripts"
|
SCRIPTS_DIR="${SRC_ROOT}/scripts"
|
||||||
BUILD_LIBRARY_DIR="${SCRIPTS_DIR}/build_library"
|
BUILD_LIBRARY_DIR="${SCRIPTS_DIR}/build_library"
|
||||||
|
|
||||||
|
# Source COREOS_* from manifest for version information.
|
||||||
|
COREOS_VERSION_FILE="${GCLIENT_ROOT}/.repo/manifests/version.txt"
|
||||||
|
source "$COREOS_VERSION_FILE" || die "Cannot source $COREOS_VERSION_FILE"
|
||||||
|
|
||||||
|
# Official builds must set COREOS_OFFICIAL=1 to use an official version.
|
||||||
|
if [ ${COREOS_OFFICIAL:-0} -ne 1 ]; then
|
||||||
|
COREOS_PATCH=$(date +%Y_%m_%d_%H%M)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Full version string.
|
||||||
|
COREOS_VERSION_STRING="${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}"
|
||||||
|
|
||||||
# Load developer's custom settings. Default location is in scripts dir,
|
# Load developer's custom settings. Default location is in scripts dir,
|
||||||
# since that's available both inside and outside the chroot. By convention,
|
# since that's available both inside and outside the chroot. By convention,
|
||||||
# settings from this file are variables starting with 'CHROMEOS_'
|
# settings from this file are variables starting with 'CHROMEOS_'
|
||||||
|
@ -36,7 +36,7 @@ DEFINE_string coreos_overlay "${SRC_ROOT}/third_party/coreos-overlay" \
|
|||||||
"Path to the coreos-overlay git checkout."
|
"Path to the coreos-overlay git checkout."
|
||||||
DEFINE_string seed_tarball "${DEFAULT_SEED}" \
|
DEFINE_string seed_tarball "${DEFAULT_SEED}" \
|
||||||
"Path to an existing stage tarball to start from."
|
"Path to an existing stage tarball to start from."
|
||||||
DEFINE_string version $(date -u +%Y%m%d%H%M%S) \
|
DEFINE_string version "${COREOS_VERSION_STRING}" \
|
||||||
"Version to use for portage snapshot and stage tarballs."
|
"Version to use for portage snapshot and stage tarballs."
|
||||||
DEFINE_string profile "${DEFAULT_PROFILE}" \
|
DEFINE_string profile "${DEFAULT_PROFILE}" \
|
||||||
"Portage profile, may be prefixed with repo:"
|
"Portage profile, may be prefixed with repo:"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user