mirror of
https://github.com/flatcar/scripts.git
synced 2025-10-14 17:01:18 +02:00
I want to start including version info in SDK builds as an alternative scheme to the existing "chroot_version_hooks" system which always assumes freshly unpacked SDKs are the latest regardless of what version they actually were.
104 lines
3.7 KiB
Bash
Executable File
104 lines
3.7 KiB
Bash
Executable File
#!/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
|
|
|
|
PRODUCTION_DEFAULT=
|
|
if [[ "${COREOS_OFFICIAL:-0}" -eq 1 ]]; then
|
|
PRODUCTION_DEFAULT="dev-channel"
|
|
fi
|
|
|
|
# Flags
|
|
DEFINE_string board "" "The board to build an image for."
|
|
DEFINE_string root "" "The root file system to write /etc/lsb-release to."
|
|
DEFINE_string production_track "${PRODUCTION_DEFAULT}" \
|
|
"Use production values and a given track for update service."
|
|
|
|
# Parse command line
|
|
FLAGS "$@" || exit 1
|
|
eval set -- "${FLAGS_ARGV}"
|
|
|
|
switch_to_strict_mode
|
|
|
|
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"
|
|
if [[ -n "${FLAGS_production_track}" ]]; then
|
|
COREOS_VERSION_TRACK="${FLAGS_production_track}"
|
|
COREOS_VERSION_DESCRIPTION="${COREOS_VERSION_STRING} (Official Build) \
|
|
${COREOS_VERSION_TRACK} $FLAGS_board test"
|
|
if [[ "${FLAGS_production_track}" != "sdk" ]]; then
|
|
COREOS_VERSION_AUSERVER="https://api.core-os.net/v1/update/"
|
|
else
|
|
COREOS_VERSION_AUSERVER=""
|
|
fi
|
|
COREOS_VERSION_DEVSERVER=""
|
|
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"
|
|
: ${COREOS_VERSION_AUSERVER:="http://$(hostname --fqdn):8080/update"}
|
|
: ${COREOS_VERSION_DEVSERVER:="http://$(hostname --fqdn):8080"}
|
|
fi
|
|
|
|
# TODO(marineam): come up with a way to support continous integration builds,
|
|
# this would provide all the bells and whistles for 'master' branch images.
|
|
#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"
|
|
|
|
|
|
# Set coreos-specific version numbers:
|
|
# COREOS_RELEASE_BOARD is the target board identifier.
|
|
# COREOS_RELEASE_DESCRIPTION is the extended human readable form.
|
|
# 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.
|
|
# DISTRIB_* are the standard names for the same values.
|
|
sudo_clobber "${ROOT_FS_DIR}/etc/lsb-release" <<EOF
|
|
DISTRIB_ID=$COREOS_VERSION_NAME
|
|
DISTRIB_RELEASE=$COREOS_VERSION_STRING
|
|
DISTRIB_CODENAME="Black Squirrel's Revenge"
|
|
DISTRIB_DESCRIPTION="$COREOS_VERSION_NAME $COREOS_VERSION_DESCRIPTION"
|
|
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
|
|
EOF
|
|
|
|
# For things like python which read gentoo-release
|
|
sudo_clobber "${ROOT_FS_DIR}/etc/gentoo-release" <<EOF
|
|
$COREOS_VERSION_NAME release $COREOS_VERSION_STRING
|
|
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
|
|
PRETTY_NAME="$COREOS_VERSION_NAME $COREOS_VERSION_DESCRIPTION"
|
|
ANSI_COLOR="1;32"
|
|
HOME_URL="http://www.coreos.com/"
|
|
EOF
|