Change names of env vars, paths, files, etc. to Flatcar

This commit is contained in:
Iago López Galeiras 2018-03-19 15:27:24 +01:00 committed by Dongsu Park
parent cf8e145926
commit f815ff8a43
47 changed files with 1981 additions and 224 deletions

View File

@ -33,7 +33,7 @@
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1
TYPE="coreos-sdk"
TYPE="flatcar-sdk"
. "${BUILD_LIBRARY_DIR}/catalyst.sh" || exit 1
@ -63,7 +63,7 @@ catalyst_init "$@"
check_gsutil_opts
if [[ "$STAGES" =~ stage4 ]]; then
info "Setting release to ${COREOS_VERSION}"
info "Setting release to ${FLATCAR_VERSION}"
rm -rf "${TEMPDIR}/stage4_overlay"
# need to setup the lib->lib64 symlink correctly
libdir=$(get_sdk_libdir)

View File

@ -94,7 +94,7 @@ case "${version}" in
"/usr/bin/docker-containerd-shim"
"/usr/bin/docker-proxy"
"/usr/bin/docker-runc"
"/usr/lib/coreos/dockerd"
"/usr/lib/flatcar/dockerd"
)
ebuild_aci_create "users.developer.core-os.net/skim/docker" \
"coreos_docker-${BOARD}-${version}_coreos.${aci_version}" \

View File

@ -166,16 +166,16 @@ fix_mtab
if [[ "${CONTAINER}" -eq 1 ]]; then
IMAGE_BUILD_TYPE="container"
create_dev_container "${COREOS_DEVELOPER_CONTAINER_NAME}" "${CONTAINER_LAYOUT}" "${FLAGS_group}" ${FLAGS_base_dev_pkg}
create_dev_container "${FLATCAR_DEVELOPER_CONTAINER_NAME}" "${CONTAINER_LAYOUT}" "${FLAGS_group}" ${FLAGS_base_dev_pkg}
fi
if [[ "${PROD_IMAGE}" -eq 1 ]]; then
IMAGE_BUILD_TYPE="prod"
create_prod_image ${COREOS_PRODUCTION_IMAGE_NAME} ${DISK_LAYOUT} ${FLAGS_group} ${FLAGS_base_pkg}
create_prod_image ${FLATCAR_PRODUCTION_IMAGE_NAME} ${DISK_LAYOUT} ${FLAGS_group} ${FLAGS_base_pkg}
if [[ ${FLAGS_generate_update} -eq ${FLAGS_TRUE} ]]; then
generate_update "${COREOS_PRODUCTION_IMAGE_NAME}" ${DISK_LAYOUT}
generate_update "${FLATCAR_PRODUCTION_IMAGE_NAME}" ${DISK_LAYOUT}
elif [[ ${FLAGS_extract_update} -eq ${FLAGS_TRUE} ]]; then
extract_update "${COREOS_PRODUCTION_IMAGE_NAME}" "${DISK_LAYOUT}"
extract_update "${FLATCAR_PRODUCTION_IMAGE_NAME}" "${DISK_LAYOUT}"
fi
fi
@ -186,15 +186,15 @@ then
fi
# Write out a version.txt file, this will be used by image_to_vm.sh
split_ver "${COREOS_VERSION_ID}" SPLIT
split_ver "${FLATCAR_VERSION_ID}" SPLIT
tee "${BUILD_DIR}/version.txt" <<EOF
COREOS_BUILD=${SPLIT[0]}
COREOS_BRANCH=${SPLIT[1]}
COREOS_PATCH=${SPLIT[2]}
COREOS_VERSION=${COREOS_VERSION}
COREOS_VERSION_ID=${COREOS_VERSION_ID}
COREOS_BUILD_ID="${COREOS_BUILD_ID}"
COREOS_SDK_VERSION=${COREOS_SDK_VERSION}
FLATCAR_BUILD=${SPLIT[0]}
FLATCAR_BRANCH=${SPLIT[1]}
FLATCAR_PATCH=${SPLIT[2]}
FLATCAR_VERSION=${FLATCAR_VERSION}
FLATCAR_VERSION_ID=${FLATCAR_VERSION_ID}
FLATCAR_BUILD_ID="${FLATCAR_BUILD_ID}"
FLATCAR_SDK_VERSION=${FLATCAR_SDK_VERSION}
EOF
upload_image "${BUILD_DIR}/version.txt"
@ -220,7 +220,7 @@ EOF
# Print out the images we generated.
if [[ "${PROD_IMAGE}" -eq 1 ]]; then
echo "CoreOS Production image created as ${COREOS_PRODUCTION_IMAGE_NAME}"
echo "Flatcar Production image created as ${FLATCAR_PRODUCTION_IMAGE_NAME}"
print_image_to_vm
fi

250
build_image.orig Executable file
View File

@ -0,0 +1,250 @@
#!/bin/bash
# Copyright (c) 2012 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 build a bootable keyfob-based chromeos system image from within
# a coreos setup. This assumes that all needed packages have been built into
# the given target's root with binary packages turned on. This script will
# build the Chrome OS image using only pre-built binary packages.
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1
# Script must run inside the chroot
assert_inside_chroot
assert_not_root_user
DEFAULT_GROUP=developer
# Developer-visible flags.
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to build an image for."
DEFINE_boolean getbinpkg "${FLAGS_FALSE}" \
"Download binary packages from remote repository."
DEFINE_string getbinpkgver "" \
"Use binary packages from a specific version."
DEFINE_boolean enable_rootfs_verification ${FLAGS_TRUE} \
"Default all bootloaders to use kernel-based root fs integrity checking."
DEFINE_string base_pkg "coreos-base/coreos" \
"The base portage package to base the build off of (only applies to prod images)"
DEFINE_string base_dev_pkg "coreos-base/coreos-dev" \
"The base portage package to base the build off of (only applies to dev containers)"
DEFINE_string torcx_manifest "${DEFAULT_BUILD_ROOT}/torcx/${DEFAULT_BOARD}/latest/torcx_manifest.json" \
"The torcx manifest describing torcx packages for this image (or blank for none)"
DEFINE_string torcx_root "${DEFAULT_BUILD_ROOT}/torcx" \
"Directory in which torcx packages can be found"
DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \
"Directory in which to place image result directories (named by version)"
DEFINE_string disk_layout "" \
"The disk layout type to use for this image."
DEFINE_string group "${DEFAULT_GROUP}" \
"The update group."
DEFINE_boolean generate_update "${FLAGS_FALSE}" \
"Generate update payload. (prod only)"
DEFINE_boolean extract_update "${FLAGS_TRUE}" \
"Extract the /usr partition for generating updates."
DEFINE_string developer_data "" \
"Insert a custom cloudinit file into the image."
# include upload options
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
FLAGS_HELP="USAGE: build_image [flags] [list of images to build].
This script is used to build a CoreOS image. CoreOS comes in many
different forms. This scripts can be used to build the following:
prod - Production image for CoreOS. This image is for booting.
container - Developer image with single filesystem, bootable by nspawn.
Examples:
build_image --board=<board> [prod] [container] - builds developer and production images.
...
"
show_help_if_requested "$@"
# The following options are advanced options, only available to those willing
# to read the source code. They are not shown in help output, since they are
# not needed for the typical developer workflow.
DEFINE_integer build_attempt 1 \
"The build attempt for this image build."
DEFINE_integer jobs "${NUM_JOBS}" \
"How many packages to build in parallel at maximum."
DEFINE_boolean replace ${FLAGS_FALSE} \
"Overwrite existing output, if any."
DEFINE_string version "" \
"Overrides version number in name to this version."
# Parse command line.
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV:-prod}"
# Only now can we die on error. shflags functions leak non-zero error codes,
# so will die prematurely if 'switch_to_strict_mode' is specified before now.
switch_to_strict_mode
check_gsutil_opts
# Patch around default values not being able to depend on other flags.
if [ "x${FLAGS_torcx_manifest}" = "x${DEFAULT_BUILD_ROOT}/torcx/${DEFAULT_BOARD}/latest/torcx_manifest.json" ]; then
FLAGS_torcx_manifest="${DEFAULT_BUILD_ROOT}/torcx/${FLAGS_board}/latest/torcx_manifest.json"
fi
# If downloading packages is enabled ensure the board is configured properly.
if [[ ${FLAGS_getbinpkg} -eq ${FLAGS_TRUE} ]]; then
"${SRC_ROOT}/scripts/setup_board" --board="${FLAGS_board}" \
--getbinpkgver="${FLAGS_getbinpkgver}" --regen_configs_only
fi
# N.B. Ordering matters for some of the libraries below, because
# some of the files contain initialization used by later files.
. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/prod_image_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/dev_container_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/test_image_content.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/torcx_manifest.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/vm_image_util.sh" || exit 1
PROD_IMAGE=0
CONTAINER=0
for arg in "$@"; do
case "${arg}" in
prod) PROD_IMAGE=1 ;;
container) CONTAINER=1 ;;
*) die_notrace "Unknown image type ${arg}" ;;
esac
done
# Check that the build root is sane.
if [[ ${skip_test_build_root} -ne 1 ]]; then
info "Checking build root"
test_image_content "${BOARD_ROOT}"
fi
# Handle existing directory.
if [[ -e "${BUILD_DIR}" ]]; then
if [[ ${FLAGS_replace} -eq ${FLAGS_TRUE} ]]; then
sudo rm -rf "${BUILD_DIR}"
else
error "Directory ${BUILD_DIR} already exists."
error "Use --build_attempt option to specify an unused attempt."
error "Or use --replace if you want to overwrite this directory."
die "Unwilling to overwrite ${BUILD_DIR}."
fi
fi
# Create the output directory and temporary mount points.
mkdir -p "${BUILD_DIR}"
DISK_LAYOUT="${FLAGS_disk_layout:-base}"
CONTAINER_LAYOUT="${FLAGS_disk_layout:-container}"
if [[ -n "${FLAGS_developer_data}" ]]; then
if [[ ! -f "${FLAGS_developer_data}" ]]; then
die_notrace "Developer data is not a file: ${FLAGS_developer_data}"
fi
info "Using developer cloudinit data: ${FLAGS_developer_data}"
elif [[ -s /etc/shared_user_passwd.txt ]]; then
FLAGS_developer_data="${BUILD_DIR}/developer_data"
info "Generating developer cloudinit with shared user password."
cat >"${FLAGS_developer_data}" <<EOF
#cloud-config
users:
- name: core
passwd: $(</etc/shared_user_passwd.txt)
EOF
fi
fix_mtab
<<<<<<< HEAD
if [[ "${CONTAINER}" -eq 1 ]]; then
IMAGE_BUILD_TYPE="container"
create_dev_container "${COREOS_DEVELOPER_CONTAINER_NAME}" "${CONTAINER_LAYOUT}" "${FLAGS_group}" ${FLAGS_base_dev_pkg}
=======
if [[ "${DEV_IMAGE}" -eq 1 ]]; then
IMAGE_BUILD_TYPE="dev"
create_dev_image ${FLATCAR_DEVELOPER_IMAGE_NAME} ${DEV_DISK_LAYOUT} ${FLAGS_group} ${FLAGS_base_dev_pkg}
if [[ ${FLAGS_extract_update} -eq ${FLAGS_TRUE} ]]; then
extract_update "${FLATCAR_DEVELOPER_IMAGE_NAME}" "${DEV_DISK_LAYOUT}"
fi
fi
if [[ "${CONTAINER}" -eq 1 ]]; then
IMAGE_BUILD_TYPE="container"
create_dev_image "${FLATCAR_DEVELOPER_CONTAINER_NAME}" "${CONTAINER_LAYOUT}" "${FLAGS_group}" ${FLAGS_base_dev_pkg}
>>>>>>> Change names of env vars, paths, files, etc. to Flatcar
fi
if [[ "${PROD_IMAGE}" -eq 1 ]]; then
IMAGE_BUILD_TYPE="prod"
create_prod_image ${FLATCAR_PRODUCTION_IMAGE_NAME} ${DISK_LAYOUT} ${FLAGS_group} ${FLAGS_base_pkg}
if [[ ${FLAGS_generate_update} -eq ${FLAGS_TRUE} ]]; then
generate_update "${FLATCAR_PRODUCTION_IMAGE_NAME}" ${DISK_LAYOUT}
elif [[ ${FLAGS_extract_update} -eq ${FLAGS_TRUE} ]]; then
extract_update "${FLATCAR_PRODUCTION_IMAGE_NAME}" "${DISK_LAYOUT}"
fi
fi
if [[ ${FLAGS_generate_update} -eq ${FLAGS_TRUE} ]] || \
[[ ${FLAGS_extract_update} -eq ${FLAGS_TRUE} ]]
then
zip_update_tools
fi
# Write out a version.txt file, this will be used by image_to_vm.sh
split_ver "${FLATCAR_VERSION_ID}" SPLIT
tee "${BUILD_DIR}/version.txt" <<EOF
FLATCAR_BUILD=${SPLIT[0]}
FLATCAR_BRANCH=${SPLIT[1]}
FLATCAR_PATCH=${SPLIT[2]}
FLATCAR_VERSION=${FLATCAR_VERSION}
FLATCAR_VERSION_ID=${FLATCAR_VERSION_ID}
FLATCAR_BUILD_ID="${FLATCAR_BUILD_ID}"
FLATCAR_SDK_VERSION=${FLATCAR_SDK_VERSION}
EOF
upload_image "${BUILD_DIR}/version.txt"
# Create a named symlink.
set_build_symlinks latest "${FLAGS_group}-latest"
echo "Done. Image(s) created in ${BUILD_DIR}"
print_image_to_vm() {
flags=
if [ $# = 1 ]; then
flags="--${1}_image"
fi
cat << EOF
To convert it to a virtual machine image, use:
./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD} ${flags}
The default type is $(get_default_vm_type ${BOARD}), see ./image_to_vm.sh --help for other options.
EOF
}
# Print out the images we generated.
if [[ "${PROD_IMAGE}" -eq 1 ]]; then
echo "Flatcar Production image created as ${FLATCAR_PRODUCTION_IMAGE_NAME}"
print_image_to_vm
fi
<<<<<<< HEAD
=======
if [[ "${DEV_IMAGE}" -eq 1 ]]; then
echo "Developer image created as ${FLATCAR_DEVELOPER_IMAGE_NAME}"
print_image_to_vm dev
fi
>>>>>>> Change names of env vars, paths, files, etc. to Flatcar
command_completed

View File

@ -12,7 +12,7 @@
# Use canonical path since some tools (e.g. mount) do not like symlinks.
# Append build attempt to output directory.
if [ -z "${FLAGS_version}" ]; then
IMAGE_SUBDIR="${FLAGS_group}-${COREOS_VERSION}-a${FLAGS_build_attempt}"
IMAGE_SUBDIR="${FLAGS_group}-${FLATCAR_VERSION}-a${FLAGS_build_attempt}"
else
IMAGE_SUBDIR="${FLAGS_group}-${FLAGS_version}"
fi
@ -66,7 +66,7 @@ extract_update() {
zip_update_tools() {
# There isn't a 'dev' variant of this zip, so always call it production.
local update_zip="coreos_production_update.zip"
local update_zip="flatcar_production_update.zip"
info "Generating update tools zip"
# Make sure some vars this script needs are exported
@ -465,9 +465,9 @@ finish_image() {
esac
# Copy kernel to support dm-verity boots
sudo mkdir -p "${root_fs_dir}/boot/coreos"
sudo mkdir -p "${root_fs_dir}/boot/flatcar"
sudo cp "${root_fs_dir}/usr/boot/vmlinuz" \
"${root_fs_dir}/boot/coreos/vmlinuz-a"
"${root_fs_dir}/boot/flatcar/vmlinuz-a"
# Record directories installed to the state partition.
# Explicitly ignore entries covered by existing configs.
@ -488,14 +488,14 @@ finish_image() {
# Create first-boot flag for grub and Ignition
info "Writing first-boot flag"
sudo_clobber "${root_fs_dir}/boot/coreos/first_boot" <<EOF
sudo_clobber "${root_fs_dir}/boot/flatcar/first_boot" <<EOF
If this file exists, Ignition will run and then delete the file.
EOF
fi
if [[ -n "${FLAGS_developer_data}" ]]; then
local data_path="/usr/share/coreos/developer_data"
local unit_path="usr-share-coreos-developer_data"
local data_path="/usr/share/flatcar/developer_data"
local unit_path="usr-share-flatcar-developer_data"
sudo cp "${FLAGS_developer_data}" "${root_fs_dir}/${data_path}"
systemd_enable "${root_fs_dir}" system-config.target \
"system-cloudinit@.service" "system-cloudinit@${unit_path}.service"
@ -535,7 +535,7 @@ EOF
# For arm64 an area between the EFI headers and the kernel text is used.
# Our modified GRUB extracts the hash and adds it to the cmdline.
printf %s "$(cat ${BUILD_DIR}/${image_name%.bin}_verity.txt)" | \
sudo dd of="${root_fs_dir}/boot/coreos/vmlinuz-a" conv=notrunc \
sudo dd of="${root_fs_dir}/boot/flatcar/vmlinuz-a" conv=notrunc \
seek=${verity_offset} count=64 bs=1 status=none
fi
@ -543,22 +543,22 @@ EOF
if [[ ${COREOS_OFFICIAL:-0} -ne 1 ]]; then
sudo sbsign --key /usr/share/sb_keys/DB.key \
--cert /usr/share/sb_keys/DB.crt \
"${root_fs_dir}/boot/coreos/vmlinuz-a"
sudo mv "${root_fs_dir}/boot/coreos/vmlinuz-a.signed" \
"${root_fs_dir}/boot/coreos/vmlinuz-a"
"${root_fs_dir}/boot/flatcar/vmlinuz-a"
sudo mv "${root_fs_dir}/boot/flatcar/vmlinuz-a.signed" \
"${root_fs_dir}/boot/flatcar/vmlinuz-a"
fi
if [[ -n "${image_kernel}" ]]; then
# copying kernel from vfat so ignore the permissions
cp --no-preserve=mode \
"${root_fs_dir}/boot/coreos/vmlinuz-a" \
"${root_fs_dir}/boot/flatcar/vmlinuz-a" \
"${BUILD_DIR}/${image_kernel}"
fi
if [[ -n "${pcr_policy}" ]]; then
mkdir -p "${BUILD_DIR}/pcrs"
${BUILD_LIBRARY_DIR}/generate_kernel_hash.sh \
"${root_fs_dir}/boot/coreos/vmlinuz-a" ${COREOS_VERSION} \
"${root_fs_dir}/boot/flatcar/vmlinuz-a" ${FLATCAR_VERSION} \
>"${BUILD_DIR}/pcrs/kernel.config"
fi
@ -596,7 +596,7 @@ EOF
if [[ -n "${pcr_policy}" ]]; then
${BUILD_LIBRARY_DIR}/generate_grub_hashes.py \
"${disk_img}" /usr/lib/grub/ "${BUILD_DIR}/pcrs" ${COREOS_VERSION}
"${disk_img}" /usr/lib/grub/ "${BUILD_DIR}/pcrs" ${FLATCAR_VERSION}
info "Generating $pcr_policy"
pushd "${BUILD_DIR}" >/dev/null

View File

@ -12,7 +12,7 @@
: ${TYPE:="coreos-sdk"}
: ${ARCH:=$(get_sdk_arch)}
: ${DEFAULT_CATALYST_ROOT:="${DEFAULT_BUILD_ROOT}/catalyst"}
: ${DEFAULT_SEED:=${COREOS_SDK_TARBALL_PATH}}
: ${DEFAULT_SEED:=${FLATCAR_SDK_TARBALL_PATH}}
: ${DEFAULT_PROFILE:=$(get_sdk_profile)}
# Set to something like "stage4" to restrict what to build
# FORCE_STAGES=
@ -34,7 +34,7 @@ DEFINE_string coreos_overlay "${SRC_ROOT}/third_party/coreos-overlay" \
"Path to the coreos-overlay git checkout."
DEFINE_string seed_tarball "${DEFAULT_SEED}" \
"Path to an existing stage tarball to start from."
DEFINE_string version "${COREOS_VERSION}" \
DEFINE_string version "${FLATCAR_VERSION}" \
"Version to use for portage snapshot and stage tarballs."
DEFINE_string profile "${DEFAULT_PROFILE}" \
"Portage profile, may be prefixed with repo:"
@ -196,7 +196,7 @@ catalyst_init() {
DISTDIR="$CATALYST_ROOT/distfiles"
# automatically download the current SDK if it is the seed tarball.
if [[ "$FLAGS_seed_tarball" == "${COREOS_SDK_TARBALL_PATH}" ]]; then
if [[ "$FLAGS_seed_tarball" == "${FLATCAR_SDK_TARBALL_PATH}" ]]; then
sdk_download_tarball
fi

View File

@ -116,7 +116,9 @@ IGNORE_SYMLINK = (
b"/etc/motd",
# Other
b"/etc/lsb-release" # set later in the build process
b"/etc/lsb-release", # set later in the build process
b"/usr/share/coreos", # set later in the build process
b"/etc/coreos" # set later in the build process
)

View File

@ -45,11 +45,11 @@ configure_pvgrub() {
sudo_clobber "${GRUB_DIR}/menu.lst.A" <<EOF
timeout 0
title CoreOS A Root
title Flatcar A Root
root (hd0,0)
kernel /syslinux/vmlinuz.A ${grub_args} ${slot_a_args}
title CoreOS B Root
title Flatcar B Root
root (hd0,0)
kernel /syslinux/vmlinuz.B ${grub_args} ${slot_b_args}
EOF

View File

@ -15,7 +15,7 @@ configure_dev_portage() {
sudo mkdir -p "$1/etc/portage/repos.conf"
sudo_clobber "$1/etc/portage/make.conf" <<EOF
# make.conf for CoreOS dev images
# make.conf for Flatcar dev images
ARCH=$(get_board_arch $BOARD)
CHOST=$(get_board_chost $BOARD)
@ -25,8 +25,8 @@ PKGDIR="/var/lib/portage/pkgs"
PORT_LOGDIR="/var/log/portage"
PORTDIR="/var/lib/portage/portage-stable"
PORTDIR_OVERLAY="/var/lib/portage/coreos-overlay"
PORTAGE_BINHOST="http://builds.developer.core-os.net/boards/${BOARD}/${COREOS_VERSION_ID}/pkgs/
http://builds.developer.core-os.net/boards/${BOARD}/${COREOS_VERSION_ID}/toolchain/"
PORTAGE_BINHOST="http://builds.developer.core-os.net/boards/${BOARD}/${FLATCAR_VERSION_ID}/pkgs/
http://builds.developer.core-os.net/boards/${BOARD}/${FLATCAR_VERSION_ID}/toolchain/"
EOF
sudo_clobber "$1/etc/portage/repos.conf/coreos.conf" <<EOF

View File

@ -0,0 +1,114 @@
# Copyright (c) 2012 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.
configure_dev_portage() {
# Need profiles at the bare minimum
local repo
for repo in portage-stable coreos-overlay; do
sudo mkdir -p "$1/var/lib/portage/${repo}"
sudo rsync -rtl --exclude=md5-cache \
"${SRC_ROOT}/third_party/${repo}/metadata" \
"${SRC_ROOT}/third_party/${repo}/profiles" \
"$1/var/lib/portage/${repo}"
done
sudo mkdir -p "$1/etc/portage/repos.conf"
sudo_clobber "$1/etc/portage/make.conf" <<EOF
# make.conf for Flatcar dev images
ARCH=$(get_board_arch $BOARD)
CHOST=$(get_board_chost $BOARD)
# Use /var/lib/portage instead of /usr/portage
DISTDIR="/var/lib/portage/distfiles"
PKGDIR="/var/lib/portage/pkgs"
PORT_LOGDIR="/var/log/portage"
PORTDIR="/var/lib/portage/portage-stable"
PORTDIR_OVERLAY="/var/lib/portage/coreos-overlay"
PORTAGE_BINHOST="http://builds.developer.core-os.net/boards/${BOARD}/${FLATCAR_VERSION_ID}/pkgs/
http://builds.developer.core-os.net/boards/${BOARD}/${FLATCAR_VERSION_ID}/toolchain/"
EOF
sudo_clobber "$1/etc/portage/repos.conf/coreos.conf" <<EOF
[DEFAULT]
main-repo = portage-stable
[gentoo]
disabled = true
[coreos]
location = /var/lib/portage/coreos-overlay
sync-type = git
sync-uri = https://github.com/coreos/coreos-overlay.git
[portage-stable]
location = /var/lib/portage/portage-stable
sync-type = git
sync-uri = https://github.com/coreos/portage-stable.git
EOF
# Now set the correct profile
sudo PORTAGE_CONFIGROOT="$1" ROOT="$1" \
PORTDIR="$1/var/lib/portage/portage-stable" \
PORTDIR_OVERLAY="$1/var/lib/portage/coreos-overlay" \
eselect profile set --force $(get_board_profile $BOARD)/dev
}
create_dev_container() {
local image_name=$1
local disk_layout=$2
local update_group=$3
local base_pkg="$4"
if [ -z "${base_pkg}" ]; then
echo "did not get base package!"
exit 1
fi
info "Building developer image ${image_name}"
local root_fs_dir="${BUILD_DIR}/rootfs"
local image_contents="${image_name%.bin}_contents.txt"
local image_packages="${image_name%.bin}_packages.txt"
local image_licenses="${image_name%.bin}_licenses.json"
start_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${update_group}"
set_image_profile dev
emerge_to_image "${root_fs_dir}" @system ${base_pkg}
run_ldconfig "${root_fs_dir}"
run_localedef "${root_fs_dir}"
write_packages "${root_fs_dir}" "${BUILD_DIR}/${image_packages}"
write_licenses "${root_fs_dir}" "${BUILD_DIR}/${image_licenses}"
# Setup portage for emerge and gmerge
<<<<<<< HEAD:build_library/dev_container_util.sh
configure_dev_portage "${root_fs_dir}"
=======
configure_dev_portage "${root_fs_dir}" "${devserver}"
sudo_append "${root_fs_dir}/etc/flatcar/update.conf" <<EOF
SERVER=${auserver}
# For gmerge
DEVSERVER=${devserver}
EOF
>>>>>>> Change names of env vars, paths, files, etc. to Flatcar:build_library/dev_image_util.sh
# Mark the image as a developer image (input to chromeos_startup).
# TODO(arkaitzr): Remove this file when applications no longer rely on it
# (crosbug.com/16648). The preferred way of determining developer mode status
# is via crossystem cros_debug?1 (checks boot args for "cros_debug").
sudo mkdir -p "${root_fs_dir}/root"
sudo touch "${root_fs_dir}/root/.dev_mode"
# Remount the system partition read-write by default.
# The remount services are provided by coreos-base/coreos-init
systemd_enable "${root_fs_dir}" "multi-user.target" "remount-usr.service"
finish_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${image_contents}"
upload_image -d "${BUILD_DIR}/${image_name}.bz2.DIGESTS" \
"${BUILD_DIR}/${image_contents}" \
"${BUILD_DIR}/${image_packages}" \
"${BUILD_DIR}/${image_licenses}" \
"${BUILD_DIR}/${image_name}"
}

View File

@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Expects BOARD, BUILD_DIR, BUILD_LIBRARY_DIR, and COREOS_VERSION in env.
# Expects BOARD, BUILD_DIR, BUILD_LIBRARY_DIR, and FLATCAR_VERSION in env.
# Copied from create_prod_image()
create_ebuild_aci_image() {
@ -60,7 +60,7 @@ ebuild_aci_create() {
local extra_version="${1?No extra version number given}"; shift
local pkg_files=( "${@}" )
local staging_image="coreos_pkg_staging_aci_stage.bin"
local staging_image="flatcar_pkg_staging_aci_stage.bin"
local ebuild_atom="=${pkg}-${version}"
@ -79,7 +79,7 @@ ebuild_aci_create() {
ebuild_aci_write_manifest \
"${aciroot}/manifest" \
"${aci_name}" \
"${version}_coreos.${extra_version}"
"${version}_flatcar.${extra_version}"
local pkg_files_in_rootfs=( "${pkg_files[@]/#/rootfs}" )

View File

@ -19,9 +19,9 @@ with open(filename, "rb") as f:
corelen = bytearray(diskboot)[508] | bytearray(diskboot)[509] << 8
f.seek(bootoffset+512)
core = f.read(corelen * 512)
hashes = {"4": {"binaryvalues": [{"values": [{"value": hashlib.sha1(boot).hexdigest(), "description": "CoreOS Grub boot.img %s" % version}]}]},
"8": {"binaryvalues" : [{"values": [{"value": hashlib.sha1(diskboot).hexdigest(), "description": "CoreOS Grub diskboot.img %s" % version}]}]},
"9": {"binaryvalues": [{"values": [{"value": hashlib.sha1(core).hexdigest(), "description": "CoreOS Grub core.img %s" % version}]}]}}
hashes = {"4": {"binaryvalues": [{"values": [{"value": hashlib.sha1(boot).hexdigest(), "description": "Flatcar Grub boot.img %s" % version}]}]},
"8": {"binaryvalues" : [{"values": [{"value": hashlib.sha1(diskboot).hexdigest(), "description": "Flatcar Grub diskboot.img %s" % version}]}]},
"9": {"binaryvalues": [{"values": [{"value": hashlib.sha1(core).hexdigest(), "description": "Flatcar Grub core.img %s" % version}]}]}}
with open(os.path.join(outputdir, "grub_loader.config"), "w") as f:
f.write(json.dumps(hashes, sort_keys=True))
@ -33,25 +33,25 @@ for folder, subs, files in os.walk(grubdir):
with open(os.path.join(folder, filename), "rb") as f:
mod = f.read()
value = hashlib.sha1(mod).hexdigest()
description = "CoreOS Grub %s %s" % (filename, version)
description = "Flatcar Grub %s %s" % (filename, version)
hashvalues.append({"value": value, "description": description})
with open(os.path.join(outputdir, "grub_modules.config"), "w") as f:
f.write(json.dumps({"9": {"binaryvalues": [{"prefix": "grub_module", "values": hashvalues}]}}))
with open(os.path.join(outputdir, "kernel_cmdline.config"), "w") as f:
f.write(json.dumps({"8": {"asciivalues": [{"prefix": "grub_kernel_cmdline", "values": [{"value": "rootflags=rw mount.usrflags=ro BOOT_IMAGE=/coreos/vmlinuz-[ab] mount.usr=PARTUUID=\S{36} rootflags=rw mount.usrflags=ro consoleblank=0 root=LABEL=ROOT (console=\S+)? (coreos.autologin=\S+)? verity.usrhash=\\S{64}", "description": "CoreOS kernel command line %s" % version}]}]}}))
f.write(json.dumps({"8": {"asciivalues": [{"prefix": "grub_kernel_cmdline", "values": [{"value": "rootflags=rw mount.usrflags=ro BOOT_IMAGE=/flatcar/vmlinuz-[ab] mount.usr=PARTUUID=\S{36} rootflags=rw mount.usrflags=ro consoleblank=0 root=LABEL=ROOT (console=\S+)? (flatcar.autologin=\S+)? verity.usrhash=\\S{64}", "description": "Flatcar kernel command line %s" % version}]}]}}))
commands = [{"value": '\[.*\]', "description": "CoreOS Grub configuration %s" % version},
{"value": 'gptprio.next -d usr -u usr_uuid', "description": "CoreOS Grub configuration %s" % version},
{"value": 'insmod all_video', "description": "CoreOS Grub configuration %s" % version},
{"value": 'linux /coreos/vmlinuz-[ab] rootflags=rw mount.usrflags=ro consoleblank=0 root=LABEL=ROOT (console=\S+)? (coreos.autologin=\S+)?', "description": "CoreOS Grub configuration %s" % version},
{"value": 'menuentry CoreOS \S+ --id=coreos\S* {', "description": "CoreOS Grub configuration %s" % version},
{"value": 'search --no-floppy --set randomize_disk_guid --disk-uuid 00000000-0000-0000-0000-000000000001', "description": "CoreOS Grub configuration %s" % version},
{"value": 'search --no-floppy --set oem --part-label OEM --hint hd0,gpt1', "description": "CoreOS Grub configuration %s" % version},
{"value": 'set .+', "description": "CoreOS Grub configuration %s" % version},
{"value": 'setparams CoreOS default', "description": "CoreOS Grub configuration %s" % version},
{"value": 'source (hd0,gpt6)/grub.cfg', "description": "CoreOS Grub configuration %s" % version}]
commands = [{"value": '\[.*\]', "description": "Flatcar Grub configuration %s" % version},
{"value": 'gptprio.next -d usr -u usr_uuid', "description": "Flatcar Grub configuration %s" % version},
{"value": 'insmod all_video', "description": "Flatcar Grub configuration %s" % version},
{"value": 'linux /flatcar/vmlinuz-[ab] rootflags=rw mount.usrflags=ro consoleblank=0 root=LABEL=ROOT (console=\S+)? (flatcar.autologin=\S+)?', "description": "Flatcar Grub configuration %s" % version},
{"value": 'menuentry Flatcar \S+ --id=flatcar\S* {', "description": "Flatcar Grub configuration %s" % version},
{"value": 'search --no-floppy --set randomize_disk_guid --disk-uuid 00000000-0000-0000-0000-000000000001', "description": "Flatcar Grub configuration %s" % version},
{"value": 'search --no-floppy --set oem --part-label OEM --hint hd0,gpt1', "description": "Flatcar Grub configuration %s" % version},
{"value": 'set .+', "description": "Flatcar Grub configuration %s" % version},
{"value": 'setparams Flatcar default', "description": "Flatcar Grub configuration %s" % version},
{"value": 'source (hd0,gpt6)/grub.cfg', "description": "Flatcar Grub configuration %s" % version}]
with open(os.path.join(outputdir, "grub_commands.config"), "w") as f:
f.write(json.dumps({"8": {"asciivalues": [{"prefix": "grub_cmd", "values": commands}]}}))

View File

@ -10,4 +10,4 @@ version=sys.argv[2]
with open(path, "rb") as f:
kernel = f.read()
print json.dumps({"9": {"binaryvalues": [{"prefix": "grub_linux", "values": [{"value": hashlib.sha1(kernel).hexdigest(), "description": "coreos-%s" % version}]}]}})
print json.dumps({"9": {"binaryvalues": [{"prefix": "grub_linux", "values": [{"value": hashlib.sha1(kernel).hexdigest(), "description": "flatcar-%s" % version}]}]}})

View File

@ -1,17 +1,17 @@
# Main GRUB config
# Set the prefix back to the correct value after we're done with memdisk
set prefix=($root)/coreos/grub
set prefix=($root)/flatcar/grub
# Load any and all video drivers.
# Required under UEFI to boot Linux with a working console.
insmod all_video
# Default menuentry id and boot timeout
set default="coreos"
set default="flatcar"
set timeout=1
# Default kernel args for root filesystem, console, and CoreOS.
# Default kernel args for root filesystem, console, and Flatcar.
set linux_root="root=LABEL=ROOT"
set linux_console=""
set first_boot=""
@ -66,20 +66,20 @@ if [ "$secure_boot" = "0" ]; then
fi
# Determine if this is a first boot.
if [ -f "($root)/coreos/first_boot" ]; then
set first_boot="coreos.first_boot=detected"
if [ -f "($root)/flatcar/first_boot" ]; then
set first_boot="flatcar.first_boot=detected"
fi
# Determine if the disk GUID needs to be randomized.
search --no-floppy --set randomize_disk_guid \
--disk-uuid 00000000-0000-0000-0000-000000000001
if [ -n "$randomize_disk_guid" ]; then
set randomize_disk_guid="coreos.randomize_disk_guid=00000000-0000-0000-0000-000000000001"
set randomize_disk_guid="flatcar.randomize_disk_guid=00000000-0000-0000-0000-000000000001"
fi
set oem=""
if [ -n "$oem_id" ]; then
set oem="coreos.oem.id=$oem_id"
set oem="flatcar.oem.id=$oem_id"
fi
# If no specific console has been set by the OEM then select based on
@ -133,28 +133,28 @@ function gptprio {
if [ $? -ne 0 -o -z "$usr_uuid" ]; then
echo
echo "Reading or updating the GPT failed!"
echo "Please file a bug with any messages above to CoreOS:"
echo " https://issues.coreos.com"
echo "Please file a bug with any messages above to Flatcar:"
echo " https://issues.flatcar-linux.org"
abort
fi
set gptprio_cmdline="@@MOUNTUSR@@=PARTUUID=$usr_uuid"
if [ "$usr_uuid" = "7130c94a-213a-4e5a-8e26-6cce9662f132" ]; then
set gptprio_kernel="/coreos/vmlinuz-a"
set gptprio_kernel="/flatcar/vmlinuz-a"
else
set gptprio_kernel="/coreos/vmlinuz-b"
set gptprio_kernel="/flatcar/vmlinuz-b"
fi
}
menuentry "CoreOS default" --id=coreos --unrestricted {
menuentry "Flatcar default" --id=flatcar {
gptprio
linux$suf $gptprio_kernel $gptprio_cmdline $linux_cmdline
}
menuentry "CoreOS USR-A" --id=coreos-a {
linux$suf /coreos/vmlinuz-a @@MOUNTUSR@@=PARTLABEL=USR-A $linux_cmdline
menuentry "Flatcar USR-A" --id=flatcar-a {
linux$suf /flatcar/vmlinuz-a @@MOUNTUSR@@=PARTLABEL=USR-A $linux_cmdline
}
menuentry "CoreOS USR-B" --id=coreos-b {
linux$suf /coreos/vmlinuz-b @@MOUNTUSR@@=PARTLABEL=USR-B $linux_cmdline
menuentry "Flatcar USR-B" --id=flatcar-b {
linux$suf /flatcar/vmlinuz-b @@MOUNTUSR@@=PARTLABEL=USR-B $linux_cmdline
}

View File

@ -36,8 +36,8 @@ switch_to_strict_mode
. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
# Our GRUB lives under coreos/grub so new pygrub versions cannot find grub.cfg
GRUB_DIR="coreos/grub/${FLAGS_target}"
# Our GRUB lives under flatcar/grub so new pygrub versions cannot find grub.cfg
GRUB_DIR="flatcar/grub/${FLAGS_target}"
# GRUB install location inside the SDK
GRUB_SRC="/usr/lib/grub/${FLAGS_target}"
@ -152,7 +152,7 @@ EOF
# this because we need conflicting default behaviors between verity and
# non-verity images.
GRUB_TEMP_DIR=$(mktemp -d)
if [[ ! -f "${ESP_DIR}/coreos/grub/grub.cfg.tar" ]]; then
if [[ ! -f "${ESP_DIR}/flatcar/grub/grub.cfg.tar" ]]; then
info "Generating grub.cfg memdisk"
if [[ ${FLAGS_verity} -eq ${FLAGS_TRUE} ]]; then
@ -166,7 +166,7 @@ if [[ ! -f "${ESP_DIR}/coreos/grub/grub.cfg.tar" ]]; then
sed 's/@@MOUNTUSR@@/mount.usr/' > "${GRUB_TEMP_DIR}/grub.cfg"
fi
sudo tar cf "${ESP_DIR}/coreos/grub/grub.cfg.tar" \
sudo tar cf "${ESP_DIR}/flatcar/grub/grub.cfg.tar" \
-C "${GRUB_TEMP_DIR}" "grub.cfg"
fi
@ -176,7 +176,7 @@ sudo grub-mkimage \
--format "${FLAGS_target}" \
--directory "${GRUB_SRC}" \
--config "${ESP_DIR}/${GRUB_DIR}/load.cfg" \
--memdisk "${ESP_DIR}/coreos/grub/grub.cfg.tar" \
--memdisk "${ESP_DIR}/flatcar/grub/grub.cfg.tar" \
--output "${ESP_DIR}/${GRUB_DIR}/${CORE_NAME}" \
"${CORE_MODULES[@]}"

View File

@ -14,7 +14,7 @@ start_modify_image() {
FLAGS_from="$(readlink -f "${FLAGS_from}")"
fi
local src_image="${FLAGS_from}/${COREOS_PRODUCTION_IMAGE_NAME}"
local src_image="${FLAGS_from}/${FLATCAR_PRODUCTION_IMAGE_NAME}"
if [[ ! -f "${src_image}" ]]; then
die_notrace "Source image does not exist: ${src_image}"
fi
@ -24,7 +24,7 @@ start_modify_image() {
die_notrace "Source version info does not exist: ${FLAGS_from}/version.txt"
fi
source "${FLAGS_from}/version.txt"
COREOS_VERSION_STRING="${COREOS_VERSION}"
FLATCAR_VERSION_STRING="${FLATCAR_VERSION}"
# Load after version.txt to set the correct output paths
. "${BUILD_LIBRARY_DIR}/toolchain_util.sh"
@ -44,7 +44,7 @@ start_modify_image() {
fi
# Create the output directory and temporary mount points.
DST_IMAGE="${BUILD_DIR}/${COREOS_PRODUCTION_IMAGE_NAME}"
DST_IMAGE="${BUILD_DIR}/${FLATCAR_PRODUCTION_IMAGE_NAME}"
ROOT_FS_DIR="${BUILD_DIR}/rootfs"
mkdir -p "${ROOT_FS_DIR}"
@ -52,10 +52,10 @@ start_modify_image() {
cp "${src_image}" "${DST_IMAGE}"
# Copy all extra useful things, these do not need to be modified.
local update_prefix="${COREOS_PRODUCTION_IMAGE_NAME%_image.bin}_update"
local production_prefix="${COREOS_PRODUCTION_IMAGE_NAME%.bin}"
local container_prefix="${COREOS_DEVELOPER_CONTAINER_NAME%.bin}"
local pcr_data="${COREOS_PRODUCTION_IMAGE_NAME%.bin}_pcr_policy.zip"
local update_prefix="${FLATCAR_PRODUCTION_IMAGE_NAME%_image.bin}_update"
local production_prefix="${FLATCAR_PRODUCTION_IMAGE_NAME%.bin}"
local container_prefix="${FLATCAR_DEVELOPER_CONTAINER_NAME%.bin}"
local pcr_data="${FLATCAR_PRODUCTION_IMAGE_NAME%.bin}_pcr_policy.zip"
EXTRA_FILES=(
"version.txt"
"${update_prefix}.bin"
@ -64,7 +64,7 @@ start_modify_image() {
"${production_prefix}_contents.txt"
"${production_prefix}_packages.txt"
"${production_prefix}_kernel_config.txt"
"${COREOS_DEVELOPER_CONTAINER_NAME}"
"${FLATCAR_DEVELOPER_CONTAINER_NAME}"
"${container_prefix}_contents.txt"
"${container_prefix}_packages.txt"
)

View File

@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Expects BOARD, BUILD_DIR, BUILD_LIBRARY_DIR, and COREOS_VERSION in env.
# Expects BOARD, BUILD_DIR, BUILD_LIBRARY_DIR, and FLATCAR_VERSION in env.
# There must be a manifest template included with the ebuild at
# files/manifest.in, which will have some variable values substituted before
@ -81,7 +81,7 @@ oem_aci_write_manifest() {
sudo cp "${manifest_template}" "${manifest}"
sudo sed "${manifest}" -i \
-e "s,@ACI_NAME@,${name}," \
-e "s,@ACI_VERSION@,${COREOS_VERSION}," \
-e "s,@ACI_VERSION@,${FLATCAR_VERSION}," \
-e "s,@ACI_ARCH@,${appc_arch},"
}
@ -113,7 +113,7 @@ oem_aci_create() {
"coreos.com/oem-${oem}"
# Write a tar ACI file containing the manifest and mounted rootfs contents.
sudo tar -C "${aciroot}" -czf "${BUILD_DIR}/coreos-oem-${oem}.aci" \
sudo tar -C "${aciroot}" -czf "${BUILD_DIR}/flatcar-oem-${oem}.aci" \
manifest rootfs
# Unmount the staging image, and delete it to save space.

View File

@ -11,8 +11,8 @@ UPLOAD_DEFAULT=${FLAGS_FALSE}
# Default upload root can be overridden from the environment.
_user="${USER}"
[[ ${USER} == "root" ]] && _user="${SUDO_USER}"
: ${COREOS_UPLOAD_ROOT:=gs://users.developer.core-os.net/${_user}}
: ${COREOS_TORCX_UPLOAD_ROOT:=${COREOS_UPLOAD_ROOT}/torcx}
: ${FLATCAR_UPLOAD_ROOT:=gs://users.developer.core-os.net/${_user}}
: ${FLATCAR_TORCX_UPLOAD_ROOT:=${FLATCAR_UPLOAD_ROOT}/torcx}
unset _user
IMAGE_ZIPPER="lbzip2 --compress --keep"
@ -22,7 +22,7 @@ DEFINE_boolean parallel ${FLAGS_TRUE} \
"Enable parallelism in gsutil."
DEFINE_boolean upload ${UPLOAD_DEFAULT} \
"Upload all packages/images via gsutil."
DEFINE_string upload_root "${COREOS_UPLOAD_ROOT}" \
DEFINE_string upload_root "${FLATCAR_UPLOAD_ROOT}" \
"Upload prefix, board/version/etc will be appended. Must be a gs:// URL."
DEFINE_string upload_path "" \
"Full upload path, overrides --upload_root. Must be a full gs:// URL."
@ -30,7 +30,7 @@ DEFINE_string download_root "" \
"HTTP download prefix, board/version/etc will be appended."
DEFINE_string download_path "" \
"HTTP download path, overrides --download_root."
DEFINE_string torcx_upload_root "${COREOS_TORCX_UPLOAD_ROOT}" \
DEFINE_string torcx_upload_root "${FLATCAR_TORCX_UPLOAD_ROOT}" \
"Tectonic torcx package and manifest Upload prefix. Must be a gs:// URL."
DEFINE_string tectonic_torcx_download_root "" \
"HTTP download prefix for tectonic torcx packages and manifests."
@ -155,7 +155,7 @@ upload_packages() {
[[ -n "${BOARD}" ]] || die "board_options.sh must be sourced first"
local board_packages="${1:-"${BOARD_ROOT}/packages"}"
local def_upload_path="${UPLOAD_ROOT}/boards/${BOARD}/${COREOS_VERSION}"
local def_upload_path="${UPLOAD_ROOT}/boards/${BOARD}/${FLATCAR_VERSION}"
sign_and_upload_files packages ${def_upload_path} "pkgs/" \
"${board_packages}"/*
}
@ -214,7 +214,7 @@ upload_image() {
fi
local log_msg=$(basename "$digests" .DIGESTS)
local def_upload_path="${UPLOAD_ROOT}/boards/${BOARD}/${COREOS_VERSION}"
local def_upload_path="${UPLOAD_ROOT}/boards/${BOARD}/${FLATCAR_VERSION}"
sign_and_upload_files "${log_msg}" "${def_upload_path}" "" "${uploads[@]}"
}
@ -233,9 +233,9 @@ download_image_url() {
download_path="${FLAGS_download_path%%/}"
elif [[ "${download_root}" = *release.core-os.net* ]]; then
# Official release download paths don't include the boards directory
download_path="${download_root%%/}/${BOARD}/${COREOS_VERSION}"
download_path="${download_root%%/}/${BOARD}/${FLATCAR_VERSION}"
else
download_path="${download_root%%/}/boards/${BOARD}/${COREOS_VERSION}"
download_path="${download_root%%/}/boards/${BOARD}/${FLATCAR_VERSION}"
fi
# Just in case download_root was set from UPLOAD_ROOT

View File

@ -143,14 +143,14 @@ get_board_binhost() {
shift
if [[ $# -eq 0 ]]; then
set -- "${COREOS_SDK_VERSION}" "${COREOS_VERSION_ID}"
set -- "${FLATCAR_SDK_VERSION}" "${FLATCAR_VERSION_ID}"
fi
for ver in "$@"; do
if [[ $toolchain_only -eq 0 ]]; then
echo "${COREOS_DEV_BUILDS}/boards/${board}/${ver}/pkgs/"
echo "${FLATCAR_DEV_BUILDS}/boards/${board}/${ver}/pkgs/"
fi
echo "${COREOS_DEV_BUILDS}/boards/${board}/${ver}/toolchain/"
echo "${FLATCAR_DEV_BUILDS}/boards/${board}/${ver}/toolchain/"
done
}
@ -172,12 +172,12 @@ get_sdk_libdir() {
get_sdk_binhost() {
local arch=$(get_sdk_arch) ver
if [[ $# -eq 0 ]]; then
set -- "${COREOS_SDK_VERSION}" "${COREOS_VERSION_ID}"
set -- "${FLATCAR_SDK_VERSION}" "${FLATCAR_VERSION_ID}"
fi
for ver in "$@"; do
echo "${COREOS_DEV_BUILDS}/sdk/${arch}/${ver}/pkgs/"
echo "${COREOS_DEV_BUILDS}/sdk/${arch}/${ver}/toolchain/"
echo "${FLATCAR_DEV_BUILDS}/sdk/${arch}/${ver}/pkgs/"
echo "${FLATCAR_DEV_BUILDS}/sdk/${arch}/${ver}/toolchain/"
done
}

View File

@ -355,7 +355,7 @@ set_vm_paths() {
VM_TMP_DIR="${dst_dir}/${dst_name}.vmtmpdir"
VM_TMP_IMG="${VM_TMP_DIR}/disk_image.bin"
VM_TMP_ROOT="${VM_TMP_DIR}/rootfs"
VM_NAME="$(_src_to_dst_name "${src_name}" "")-${COREOS_VERSION}"
VM_NAME="$(_src_to_dst_name "${src_name}" "")-${FLATCAR_VERSION}"
VM_README="${dst_dir}/$(_src_to_dst_name "${src_name}" ".README")"
# Make VM_NAME safe for use as a hostname
@ -441,8 +441,8 @@ setup_disk_image() {
sudo mount -o remount,ro "${VM_TMP_ROOT}"
VM_GROUP=$(grep --no-messages --no-filename ^GROUP= \
"${VM_TMP_ROOT}/usr/share/coreos/update.conf" \
"${VM_TMP_ROOT}/etc/coreos/update.conf" | \
"${VM_TMP_ROOT}/usr/share/flatcar/update.conf" \
"${VM_TMP_ROOT}/etc/flatcar/update.conf" | \
tail -n 1 | sed -e 's/^GROUP=//')
if [[ -z "${VM_GROUP}" ]]; then
die "Unable to determine update group for this image."
@ -485,7 +485,7 @@ install_oem_package() {
install_oem_aci() {
local oem_aci=$(_get_vm_opt OEM_ACI)
local aci_dir="${FLAGS_to}/oem-${oem_aci}-aci"
local aci_path="${aci_dir}/coreos-oem-${oem_aci}.aci"
local aci_path="${aci_dir}/flatcar-oem-${oem_aci}.aci"
local binpkgflags=(--nogetbinpkg)
[ -n "${oem_aci}" ] || return 0
@ -505,7 +505,7 @@ install_oem_aci() {
info "Installing ${oem_aci} OEM ACI"
sudo install -Dpm 0644 \
"${aci_path}" \
"${VM_TMP_ROOT}/usr/share/oem/coreos-oem-${oem_aci}.aci" ||
"${VM_TMP_ROOT}/usr/share/oem/flatcar-oem-${oem_aci}.aci" ||
die "Could not install ${oem_aci} OEM ACI"
}
@ -595,8 +595,8 @@ _write_cpio_common() {
echo "/.noupdate f 444 root root echo -n" >"${VM_TMP_DIR}/extra"
# Set correct group for PXE/ISO, which has no writeable /etc
echo /usr/share/coreos/update.conf f 644 root root \
"sed -e 's/GROUP=.*$/GROUP=${VM_GROUP}/' ${base_dir}/share/coreos/update.conf" \
echo /usr/share/flatcar/update.conf f 644 root root \
"sed -e 's/GROUP=.*$/GROUP=${VM_GROUP}/' ${base_dir}/share/flatcar/update.conf" \
>> "${VM_TMP_DIR}/extra"
# Build the squashfs, embed squashfs into a gzipped cpio
@ -616,7 +616,7 @@ _write_cpio_disk() {
local grub_name="$(_dst_name "_grub.efi")"
_write_cpio_common $@
# Pull the kernel and loader out of the filesystem
cp "${base_dir}"/boot/coreos/vmlinuz-a "${dst_dir}/${vmlinuz_name}"
cp "${base_dir}"/boot/flatcar/vmlinuz-a "${dst_dir}/${vmlinuz_name}"
local grub_arch
case $BOARD in
@ -624,7 +624,7 @@ _write_cpio_disk() {
arm64-usr) grub_arch="arm64-efi" ;;
esac
cp "${base_dir}/boot/coreos/grub/${grub_arch}/core.efi" "${dst_dir}/${grub_name}"
cp "${base_dir}/boot/flatcar/grub/${grub_arch}/core.efi" "${dst_dir}/${grub_name}"
VM_GENERATED_FILES+=( "${dst_dir}/${vmlinuz_name}" "${dst_dir}/${grub_name}" )
}
@ -636,22 +636,22 @@ _write_iso_disk() {
mkdir "${iso_target}"
pushd "${iso_target}" >/dev/null
mkdir isolinux syslinux coreos
_write_cpio_common "$1" "${iso_target}/coreos/cpio.gz"
cp "${base_dir}"/boot/vmlinuz "${iso_target}/coreos/vmlinuz"
mkdir isolinux syslinux flatcar
_write_cpio_common "$1" "${iso_target}/flatcar/cpio.gz"
cp "${base_dir}"/boot/vmlinuz "${iso_target}/flatcar/vmlinuz"
cp -R /usr/share/syslinux/* isolinux/
cat<<EOF > isolinux/isolinux.cfg
INCLUDE /syslinux/syslinux.cfg
EOF
cat<<EOF > syslinux/syslinux.cfg
default coreos
default flatcar
prompt 1
timeout 15
label coreos
label flatcar
menu default
kernel /coreos/vmlinuz
append initrd=/coreos/cpio.gz coreos.autologin
kernel /flatcar/vmlinuz
append initrd=/flatcar/cpio.gz flatcar.autologin
EOF
mkisofs -v -l -r -J -o $2 -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .
isohybrid $2
@ -1107,10 +1107,10 @@ EOF
cat >"${json}" <<EOF
{
"name": "coreos-${VM_GROUP}",
"description": "CoreOS ${VM_GROUP}",
"name": "flatcar-${VM_GROUP}",
"description": "Flatcar ${VM_GROUP}",
"versions": [{
"version": "${COREOS_VERSION_ID}",
"version": "${FLATCAR_VERSION_ID}",
"providers": [{
"name": "${provider}",
"url": "$(download_image_url "$(_dst_name ".box")")",
@ -1202,7 +1202,7 @@ vm_upload() {
cp "${digests}.asc" "${legacy_digests}.asc"
fi
local def_upload_path="${UPLOAD_ROOT}/boards/${BOARD}/${COREOS_VERSION}"
local def_upload_path="${UPLOAD_ROOT}/boards/${BOARD}/${FLATCAR_VERSION}"
upload_files "$(_dst_name)" "${def_upload_path}" "" "${legacy_uploads[@]}"
}

View File

@ -264,7 +264,7 @@ done
# order to get signed.
sign_and_upload_files \
'torcx manifest' \
"${UPLOAD_ROOT}/torcx/manifests/${BOARD}/${COREOS_VERSION}" \
"${UPLOAD_ROOT}/torcx/manifests/${BOARD}/${FLATCAR_VERSION}" \
"" \
"${manifest_path}"

View File

@ -233,7 +233,7 @@ get_gclient_root() {
# Populate the ENVIRONMENT_WHITELIST array.
load_environment_whitelist() {
ENVIRONMENT_WHITELIST=(
COREOS_BUILD_ID
FLATCAR_BUILD_ID
COREOS_OFFICIAL
GIT_AUTHOR_EMAIL
GIT_AUTHOR_NAME
@ -287,39 +287,39 @@ BUILD_LIBRARY_DIR="${SCRIPTS_DIR}/build_library"
REPO_CACHE_DIR="${REPO_ROOT}/.cache"
REPO_MANIFESTS_DIR="${REPO_ROOT}/.repo/manifests"
# Source COREOS_VERSION_ID from manifest.
# Source FLATCAR_VERSION_ID from manifest.
if [[ -f "${REPO_MANIFESTS_DIR}/version.txt" ]]; then
# The build id may be provided externally by the build system.
if [[ -n ${COREOS_BUILD_ID} ]]; then
if [[ -n ${FLATCAR_BUILD_ID} ]]; then
load_environment_var "${REPO_MANIFESTS_DIR}/version.txt" \
COREOS_VERSION_ID COREOS_SDK_VERSION
FLATCAR_VERSION_ID FLATCAR_SDK_VERSION
else
load_environment_var "${REPO_MANIFESTS_DIR}/version.txt" \
COREOS_VERSION_ID COREOS_BUILD_ID COREOS_SDK_VERSION
# Don't promote COREOS_BUILD_ID into an environment variable when it
FLATCAR_VERSION_ID FLATCAR_BUILD_ID FLATCAR_SDK_VERSION
# Don't promote FLATCAR_BUILD_ID into an environment variable when it
# didn't start as one, since we don't want it leaking into the SDK
# chroot environment via ENVIRONMENT_WHITELIST.
declare +x COREOS_BUILD_ID
declare +x FLATCAR_BUILD_ID
fi
: ${COREOS_BUILD_ID:=$(date +%Y-%m-%d-%H%M)}
: ${FLATCAR_BUILD_ID:=$(date +%Y-%m-%d-%H%M)}
elif [[ -f "${SCRIPT_LOCATION}/version.txt" ]]; then
# This only happens in update.zip where we must use the current build id.
load_environment_var "${SCRIPT_LOCATION}/version.txt" \
COREOS_VERSION_ID COREOS_BUILD_ID COREOS_SDK_VERSION
FLATCAR_VERSION_ID FLATCAR_BUILD_ID FLATCAR_SDK_VERSION
else
die "Unable to locate version.txt"
fi
# Official builds must set COREOS_OFFICIAL=1 to use an official version.
# Unofficial builds always appended the build identifier.
if [[ ${COREOS_OFFICIAL:-0} -ne 1 && -n "${COREOS_BUILD_ID}" ]]; then
COREOS_VERSION="${COREOS_VERSION_ID}+${COREOS_BUILD_ID}"
if [[ ${COREOS_OFFICIAL:-0} -ne 1 && -n "${FLATCAR_BUILD_ID}" ]]; then
FLATCAR_VERSION="${FLATCAR_VERSION_ID}+${FLATCAR_BUILD_ID}"
else
COREOS_VERSION="${COREOS_VERSION_ID}"
FLATCAR_VERSION="${FLATCAR_VERSION_ID}"
fi
# Compatibility alias
COREOS_VERSION_STRING="${COREOS_VERSION}"
FLATCAR_VERSION_STRING="${FLATCAR_VERSION}"
# Calculate what today's build version should be, used by release
# scripts to provide a reasonable default value. The value is the number
@ -389,8 +389,8 @@ fi
BUILD_DIR=
# Standard filenames
COREOS_DEVELOPER_CONTAINER_NAME="coreos_developer_container.bin"
COREOS_PRODUCTION_IMAGE_NAME="coreos_production_image.bin"
FLATCAR_DEVELOPER_CONTAINER_NAME="flatcar_developer_container.bin"
FLATCAR_PRODUCTION_IMAGE_NAME="flatcar_production_image.bin"
# -----------------------------------------------------------------------------
# Functions

965
common.sh.orig Normal file
View File

@ -0,0 +1,965 @@
#!/bin/bash
# Copyright (c) 2012 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.
# All scripts should die on error unless commands are specifically excepted
# by prefixing with '!' or surrounded by 'set +e' / 'set -e'.
# The number of jobs to pass to tools that can run in parallel (such as make
# and dpkg-buildpackage
if [[ -z ${NUM_JOBS} ]]; then
NUM_JOBS=$(grep -c "^processor" /proc/cpuinfo)
fi
# Ensure that any sub scripts we invoke get the max proc count.
export NUM_JOBS
# Make sure we have the location and name of the calling script, using
# the current value if it is already set.
: ${SCRIPT_LOCATION:=$(dirname "$(readlink -f "$0")")}
: ${SCRIPT_NAME:=$(basename "$0")}
# Detect whether we're inside a chroot or not
if [[ -e /etc/debian_chroot ]]; then
INSIDE_CHROOT=1
else
INSIDE_CHROOT=0
fi
# Determine and set up variables needed for fancy color output (if supported).
V_BOLD_RED=
V_BOLD_GREEN=
V_BOLD_YELLOW=
V_REVERSE=
V_VIDOFF=
if tput colors >&/dev/null; then
# order matters: we want VIDOFF last so that when we trace with `set -x`,
# our terminal doesn't bleed colors as bash dumps the values of vars.
V_BOLD_RED=$(tput bold; tput setaf 1)
V_BOLD_GREEN=$(tput bold; tput setaf 2)
V_BOLD_YELLOW=$(tput bold; tput setaf 3)
V_REVERSE=$(tput rev)
V_VIDOFF=$(tput sgr0)
fi
# Turn on bash debug support if available for backtraces.
shopt -s extdebug 2>/dev/null
# Output a backtrace all the way back to the raw invocation, suppressing
# only the _dump_trace frame itself.
_dump_trace() {
local j n p func src line args
p=${#BASH_ARGV[@]}
for (( n = ${#FUNCNAME[@]}; n > 1; --n )); do
func=${FUNCNAME[${n} - 1]}
src=${BASH_SOURCE[${n}]##*/}
line=${BASH_LINENO[${n} - 1]}
args=
if [[ -z ${BASH_ARGC[${n} -1]} ]]; then
args='(args unknown, no debug available)'
else
for (( j = 0; j < ${BASH_ARGC[${n} -1]}; ++j )); do
args="${args:+${args} }'${BASH_ARGV[$(( p - j - 1 ))]}'"
done
! (( p -= ${BASH_ARGC[${n} - 1]} ))
fi
if [[ ${n} == ${#FUNCNAME[@]} ]]; then
error "script called: ${0##*/} ${args}"
error "Backtrace: (most recent call is last)"
else
error "$(printf ' file %s, line %s, called: %s %s' \
"${src}" "${line}" "${func}" "${args}")"
fi
done
}
# Declare these asap so that code below can safely assume they exist.
_message() {
local prefix="$1${CROS_LOG_PREFIX:-${SCRIPT_NAME}}"
shift
if [[ $# -eq 0 ]]; then
echo -e "${prefix}:${V_VIDOFF}" >&2
return
fi
(
# Handle newlines in the message, prefixing each chunk correctly.
# Do this in a subshell to avoid having to track IFS/set -f state.
IFS="
"
set +f
set -- $*
IFS=' '
if [[ $# -eq 0 ]]; then
# Empty line was requested.
set -- ''
fi
for line in "$@"; do
echo -e "${prefix}: ${line}${V_VIDOFF}" >&2
done
)
}
info() {
_message "${V_BOLD_GREEN}INFO " "$*"
}
warn() {
_message "${V_BOLD_YELLOW}WARNING " "$*"
}
error() {
_message "${V_BOLD_RED}ERROR " "$*"
}
# For all die functions, they must explicitly force set +eu;
# no reason to have them cause their own crash if we're inthe middle
# of reporting an error condition then exiting.
die_err_trap() {
local command=$1 result=$2
set +e +u
# Per the message, bash misreports 127 as 1 during err trap sometimes.
# Note this fact to ensure users don't place too much faith in the
# exit code in that case.
set -- "Command '${command}' exited with nonzero code: ${result}"
if [[ ${result} -eq 1 ]] && [[ -z $(type -t ${command}) ]]; then
set -- "$@" \
'(Note bash sometimes misreports "command not found" as exit code 1 '\
'instead of 127)'
fi
_dump_trace
error
error "Command failed:"
DIE_PREFIX=' '
die_notrace "$@"
}
# Exit this script due to a failure, outputting a backtrace in the process.
die() {
set +e +u
_dump_trace
error
error "Error was:"
DIE_PREFIX=' '
die_notrace "$@"
}
# Exit this script w/out a backtrace.
die_notrace() {
set +e +u
if [[ $# -eq 0 ]]; then
set -- '(no error message given)'
fi
local line
for line in "$@"; do
error "${DIE_PREFIX}${line}"
done
exit 1
}
# Simple version comparison routine
# Note: not a true semver comparison and build revisions are ignored
cmp_ver() {
local rev a="${2%%+*}" b="${3%%+*}"
case "$1" in
le) rev="" ;;
ge) rev="--reverse" ;;
*) die "Invalid operator $1" ;;
esac
printf '%s\n%s\n' "$a" "$b" | sort --version-sort --check=quiet $rev
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"
# Construct a list of possible locations for the source tree. This list is
# based on various environment variables and globals that may have been set
# by the calling script.
get_gclient_root_list() {
if [[ ${INSIDE_CHROOT} -eq 1 ]]; then
echo "${CHROOT_TRUNK_DIR}"
fi
if [[ -n ${COMMON_SH} ]]; then echo "$(dirname "${COMMON_SH}")/../.."; fi
if [[ -n ${BASH_SOURCE} ]]; then echo "$(dirname "${BASH_SOURCE}")/../.."; fi
}
# Based on the list of possible source locations we set GCLIENT_ROOT if it is
# not already defined by looking for a src directory in each seach path
# location. If we do not find a valid looking root we error out.
get_gclient_root() {
if [[ -n ${GCLIENT_ROOT} ]]; then
return
fi
for path in $(get_gclient_root_list); do
if [[ -d ${path}/src ]]; then
GCLIENT_ROOT=${path}
break
fi
done
if [[ -z ${GCLIENT_ROOT} ]]; then
# Using dash or sh, we don't know where we are. $0 refers to the calling
# script, not ourselves, so that doesn't help us.
echo "Unable to determine location for common.sh. If you are sourcing"
echo "common.sh from a script run via dash or sh, you must do it in the"
echo "following way:"
echo ' COMMON_SH="$(dirname "$0")/../../scripts/common.sh"'
echo ' . "${COMMON_SH}"'
echo "where the first line is the relative path from your script to"
echo "common.sh."
exit 1
fi
}
# Populate the ENVIRONMENT_WHITELIST array.
load_environment_whitelist() {
ENVIRONMENT_WHITELIST=(
FLATCAR_BUILD_ID
COREOS_OFFICIAL
GIT_AUTHOR_EMAIL
GIT_AUTHOR_NAME
GIT_COMMITTER_EMAIL
GIT_COMMITTER_NAME
GIT_PROXY_COMMAND
GIT_SSH
RSYNC_PROXY
GNUPGHOME
GPG_AGENT_INFO
SSH_AGENT_PID
SSH_AUTH_SOCK
USE
all_proxy
ftp_proxy
http_proxy
https_proxy
no_proxy
)
}
load_environment_var() {
local file="$1" name value
shift
for name in "$@"; do
value=$(grep "^${name}=" "${file}" | sed 's|"||g')
export "${value}"
done
}
# Find root of source tree
get_gclient_root
# Canonicalize the directories for the root dir and the calling script.
# readlink is part of coreutils and should be present even in a bare chroot.
# This is better than just using
# FOO="$(cd ${FOO} ; pwd)"
# since that leaves symbolic links intact.
# Note that 'realpath' is equivalent to 'readlink -f'.
SCRIPT_LOCATION=$(readlink -f "${SCRIPT_LOCATION}")
GCLIENT_ROOT=$(readlink -f "${GCLIENT_ROOT}")
# TODO(marineam): I'm tempted to deprecate GCLIENT_ROOT, this isn't Google
# and even if it was the source is managed by 'repo', not 'gclient'
REPO_ROOT="${GCLIENT_ROOT}"
# Other directories should always be pathed down from GCLIENT_ROOT.
SRC_ROOT="${GCLIENT_ROOT}/src"
SRC_INTERNAL="${GCLIENT_ROOT}/src-internal"
SCRIPTS_DIR="${SRC_ROOT}/scripts"
BUILD_LIBRARY_DIR="${SCRIPTS_DIR}/build_library"
REPO_CACHE_DIR="${REPO_ROOT}/.cache"
REPO_MANIFESTS_DIR="${REPO_ROOT}/.repo/manifests"
# Source FLATCAR_VERSION_ID from manifest.
if [[ -f "${REPO_MANIFESTS_DIR}/version.txt" ]]; then
# The build id may be provided externally by the build system.
if [[ -n ${FLATCAR_BUILD_ID} ]]; then
load_environment_var "${REPO_MANIFESTS_DIR}/version.txt" \
FLATCAR_VERSION_ID FLATCAR_SDK_VERSION
else
load_environment_var "${REPO_MANIFESTS_DIR}/version.txt" \
FLATCAR_VERSION_ID FLATCAR_BUILD_ID FLATCAR_SDK_VERSION
# Don't promote FLATCAR_BUILD_ID into an environment variable when it
# didn't start as one, since we don't want it leaking into the SDK
# chroot environment via ENVIRONMENT_WHITELIST.
declare +x FLATCAR_BUILD_ID
fi
: ${FLATCAR_BUILD_ID:=$(date +%Y-%m-%d-%H%M)}
elif [[ -f "${SCRIPT_LOCATION}/version.txt" ]]; then
# This only happens in update.zip where we must use the current build id.
load_environment_var "${SCRIPT_LOCATION}/version.txt" \
FLATCAR_VERSION_ID FLATCAR_BUILD_ID FLATCAR_SDK_VERSION
else
die "Unable to locate version.txt"
fi
# Official builds must set COREOS_OFFICIAL=1 to use an official version.
# Unofficial builds always appended the build identifier.
if [[ ${COREOS_OFFICIAL:-0} -ne 1 && -n "${FLATCAR_BUILD_ID}" ]]; then
FLATCAR_VERSION="${FLATCAR_VERSION_ID}+${FLATCAR_BUILD_ID}"
else
FLATCAR_VERSION="${FLATCAR_VERSION_ID}"
fi
# Compatibility alias
FLATCAR_VERSION_STRING="${FLATCAR_VERSION}"
# Calculate what today's build version should be, used by release
# scripts to provide a reasonable default value. The value is the number
# of days since COREOS_EPOCH, Mon Jul 1 00:00:00 UTC 2013
readonly COREOS_EPOCH=1372636800
TODAYS_VERSION=$(( (`date +%s` - ${COREOS_EPOCH}) / 86400 ))
# Download URL prefix for SDK and board binary packages
: ${COREOS_DEV_BUILDS:=http://builds.developer.core-os.net}
# Load developer's custom settings. Default location is in scripts dir,
# since that's available both inside and outside the chroot. By convention,
# settings from this file are variables starting with 'CHROMEOS_'
: ${CHROMEOS_DEV_SETTINGS:=${SCRIPTS_DIR}/.chromeos_dev}
if [[ -f ${CHROMEOS_DEV_SETTINGS} ]]; then
# Turn on exit-on-error during custom settings processing
SAVE_OPTS=$(set +o)
switch_to_strict_mode
# Read settings
. "${CHROMEOS_DEV_SETTINGS}"
# Restore previous state of exit-on-error
eval "${SAVE_OPTS}"
fi
# Load shflags
# NOTE: This code snippet is in particular used by the au-generator (which
# stores shflags in ./lib/shflags/) and should not be touched.
if [[ -f ${SCRIPTS_DIR}/lib/shflags/shflags ]]; then
. "${SCRIPTS_DIR}/lib/shflags/shflags" || die "Couldn't find shflags"
else
. ./lib/shflags/shflags || die "Couldn't find shflags"
fi
# Our local mirror
DEFAULT_CHROMEOS_SERVER=${CHROMEOS_SERVER:-"http://build.chromium.org/mirror"}
# Upstream mirrors and build suites come in 2 flavors
# DEV - development chroot, used to build the chromeos image
# IMG - bootable image, to run on actual hardware
DEFAULT_DEV_MIRROR=${CHROMEOS_DEV_MIRROR:-"${DEFAULT_CHROMEOS_SERVER}/ubuntu"}
DEFAULT_DEV_SUITE=${CHROMEOS_DEV_SUITE:-"karmic"}
DEFAULT_IMG_MIRROR=${CHROMEOS_IMG_MIRROR:-"${DEFAULT_CHROMEOS_SERVER}/ubuntu"}
DEFAULT_IMG_SUITE=${CHROMEOS_IMG_SUITE:-"karmic"}
# Default location for chroot
DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"${GCLIENT_ROOT}/chroot"}
# All output files from build should go under ${DEFAULT_BUILD_ROOT}, so that
# they don't pollute the source directory.
DEFAULT_BUILD_ROOT=${CHROMEOS_BUILD_ROOT:-"${SRC_ROOT}/build"}
# Sets the default board variable for calling script.
if [[ -f ${GCLIENT_ROOT}/src/scripts/.default_board ]]; then
DEFAULT_BOARD=$(<"${GCLIENT_ROOT}/src/scripts/.default_board")
# Check for user typos like whitespace.
if [[ -n ${DEFAULT_BOARD//[a-zA-Z0-9-_]} ]]; then
die ".default_board: invalid name detected; please fix:" \
"'${DEFAULT_BOARD}'"
fi
fi
# Directory to store built images. Should be set by sourcing script when used.
BUILD_DIR=
# Standard filenames
<<<<<<< HEAD
COREOS_DEVELOPER_CONTAINER_NAME="coreos_developer_container.bin"
COREOS_PRODUCTION_IMAGE_NAME="coreos_production_image.bin"
=======
FLATCAR_DEVELOPER_IMAGE_NAME="flatcar_developer_image.bin"
FLATCAR_DEVELOPER_CONTAINER_NAME="flatcar_developer_container.bin"
FLATCAR_PRODUCTION_IMAGE_NAME="flatcar_production_image.bin"
>>>>>>> Change names of env vars, paths, files, etc. to Flatcar
# -----------------------------------------------------------------------------
# Functions
setup_board_warning() {
echo
echo "${V_REVERSE}================ WARNING =====================${V_VIDOFF}"
echo
echo "*** No default board detected in " \
"${GCLIENT_ROOT}/src/scripts/.default_board"
echo "*** Either run setup_board with default flag set"
echo "*** or echo |board_name| > ${GCLIENT_ROOT}/src/scripts/.default_board"
echo
}
is_nfs() {
[[ $(stat -f -L -c %T "$1") == "nfs" ]]
}
warn_if_nfs() {
if is_nfs "$1"; then
warn "$1 is on NFS. This is untested. You can send patches if it's broken."
fi
}
# Fail unless we're inside the chroot. This guards against messing up your
# workstation.
assert_inside_chroot() {
if [[ ${INSIDE_CHROOT} -ne 1 ]]; then
echo "This script must be run inside the chroot. Run this first:"
echo " cros_sdk"
exit 1
fi
}
# Fail if we're inside the chroot. This guards against creating or entering
# nested chroots, among other potential problems.
assert_outside_chroot() {
if [[ ${INSIDE_CHROOT} -ne 0 ]]; then
echo "This script must be run outside the chroot."
exit 1
fi
}
assert_not_root_user() {
if [[ ${UID:-$(id -u)} == 0 ]]; then
echo "This script must be run as a non-root user."
exit 1
fi
}
assert_root_user() {
if [[ ${UID:-$(id -u)} != 0 ]] || [[ ${SUDO_USER:-root} == "root" ]]; then
die_notrace "This script must be run using sudo from a non-root user."
fi
}
# We depend on some relatively modern kernel features, in particular a
# reasonably recent btrfs version is required to generate images.
# Current requirement: 3.7 added btrfs' extref incompat feature
assert_kernel_version() {
local req_kv="3.7"
local cur_kv=$(uname -r)
if ! cmp_ver ge "${cur_kv}" "${req_kv}"; then
die_notrace "Detected kernel ${cur_kv}, ${req_kv} or later is required"
fi
}
# Check that all arguments are flags; that is, there are no remaining arguments
# after parsing from shflags. Allow (with a warning) a single empty-string
# argument.
#
# TODO: fix buildbot so that it doesn't pass the empty-string parameter,
# then change this function.
#
# Usage: check_flags_only_and_allow_null_arg "$@" && set --
check_flags_only_and_allow_null_arg() {
local do_shift=1
if [[ $# -eq 1 ]] && [[ -z $1 ]]; then
echo "$0: warning: ignoring null argument" >&2
shift
do_shift=0
fi
if [[ $# -gt 0 ]]; then
echo "error: invalid arguments: \"$*\"" >&2
flags_help
exit 1
fi
return ${do_shift}
}
# Removes single quotes around parameter
# Arguments:
# $1 - string which optionally has surrounding quotes
# Returns:
# None, but prints the string without quotes.
remove_quotes() {
echo "$1" | sed -e "s/^'//; s/'$//"
}
# Writes stdin to the given file name as root using sudo in overwrite mode.
#
# $1 - The output file name.
sudo_clobber() {
sudo tee "$1" >/dev/null
}
# Writes stdin to the given file name as root using sudo in append mode.
#
# $1 - The output file name.
sudo_append() {
sudo tee -a "$1" >/dev/null
}
# Execute multiple commands in a single sudo. Generally will speed things
# up by avoiding multiple calls to `sudo`. If any commands fail, we will
# call die with the failing command. We can handle a max of ~100 commands,
# but hopefully no one will ever try that many at once.
#
# $@ - The commands to execute, one per arg.
sudo_multi() {
local i cmds
# Construct the shell code to execute. It'll be of the form:
# ... && ( ( command ) || exit <command index> ) && ...
# This way we know which command exited. The exit status of
# the underlying command is lost, but we never cared about it
# in the first place (other than it is non zero), so oh well.
for (( i = 1; i <= $#; ++i )); do
cmds+=" && ( ( ${!i} ) || exit $(( i + 10 )) )"
done
# Execute our constructed shell code.
sudo -- sh -c ":${cmds[*]}" && i=0 || i=$?
# See if this failed, and if so, print out the failing command.
if [[ $i -gt 10 ]]; then
: $(( i -= 10 ))
die "sudo_multi failed: ${!i}"
elif [[ $i -ne 0 ]]; then
die "sudo_multi failed for unknown reason $i"
fi
}
# Writes stdin to the given file name as the sudo user in overwrite mode.
#
# $@ - The output file names.
user_clobber() {
install -m644 -o ${SUDO_UID} -g ${SUDO_GID} /dev/stdin "$@"
}
# Copies the specified file owned by the user to the specified location.
# If the copy fails as root (e.g. due to root_squash and NFS), retry the copy
# with the user's account before failing.
user_cp() {
cp -p "$@" 2>/dev/null || sudo -u ${SUDO_USER} -- cp -p "$@"
}
# Appends stdin to the given file name as the sudo user.
#
# $1 - The output file name.
user_append() {
cat >> "$1"
chown ${SUDO_UID}:${SUDO_GID} "$1"
}
# Create the specified directory, along with parents, as the sudo user.
#
# $@ - The directories to create.
user_mkdir() {
install -o ${SUDO_UID} -g ${SUDO_GID} -d "$@"
}
# Create the specified symlink as the sudo user.
#
# $1 - Link target
# $2 - Link name
user_symlink() {
ln -sfT "$1" "$2"
chown -h ${SUDO_UID}:${SUDO_GID} "$2"
}
# Locate all mounts below a specified directory.
#
# $1 - The root tree.
sub_mounts() {
# Assume that `mount` outputs a list of mount points in the order
# that things were mounted (since it always has and hopefully always
# will). As such, we have to unmount in reverse order to cleanly
# unmount submounts (think /dev/pts and /dev).
awk -v path=$1 -v len="${#1}" \
'(substr($2, 1, len) == path) { print $2 }' /proc/self/mounts | \
tac | \
sed -e 's/\\040(deleted)$//'
# Hack(zbehan): If a bind mount's source is mysteriously removed,
# we'd end up with an orphaned mount with the above string in its name.
# It can only be seen through /proc/mounts and will stick around even
# when it should be gone already. crosbug.com/31250
}
# Unmounts a directory, if the unmount fails, warn, and then lazily unmount.
#
# $1 - The path to unmount.
safe_umount_tree() {
local mounts=$(sub_mounts "$1")
# Hmm, this shouldn't normally happen, but anything is possible.
if [[ -z ${mounts} ]]; then
return 0
fi
# First try to unmount, this might fail because of nested binds.
if sudo umount -d ${mounts}; then
return 0;
fi
# Check whether our mounts were successfully unmounted.
mounts=$(sub_mounts "$1")
if [[ -z ${mounts} ]]; then
warn "umount failed, but devices were unmounted anyway"
return 0
fi
# Try one more time, this one will die hard if it fails.
warn "Failed to unmount ${mounts}"
safe_umount -d ${mounts}
}
# Run umount as root.
safe_umount() {
if sudo umount "$@"; then
return 0;
else
failboat safe_umount
fi
}
# Check if a single path is mounted.
is_mounted() {
if grep -q "$(readlink -f "$1")" /proc/self/mounts; then
return 0
else
return 1
fi
}
fix_mtab() {
local root="$1" mounts="../proc/self/mounts"
if [[ "$(readlink "${root}/etc/mtab")" != "${mounts}" ]]; then
sudo ln -sf "${mounts}" "${root}/etc/mtab"
fi
}
get_git_id() {
git var GIT_COMMITTER_IDENT | sed -e 's/^.*<\(\S\+\)>.*$/\1/'
}
# Generate a DIGESTS file, as normally used by Gentoo.
# This is an alternative to shash which doesn't know how to report errors.
# Usage: make_digests -d file.DIGESTS file1 [file2...]
_digest_types="md5 sha1 sha512"
make_digests() {
[[ "$1" == "-d" ]] || die
local digests="$(readlink -f "$2")"
shift 2
pushd "$(dirname "$1")" >/dev/null
echo -n > "${digests}"
for filename in "$@"; do
filename=$(basename "$filename")
info "Computing DIGESTS for ${filename}"
for hash_type in $_digest_types; do
echo "# $hash_type HASH" | tr "a-z" "A-Z" >> "${digests}"
${hash_type}sum "${filename}" >> "${digests}"
done
done
popd >/dev/null
}
# Validate a DIGESTS file. Essentially the inverse of make_digests.
# Usage: verify_digests [-d file.DIGESTS] file1 [file2...]
# If -d is not specified file1.DIGESTS will be used
verify_digests() {
local digests filename hash_type status
if [[ "$1" == "-d" ]]; then
[[ -n "$2" ]] || die "-d requires an argument"
digests="$(readlink -f "$2")"
shift 2
else
digests=$(basename "${1}.DIGESTS")
fi
pushd "$(dirname "$1")" >/dev/null
for filename in "$@"; do
filename=$(basename "$filename")
info "Validating DIGESTS for ${filename}"
for hash_type in $_digest_types; do
grep -A1 -i "^# ${hash_type} HASH$" "${digests}" | \
grep "$filename$" | ${hash_type}sum -c - --strict || return 1
# Also check that none of the greps failed in the above pipeline
for status in ${PIPESTATUS[@]}; do
[[ $status -eq 0 ]] || return 1
done
done
done
popd >/dev/null
}
# Get current timestamp. Assumes common.sh runs at startup.
start_time=$(date +%s)
# Get time elapsed since start_time in seconds.
get_elapsed_seconds() {
local end_time=$(date +%s)
local elapsed_seconds=$(( end_time - start_time ))
echo ${elapsed_seconds}
}
# Print time elapsed since start_time.
print_time_elapsed() {
# Optional first arg to specify elapsed_seconds. If not given, will
# recalculate elapsed time to now. Optional second arg to specify
# command name associated with elapsed time.
local elapsed_seconds=${1:-$(get_elapsed_seconds)}
local cmd_base=${2:-}
local minutes=$(( elapsed_seconds / 60 ))
local seconds=$(( elapsed_seconds % 60 ))
if [[ -n ${cmd_base} ]]; then
info "Elapsed time (${cmd_base}): ${minutes}m${seconds}s"
else
info "Elapsed time: ${minutes}m${seconds}s"
fi
}
# Save original command line.
command_line_arr=( "$0" "$@" )
command_completed() {
# Call print_elapsed_time regardless.
local run_time=$(get_elapsed_seconds)
local cmd_base=$(basename "${command_line_arr[0]}")
print_time_elapsed ${run_time} ${cmd_base}
}
# The board and variant command line options can be used in a number of ways
# to specify the board and variant. The board can encode both pieces of
# information separated by underscores. Or the variant can be passed using
# the separate variant option. This function extracts the canonical board and
# variant information and provides it in the BOARD, VARIANT and BOARD_VARIANT
# variables.
get_board_and_variant() {
local flags_board=$1
local flags_variant=$2
BOARD=$(echo "${flags_board}" | cut -d '_' -f 1)
VARIANT=${flags_variant:-$(echo "${flags_board}" | cut -s -d '_' -f 2)}
BOARD_VARIANT=${BOARD}
if [[ -n ${VARIANT} ]]; then
BOARD_VARIANT+="_${VARIANT}"
fi
}
# Check that the specified file exists. If the file path is empty or the file
# doesn't exist on the filesystem generate useful error messages. Otherwise
# show the user the name and path of the file that will be used. The padding
# parameter can be used to tabulate multiple name:path pairs. For example:
#
# check_for_file "really long name" "...:" "file.foo"
# check_for_file "short name" ".........:" "another.bar"
#
# Results in the following output:
#
# Using really long name...: file.foo
# Using short name.........: another.bar
#
# If tabulation is not required then passing "" for padding generates the
# output "Using <name> <path>"
check_for_file() {
local name=$1
local padding=$2
local path=$3
if [[ -z ${path} ]]; then
die "No ${name} file specified."
fi
if [[ ! -e ${path} ]]; then
die "No ${name} file found at: ${path}"
else
info "Using ${name}${padding} ${path}"
fi
}
# Check that the specified tool exists. If it does not exist in the PATH
# generate a useful error message indicating how to install the ebuild
# that contains the required tool.
check_for_tool() {
local tool=$1
local ebuild=$2
if ! which "${tool}" >/dev/null; then
error "The ${tool} utility was not found in your path. Run the following"
error "command in your chroot to install it: sudo -E emerge ${ebuild}"
exit 1
fi
}
# Reinterprets path from outside the chroot for use inside.
# Returns "" if "" given.
# $1 - The path to reinterpret.
reinterpret_path_for_chroot() {
if [[ ${INSIDE_CHROOT} -ne 1 ]]; then
if [[ -z $1 ]]; then
echo ""
else
local path_abs_path=$(readlink -f "$1")
local gclient_root_abs_path=$(readlink -f "${GCLIENT_ROOT}")
# Strip the repository root from the path.
local relative_path=$(echo ${path_abs_path} \
| sed "s:${gclient_root_abs_path}/::")
if [[ ${relative_path} == "${path_abs_path}" ]]; then
die "Error reinterpreting path. Path $1 is not within source tree."
fi
# Prepend the chroot repository path.
echo "/home/${USER}/trunk/${relative_path}"
fi
else
# Path is already inside the chroot :).
echo "$1"
fi
}
# Get the relative path between two locations. Handy for printing paths to
# the user that will usually make sense both inside and outside the chroot.
relpath() {
local py='import sys, os; print os.path.relpath(sys.argv[1], sys.argv[2])'
python2 -c "${py}" "${1}" "${2:-.}"
}
enable_strict_sudo() {
if [[ -z ${CROS_SUDO_KEEP_ALIVE} ]]; then
echo "$0 was somehow invoked in a way that the sudo keep alive could"
echo "not be found. Failing due to this. See crosbug.com/18393."
exit 126
fi
sudo() {
$(type -P sudo) -n "$@"
}
}
# Checks that stdin and stderr are both terminals.
# If so, we assume that there is a live user we can interact with.
# This check can be overridden by setting the CROS_NO_PROMPT environment
# variable to a non-empty value.
is_interactive() {
[[ -z ${CROS_NO_PROMPT} && -t 0 && -t 2 ]]
}
assert_interactive() {
if ! is_interactive; then
die "Script ${0##*/} tried to get user input on a non-interactive terminal."
fi
}
# Display --help if requested. This is used to hide options from help
# that are not intended for developer use.
#
# How to use:
# 1) Declare the options that you want to appear in help.
# 2) Call this function.
# 3) Declare the options that you don't want to appear in help.
#
# See build_packages for example usage.
show_help_if_requested() {
local opt
for opt in "$@"; do
if [[ ${opt} == "-h" || ${opt} == "--help" ]]; then
flags_help
exit 0
fi
done
}
switch_to_strict_mode() {
# Set up strict execution mode; note that the trap
# must follow switch_to_strict_mode, else it will have no effect.
set -e
trap 'die_err_trap "${BASH_COMMAND:-command unknown}" "$?"' ERR
if [[ $# -ne 0 ]]; then
set "$@"
fi
}
# TODO: Re-enable this once shflags is set -e safe.
#switch_to_strict_mode
okboat() {
# http://www.chris.com/ascii/index.php?art=transportation/nautical
echo -e "${V_BOLD_GREEN}"
cat <<BOAT
. o ..
o . o o.o
...oo_
_[__\\___
__|_o_o_o_o\\__
OK \\' ' ' ' ' ' /
^^^^^^^^^^^^^^^^^^^^
BOAT
echo -e "${V_VIDOFF}"
}
failboat() {
echo -e "${V_BOLD_RED}"
cat <<BOAT
'
' )
) (
( .') __/\\
(. /o/\` \\
__/o/\` \\
FAIL / /o/\` /
^^^^^^^^^^^^^^^^^^^^
BOAT
echo -e "${V_VIDOFF}"
die "$* failed"
}
# The binfmt_misc support in the kernel is required.
# The aarch64 binaries should be executed through
# "/usr/bin/qemu-aarch64-static"
setup_qemu_static() {
local root_fs_dir="$1"
case "${BOARD}" in
amd64-usr) return 0;;
arm64-usr)
if [[ -f "${root_fs_dir}/sbin/ldconfig" ]]; then
sudo cp /usr/bin/qemu-aarch64 "${root_fs_dir}"/usr/bin/qemu-aarch64-static
else
die "Missing basic layout in target rootfs"
fi
;;
*) die "Unsupported arch" ;;
esac
}
clean_qemu_static() {
local root_fs_dir="$1"
case "${BOARD}" in
amd64-usr) return 0;;
arm64-usr)
if [[ -f "${root_fs_dir}/usr/bin/qemu-aarch64-static" ]]; then
sudo rm "${root_fs_dir}"/usr/bin/qemu-aarch64-static
else
die "File not found"
fi
;;
*) die "Unsupported arch" ;;
esac
}

View File

@ -77,12 +77,12 @@ if ! wget --spider --quiet "${DIGESTS_URL}"; then
exit 1
fi
# Gets CoreOS verion from version.txt file
# Gets Flatcar verion from version.txt file
VERSION_NAME="version.txt"
VERSION_URL="${BASE_URL}/${VERSION_NAME}"
wget --no-verbose -O "${WORKDIR}/${VERSION_NAME}" "${VERSION_URL}"
. "${WORKDIR}/${VERSION_NAME}"
VDI_IMAGE_NAME="coreos_production_${COREOS_BUILD}.${COREOS_BRANCH}.${COREOS_PATCH}.vdi"
VDI_IMAGE_NAME="flatcar_production_${FLATCAR_BUILD}.${FLATCAR_BRANCH}.${FLATCAR_PATCH}.vdi"
VDI_IMAGE="${DEST}/${VDI_IMAGE_NAME}"
# Setup GnuPG for verifying the image signature
@ -118,6 +118,6 @@ VBoxManage convertdd "${DOWN_IMAGE}" "${VDI_IMAGE}" --format VDI
rm -rf "${WORKDIR}"
trap - EXIT
echo "Success! CoreOS ${VERSION_ID} VDI image was created on ${VDI_IMAGE_NAME}"
echo "Success! Flatcar ${VERSION_ID} VDI image was created on ${VDI_IMAGE_NAME}"
# vim: ts=4 et

View File

@ -35,7 +35,7 @@ case "$1" in
v="$1"
shift
else
v="${COREOS_VERSION}"
v="${FLATCAR_VERSION}"
fi
# strip of a v prefix or .0.0 suffix

View File

@ -12,7 +12,7 @@ export GCLIENT_ROOT=$(readlink -f "${SCRIPT_ROOT}/../../")
DEFINE_string board "amd64-usr" \
"Board type of the image"
DEFINE_string version "${COREOS_VERSION}" \
DEFINE_string version "${FLATCAR_VERSION}" \
"Version number to promote."
DEFINE_string build_storage "gs://builds.release.core-os.net" \

View File

@ -14,7 +14,7 @@ DEFINE_string board "amd64-usr" \
"Board type of the image"
DEFINE_string payload "coreos_production_update.gz" \
"Path to the update payload"
DEFINE_string version "${COREOS_VERSION}" \
DEFINE_string version "${FLATCAR_VERSION}" \
"Version number of this build."
DEFINE_string app_id "e96281a6-d1af-4bde-9a0a-97b76e56dc57" \
"CoreOS AppId in roller."

View File

@ -28,7 +28,7 @@ DEFINE_string board "${DEFAULT_BOARD}" \
DEFINE_string disk_layout "base" \
"The disk layout type to use for this image."
DEFINE_string from "" \
"Directory containing ${COREOS_PRODUCTION_IMAGE_NAME}"
"Directory containing ${FLATCAR_PRODUCTION_IMAGE_NAME}"
DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \
"Directory in which to place image result directories (named by version)"
DEFINE_boolean replace ${FLAGS_FALSE} \
@ -74,7 +74,7 @@ do_copy() {
start_modify_image
if [[ -n "${FLAGS_kernel_path}" ]]; then
do_copy "${FLAGS_kernel_path}" "/boot/coreos/vmlinuz-a"
do_copy "${FLAGS_kernel_path}" "/boot/flatcar/vmlinuz-a"
fi
# FIXME(bgilbert): no shim on arm64

View File

@ -20,7 +20,7 @@ DEFINE_string board "${DEFAULT_BOARD}" \
DEFINE_string disk_layout "base" \
"The disk layout type to use for this image."
DEFINE_string from "" \
"Directory containing ${COREOS_PRODUCTION_IMAGE_NAME}"
"Directory containing ${FLATCAR_PRODUCTION_IMAGE_NAME}"
DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \
"Directory in which to place image result directories (named by version)"
DEFINE_boolean replace ${FLAGS_FALSE} \
@ -56,9 +56,9 @@ fi
start_modify_image
info "Replacing /etc/coreos/update.conf"
sudo mkdir -p "${ROOT_FS_DIR}/etc/coreos"
sudo_clobber "${ROOT_FS_DIR}/etc/coreos/update.conf" <<EOF
info "Replacing /etc/flatcar/update.conf"
sudo mkdir -p "${ROOT_FS_DIR}/etc/flatcar"
sudo_clobber "${ROOT_FS_DIR}/etc/flatcar/update.conf" <<EOF
GROUP=${FLAGS_group}
EOF

View File

@ -31,7 +31,7 @@ DEFINE_string board "${DEFAULT_BOARD}" \
DEFINE_string format "" \
"Output format, one of: ${VALID_IMG_TYPES[*]}"
DEFINE_string from "" \
"Directory containing coreos_production_image.bin."
"Directory containing flatcar_production_image.bin."
DEFINE_string disk_layout "" \
"The disk layout type to use for this image."
DEFINE_integer mem "${DEFAULT_MEM}" \
@ -102,10 +102,10 @@ FLAGS_to=`eval readlink -f $FLAGS_to`
# If source includes version.txt switch to its version information
if [ -f "${FLAGS_from}/version.txt" ]; then
source "${FLAGS_from}/version.txt"
COREOS_VERSION_STRING="${COREOS_VERSION}"
FLATCAR_VERSION_STRING="${FLATCAR_VERSION}"
fi
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${COREOS_PRODUCTION_IMAGE_NAME}"
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${FLATCAR_PRODUCTION_IMAGE_NAME}"
# Make sure things are cleaned up on failure
trap vm_cleanup EXIT

152
image_to_vm.sh.orig Executable file
View File

@ -0,0 +1,152 @@
#!/bin/bash
# Copyright (c) 2010 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 convert the output of build_image.sh to a usable virtual machine
# disk image, supporting a variety of different targets.
# Helper scripts should be run from the same location as this script.
SCRIPT_ROOT=$(dirname "$(readlink -f "$0")")
. "${SCRIPT_ROOT}/common.sh" || exit 1
# Script must run inside the chroot
assert_inside_chroot
assert_not_root_user
. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/vm_image_util.sh" || exit 1
. "${SCRIPT_ROOT}/lib/cros_vm_constants.sh" || exit 1
# Flags
DEFINE_string board "${DEFAULT_BOARD}" \
"Board for which the image was built"
# We default to TRUE so the buildbot gets its image. Note this is different
# behavior from image_to_usb.sh
DEFINE_string format "" \
"Output format, one of: ${VALID_IMG_TYPES[*]}"
DEFINE_string from "" \
<<<<<<< HEAD
"Directory containing coreos_production_image.bin."
=======
"Directory containing flatcar_developer_image.bin or flatcar_production_image.bin."
>>>>>>> Change names of env vars, paths, files, etc. to Flatcar
DEFINE_string disk_layout "" \
"The disk layout type to use for this image."
DEFINE_integer mem "${DEFAULT_MEM}" \
"Memory size for the vm config in MBs."
DEFINE_string to "" \
"Destination folder for VM output file(s)"
DEFINE_string oem_pkg "" \
"OEM package to install"
DEFINE_boolean getbinpkg "${FLAGS_FALSE}" \
"Download binary packages from remote repository."
DEFINE_string getbinpkgver "" \
"Use binary packages from a specific version."
# include upload options
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
# Parse command line
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
# Die on any errors.
switch_to_strict_mode
check_gsutil_opts
if [[ -z "${FLAGS_format}" ]]; then
FLAGS_format="$(get_default_vm_type ${FLAGS_board})"
fi
if ! set_vm_type "${FLAGS_format}"; then
die_notrace "Invalid format: ${FLAGS_format}"
fi
if [ ! -z "${FLAGS_oem_pkg}" ] && ! set_vm_oem_pkg "${FLAGS_oem_pkg}"; then
die_notrace "Invalid oem : ${FLAGS_oem_pkg}"
fi
if [ -z "${FLAGS_board}" ] ; then
die_notrace "--board is required."
fi
# If downloading packages is enabled ensure the board is configured properly.
if [[ ${FLAGS_getbinpkg} -eq ${FLAGS_TRUE} ]]; then
"${SRC_ROOT}/scripts/setup_board" --board="${FLAGS_board}" \
--getbinpkgver="${FLAGS_getbinpkgver}" --regen_configs_only
fi
# Loaded late because board_options depends on setup_board
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
# Default to the most recent image
if [ -z "${FLAGS_from}" ] ; then
FLAGS_from="$(${SCRIPT_ROOT}/get_latest_image.sh --board=${FLAGS_board})"
else
pushd "${FLAGS_from}" >/dev/null && FLAGS_from=`pwd` && popd >/dev/null
fi
if [ -z "${FLAGS_to}" ] ; then
FLAGS_to="${FLAGS_from}"
fi
# Convert args to paths. Need eval to un-quote the string so that shell
# chars like ~ are processed; just doing FOO=`readlink -f $FOO` won't work.
FLAGS_from=`eval readlink -f $FLAGS_from`
FLAGS_to=`eval readlink -f $FLAGS_to`
# If source includes version.txt switch to its version information
if [ -f "${FLAGS_from}/version.txt" ]; then
source "${FLAGS_from}/version.txt"
FLATCAR_VERSION_STRING="${FLATCAR_VERSION}"
fi
<<<<<<< HEAD
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${COREOS_PRODUCTION_IMAGE_NAME}"
=======
if [ ${FLAGS_dev_image} -eq ${FLAGS_TRUE} ]; then
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${FLATCAR_DEVELOPER_IMAGE_NAME}"
if [[ "${FLAGS_disk_layout}" == "" ]]; then
FLAGS_disk_layout=devel
fi
else
set_vm_paths "${FLAGS_from}" "${FLAGS_to}" "${FLATCAR_PRODUCTION_IMAGE_NAME}"
fi
>>>>>>> Change names of env vars, paths, files, etc. to Flatcar
# Make sure things are cleaned up on failure
trap vm_cleanup EXIT
fix_mtab
# Setup new (raw) image, possibly resizing filesystems
setup_disk_image "${FLAGS_disk_layout}"
# Optionally install any OEM packages
install_oem_package
install_oem_aci
run_fs_hook
# Changes done, glue it together
write_vm_disk
write_vm_conf "${FLAGS_mem}"
write_vm_bundle
vm_cleanup
trap - EXIT
# Optionally upload all of our hard work
vm_upload
# Ready to set sail!
okboat
command_completed
print_readme

View File

@ -10,8 +10,8 @@ enter() {
sudo ln -f verify.asc chroot/etc/portage/gangue.asc &&
verify_key=--verify-key=/etc/portage/gangue.asc
sudo ln -f "${GS_DEVEL_CREDS}" chroot/etc/portage/gangue.json
bin/cork enter --bind-gpg-agent=false -- env \
COREOS_DEV_BUILDS="${DOWNLOAD_ROOT}" \
bin/cork enter --experimental -- env \
FLATCAR_DEV_BUILDS="${DOWNLOAD_ROOT}" \
{FETCH,RESUME}COMMAND_GS="/usr/bin/gangue get \
--json-key=/etc/portage/gangue.json $verify_key \
"'"${URI}" "${DISTDIR}/${FILE}"' \
@ -23,14 +23,14 @@ script() {
}
source .repo/manifests/version.txt
export COREOS_BUILD_ID
export FLATCAR_BUILD_ID
# Set up GPG for signing uploads.
gpg --import "${GPG_SECRET_KEY_FILE}"
script setup_board \
--board="${BOARD}" \
--getbinpkgver="${COREOS_VERSION}" \
--getbinpkgver="${FLATCAR_VERSION}" \
--regen_configs_only
if [ "x${COREOS_OFFICIAL}" == x1 ]
@ -43,7 +43,7 @@ fi
# Retrieve this version's torcx manifest
mkdir -p torcx/pkgs
enter gsutil cp -r \
"${DOWNLOAD_ROOT}/torcx/manifests/${BOARD}/${COREOS_VERSION}/torcx_manifest.json"{,.sig} \
"${DOWNLOAD_ROOT}/torcx/manifests/${BOARD}/${FLATCAR_VERSION}/torcx_manifest.json"{,.sig} \
/mnt/host/source/torcx/
gpg --verify torcx/torcx_manifest.json.sig
@ -67,7 +67,7 @@ script build_image \
--board="${BOARD}" \
--group="${GROUP}" \
--getbinpkg \
--getbinpkgver="${COREOS_VERSION}" \
--getbinpkgver="${FLATCAR_VERSION}" \
--sign="${SIGNING_USER}" \
--sign_digests="${SIGNING_USER}" \
--torcx_manifest=/mnt/host/source/torcx/torcx_manifest.json \

View File

@ -15,7 +15,7 @@ enter() {
bin/cork enter --bind-gpg-agent=false -- env \
CCACHE_DIR=/mnt/host/source/.cache/ccache \
CCACHE_MAXSIZE=5G \
COREOS_DEV_BUILDS="${DOWNLOAD_ROOT}" \
FLATCAR_DEV_BUILDS="${DOWNLOAD_ROOT}" \
{FETCH,RESUME}COMMAND_GS="/usr/bin/gangue get \
--json-key=/etc/portage/gangue.json $verify_key \
"'"${URI}" "${DISTDIR}/${FILE}"' \
@ -27,7 +27,7 @@ script() {
}
source .repo/manifests/version.txt
export COREOS_BUILD_ID
export FLATCAR_BUILD_ID
# Set up GPG for signing uploads.
gpg --import "${GPG_SECRET_KEY_FILE}"
@ -37,13 +37,13 @@ enter ccache --zero-stats
script setup_board \
--board="${BOARD}" \
--getbinpkgver=${RELEASE_BASE:-"${COREOS_VERSION}" --toolchainpkgonly} \
--getbinpkgver=${RELEASE_BASE:-"${FLATCAR_VERSION}" --toolchainpkgonly} \
--skip_chroot_upgrade \
--force
script build_packages \
--board="${BOARD}" \
--getbinpkgver=${RELEASE_BASE:-"${COREOS_VERSION}" --toolchainpkgonly} \
--getbinpkgver=${RELEASE_BASE:-"${FLATCAR_VERSION}" --toolchainpkgonly} \
--skip_chroot_upgrade \
--skip_torcx_store \
--sign="${SIGNING_USER}" \

View File

@ -5,7 +5,7 @@ enter() {
}
source .repo/manifests/version.txt
export COREOS_BUILD_ID
export FLATCAR_BUILD_ID
# Set up GPG for signing uploads.
gpg --import "${GPG_SECRET_KEY_FILE}"

View File

@ -5,7 +5,7 @@ enter() {
}
source .repo/manifests/version.txt
export COREOS_BUILD_ID
export FLATCAR_BUILD_ID
# Set up GPG for signing uploads.
gpg --import "${GPG_SECRET_KEY_FILE}"

View File

@ -10,8 +10,8 @@ enter() {
sudo ln -f verify.asc chroot/etc/portage/gangue.asc &&
verify_key=--verify-key=/etc/portage/gangue.asc
sudo ln -f "${GS_DEVEL_CREDS}" chroot/etc/portage/gangue.json
bin/cork enter --bind-gpg-agent=false -- env \
COREOS_DEV_BUILDS="${GS_DEVEL_ROOT}" \
bin/cork enter --experimental -- env \
FLATCAR_DEV_BUILDS="${GS_DEVEL_ROOT}" \
{FETCH,RESUME}COMMAND_GS="/usr/bin/gangue get \
--json-key=/etc/portage/gangue.json $verify_key \
"'"${URI}" "${DISTDIR}/${FILE}"' \
@ -23,7 +23,7 @@ script() {
}
source .repo/manifests/version.txt
export COREOS_BUILD_ID
export FLATCAR_BUILD_ID
# Set up GPG for signing uploads.
gpg --import "${GPG_SECRET_KEY_FILE}"
@ -32,13 +32,13 @@ gpg --import "${GPG_SECRET_KEY_FILE}"
mkdir -p src tmp
bin/cork download-image \
--root="${UPLOAD_ROOT}/boards/${BOARD}/${COREOS_VERSION}" \
--root="${UPLOAD_ROOT}/boards/${BOARD}/${FLATCAR_VERSION}" \
--json-key="${GOOGLE_APPLICATION_CREDENTIALS}" \
--cache-dir=./src \
--platform=qemu \
--verify=true $verify_key
img=src/coreos_production_image.bin
img=src/flatcar_production_image.bin
[[ "${img}.bz2" -nt "${img}" ]] &&
enter lbunzip2 -k -f "/mnt/host/source/${img}.bz2"
@ -46,7 +46,7 @@ script image_to_vm.sh \
--board="${BOARD}" \
--format="${FORMAT}" \
--getbinpkg \
--getbinpkgver="${COREOS_VERSION}" \
--getbinpkgver="${FLATCAR_VERSION}" \
--from=/mnt/host/source/src \
--to=/mnt/host/source/tmp \
--sign="${SIGNING_USER}" \

View File

@ -7,7 +7,7 @@
# Default values for creating VM's.
DEFAULT_MEM="1024"
DEFAULT_VMDK="ide.vmdk"
DEFAULT_VMX="coreos.vmx"
DEFAULT_VMX="flatcar.vmx"
DEFAULT_VBOX_DISK="os.vdi"
# Minimum sizes for full size vm images -- needed for update.

View File

@ -0,0 +1,19 @@
# Copyright (c) 2010 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.
# Common constants for vm scripts.
# Default values for creating VM's.
DEFAULT_MEM="1024"
DEFAULT_VMDK="ide.vmdk"
DEFAULT_VMX="flatcar.vmx"
DEFAULT_VBOX_DISK="os.vdi"
<<<<<<< HEAD
=======
DEFAULT_QEMU_IMAGE="flatcar_developer_qemu_image.img"
>>>>>>> Change names of env vars, paths, files, etc. to Flatcar
# Minimum sizes for full size vm images -- needed for update.
MIN_VDISK_SIZE_FULL=9216
MIN_STATEFUL_FS_SIZE_FULL=6144

View File

@ -50,7 +50,7 @@ if [[ -z "${baseurl}" ]]; then
fi
version_url="${baseurl}/version.txt"
image_url="${baseurl}/coreos_production_openstack_image.img.bz2"
image_url="${baseurl}/flatcar_production_openstack_image.img.bz2"
# use the following location as our local work space
tmplocation=$(mktemp -d /var/tmp/glanceload.XXX)
@ -60,25 +60,25 @@ curl --fail -s -L -O ${version_url}
. version.txt
# if we already have the image don't waste time
if glance image-show "CoreOS-${release}-v${COREOS_VERSION}"; then
if glance image-show "Flatcar-${release}-v${Flatcar_VERSION}"; then
echo "Image already exists."
rm -rf ${tmplocation}
exit
fi
coreosimg="coreos_${COREOS_VERSION}_openstack_image.img"
flatcarimg="flatcar_${FLATCAR_VERSION}_openstack_image.img"
# change the following line to reflect the image to be chosen, openstack
# is used by default
curl --fail -s -L ${image_url} | bunzip2 > ${coreosimg}
curl --fail -s -L ${image_url} | bunzip2 > ${flatcarimg}
# perform actual image creation
# here we set the os_release, os_verison, os_family, and os_distro variables
# for intelligent consumption of images by scripts
glance --os-image-api-version 1 image-create --name CoreOS-${release}-v${COREOS_VERSION} --progress \
--is-public true --property os_distro=coreos --property os_family=coreos \
--property os_version=${COREOS_VERSION} \
--disk-format qcow2 --container-format bare --min-disk 6 --file $coreosimg
glance --os-image-api-version 1 image-create --name Flatcar-${release}-v${FLATCAR_VERSION} --progress \
--is-public true --property os_distro=flatcar --property os_family=flatcar \
--property os_version=${FLATCAR_VERSION} \
--disk-format qcow2 --container-format bare --min-disk 6 --file $flatcarimg
# optionally, set --property os_release=${release} in the glance image-create
# command above and uncomment the two commands below to support searching by

22
offline_signing/sign.sh Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -ex
DATA_DIR="$(readlink -f "$1")"
KEYS_DIR="$(readlink -f "$(dirname "$0")")"
gpg2 --verify "${DATA_DIR}/flatcar_production_update.bin.bz2.sig"
gpg2 --verify "${DATA_DIR}/flatcar_production_image.vmlinuz.sig"
gpg2 --verify "${DATA_DIR}/flatcar_production_update.zip.sig"
bunzip2 --keep "${DATA_DIR}/flatcar_production_update.bin.bz2"
unzip "${DATA_DIR}/flatcar_production_update.zip" -d "${DATA_DIR}"
export PATH="${DATA_DIR}:${PATH}"
cd "${DATA_DIR}"
./core_sign_update \
--image "${DATA_DIR}/flatcar_production_update.bin" \
--kernel "${DATA_DIR}/flatcar_production_image.vmlinuz" \
--output "${DATA_DIR}/flatcar_production_update.gz" \
--private_keys "${KEYS_DIR}/devel.key.pem+pkcs11:object=CoreOS_Update_Signing_Key;type=private" \
--public_keys "${KEYS_DIR}/devel.pub.pem+${KEYS_DIR}/prod-2.pub.pem" \
--keys_separator "+"

22
offline_signing/sign.sh.orig Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -ex
DATA_DIR="$(readlink -f "$1")"
KEYS_DIR="$(readlink -f "$(dirname "$0")")"
gpg2 --verify "${DATA_DIR}/flatcar_production_update.bin.bz2.sig"
gpg2 --verify "${DATA_DIR}/flatcar_production_image.vmlinuz.sig"
gpg2 --verify "${DATA_DIR}/flatcar_production_update.zip.sig"
bunzip2 --keep "${DATA_DIR}/flatcar_production_update.bin.bz2"
unzip "${DATA_DIR}/flatcar_production_update.zip" -d "${DATA_DIR}"
export PATH="${DATA_DIR}:${PATH}"
cd "${DATA_DIR}"
./core_sign_update \
--image "${DATA_DIR}/flatcar_production_update.bin" \
--kernel "${DATA_DIR}/flatcar_production_image.vmlinuz" \
--output "${DATA_DIR}/flatcar_production_update.gz" \
--private_keys "${KEYS_DIR}/devel.key.pem+pkcs11:object=CoreOS_Update_Signing_Key;type=private" \
--public_keys "${KEYS_DIR}/devel.pub.pem+${KEYS_DIR}/prod-2.pub.pem" \
--keys_separator "+"

View File

@ -5,13 +5,13 @@
# found in the LICENSE file.
# common.sh must be properly sourced before this file.
[[ -n "${COREOS_SDK_VERSION}" ]] || exit 1
[[ -n "${FLATCAR_SDK_VERSION}" ]] || exit 1
COREOS_SDK_ARCH="amd64" # We are unlikely to support anything else.
COREOS_SDK_TARBALL="coreos-sdk-${COREOS_SDK_ARCH}-${COREOS_SDK_VERSION}.tar.bz2"
COREOS_SDK_TARBALL_CACHE="${REPO_CACHE_DIR}/sdks"
COREOS_SDK_TARBALL_PATH="${COREOS_SDK_TARBALL_CACHE}/${COREOS_SDK_TARBALL}"
COREOS_SDK_URL="${COREOS_DEV_BUILDS}/sdk/${COREOS_SDK_ARCH}/${COREOS_SDK_VERSION}/${COREOS_SDK_TARBALL}"
FLATCAR_SDK_ARCH="amd64" # We are unlikely to support anything else.
FLATCAR_SDK_TARBALL="flatcar-sdk-${FLATCAR_SDK_ARCH}-${FLATCAR_SDK_VERSION}.tar.bz2"
FLATCAR_SDK_TARBALL_CACHE="${REPO_CACHE_DIR}/sdks"
FLATCAR_SDK_TARBALL_PATH="${FLATCAR_SDK_TARBALL_CACHE}/${FLATCAR_SDK_TARBALL}"
FLATCAR_SDK_URL="${FLATCAR_DEV_BUILDS}/sdk/${FLATCAR_SDK_ARCH}/${FLATCAR_SDK_VERSION}/${FLATCAR_SDK_TARBALL}"
# Download the current SDK tarball (if required) and verify digests/sig
sdk_download_tarball() {
@ -19,13 +19,13 @@ sdk_download_tarball() {
return 0
fi
info "Downloading ${COREOS_SDK_TARBALL}"
info "URL: ${COREOS_SDK_URL}"
info "Downloading ${FLATCAR_SDK_TARBALL}"
info "URL: ${FLATCAR_SDK_URL}"
local suffix
for suffix in "" ".DIGESTS"; do # TODO(marineam): download .asc
wget --tries=3 --timeout=30 --continue \
-O "${COREOS_SDK_TARBALL_PATH}${suffix}" \
"${COREOS_SDK_URL}${suffix}" \
-O "${FLATCAR_SDK_TARBALL_PATH}${suffix}" \
"${FLATCAR_SDK_URL}${suffix}" \
|| die_notrace "SDK download failed!"
done
@ -34,21 +34,21 @@ sdk_download_tarball() {
}
sdk_verify_digests() {
if [[ ! -f "${COREOS_SDK_TARBALL_PATH}" || \
! -f "${COREOS_SDK_TARBALL_PATH}.DIGESTS" ]]; then
if [[ ! -f "${FLATCAR_SDK_TARBALL_PATH}" || \
! -f "${FLATCAR_SDK_TARBALL_PATH}.DIGESTS" ]]; then
return 1
fi
# TODO(marineam): Add gpg signature verification too.
verify_digests "${COREOS_SDK_TARBALL_PATH}" || return 1
verify_digests "${FLATCAR_SDK_TARBALL_PATH}" || return 1
}
sdk_clean_cache() {
pushd "${COREOS_SDK_TARBALL_CACHE}" >/dev/null
pushd "${FLATCAR_SDK_TARBALL_CACHE}" >/dev/null
local filename
for filename in *; do
if [[ "${filename}" == "${COREOS_SDK_TARBALL}"* ]]; then
if [[ "${filename}" == "${FLATCAR_SDK_TARBALL}"* ]]; then
continue
fi
info "Cleaning up ${filename}"

View File

@ -120,9 +120,9 @@ EOF
generate_binhost_list() {
local t
[[ "${FLAGS_toolchainpkgonly}" -eq "${FLAGS_TRUE}" ]] && t="-t"
FLAGS_getbinpkgver="${FLAGS_getbinpkgver/current/${COREOS_VERSION_ID}}"
FLAGS_getbinpkgver="${FLAGS_getbinpkgver/latest/${COREOS_VERSION_ID}}"
FLAGS_getbinpkgver="${FLAGS_getbinpkgver/sdk/${COREOS_SDK_VERSION}}"
FLAGS_getbinpkgver="${FLAGS_getbinpkgver/current/${FLATCAR_VERSION_ID}}"
FLAGS_getbinpkgver="${FLAGS_getbinpkgver/latest/${FLATCAR_VERSION_ID}}"
FLAGS_getbinpkgver="${FLAGS_getbinpkgver/sdk/${FLATCAR_SDK_VERSION}}"
get_board_binhost $t "${BOARD}" ${FLAGS_getbinpkgver}
}

View File

@ -20,12 +20,12 @@ download() {
pushd "${dir}" >/dev/null
gsutil -m cp \
"${gs}/coreos_production_image.vmlinuz" \
"${gs}/coreos_production_image.vmlinuz.sig" \
"${gs}/coreos_production_update.bin.bz2" \
"${gs}/coreos_production_update.bin.bz2.sig" \
"${gs}/coreos_production_update.zip" \
"${gs}/coreos_production_update.zip.sig" ./
"${gs}/flatcar_production_image.vmlinuz" \
"${gs}/flatcar_production_image.vmlinuz.sig" \
"${gs}/flatcar_production_update.bin.bz2" \
"${gs}/flatcar_production_update.bin.bz2.sig" \
"${gs}/flatcar_production_update.zip" \
"${gs}/flatcar_production_update.zip.sig" ./
# torcx manifest: try embargoed release bucket first
local torcx_base="gs://builds.release.core-os.net/embargoed/devfiles/torcx/manifests/${BOARD}/${version}"
@ -38,9 +38,9 @@ download() {
"${torcx_base}/torcx_manifest.json.sig" \
./
gpg2 --verify "coreos_production_image.vmlinuz.sig"
gpg2 --verify "coreos_production_update.bin.bz2.sig"
gpg2 --verify "coreos_production_update.zip.sig"
gpg2 --verify "flatcar_production_image.vmlinuz.sig"
gpg2 --verify "flatcar_production_update.bin.bz2.sig"
gpg2 --verify "flatcar_production_update.zip.sig"
gpg2 --verify "torcx_manifest.json.sig"
popd >/dev/null
@ -51,7 +51,7 @@ upload() {
local version="$2"
local dir="${BASEDIR}/${BOARD}/${version}"
local payload="${dir}/coreos_production_update.gz"
local payload="${dir}/flatcar_production_update.gz"
local torcx_manifest="${dir}/torcx_manifest.json"
local torcx_manifest_sig="${dir}/torcx_manifest.json.asc"
local path
@ -129,7 +129,7 @@ roll() {
# automatically activates the new one.
echo "Creating linear rollout that will get to 100% in ${hours}h"
updateservicectl \
--server="https://public.update.core-os.net" \
--server="https://public.update.flatcar-linux.net" \
--user="${ROLLER_USERNAME}" \
--key="${ROLLER_API_KEY}" \
rollout create linear \

211
signing/transfer.sh.orig Executable file
View File

@ -0,0 +1,211 @@
#!/usr/bin/env bash
set -eux
APPID=e96281a6-d1af-4bde-9a0a-97b76e56dc57
BOARD=amd64-usr
declare -A RELEASE_CHANNEL
RELEASE_CHANNEL[alpha]=Alpha
RELEASE_CHANNEL[beta]=Beta
RELEASE_CHANNEL[stable]=Stable
download() {
local channel="$1"
local version="$2"
local gs="gs://builds.release.core-os.net/${channel}/boards/${BOARD}/${version}"
local dir="${BASEDIR}/${BOARD}/${version}"
mkdir -p "${dir}"
pushd "${dir}" >/dev/null
gsutil -m cp \
"${gs}/flatcar_production_image.vmlinuz" \
"${gs}/flatcar_production_image.vmlinuz.sig" \
"${gs}/flatcar_production_update.bin.bz2" \
"${gs}/flatcar_production_update.bin.bz2.sig" \
"${gs}/flatcar_production_update.zip" \
"${gs}/flatcar_production_update.zip.sig" ./
# torcx manifest: try embargoed release bucket first
local torcx_base="gs://builds.release.core-os.net/embargoed/devfiles/torcx/manifests/${BOARD}/${version}"
if ! gsutil -q stat "${torcx_base}/torcx_manifest.json"; then
# Non-embargoed release
local torcx_base="gs://builds.developer.core-os.net/torcx/manifests/${BOARD}/${version}"
fi
gsutil -m cp \
"${torcx_base}/torcx_manifest.json" \
"${torcx_base}/torcx_manifest.json.sig" \
./
gpg2 --verify "flatcar_production_image.vmlinuz.sig"
gpg2 --verify "flatcar_production_update.bin.bz2.sig"
gpg2 --verify "flatcar_production_update.zip.sig"
gpg2 --verify "torcx_manifest.json.sig"
popd >/dev/null
}
upload() {
local channel="$1"
local version="$2"
<<<<<<< HEAD:signing/transfer.sh
local dir="${BASEDIR}/${BOARD}/${version}"
local payload="${dir}/coreos_production_update.gz"
=======
local dir="${BASEDIR}/${board}/${version}"
local payload="${dir}/flatcar_production_update.gz"
>>>>>>> Change names of env vars, paths, files, etc. to Flatcar:offline_signing/transfer.sh
local torcx_manifest="${dir}/torcx_manifest.json"
local torcx_manifest_sig="${dir}/torcx_manifest.json.asc"
local path
for path in "${payload}" "${torcx_manifest}" "${torcx_manifest_sig}"; do
if [[ ! -e "${path}" ]]; then
echo "No such file: ${path}" >&2
exit 1
fi
done
"$(dirname $0)/../core_roller_upload" \
--user="${ROLLER_USERNAME}" \
--api_key="${ROLLER_API_KEY}" \
--app_id="${APPID}" \
--board="${BOARD}" \
--version="${version}" \
--payload="${payload}"
# Upload torcx manifests
gsutil cp \
"${torcx_manifest}" \
"${torcx_manifest_sig}" \
"gs://coreos-tectonic-torcx/manifests/${BOARD}/${version}/"
# Update version in a canary channel if one is defined.
local -n canary_channel="ROLLER_CANARY_CHANNEL_${channel^^}"
if [[ -n "${canary_channel}" ]]; then
updateservicectl \
--server="https://public.update.core-os.net" \
--user="${ROLLER_USERNAME}" \
--key="${ROLLER_API_KEY}" \
channel update \
--app-id="${APPID}" \
--channel="${canary_channel}" \
--version="${version}"
fi
}
ready() {
local channel="$1"
local version="$2"
# setting the percent will deactivate (not delete) any existing rollouts for
# this specific group.
echo "Rollout set to 0%"
updateservicectl \
--server="https://public.update.core-os.net" \
--user="${ROLLER_USERNAME}" \
--key="${ROLLER_API_KEY}" \
group percent \
--app-id="${APPID}" \
--group-id="${channel}" \
--update-percent=0
# FIXME(bgilbert): We set --publish=true because there's no way to
# say --publish=unchanged
updateservicectl \
--server="https://public.update.core-os.net" \
--user="${ROLLER_USERNAME}" \
--key="${ROLLER_API_KEY}" \
channel update \
--app-id="${APPID}" \
--channel="${RELEASE_CHANNEL[${channel}]}" \
--publish=true \
--version="${version}"
}
roll() {
local channel="$1"
local hours="$2"
local seconds=$((${hours} * 3600))
# creating a new rollout deletes any existing rollout for this group and
# automatically activates the new one.
echo "Creating linear rollout that will get to 100% in ${hours}h"
updateservicectl \
--server="https://public.update.core-os.net" \
--user="${ROLLER_USERNAME}" \
--key="${ROLLER_API_KEY}" \
rollout create linear \
--app-id="${APPID}" \
--group-id="${channel}" \
--duration="${seconds}" \
--frame-size="60"
}
usage() {
echo "Usage: $0 {download|upload} <ARTIFACT-DIR> [{-a|-b|-s} <VERSION>]..." >&2
echo "Usage: $0 ready [{-a|-b|-s} <VERSION>]..." >&2
echo "Usage: $0 roll [{-a|-b|-s} <HOURS-TO-100-PERCENT>]..." >&2
exit 1
}
# Parse subcommand.
CMD="${1:-}"
shift ||:
case "${CMD}" in
download)
;;
upload|ready|roll)
if [[ -e "${HOME}/.config/roller.conf" ]]; then
. "${HOME}/.config/roller.conf"
fi
if [[ -z "${ROLLER_USERNAME:-}" || -z "${ROLLER_API_KEY:-}" ]]; then
echo 'Missing $ROLLER_USERNAME or $ROLLER_API_KEY.' >&2
echo "Consider adding shell assignments to ~/.config/roller.conf." >&2
exit 1
fi
;;
*)
usage
;;
esac
# Parse basedir if necessary.
case "${CMD}" in
download|upload)
BASEDIR="${1:-}"
shift ||:
if [[ -z "${BASEDIR}" ]]; then
usage
fi
if [[ -d "${BASEDIR}" && ! -O "${BASEDIR}" ]]; then
echo "Fixing ownership of ${BASEDIR}..."
sudo chown -R "${USER}" "${BASEDIR}"
fi
;;
esac
# Walk argument pairs.
while [[ $# > 0 ]]; do
c="$1"
v="${2?Must provide an argument for each channel (see usage)}"
shift 2
case "${c}" in
-a)
$CMD "alpha" "${v}"
;;
-b)
$CMD "beta" "${v}"
;;
-s)
$CMD "stable" "${v}"
;;
*)
usage
;;
esac
done

View File

@ -28,7 +28,7 @@ DEFAULT_MINOR=0
DEFAULT_BRANCH=${FLAGS_FALSE}
DEFAULT_BRANCH_PROJECTS=
CURRENT_VERSION=( ${COREOS_VERSION_ID//./ } )
CURRENT_VERSION=( ${FLATCAR_VERSION_ID//./ } )
# Detect if we are on a branch or still tracking master.
DEFAULT_MANIFEST=$(readlink "${REPO_MANIFESTS_DIR}/default.xml") \
@ -48,8 +48,8 @@ fi
DEFINE_integer major ${DEFAULT_MAJOR} "Branch major version (aka 'build')"
DEFINE_integer minor ${DEFAULT_MINOR} "Branch revision or minor version"
DEFINE_integer patch 0 "Branch patch id, normally 0"
DEFINE_string sdk_version "${COREOS_VERSION_ID}" \
"SDK version to use, or 'keep'. (current: ${COREOS_SDK_VERSION})"
DEFINE_string sdk_version "${FLATCAR_VERSION_ID}" \
"SDK version to use, or 'keep'. (current: ${FLATCAR_SDK_VERSION})"
DEFINE_boolean branch ${DEFAULT_BRANCH} "Release branch, diverge from master"
DEFINE_string branch_projects "${DEFAULT_BRANCH_PROJECTS}" \
"Branch the named projects (with a 'coreos/' prefix) in the manifest."
@ -82,7 +82,7 @@ TAG_NAME="v${BRANCH_VERSION}"
if [[ "${FLAGS_sdk_version}" == keep || "${FLAGS_sdk_version}" == current ]]
then
FLAGS_sdk_version="${COREOS_SDK_VERSION}"
FLAGS_sdk_version="${FLATCAR_SDK_VERSION}"
fi
if [[ "${FLAGS_sdk_version}" == "${BRANCH_VERSION}" ]]; then
@ -92,9 +92,9 @@ if [[ "${FLAGS_sdk_version}" == "${BRANCH_VERSION}" ]]; then
fi
# Verify that the specified SDK version exists
COREOS_SDK_VERSION="${FLAGS_sdk_version}"
FLATCAR_SDK_VERSION="${FLAGS_sdk_version}"
. "${SCRIPT_ROOT}/sdk_lib/sdk_util.sh"
if ! curl --head --fail --silent "${COREOS_SDK_URL}" > /dev/null ; then
if ! curl --head --fail --silent "${FLATCAR_SDK_URL}" > /dev/null ; then
die_notrace "SDK version does not exist." \
"Try --sdk_version keep to use the existing SDK."
fi
@ -140,10 +140,10 @@ if [[ ${FLAGS_branch} -eq ${FLAGS_TRUE} ]]; then
fi
tee version.txt <<EOF
COREOS_VERSION=${BRANCH_VERSION}
COREOS_VERSION_ID=${BRANCH_VERSION}
COREOS_BUILD_ID=""
COREOS_SDK_VERSION=${FLAGS_sdk_version}
FLATCAR_VERSION=${BRANCH_VERSION}
FLATCAR_VERSION_ID=${BRANCH_VERSION}
FLATCAR_BUILD_ID=""
FLATCAR_SDK_VERSION=${FLAGS_sdk_version}
EOF
git add version.txt
@ -154,7 +154,7 @@ export GPG_TTY
info "Creating ${BRANCH_NAME} and tag ${TAG_NAME}"
git commit -m "${BRANCH_NAME}: release ${TAG_NAME}"
git branch -f "${BRANCH_NAME}"
git tag "${sign_args[@]}" -m "CoreOS ${TAG_NAME}" "${TAG_NAME}"
git tag "${sign_args[@]}" -m "Flatcar ${TAG_NAME}" "${TAG_NAME}"
# Unpin and branch the important projects, if requested and they are pinned.
if [[ -n "${FLAGS_branch_projects}" ]]; then

View File

@ -159,14 +159,14 @@ fi
info "Updating chroot:"
info " chroot version: $OLDVER"
info " CoreOS version: $COREOS_VERSION"
info " Flatcar version: $FLATCAR_VERSION"
# Updates should be of the form 1.2.3_desc.sh
for update_script in ${SCRIPTS_DIR}/sdk_lib/updates/*.sh; do
update_name="${update_script##*/}"
update_ver="${update_name%%_*}"
# Run newer updates but don't pass our current version
if ! cmp_ver le "$update_ver" "$COREOS_VERSION"; then
if ! cmp_ver le "$update_ver" "$FLATCAR_VERSION"; then
warn "Skipping update from the future: $update_name"
warn "Perhaps it is time to run a repo sync?"
elif ! cmp_ver ge "$OLDVER" "$update_ver"; then