Commit 703c2ec1 authored by Guido Gunther's avatar Guido Gunther

build-image: Store size and checksum in metadata

This will allow us to verify that the downloaded image uncompressed
correctly and to have a proper progress bare even with images of
different sizes.
parent d5a5f448
......@@ -68,6 +68,22 @@ setup_loop() {
return 0
}
write_meta() {
local out="$1"
local image="$2"
image_sha256sum=$(sha256sum "${image}" | sed 's/\([a-f0-9]\+\) .*/\1/')
image_size=$(stat --format='%s' "${image}")
echo "Image '${image} has sha256sum ${image_sha256sum}"
cat <<EOF >> "${out}"
gitrev: $(git log --format=format:%H -1)
image:
size: ${image_size}
sha256sum: ${image_sha256sum}
EOF
}
cwd=$(pwd)
distro=${DIST:-buster+ci}
......@@ -83,6 +99,7 @@ debootstrap_dist=
kernel_deb=
custom_package_opt=
board_packages=
meta_yml=files/meta.yml
while getopts ":hb:d:T:B" opt; do
case ${opt} in
......@@ -127,8 +144,7 @@ echo "Installing extra packages ${packages}"
[ -z "${board_packages}" ] || echo "Installing extra board specific packages ${board_packages}"
mkdir -p tmp/ files/
echo -n > files/meta.yml
rm -f "./tmp/${pureos_board}-report.log"
rm -f "./tmp/${pureos_board}-report.log" "${meta_yml}"
if [ "${build_type}" == "latest" ]; then
fetch_latest_kernel
......@@ -191,7 +207,6 @@ sudo pureos_board="${pureos_board}" \
${NULL}
set +x
echo "gitrev: $(git log --format=format:%H -1)" >> files/meta.yml
if [ "${arch}" == "arm64" ]; then
if [ ! -f "files/uboot-${uboot_type}/m4.bin" ]; then
......@@ -206,6 +221,8 @@ fi
[ -f "./tmp/${pureos_board}-report.log" ] || { echo "No install report found."; exit 1; }
write_meta "${meta_yml}" "${bootimg}"
if [ "${want_qcow2}" == 1 ]; then
qcow2="$(basename "${bootimg}" .img)".qcow2
qemu-img convert -f raw -O qcow2 "${bootimg}" "${qcow2}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment