diff options
| author | Ivan Gulakov <gulakov@amazon.de> | 2025-01-15 10:48:41 +0000 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-01-15 11:30:23 +0000 |
| commit | 73c2b1ea7b9f1744b7188d46fd1a8d0eac92a4d5 (patch) | |
| tree | 7f335569dd66d3e5b6ef916bdce47a5aa9c131d6 | |
| parent | 7315a7cf6c6eb74abe6888b820a131efaae8a0f4 (diff) | |
tools: add platform to create_ec2_image.sh
If we pass a platform argument to docker the script could also create us
a rootfs image for arm64. (and maybe more in the future, who knows)
Set it to linux/amd64 by default.
While there, remove some confirmations by automating them.
| -rwxr-xr-x | tools/create-ec2-rootfs.sh | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/create-ec2-rootfs.sh b/tools/create-ec2-rootfs.sh index 6f5dd2798..1756b569e 100755 --- a/tools/create-ec2-rootfs.sh +++ b/tools/create-ec2-rootfs.sh @@ -35,6 +35,7 @@ FORMAT="ext4" RESIZER="resize2fs" SIZE="1G" IMAGE="amazonlinux:2023" +PLATFORM="linux/amd64" # Display help function display_help() { @@ -43,6 +44,7 @@ display_help() { echo " -f, --format rootfs format (ext4 or xfs), default ext4" echo " -h, --help Display help message" echo " -n, --name rootfs name, default rootfs.ext4" + echo " -p, --platform linux platform type, default linux/amd64" echo " -s, --size rootfs size, default 1G" echo } @@ -77,6 +79,10 @@ while true; do NAME=$2 shift 2 ;; + -p | --platform) + PLATFORM=$2 + shift 2 + ;; -s | --size) SIZE=$2 shift 2 @@ -103,20 +109,20 @@ if [ -f "${NAME}" ]; then fi truncate -s ${SIZE} ${NAME} -mkfs.${FORMAT} ${NAME} +yes | mkfs.${FORMAT} ${NAME} sudo mount -o loop ${NAME} ${MOUNT_DIR} REMOVE_IMAGE=false -if [[ "$(sudo docker images -q ${IMAGE} 2>/dev/null)" == "" ]]; then +if [[ "$(sudo docker images --platform ${PLATFORM} -q ${IMAGE} 2>/dev/null)" == "" ]]; then REMOVE_IMAGE=true fi -CONTAINER=$(sudo docker create ${IMAGE}) +CONTAINER=$(sudo docker create --platform ${PLATFORM} ${IMAGE}) sudo docker export ${CONTAINER} | sudo tar -xC ${MOUNT_DIR} sudo docker rm ${CONTAINER} if "${REMOVE_IMAGE}" ; then - sudo docker rmi ${IMAGE} + sudo docker rmi -f ${IMAGE} fi sudo cp /etc/resolv.conf ${MOUNT_DIR}/etc/resolv.conf |
