flatcar-scripts/build_library/set_lsb_release
Michael Marineau 8244c7a260 cleanup(set_lsb_release): Rework release config setup
- Remove custom COREOS_* attributes from /etc/lsb-release
- Move dev image logic to dev_image_util
  For extra fun fix detection of local host URL for devserver.
- Remove weirdly verbose "DESCRIPTION" format.
- Add COREOS_RELEASE_BOARD back to /usr/share/coreos/release
  This is mostly just so update_engine and gmerge report the correct
  board name to devserver, informative-only on prod images.
- Remove version info from /etc/gentoo-release
- Switch from 'track' to 'group' terminology.
2014-03-19 15:56:21 -07:00

81 lines
2.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="alpha"
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 group "" "The default update group for update_engine."
# 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"
COREOS_VERSION_AUSERVER=""
if [[ -n "${FLAGS_group}" ]]; then
if [[ "${FLAGS_board}" == "amd64-usr" ]]; then
COREOS_VERSION_AUSERVER="http://public.roller.core-os.net/v1/update/"
elif [[ "${FLAGS_board}" == "amd64-generic" ]]; then
COREOS_VERSION_AUSERVER="https://api.core-os.net/v1/update/"
fi
fi
# DISTRIB_* are the standard lsb-release names
sudo mkdir -p "${ROOT_FS_DIR}/usr/share/coreos" "${ROOT_FS_DIR}/etc"
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/lsb-release" <<EOF
DISTRIB_ID=$COREOS_VERSION_NAME
DISTRIB_RELEASE=$COREOS_VERSION_STRING
DISTRIB_CODENAME="Bear Creek Manor"
DISTRIB_DESCRIPTION="$COREOS_VERSION_NAME $COREOS_VERSION_STRING"
EOF
sudo ln -sf "../usr/share/coreos/lsb-release" "${ROOT_FS_DIR}/etc/lsb-release"
# 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")
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/os-release" <<EOF
NAME=$COREOS_VERSION_NAME
ID=$OS_ID
VERSION=$COREOS_VERSION_STRING
VERSION_ID=$COREOS_VERSION_ID
BUILD_ID=$COREOS_BUILD_ID
PRETTY_NAME="$COREOS_VERSION_NAME $COREOS_VERSION_STRING"
ANSI_COLOR="1;32"
HOME_URL="http://www.coreos.com/"
EOF
sudo ln -sf "../usr/share/coreos/os-release" "${ROOT_FS_DIR}/etc/os-release"
# Create the defaults for the coreos configuration files in the usr directory
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/release" <<EOF
COREOS_RELEASE_VERSION=$COREOS_VERSION_STRING
COREOS_RELEASE_BOARD=$FLAGS_board
EOF
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/update.conf" <<EOF
SERVER=$COREOS_VERSION_AUSERVER
GROUP=$FLAGS_group
EOF
# For old versions of vagrant
sudo_clobber "${ROOT_FS_DIR}/etc/gentoo-release" <<<"$COREOS_VERSION_NAME"