mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-29 06:21:46 +01:00
Revert "fix(build_library): Create disk image first instead of last."
This reverts commit b97cfe126f0934d1505e352e17f15d580879d3cc. The minor device numbers of loop partitions are allocated dynamically which significantly complicates dunning under Docker which uses a static /dev. Rolling this back until we can rely on /dev being dynamic.
This commit is contained in:
parent
4f18deb87f
commit
8b7cc15bc6
@ -32,11 +32,6 @@ cleanup_mounts() {
|
|||||||
safe_umount_tree "${esp_fs_dir}"
|
safe_umount_tree "${esp_fs_dir}"
|
||||||
safe_umount_tree "${oem_fs_dir}"
|
safe_umount_tree "${oem_fs_dir}"
|
||||||
|
|
||||||
if [[ -n "${loop_dev}" ]]; then
|
|
||||||
sudo losetup -d "${loop_dev}"
|
|
||||||
loop_dev=
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Turn die on error back on.
|
# Turn die on error back on.
|
||||||
set -e
|
set -e
|
||||||
}
|
}
|
||||||
@ -64,33 +59,36 @@ create_base_image() {
|
|||||||
trap "cleanup_mounts && delete_prompt" EXIT
|
trap "cleanup_mounts && delete_prompt" EXIT
|
||||||
cleanup_mounts &> /dev/null
|
cleanup_mounts &> /dev/null
|
||||||
|
|
||||||
write_partition_table "${image_type}" "${BUILD_DIR}/${image_name}"
|
|
||||||
loop_dev=$(sudo losetup -P -f --show "${BUILD_DIR}/${image_name}")
|
|
||||||
|
|
||||||
local fs_block_size=$(get_fs_block_size)
|
|
||||||
|
|
||||||
local root_fs_label="ROOT-A"
|
local root_fs_label="ROOT-A"
|
||||||
local root_fs_num=$(get_num ${image_type} ${root_fs_label})
|
local root_fs_num=$(get_num ${image_type} ${root_fs_label})
|
||||||
local root_fs_dev="${loop_dev}p${root_fs_num}"
|
local root_fs_img="${BUILD_DIR}/rootfs.image"
|
||||||
local root_fs_bytes=$(get_filesystem_size ${image_type} ${root_fs_num})
|
local root_fs_bytes=$(get_filesystem_size ${image_type} ${root_fs_num})
|
||||||
local root_fs_blocks=$((root_fs_bytes / fs_block_size))
|
|
||||||
|
|
||||||
local state_fs_label="STATE"
|
local state_fs_label="STATE"
|
||||||
local state_fs_num=$(get_num ${image_type} ${state_fs_label})
|
local state_fs_num=$(get_num ${image_type} ${state_fs_label})
|
||||||
local state_fs_dev="${loop_dev}p${state_fs_num}"
|
local state_fs_img="${BUILD_DIR}/state.image"
|
||||||
|
local state_fs_bytes=$(get_filesystem_size ${image_type} ${state_fs_num})
|
||||||
|
local state_fs_uuid=$(uuidgen)
|
||||||
|
|
||||||
local esp_fs_label="EFI-SYSTEM"
|
local esp_fs_label="EFI-SYSTEM"
|
||||||
local esp_fs_num=$(get_num ${image_type} ${esp_fs_label})
|
local esp_fs_num=$(get_num ${image_type} ${esp_fs_label})
|
||||||
local esp_fs_dev="${loop_dev}p${esp_fs_num}"
|
local esp_fs_img="${BUILD_DIR}/esp.image"
|
||||||
|
local esp_fs_bytes=$(get_filesystem_size ${image_type} ${esp_fs_num})
|
||||||
|
|
||||||
local oem_fs_label="OEM"
|
local oem_fs_label="OEM"
|
||||||
local oem_fs_num=$(get_num ${image_type} ${oem_fs_label})
|
local oem_fs_num=$(get_num ${image_type} ${oem_fs_label})
|
||||||
local oem_fs_dev="${loop_dev}p${oem_fs_num}"
|
local oem_fs_img="${BUILD_DIR}/oem.image"
|
||||||
|
local oem_fs_bytes=$(get_filesystem_size ${image_type} ${oem_fs_num})
|
||||||
|
local oem_fs_uuid=$(uuidgen)
|
||||||
|
|
||||||
|
local fs_block_size=$(get_fs_block_size)
|
||||||
|
|
||||||
# Build root FS image.
|
# Build root FS image.
|
||||||
info "Building ROOT filesystem"
|
info "Building ${root_fs_img}"
|
||||||
sudo mkfs.ext2 -F -q -b ${fs_block_size} "${root_fs_dev}" "${root_fs_blocks}"
|
truncate --size="${root_fs_bytes}" "${root_fs_img}"
|
||||||
sudo tune2fs -L "${root_fs_label}" \
|
/sbin/mkfs.ext2 -F -q -b ${fs_block_size} "${root_fs_img}" \
|
||||||
|
"$((root_fs_bytes / fs_block_size))"
|
||||||
|
/sbin/tune2fs -L "${root_fs_label}" \
|
||||||
-U clear \
|
-U clear \
|
||||||
-T 20091119110000 \
|
-T 20091119110000 \
|
||||||
-c 0 \
|
-c 0 \
|
||||||
@ -98,33 +96,34 @@ create_base_image() {
|
|||||||
-m 0 \
|
-m 0 \
|
||||||
-r 0 \
|
-r 0 \
|
||||||
-e remount-ro \
|
-e remount-ro \
|
||||||
"${root_fs_dev}"
|
"${root_fs_img}"
|
||||||
mkdir -p "${root_fs_dir}"
|
mkdir -p "${root_fs_dir}"
|
||||||
sudo mount "${root_fs_dev}" "${root_fs_dir}"
|
sudo mount -o loop "${root_fs_img}" "${root_fs_dir}"
|
||||||
|
|
||||||
|
df -h "${root_fs_dir}"
|
||||||
|
|
||||||
# Build state FS disk image.
|
# Build state FS disk image.
|
||||||
info "Building STATE filesystem"
|
info "Building ${state_fs_img}"
|
||||||
sudo mkfs.ext4 -F -q "${state_fs_dev}"
|
truncate --size="${state_fs_bytes}" "${state_fs_img}"
|
||||||
sudo tune2fs -L "${state_fs_label}" \
|
/sbin/mkfs.ext4 -F -q "${state_fs_img}"
|
||||||
-c 0 \
|
/sbin/tune2fs -L "${state_fs_label}" -U "${state_fs_uuid}" \
|
||||||
-i 0 \
|
-c 0 -i 0 "${state_fs_img}"
|
||||||
"${state_fs_dev}"
|
|
||||||
mkdir -p "${state_fs_dir}"
|
mkdir -p "${state_fs_dir}"
|
||||||
sudo mount "${state_fs_dev}" "${state_fs_dir}"
|
sudo mount -o loop "${state_fs_img}" "${state_fs_dir}"
|
||||||
|
|
||||||
# Build ESP disk image.
|
# Build ESP disk image.
|
||||||
info "Building ESP filesystem"
|
info "Building ${esp_fs_img}"
|
||||||
sudo mkfs.vfat "${esp_fs_dev}"
|
truncate --size="${esp_fs_bytes}" "${esp_fs_img}"
|
||||||
|
/usr/sbin/mkfs.vfat "${esp_fs_img}"
|
||||||
|
|
||||||
# Build OEM FS disk image.
|
# Build OEM FS disk image.
|
||||||
info "Building OEM filesystem"
|
info "Building ${oem_fs_img}"
|
||||||
sudo mkfs.ext4 -F -q "${oem_fs_dev}"
|
truncate --size="${oem_fs_bytes}" "${oem_fs_img}"
|
||||||
sudo tune2fs -L "${oem_fs_label}" \
|
/sbin/mkfs.ext4 -F -q "${oem_fs_img}"
|
||||||
-c 0 \
|
/sbin/tune2fs -L "${oem_fs_label}" -U "${oem_fs_uuid}" \
|
||||||
-i 0 \
|
-c 0 -i 0 "${oem_fs_img}"
|
||||||
"${oem_fs_dev}"
|
|
||||||
mkdir -p "${oem_fs_dir}"
|
mkdir -p "${oem_fs_dir}"
|
||||||
sudo mount "${oem_fs_dev}" "${oem_fs_dir}"
|
sudo mount -o loop "${oem_fs_img}" "${oem_fs_dir}"
|
||||||
|
|
||||||
# Prepare state partition with some pre-created directories.
|
# Prepare state partition with some pre-created directories.
|
||||||
for i in ${ROOT_OVERLAYS}; do
|
for i in ${ROOT_OVERLAYS}; do
|
||||||
@ -269,6 +268,16 @@ create_base_image() {
|
|||||||
|
|
||||||
cleanup_mounts
|
cleanup_mounts
|
||||||
|
|
||||||
|
# Create the GPT-formatted image.
|
||||||
|
build_gpt "${BUILD_DIR}/${image_name}" \
|
||||||
|
"${root_fs_img}" \
|
||||||
|
"${state_fs_img}" \
|
||||||
|
"${esp_fs_img}" \
|
||||||
|
"${oem_fs_img}"
|
||||||
|
|
||||||
|
# Clean up temporary files.
|
||||||
|
rm -f "${root_fs_img}" "${state_fs_img}" "${esp_fs_img}" "{oem_fs_img}"
|
||||||
|
|
||||||
# Emit helpful scripts for testers, etc.
|
# Emit helpful scripts for testers, etc.
|
||||||
emit_gpt_scripts "${BUILD_DIR}/${image_name}" "${BUILD_DIR}"
|
emit_gpt_scripts "${BUILD_DIR}/${image_name}" "${BUILD_DIR}"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user