mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 11:51:14 +02:00
Merge pull request #51 from flatcar-linux/kai/build-prod-container-tar
build_image: Add prodtar command to build a tar ball
This commit is contained in:
commit
2f99e2a1f6
10
build_image
10
build_image
@ -56,12 +56,13 @@ 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.
|
||||
prod - Production image for CoreOS. This image is for booting (default if no argument is given).
|
||||
prodtar - Production container tar ball (implies prod). This can e.g. be used to run the Flatcar production image as a container (run machinectl import-tar or docker import).
|
||||
container - Developer image with single filesystem, bootable by nspawn.
|
||||
|
||||
Examples:
|
||||
|
||||
build_image --board=<board> [prod] [container] - builds developer and production images.
|
||||
build_image --board=<board> [prod] [prodtar] [container] - builds developer and production images/tars.
|
||||
...
|
||||
"
|
||||
show_help_if_requested "$@"
|
||||
@ -112,10 +113,12 @@ fi
|
||||
. "${BUILD_LIBRARY_DIR}/vm_image_util.sh" || exit 1
|
||||
|
||||
PROD_IMAGE=0
|
||||
PROD_TAR=0
|
||||
CONTAINER=0
|
||||
for arg in "$@"; do
|
||||
case "${arg}" in
|
||||
prod) PROD_IMAGE=1 ;;
|
||||
prodtar) PROD_IMAGE=1 PROD_TAR=1 ;;
|
||||
container) CONTAINER=1 ;;
|
||||
*) die_notrace "Unknown image type ${arg}" ;;
|
||||
esac
|
||||
@ -177,6 +180,9 @@ if [[ "${PROD_IMAGE}" -eq 1 ]]; then
|
||||
elif [[ ${FLAGS_extract_update} -eq ${FLAGS_TRUE} ]]; then
|
||||
extract_update "${FLATCAR_PRODUCTION_IMAGE_NAME}" "${DISK_LAYOUT}"
|
||||
fi
|
||||
if [[ "${PROD_TAR}" -eq 1 ]]; then
|
||||
create_prod_tar ${FLATCAR_PRODUCTION_IMAGE_NAME}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ${FLAGS_generate_update} -eq ${FLAGS_TRUE} ]] || \
|
||||
|
||||
@ -149,3 +149,20 @@ EOF
|
||||
fi
|
||||
upload_image -d "${BUILD_DIR}/${image_name}.bz2.DIGESTS" "${to_upload[@]}"
|
||||
}
|
||||
|
||||
create_prod_tar() {
|
||||
local image_name="$1"
|
||||
local image="${BUILD_DIR}/${image_name}"
|
||||
local container="${BUILD_DIR}/flatcar-container.tar.gz"
|
||||
local lodev="$(sudo losetup --find --show -r -P "${image}")"
|
||||
local lodevbase="$(basename "${lodev}")"
|
||||
sudo mkdir -p "/mnt/${lodevbase}p9"
|
||||
sudo mount "${lodev}p9" "/mnt/${lodevbase}p9"
|
||||
sudo mount "${lodev}p3" "/mnt/${lodevbase}p9/usr"
|
||||
sudo tar --xattrs -czpf "${container}" -C "/mnt/${lodevbase}p9" .
|
||||
sudo umount "/mnt/${lodevbase}p9/usr"
|
||||
sudo umount "/mnt/${lodevbase}p9"
|
||||
sudo rmdir "/mnt/${lodevbase}p9"
|
||||
sudo losetup --detach "${lodev}"
|
||||
upload_image "${container}"
|
||||
}
|
||||
|
||||
@ -73,4 +73,4 @@ script build_image \
|
||||
--torcx_manifest=/mnt/host/source/torcx/torcx_manifest.json \
|
||||
--torcx_root=/mnt/host/source/torcx/ \
|
||||
--upload_root="${UPLOAD_ROOT}" \
|
||||
--upload prod container
|
||||
--upload prodtar container
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user