mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-30 01:51:09 +02:00
Drop more unused "modify_image" code
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
This commit is contained in:
parent
e44b946abf
commit
0fd811f453
@ -1,100 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright (c) 2014 The CoreOS Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
|
||||||
# found in the LICENSE file.
|
|
||||||
|
|
||||||
# Shell library for modifying an image built with build_image.
|
|
||||||
|
|
||||||
start_modify_image() {
|
|
||||||
# Default to the most recent image
|
|
||||||
if [[ -z "${FLAGS_from}" ]] ; then
|
|
||||||
FLAGS_from="$(${SCRIPT_ROOT}/get_latest_image.sh --board=${FLAGS_board})"
|
|
||||||
else
|
|
||||||
FLAGS_from="$(readlink -f "${FLAGS_from}")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local src_image="${FLAGS_from}/${FLATCAR_PRODUCTION_IMAGE_NAME}"
|
|
||||||
if [[ ! -f "${src_image}" ]]; then
|
|
||||||
die_notrace "Source image does not exist: ${src_image}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Source should include version.txt, switch to its version information
|
|
||||||
if [[ ! -f "${FLAGS_from}/version.txt" ]]; then
|
|
||||||
die_notrace "Source version info does not exist: ${FLAGS_from}/version.txt"
|
|
||||||
fi
|
|
||||||
source "${FLAGS_from}/version.txt"
|
|
||||||
FLATCAR_VERSION_STRING="${FLATCAR_VERSION}"
|
|
||||||
|
|
||||||
# Load after version.txt to set the correct output paths
|
|
||||||
. "${BUILD_LIBRARY_DIR}/toolchain_util.sh"
|
|
||||||
. "${BUILD_LIBRARY_DIR}/board_options.sh"
|
|
||||||
. "${BUILD_LIBRARY_DIR}/build_image_util.sh"
|
|
||||||
|
|
||||||
# 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.
|
|
||||||
DST_IMAGE="${BUILD_DIR}/${FLATCAR_PRODUCTION_IMAGE_NAME}"
|
|
||||||
ROOT_FS_DIR="${BUILD_DIR}/rootfs"
|
|
||||||
mkdir -p "${ROOT_FS_DIR}"
|
|
||||||
|
|
||||||
info "Copying from ${FLAGS_from}"
|
|
||||||
cp "${src_image}" "${DST_IMAGE}"
|
|
||||||
|
|
||||||
# Copy all extra useful things, these do not need to be modified.
|
|
||||||
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"
|
|
||||||
"${update_prefix}.zip"
|
|
||||||
"${pcr_data}"
|
|
||||||
"${production_prefix}_contents.txt"
|
|
||||||
"${production_prefix}_packages.txt"
|
|
||||||
"${production_prefix}_kernel_config.txt"
|
|
||||||
"${FLATCAR_DEVELOPER_CONTAINER_NAME}"
|
|
||||||
"${container_prefix}_contents.txt"
|
|
||||||
"${container_prefix}_packages.txt"
|
|
||||||
)
|
|
||||||
for filename in "${EXTRA_FILES[@]}"; do
|
|
||||||
if [[ -e "${FLAGS_from}/${filename}" ]]; then
|
|
||||||
cp "${FLAGS_from}/${filename}" "${BUILD_DIR}/${filename}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
"${BUILD_LIBRARY_DIR}/disk_util" --disk_layout="${FLAGS_disk_layout}" \
|
|
||||||
mount "${DST_IMAGE}" "${ROOT_FS_DIR}"
|
|
||||||
trap "cleanup_mounts '${ROOT_FS_DIR}'" EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
finish_modify_image() {
|
|
||||||
cleanup_mounts "${ROOT_FS_DIR}"
|
|
||||||
trap - EXIT
|
|
||||||
|
|
||||||
|
|
||||||
declare -a files_to_evaluate
|
|
||||||
files_to_evaluate+=( "${DST_IMAGE}" )
|
|
||||||
compress_disk_images files_to_evaluate
|
|
||||||
|
|
||||||
set_build_symlinks "${FLAGS_group}-latest"
|
|
||||||
|
|
||||||
info "Done. Updated image is in ${BUILD_DIR}"
|
|
||||||
cat << EOF
|
|
||||||
To convert it to a virtual machine image, use:
|
|
||||||
./image_to_vm.sh --from=${OUTSIDE_OUTPUT_DIR} --board=${BOARD}
|
|
||||||
|
|
||||||
The default type is qemu, see ./image_to_vm.sh --help for other options.
|
|
||||||
EOF
|
|
||||||
}
|
|
@ -1,99 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright (c) 2014 The CoreOS 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_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
|
|
||||||
|
|
||||||
# Flags
|
|
||||||
DEFINE_string kernel_path "" \
|
|
||||||
"Path to the kernel to inject."
|
|
||||||
DEFINE_string efi_grub_path "" \
|
|
||||||
"Path to the EFI GRUB image to inject."
|
|
||||||
DEFINE_string shim_path "" \
|
|
||||||
"Path to the shim image to inject."
|
|
||||||
DEFINE_string group "${DEFAULT_GROUP}" \
|
|
||||||
"The update group."
|
|
||||||
DEFINE_string board "${DEFAULT_BOARD}" \
|
|
||||||
"Board for which the image was built"
|
|
||||||
DEFINE_string disk_layout "base" \
|
|
||||||
"The disk layout type to use for this image."
|
|
||||||
DEFINE_string from "" \
|
|
||||||
"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} \
|
|
||||||
"Overwrite existing output, if any."
|
|
||||||
|
|
||||||
# include upload options
|
|
||||||
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
|
|
||||||
|
|
||||||
show_help_if_requested "$@"
|
|
||||||
|
|
||||||
# Usually unneeded, so just leave this option hidden.
|
|
||||||
DEFINE_integer build_attempt 1 \
|
|
||||||
"The build attempt for this image build."
|
|
||||||
|
|
||||||
# Parse command line
|
|
||||||
FLAGS "$@" || exit 1
|
|
||||||
eval set -- "${FLAGS_ARGV}"
|
|
||||||
|
|
||||||
# Die on any errors.
|
|
||||||
switch_to_strict_mode
|
|
||||||
|
|
||||||
if [[ -z "${FLAGS_kernel_path}" && -z "${FLAGS_efi_grub_path}" &&
|
|
||||||
-z "${FLAGS_shim_path}" ]]; then
|
|
||||||
die_notrace "Specify at least one of --kernel_path, --efi_grub_path, --shim_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
. "${BUILD_LIBRARY_DIR}/modify_image_util.sh"
|
|
||||||
|
|
||||||
do_copy() {
|
|
||||||
local src="$1"
|
|
||||||
local dst="$2"
|
|
||||||
|
|
||||||
if [[ ! -f "${ROOT_FS_DIR}/${dst}" ]]; then
|
|
||||||
# We should only be overwriting existing files.
|
|
||||||
die "${dst} doesn't exist in image; refusing to create it"
|
|
||||||
fi
|
|
||||||
info "Replacing ${dst}"
|
|
||||||
sudo cp "${src}" "${ROOT_FS_DIR}/${dst}"
|
|
||||||
}
|
|
||||||
|
|
||||||
start_modify_image
|
|
||||||
|
|
||||||
if [[ -n "${FLAGS_kernel_path}" ]]; then
|
|
||||||
do_copy "${FLAGS_kernel_path}" "/boot/flatcar/vmlinuz-a"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# FIXME(bgilbert): no shim on arm64
|
|
||||||
if [[ -n "${FLAGS_efi_grub_path}" ]]; then
|
|
||||||
case "${BOARD}" in
|
|
||||||
amd64-usr) image_name="grub.efi" ;;
|
|
||||||
arm64-usr) image_name="bootaa64.efi" ;;
|
|
||||||
*) die "GRUB filename not known for this board" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
do_copy "${FLAGS_efi_grub_path}" "/boot/EFI/boot/${image_name}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "${FLAGS_shim_path}" ]]; then
|
|
||||||
case "${BOARD}" in
|
|
||||||
amd64-usr) image_name="bootx64.efi" ;;
|
|
||||||
*) die "Shim filename not known for this board" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
do_copy "${FLAGS_shim_path}" "/boot/EFI/boot/${image_name}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
finish_modify_image
|
|
||||||
command_completed
|
|
@ -1,64 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Copyright (c) 2014 The CoreOS 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_ROOT=$(dirname "$(readlink -f "$0")")
|
|
||||||
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
|
||||||
|
|
||||||
# Script must run inside the chroot
|
|
||||||
assert_inside_chroot
|
|
||||||
|
|
||||||
assert_not_root_user
|
|
||||||
|
|
||||||
# Flags
|
|
||||||
DEFINE_string group "" \
|
|
||||||
"The update group, required."
|
|
||||||
DEFINE_string board "${DEFAULT_BOARD}" \
|
|
||||||
"Board for which the image was built"
|
|
||||||
DEFINE_string disk_layout "base" \
|
|
||||||
"The disk layout type to use for this image."
|
|
||||||
DEFINE_string from "" \
|
|
||||||
"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} \
|
|
||||||
"Overwrite existing output, if any."
|
|
||||||
|
|
||||||
# include upload options
|
|
||||||
. "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1
|
|
||||||
|
|
||||||
show_help_if_requested "$@"
|
|
||||||
|
|
||||||
# Usually unneded, so just leave this option hidden.
|
|
||||||
DEFINE_integer build_attempt 1 \
|
|
||||||
"The build attempt for this image build."
|
|
||||||
|
|
||||||
# Parse command line
|
|
||||||
FLAGS "$@" || exit 1
|
|
||||||
eval set -- "${FLAGS_ARGV}"
|
|
||||||
|
|
||||||
# Die on any errors.
|
|
||||||
switch_to_strict_mode
|
|
||||||
|
|
||||||
if [[ -z "${FLAGS_board}" ]] ; then
|
|
||||||
die_notrace "--board is required."
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${FLAGS_group}" ]] ; then
|
|
||||||
die_notrace "--group is required."
|
|
||||||
fi
|
|
||||||
|
|
||||||
. "${BUILD_LIBRARY_DIR}/modify_image_util.sh"
|
|
||||||
|
|
||||||
start_modify_image
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
finish_modify_image
|
|
||||||
command_completed
|
|
Loading…
x
Reference in New Issue
Block a user