mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-10 06:26:57 +02:00
Merge pull request #148 from marineam/switch-usr
Experimantal amd64-usr board and disk layouts
This commit is contained in:
commit
007ab712bf
10
build_image
10
build_image
@ -119,8 +119,11 @@ fi
|
||||
# Create the output directory and temporary mount points.
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
DISK_LAYOUT_SUFFIX=$(portageq-$BOARD envvar COREOS_DISK_LAYOUT_SUFFIX)
|
||||
DISK_LAYOUT="${FLAGS_disk_layout:-base}${DISK_LAYOUT_SUFFIX}"
|
||||
|
||||
# Create the base image.
|
||||
create_base_image ${PRISTINE_IMAGE_NAME}
|
||||
create_base_image ${PRISTINE_IMAGE_NAME} ${DISK_LAYOUT}
|
||||
if should_build_image ${PRISTINE_IMAGE_NAME}; then
|
||||
upload_image "${BUILD_DIR}/${PRISTINE_IMAGE_NAME}"
|
||||
fi
|
||||
@ -138,14 +141,15 @@ if should_build_image ${CHROMEOS_DEVELOPER_IMAGE_NAME}; then
|
||||
else
|
||||
copy_image ${PRISTINE_IMAGE_NAME} ${CHROMEOS_DEVELOPER_IMAGE_NAME}
|
||||
fi
|
||||
install_dev_packages ${CHROMEOS_DEVELOPER_IMAGE_NAME}
|
||||
install_dev_packages ${CHROMEOS_DEVELOPER_IMAGE_NAME} ${DISK_LAYOUT}
|
||||
upload_image "${BUILD_DIR}/${CHROMEOS_DEVELOPER_IMAGE_NAME}"
|
||||
fi
|
||||
|
||||
if should_build_image ${COREOS_PRODUCTION_IMAGE_NAME}; then
|
||||
copy_image ${CHROMEOS_BASE_IMAGE_NAME} ${COREOS_PRODUCTION_IMAGE_NAME}
|
||||
|
||||
setup_prod_image ${COREOS_PRODUCTION_IMAGE_NAME} "dev-channel" \
|
||||
setup_prod_image ${COREOS_PRODUCTION_IMAGE_NAME} ${DISK_LAYOUT} \
|
||||
"dev-channel" \
|
||||
${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}"
|
||||
|
@ -6,9 +6,8 @@
|
||||
|
||||
create_base_image() {
|
||||
local image_name=$1
|
||||
local rootfs_verification_enabled=$2
|
||||
local disk_layout=$2
|
||||
|
||||
local disk_layout="${FLAGS_disk_layout:-base}"
|
||||
local disk_img="${BUILD_DIR}/${image_name}"
|
||||
local mbr_img="/usr/share/syslinux/gptmbr.bin"
|
||||
local root_fs_dir="${BUILD_DIR}/rootfs"
|
||||
@ -53,6 +52,7 @@ create_base_image() {
|
||||
|
||||
${BUILD_LIBRARY_DIR}/create_legacy_bootloader_templates.sh \
|
||||
--arch=${ARCH} \
|
||||
--disk_layout="${disk_layout}" \
|
||||
--boot_dir="${root_fs_dir}"/boot \
|
||||
--esp_dir="${root_fs_dir}"/boot/efi \
|
||||
--boot_args="${FLAGS_boot_args}"
|
||||
|
@ -22,6 +22,8 @@ DEFINE_string esp_dir "" \
|
||||
"Path to ESP partition mount point (Default: none)"
|
||||
DEFINE_string boot_args "" \
|
||||
"Additional boot arguments to pass to the commandline (Default: '')"
|
||||
DEFINE_string disk_layout "base" \
|
||||
"The disk layout type to use for this image."
|
||||
|
||||
# Parse flags
|
||||
FLAGS "$@" || exit 1
|
||||
@ -34,10 +36,20 @@ common_args="${common_args} ${FLAGS_boot_args}"
|
||||
|
||||
# Get partition UUIDs from the json config
|
||||
get_uuid() {
|
||||
"${BUILD_LIBRARY_DIR}/disk_util" readuuid "$1"
|
||||
"${BUILD_LIBRARY_DIR}/disk_util" --disk_layout="${FLAGS_disk_layout}" \
|
||||
readuuid "$1"
|
||||
}
|
||||
ROOTA="PARTUUID=$(get_uuid ROOT-A)"
|
||||
ROOTB="PARTUUID=$(get_uuid ROOT-B)"
|
||||
|
||||
# Filesystem args differ between the old and new usr layouts.
|
||||
if [[ "${FLAGS_disk_layout}" == *-usr ]]; then
|
||||
gptprio_args="root=LABEL=ROOT usr=gptprio:"
|
||||
slot_a_args="root=LABEL=ROOT usr=PARTUUID=$(get_uuid USR-A)"
|
||||
slot_b_args="root=LABEL=ROOT usr=PARTUUID=$(get_uuid USR-B)"
|
||||
else
|
||||
gptprio_args="root=gptprio:"
|
||||
slot_a_args="root=PARTUUID=$(get_uuid ROOT-A)"
|
||||
slot_b_args="root=PARTUUID=$(get_uuid ROOT-B)"
|
||||
fi
|
||||
|
||||
GRUB_DIR="${FLAGS_boot_dir}/grub"
|
||||
SYSLINUX_DIR="${FLAGS_boot_dir}/syslinux"
|
||||
@ -54,11 +66,11 @@ timeout 0
|
||||
|
||||
title CoreOS A Root
|
||||
root (hd0,0)
|
||||
kernel /syslinux/vmlinuz.A ${grub_args} root=${ROOTA}
|
||||
kernel /syslinux/vmlinuz.A ${grub_args} ${slot_a_args}
|
||||
|
||||
title CoreOS B Root
|
||||
root (hd0,0)
|
||||
kernel /syslinux/vmlinuz.B ${grub_args} root=${ROOTB}
|
||||
kernel /syslinux/vmlinuz.B ${grub_args} ${slot_b_args}
|
||||
EOF
|
||||
info "Emitted ${GRUB_DIR}/menu.lst.A"
|
||||
|
||||
@ -101,7 +113,7 @@ EOF
|
||||
label boot_kernel
|
||||
menu label boot_kernel
|
||||
kernel vmlinuz-boot_kernel
|
||||
append ${syslinux_args} root=gptprio:
|
||||
append ${syslinux_args} ${gptprio_args}
|
||||
EOF
|
||||
info "Emitted ${SYSLINUX_DIR}/boot_kernel.cfg"
|
||||
|
||||
@ -109,7 +121,7 @@ EOF
|
||||
label coreos.A
|
||||
menu label coreos.A
|
||||
kernel vmlinuz.A
|
||||
append ${syslinux_args} root=${ROOTA}
|
||||
append ${syslinux_args} ${slot_a_args}
|
||||
EOF
|
||||
info "Emitted ${SYSLINUX_DIR}/root.A.cfg"
|
||||
|
||||
@ -117,7 +129,7 @@ EOF
|
||||
label coreos.B
|
||||
menu label coreos.B
|
||||
kernel vmlinuz.B
|
||||
append ${syslinux_args} root=${ROOTB}
|
||||
append ${syslinux_args} ${slot_b_args}
|
||||
EOF
|
||||
info "Emitted ${SYSLINUX_DIR}/root.B.cfg"
|
||||
}
|
||||
@ -133,6 +145,8 @@ copy_to_esp() {
|
||||
sudo cp -r "${SYSLINUX_DIR}/." "${FLAGS_esp_dir}/syslinux"
|
||||
|
||||
# Stage all kernels with the only one we built.
|
||||
# FIXME(marineam): without an EFI bootloader like gummiboot we currently
|
||||
# don't have a way to set the correct mount options based on disk layout.
|
||||
for kernel in syslinux/{vmlinuz-boot_kernel,vmlinuz.A,vmlinuz.B} \
|
||||
EFI/boot/bootx64.efi
|
||||
do
|
||||
|
@ -11,9 +11,9 @@
|
||||
# Takes as an arg the name of the image to be created.
|
||||
install_dev_packages() {
|
||||
local image_name=$1
|
||||
local disk_layout=$2
|
||||
|
||||
info "Adding developer packages to ${image_name}"
|
||||
local disk_layout="${FLAGS_disk_layout:-base}"
|
||||
local root_fs_dir="${BUILD_DIR}/rootfs"
|
||||
|
||||
"${BUILD_LIBRARY_DIR}/disk_util" --disk_layout="${disk_layout}" \
|
||||
|
@ -74,6 +74,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"base-usr":{
|
||||
"3":{
|
||||
"label":"USR-A",
|
||||
"mount":"/usr"
|
||||
},
|
||||
"4":{
|
||||
"label":"USR-B"
|
||||
},
|
||||
"9":{
|
||||
"label":"ROOT",
|
||||
"mount":"/",
|
||||
"binds":{}
|
||||
}
|
||||
},
|
||||
"vm":{
|
||||
"9":{
|
||||
"label":"STATE",
|
||||
@ -81,12 +95,42 @@
|
||||
"blocks":"6291456"
|
||||
}
|
||||
},
|
||||
"vm-usr":{
|
||||
"3":{
|
||||
"label":"USR-A",
|
||||
"mount":"/usr"
|
||||
},
|
||||
"4":{
|
||||
"label":"USR-B"
|
||||
},
|
||||
"9":{
|
||||
"label":"ROOT",
|
||||
"mount":"/",
|
||||
"binds":{},
|
||||
"blocks":"6291456"
|
||||
}
|
||||
},
|
||||
"vagrant":{
|
||||
"9":{
|
||||
"label":"STATE",
|
||||
"type":"data",
|
||||
"blocks":"33587200"
|
||||
}
|
||||
},
|
||||
"vagrant-usr":{
|
||||
"3":{
|
||||
"label":"USR-A",
|
||||
"mount":"/usr"
|
||||
},
|
||||
"4":{
|
||||
"label":"USR-B"
|
||||
},
|
||||
"9":{
|
||||
"label":"ROOT",
|
||||
"mount":"/",
|
||||
"binds":{},
|
||||
"blocks":"33587200"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@
|
||||
|
||||
setup_prod_image() {
|
||||
local image_name="$1"
|
||||
local update_track="$2"
|
||||
local au_key="$3"
|
||||
local disk_layout="$2"
|
||||
local update_track="$3"
|
||||
local au_key="$4"
|
||||
|
||||
info "Configuring production image ${image_name}"
|
||||
local disk_layout="${FLAGS_disk_layout:-base}"
|
||||
local root_fs_dir="${BUILD_DIR}/rootfs"
|
||||
local enable_rootfs_verification_flag=--noenable_rootfs_verification
|
||||
if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_TRUE} ]]; then
|
||||
|
@ -22,6 +22,8 @@ CROSS_PROFILES["x86_64-cros-linux-gnu"]="coreos:coreos/amd64/generic"
|
||||
declare -A BOARD_CHOSTS BOARD_PROFILES
|
||||
BOARD_CHOSTS["amd64-generic"]="x86_64-cros-linux-gnu"
|
||||
BOARD_PROFILES["amd64-generic"]="coreos:coreos/amd64/generic"
|
||||
BOARD_CHOSTS["amd64-usr"]="x86_64-cros-linux-gnu"
|
||||
BOARD_PROFILES["amd64-usr"]="coreos:coreos/amd64/usr"
|
||||
BOARD_NAMES=( "${!BOARD_CHOSTS[@]}" )
|
||||
|
||||
# Declare the above globals as read-only to avoid accidental conflicts.
|
||||
|
@ -198,7 +198,8 @@ _disk_ext() {
|
||||
}
|
||||
|
||||
setup_disk_image() {
|
||||
local disk_layout="${1:-$(_get_vm_opt DISK_LAYOUT)}"
|
||||
local suffix=$(portageq-$BOARD envvar COREOS_DISK_LAYOUT_SUFFIX)
|
||||
local disk_layout="${1:-$(_get_vm_opt DISK_LAYOUT)}${suffix}"
|
||||
|
||||
rm -rf "${VM_TMP_DIR}"
|
||||
mkdir -p "${VM_TMP_DIR}" "${VM_TMP_ROOT}"
|
||||
|
Loading…
Reference in New Issue
Block a user