Skip to content

Commit 989c601

Browse files
committed
board/common: Restore capability to create QEMU image from tarball
Previously, post-image.sh was able to create QEMU images from an existing release tarball. This was useful when you wanted to test a new bootloader build without having to wait for a full Infix build. Restore this capability by adding a separate image target for it, and then allow image-itb-qcow to source its input images from that instead of a locally build squash+aux.
1 parent 55d2fc5 commit 989c601

File tree

6 files changed

+57
-14
lines changed

6 files changed

+57
-14
lines changed

board/common/Config.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-aux/Config.in"
55
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-qcow/Config.in"
66
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-gns3a/Config.in"
77
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-rauc/Config.in"
8+
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-itb-dl-release/Config.in"
89
source "$BR2_EXTERNAL_INFIX_PATH/board/common/image/image-readme/Config.in"
910

1011
endmenu
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
menuconfig IMAGE_ITB_DL_RELEASE
2+
bool "Download existing release"
3+
depends on !BR2_TARGET_ROOTFS_SQUASHFS
4+
help
5+
This is primarily used by target specific builds, where the
6+
bootloader artifact needs to be combined with an existing
7+
Infix image, to create a full disk image that can be
8+
provisioned to an SD-card or eMMC.
9+
10+
config IMAGE_ITB_DL_RELEASE_URL
11+
string "URL"
12+
depends on IMAGE_ITB_DL_RELEASE
13+
default "https://github.com/kernelkit/infix/releases/download/latest/infix-${BR2_ARCH}.tar.gz"
14+
help
15+
URL to release tarball.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
squash="${BINARIES_DIR}"/rootfs.squashfs
6+
aux="${BINARIES_DIR}"/aux.ext4
7+
8+
[ -f "${squash}" ] && [ -f "${aux}" ] && exit 0
9+
10+
archive="${WORKDIR}/$(basename ${URL})"
11+
[ -f "${archive}" ] || wget -O"${archive}" "${URL}"
12+
13+
echo "Unpacking..."
14+
tar -xa --strip-components=1 -C "${BINARIES_DIR}" -f "${archive}"
15+
16+
auxsize=$(stat -c %s "${aux}")
17+
if [ "${auxsize}" -gt $((8 << 20)) ]; then
18+
# In older releases, 16M aux.ext4 images were generated. In order
19+
# to keep the image-itb-qcow logic simpler, trim it 8M, which we
20+
# always generate nowadays.
21+
echo "WARNING: Auxiliary partition is unexpectedly large. Resizing..."
22+
resize2fs "${aux}" 8M
23+
truncate -s 8M "${aux}"
24+
tune2fs -l "${aux}"
25+
fi
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
################################################################################
2+
#
3+
# image-itb-dl-release
4+
#
5+
################################################################################
6+
7+
IMAGE_ITB_DL_RELEASE_CONFIG_VARS := URL
8+
9+
$(eval $(ix-image))

board/common/image/image-itb-qcow/Config.in

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
menuconfig IMAGE_ITB_QCOW
22
bool "QEMU disk image (ITB)"
3-
default y
4-
select IMAGE_ITB_ROOTFS
5-
select IMAGE_ITB_AUX
3+
depends on (IMAGE_ITB_ROOTFS && IMAGE_ITB_AUX) || IMAGE_ITB_DL_RELEASE
64
select BR2_PACKAGE_HOST_GENIMAGE
75
help
86
Compose a full disk image with redundant Linux OS partitions,
@@ -68,13 +66,3 @@ config IMAGE_ITB_QCOW_BOOT_OFFSET
6866
Offset at which the bootloader partition is placed. Remember
6967
to make sure that the GPT still fits at the start of the
7068
image.
71-
72-
config IMAGE_ITB_QCOW_RELEASE_URL
73-
string "Infix URL"
74-
depends on IMAGE_ITB_QCOW
75-
depends on !BR2_TARGET_ROOTFS_SQUASHFS
76-
default "https://github.com/kernelkit/infix/releases/download/latest/infix-${BR2_ARCH}.tar.gz"
77-
help
78-
In situations where Infix itself is not being built, but a
79-
disk image is, i.e. when building a bootloader: place this
80-
Infix release in the primary and secondary partitions.

board/common/image/image-itb-qcow/image-itb-qcow.mk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
#
55
################################################################################
66

7-
IMAGE_ITB_QCOW_DEPENDENCIES := host-genimage image-itb-rootfs image-itb-aux
7+
# We can source the rootfs+aux from a local build, or from a
8+
# downloaded release; so adjust our dependencies accordingly.
9+
IMAGE_ITB_QCOW_SRC-$(IMAGE_ITB_ROOTFS) := image-itb-rootfs image-itb-aux
10+
IMAGE_ITB_QCOW_SRC-$(IMAGE_ITB_DL_RELEASE) := image-itb-dl-release
11+
12+
IMAGE_ITB_QCOW_DEPENDENCIES := host-genimage $(IMAGE_ITB_QCOW_SRC-y)
813
IMAGE_ITB_QCOW_CONFIG_VARS := BOOT_DATA BOOT_OFFSET SIZE
914

1015
$(eval $(ix-image))

0 commit comments

Comments
 (0)