mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-10 22:46:58 +02:00
Merge pull request #197 from marineam/release-files
cleanup(set_lsb_release): Rework release config setup
This commit is contained in:
commit
e59e366770
@ -60,8 +60,7 @@ if [[ "$STAGES" =~ stage4 ]]; then
|
|||||||
rm -rf "${TEMPDIR}/stage4_overlay"
|
rm -rf "${TEMPDIR}/stage4_overlay"
|
||||||
mkdir -p "${TEMPDIR}/stage4_overlay"
|
mkdir -p "${TEMPDIR}/stage4_overlay"
|
||||||
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
|
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
|
||||||
--root "${TEMPDIR}/stage4_overlay" \
|
--root "${TEMPDIR}/stage4_overlay"
|
||||||
--production_track sdk --board "${ARCH}-host"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
catalyst_build
|
catalyst_build
|
||||||
|
@ -34,8 +34,7 @@ if [[ "$STAGES" =~ stage4 ]]; then
|
|||||||
rm -rf "${TEMPDIR}/stage4_overlay"
|
rm -rf "${TEMPDIR}/stage4_overlay"
|
||||||
mkdir -p "${TEMPDIR}/stage4_overlay"
|
mkdir -p "${TEMPDIR}/stage4_overlay"
|
||||||
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
|
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
|
||||||
--root "${TEMPDIR}/stage4_overlay" \
|
--root "${TEMPDIR}/stage4_overlay"
|
||||||
--production_track sdk --board "${ARCH}-host"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
catalyst_build
|
catalyst_build
|
||||||
|
12
build_image
12
build_image
@ -23,6 +23,8 @@ DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/images" \
|
|||||||
"Directory in which to place image result directories (named by version)"
|
"Directory in which to place image result directories (named by version)"
|
||||||
DEFINE_string disk_layout "base" \
|
DEFINE_string disk_layout "base" \
|
||||||
"The disk layout type to use for this image."
|
"The disk layout type to use for this image."
|
||||||
|
DEFINE_string prod_group "" \
|
||||||
|
"The update group for production images."
|
||||||
|
|
||||||
# include upload options
|
# include upload options
|
||||||
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
|
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
|
||||||
@ -122,6 +124,14 @@ mkdir -p "${BUILD_DIR}"
|
|||||||
DISK_LAYOUT_SUFFIX=$(portageq-$BOARD envvar COREOS_DISK_LAYOUT_SUFFIX)
|
DISK_LAYOUT_SUFFIX=$(portageq-$BOARD envvar COREOS_DISK_LAYOUT_SUFFIX)
|
||||||
DISK_LAYOUT="${FLAGS_disk_layout:-base}${DISK_LAYOUT_SUFFIX}"
|
DISK_LAYOUT="${FLAGS_disk_layout:-base}${DISK_LAYOUT_SUFFIX}"
|
||||||
|
|
||||||
|
if [[ -z "${FLAGS_prod_group}" ]]; then
|
||||||
|
if [[ "$BOARD" == "amd64-generic" ]]; then
|
||||||
|
FLAGS_prod_group="dev-channel"
|
||||||
|
else
|
||||||
|
FLAGS_prod_group="alpha"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Create the base image.
|
# Create the base image.
|
||||||
create_base_image ${PRISTINE_IMAGE_NAME} ${DISK_LAYOUT}
|
create_base_image ${PRISTINE_IMAGE_NAME} ${DISK_LAYOUT}
|
||||||
if should_build_image ${PRISTINE_IMAGE_NAME}; then
|
if should_build_image ${PRISTINE_IMAGE_NAME}; then
|
||||||
@ -149,7 +159,7 @@ if should_build_image ${COREOS_PRODUCTION_IMAGE_NAME}; then
|
|||||||
copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${COREOS_PRODUCTION_IMAGE_NAME}
|
copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${COREOS_PRODUCTION_IMAGE_NAME}
|
||||||
|
|
||||||
setup_prod_image ${COREOS_PRODUCTION_IMAGE_NAME} ${DISK_LAYOUT} \
|
setup_prod_image ${COREOS_PRODUCTION_IMAGE_NAME} ${DISK_LAYOUT} \
|
||||||
"dev-channel" \
|
"${FLAGS_prod_group}" \
|
||||||
${SRC_ROOT}/third_party/coreos-overlay/coreos-base/coreos-au-key/files/update-payload-key.pub.pem
|
${SRC_ROOT}/third_party/coreos-overlay/coreos-base/coreos-au-key/files/update-payload-key.pub.pem
|
||||||
|
|
||||||
upload_image "${BUILD_DIR}/${COREOS_PRODUCTION_IMAGE_NAME}"
|
upload_image "${BUILD_DIR}/${COREOS_PRODUCTION_IMAGE_NAME}"
|
||||||
|
@ -38,11 +38,32 @@ EOF
|
|||||||
eselect profile set --force $(get_board_profile $BOARD)
|
eselect profile set --force $(get_board_profile $BOARD)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
detect_dev_url() {
|
||||||
|
local port=":8080"
|
||||||
|
local host=$(hostname --fqdn 2>/dev/null)
|
||||||
|
if [[ -z "${host}" ]]; then
|
||||||
|
host=$(ip addr show scope global | \
|
||||||
|
awk '$1 == "inet" { sub(/[/].*/, "", $2); print $2; exit }')
|
||||||
|
fi
|
||||||
|
if [[ -n "${host}" ]]; then
|
||||||
|
echo "http://${host}${port}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Modifies an existing image to add development packages.
|
# Modifies an existing image to add development packages.
|
||||||
# Takes as an arg the name of the image to be created.
|
# Takes as an arg the name of the image to be created.
|
||||||
install_dev_packages() {
|
install_dev_packages() {
|
||||||
local image_name=$1
|
local image_name=$1
|
||||||
local disk_layout=$2
|
local disk_layout=$2
|
||||||
|
local devserver=$(detect_dev_url)
|
||||||
|
local auserver=""
|
||||||
|
|
||||||
|
if [[ -n "${devserver}" ]]; then
|
||||||
|
info "Using ${devserver} for local dev server URL."
|
||||||
|
auserver="${devserver}/update"
|
||||||
|
else
|
||||||
|
info "Unable do detect local dev server address."
|
||||||
|
fi
|
||||||
|
|
||||||
info "Adding developer packages to ${image_name}"
|
info "Adding developer packages to ${image_name}"
|
||||||
local root_fs_dir="${BUILD_DIR}/rootfs"
|
local root_fs_dir="${BUILD_DIR}/rootfs"
|
||||||
@ -58,7 +79,16 @@ install_dev_packages() {
|
|||||||
sudo ROOT="${root_fs_dir}" env-update
|
sudo ROOT="${root_fs_dir}" env-update
|
||||||
|
|
||||||
# Setup portage for emerge and gmerge
|
# Setup portage for emerge and gmerge
|
||||||
configure_dev_portage "${root_fs_dir}"
|
configure_dev_portage "${root_fs_dir}" "${devserver}"
|
||||||
|
|
||||||
|
sudo mkdir -p "${root_fs_dir}/etc/coreos"
|
||||||
|
sudo_clobber "${root_fs_dir}/etc/coreos/update.conf" <<EOF
|
||||||
|
SERVER=${auserver}
|
||||||
|
GROUP=developer-build
|
||||||
|
|
||||||
|
# For gmerge
|
||||||
|
DEVSERVER=${devserver}
|
||||||
|
EOF
|
||||||
|
|
||||||
# Mark the image as a developer image (input to chromeos_startup).
|
# Mark the image as a developer image (input to chromeos_startup).
|
||||||
# TODO(arkaitzr): Remove this file when applications no longer rely on it
|
# TODO(arkaitzr): Remove this file when applications no longer rely on it
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
setup_prod_image() {
|
setup_prod_image() {
|
||||||
local image_name="$1"
|
local image_name="$1"
|
||||||
local disk_layout="$2"
|
local disk_layout="$2"
|
||||||
local update_track="$3"
|
local update_group="$3"
|
||||||
local au_key="$4"
|
local au_key="$4"
|
||||||
|
|
||||||
info "Configuring production image ${image_name}"
|
info "Configuring production image ${image_name}"
|
||||||
@ -22,7 +22,7 @@ setup_prod_image() {
|
|||||||
|
|
||||||
# Replace /etc/lsb-release on the image.
|
# Replace /etc/lsb-release on the image.
|
||||||
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
|
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
|
||||||
--production_track="${update_track}" \
|
--group="${update_group}" \
|
||||||
--root="${root_fs_dir}" \
|
--root="${root_fs_dir}" \
|
||||||
--board="${BOARD}"
|
--board="${BOARD}"
|
||||||
|
|
||||||
|
@ -18,8 +18,7 @@ fi
|
|||||||
# Flags
|
# Flags
|
||||||
DEFINE_string board "" "The board to build an image for."
|
DEFINE_string board "" "The board to build an image for."
|
||||||
DEFINE_string root "" "The root file system to write /etc/lsb-release to."
|
DEFINE_string root "" "The root file system to write /etc/lsb-release to."
|
||||||
DEFINE_string production_track "${PRODUCTION_DEFAULT}" \
|
DEFINE_string group "" "The default update group for update_engine."
|
||||||
"Use production values and a given track for update service."
|
|
||||||
|
|
||||||
# Parse command line
|
# Parse command line
|
||||||
FLAGS "$@" || exit 1
|
FLAGS "$@" || exit 1
|
||||||
@ -32,72 +31,25 @@ ROOT_FS_DIR="$FLAGS_root"
|
|||||||
[ -d "$ROOT_FS_DIR" ] || die "Root FS does not exist? ($ROOT_FS_DIR)"
|
[ -d "$ROOT_FS_DIR" ] || die "Root FS does not exist? ($ROOT_FS_DIR)"
|
||||||
|
|
||||||
COREOS_VERSION_NAME="CoreOS"
|
COREOS_VERSION_NAME="CoreOS"
|
||||||
if [[ -n "${FLAGS_production_track}" ]]; then
|
COREOS_VERSION_AUSERVER=""
|
||||||
|
if [[ -n "${FLAGS_group}" ]]; then
|
||||||
if [[ "${FLAGS_board}" == "amd64-usr" ]]; then
|
if [[ "${FLAGS_board}" == "amd64-usr" ]]; then
|
||||||
FLAGS_production_track="alpha"
|
COREOS_VERSION_AUSERVER="http://public.roller.core-os.net/v1/update/"
|
||||||
|
elif [[ "${FLAGS_board}" == "amd64-generic" ]]; then
|
||||||
|
COREOS_VERSION_AUSERVER="https://api.core-os.net/v1/update/"
|
||||||
fi
|
fi
|
||||||
COREOS_VERSION_TRACK="${FLAGS_production_track}"
|
|
||||||
COREOS_VERSION_DESCRIPTION="${COREOS_VERSION_STRING} (Official Build) \
|
|
||||||
${COREOS_VERSION_TRACK} $FLAGS_board test"
|
|
||||||
if [[ "${FLAGS_production_track}" != "sdk" ]]; then
|
|
||||||
if [[ "${FLAGS_board}" == "amd64-usr" ]]; then
|
|
||||||
COREOS_VERSION_AUSERVER="http://public.roller.core-os.net/v1/update/"
|
|
||||||
else
|
|
||||||
COREOS_VERSION_AUSERVER="https://api.core-os.net/v1/update/"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
COREOS_VERSION_AUSERVER=""
|
|
||||||
fi
|
|
||||||
COREOS_VERSION_DEVSERVER=""
|
|
||||||
else
|
|
||||||
# Developer hand-builds
|
|
||||||
COREOS_VERSION_TRACK=${COREOS_VERSION_TRACK:-"developer-build"}
|
|
||||||
COREOS_VERSION_DESCRIPTION="${COREOS_VERSION_STRING} (Developer Build \
|
|
||||||
- $USER) ${COREOS_VERSION_TRACK} $FLAGS_board"
|
|
||||||
: ${COREOS_VERSION_AUSERVER:="http://$(hostname --fqdn):8080/update"}
|
|
||||||
: ${COREOS_VERSION_DEVSERVER:="http://$(hostname --fqdn):8080"}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# DISTRIB_* are the standard lsb-release names
|
||||||
# TODO(marineam): come up with a way to support continous integration builds,
|
sudo mkdir -p "${ROOT_FS_DIR}/usr/share/coreos" "${ROOT_FS_DIR}/etc"
|
||||||
# this would provide all the bells and whistles for 'master' branch images.
|
|
||||||
#elif [ "$USER" = "chrome-bot" ]; then
|
|
||||||
# # Continuous builder
|
|
||||||
# COREOS_VERSION_TRACK="buildbot-build"
|
|
||||||
# COREOS_VERSION_DESCRIPTION="${COREOS_VERSION_STRING} (Continuous Build \
|
|
||||||
#- Builder: ${BUILDBOT_BUILD:-"N/A"}) $FLAGS_board"
|
|
||||||
|
|
||||||
|
|
||||||
# Set coreos-specific version numbers:
|
|
||||||
# COREOS_RELEASE_BOARD is the target board identifier.
|
|
||||||
# COREOS_RELEASE_DESCRIPTION is the extended human readable form.
|
|
||||||
# COREOS_RELEASE_NAME is a human readable name for the build.
|
|
||||||
# COREOS_RELEASE_TRACK and COREOS_RELEASE_VERSION are used by the software
|
|
||||||
# update service.
|
|
||||||
# DISTRIB_* are the standard names for the same values.
|
|
||||||
sudo mkdir -p "${ROOT_FS_DIR}/usr/share/coreos"
|
|
||||||
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/lsb-release" <<EOF
|
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/lsb-release" <<EOF
|
||||||
DISTRIB_ID=$COREOS_VERSION_NAME
|
DISTRIB_ID=$COREOS_VERSION_NAME
|
||||||
DISTRIB_RELEASE=$COREOS_VERSION_STRING
|
DISTRIB_RELEASE=$COREOS_VERSION_STRING
|
||||||
DISTRIB_CODENAME="Bear Creek Manor"
|
DISTRIB_CODENAME="Bear Creek Manor"
|
||||||
DISTRIB_DESCRIPTION="$COREOS_VERSION_NAME $COREOS_VERSION_DESCRIPTION"
|
DISTRIB_DESCRIPTION="$COREOS_VERSION_NAME $COREOS_VERSION_STRING"
|
||||||
COREOS_RELEASE_BOARD=$FLAGS_board
|
|
||||||
COREOS_RELEASE_DESCRIPTION="$COREOS_VERSION_DESCRIPTION"
|
|
||||||
COREOS_RELEASE_NAME=$COREOS_VERSION_NAME
|
|
||||||
COREOS_RELEASE_TRACK=$COREOS_VERSION_TRACK
|
|
||||||
COREOS_RELEASE_VERSION=$COREOS_VERSION_STRING
|
|
||||||
COREOS_AUSERVER=$COREOS_VERSION_AUSERVER
|
|
||||||
COREOS_DEVSERVER=$COREOS_VERSION_DEVSERVER
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sudo mkdir -p "${ROOT_FS_DIR}/etc"
|
|
||||||
sudo ln -sf "../usr/share/coreos/lsb-release" "${ROOT_FS_DIR}/etc/lsb-release"
|
sudo ln -sf "../usr/share/coreos/lsb-release" "${ROOT_FS_DIR}/etc/lsb-release"
|
||||||
|
|
||||||
# For things like python which read gentoo-release
|
|
||||||
sudo_clobber "${ROOT_FS_DIR}/etc/gentoo-release" <<EOF
|
|
||||||
$COREOS_VERSION_NAME release $COREOS_VERSION_STRING
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Aaaannd for the new systemd world order
|
# Aaaannd for the new systemd world order
|
||||||
# os-release provides a separate build-id field, so split it from version
|
# os-release provides a separate build-id field, so split it from version
|
||||||
OS_ID=$(tr '[:upper:]' '[:lower:]' <<<"$COREOS_VERSION_NAME")
|
OS_ID=$(tr '[:upper:]' '[:lower:]' <<<"$COREOS_VERSION_NAME")
|
||||||
@ -107,21 +59,22 @@ ID=$OS_ID
|
|||||||
VERSION=$COREOS_VERSION_STRING
|
VERSION=$COREOS_VERSION_STRING
|
||||||
VERSION_ID=$COREOS_VERSION_ID
|
VERSION_ID=$COREOS_VERSION_ID
|
||||||
BUILD_ID=$COREOS_BUILD_ID
|
BUILD_ID=$COREOS_BUILD_ID
|
||||||
PRETTY_NAME="$COREOS_VERSION_NAME $COREOS_VERSION_DESCRIPTION"
|
PRETTY_NAME="$COREOS_VERSION_NAME $COREOS_VERSION_STRING"
|
||||||
ANSI_COLOR="1;32"
|
ANSI_COLOR="1;32"
|
||||||
HOME_URL="http://www.coreos.com/"
|
HOME_URL="http://www.coreos.com/"
|
||||||
EOF
|
EOF
|
||||||
# The first time through the image, we have an os-release from a package,
|
|
||||||
# the second time through this script, we don't, so we need to test if it's
|
|
||||||
# present before trying to remove it.
|
|
||||||
sudo ln -sf "../usr/share/coreos/os-release" "${ROOT_FS_DIR}/etc/os-release"
|
sudo ln -sf "../usr/share/coreos/os-release" "${ROOT_FS_DIR}/etc/os-release"
|
||||||
|
|
||||||
# Create the defaults for the coreos configuration files in the usr directory
|
# Create the defaults for the coreos configuration files in the usr directory
|
||||||
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/release" <<EOF
|
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/release" <<EOF
|
||||||
COREOS_RELEASE_VERSION=$COREOS_VERSION_STRING
|
COREOS_RELEASE_VERSION=$COREOS_VERSION_STRING
|
||||||
|
COREOS_RELEASE_BOARD=$FLAGS_board
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/update.conf" <<EOF
|
sudo_clobber "${ROOT_FS_DIR}/usr/share/coreos/update.conf" <<EOF
|
||||||
SERVER=$COREOS_VERSION_AUSERVER
|
SERVER=$COREOS_VERSION_AUSERVER
|
||||||
GROUP=$COREOS_VERSION_TRACK
|
GROUP=$FLAGS_group
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# For old versions of vagrant
|
||||||
|
sudo_clobber "${ROOT_FS_DIR}/etc/gentoo-release" <<<"$COREOS_VERSION_NAME"
|
||||||
|
@ -60,8 +60,8 @@ switch_to_strict_mode
|
|||||||
create_host_setup
|
create_host_setup
|
||||||
|
|
||||||
# Run version hooks as pre-update
|
# Run version hooks as pre-update
|
||||||
if [[ -f /etc/lsb-release ]]; then
|
if [[ -f /etc/os-release ]]; then
|
||||||
OLDVER=$(grep "^COREOS_RELEASE_VERSION=" /etc/lsb-release | cut -d = -f 2-)
|
OLDVER=$(grep "^VERSION=" /etc/os-release | cut -d = -f 2-)
|
||||||
else
|
else
|
||||||
OLDVER="0.0.0"
|
OLDVER="0.0.0"
|
||||||
fi
|
fi
|
||||||
@ -84,9 +84,7 @@ for update_script in ${SCRIPTS_DIR}/sdk_lib/updates/*.sh; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
"${BUILD_LIBRARY_DIR}/set_lsb_release" \
|
"${BUILD_LIBRARY_DIR}/set_lsb_release" --root /
|
||||||
--root / --production_track sdk \
|
|
||||||
--board "$(portageq envvar ARCH)-host"
|
|
||||||
|
|
||||||
EMERGE_FLAGS="-uNv --with-bdeps=y --select"
|
EMERGE_FLAGS="-uNv --with-bdeps=y --select"
|
||||||
if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then
|
if [ "${FLAGS_usepkg}" -eq "${FLAGS_TRUE}" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user