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() { ...@@ -68,6 +68,22 @@ setup_loop() {
return 0 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) cwd=$(pwd)
distro=${DIST:-buster+ci} distro=${DIST:-buster+ci}
...@@ -83,6 +99,7 @@ debootstrap_dist= ...@@ -83,6 +99,7 @@ debootstrap_dist=
kernel_deb= kernel_deb=
custom_package_opt= custom_package_opt=
board_packages= board_packages=
meta_yml=files/meta.yml
while getopts ":hb:d:T:B" opt; do while getopts ":hb:d:T:B" opt; do
case ${opt} in case ${opt} in
...@@ -127,8 +144,7 @@ echo "Installing extra packages ${packages}" ...@@ -127,8 +144,7 @@ echo "Installing extra packages ${packages}"
[ -z "${board_packages}" ] || echo "Installing extra board specific packages ${board_packages}" [ -z "${board_packages}" ] || echo "Installing extra board specific packages ${board_packages}"
mkdir -p tmp/ files/ mkdir -p tmp/ files/
echo -n > files/meta.yml rm -f "./tmp/${pureos_board}-report.log" "${meta_yml}"
rm -f "./tmp/${pureos_board}-report.log"
if [ "${build_type}" == "latest" ]; then if [ "${build_type}" == "latest" ]; then
fetch_latest_kernel fetch_latest_kernel
...@@ -191,7 +207,6 @@ sudo pureos_board="${pureos_board}" \ ...@@ -191,7 +207,6 @@ sudo pureos_board="${pureos_board}" \
${NULL} ${NULL}
set +x set +x
echo "gitrev: $(git log --format=format:%H -1)" >> files/meta.yml
if [ "${arch}" == "arm64" ]; then if [ "${arch}" == "arm64" ]; then
if [ ! -f "files/uboot-${uboot_type}/m4.bin" ]; then if [ ! -f "files/uboot-${uboot_type}/m4.bin" ]; then
...@@ -206,6 +221,8 @@ fi ...@@ -206,6 +221,8 @@ fi
[ -f "./tmp/${pureos_board}-report.log" ] || { echo "No install report found."; exit 1; } [ -f "./tmp/${pureos_board}-report.log" ] || { echo "No install report found."; exit 1; }
write_meta "${meta_yml}" "${bootimg}"
if [ "${want_qcow2}" == 1 ]; then if [ "${want_qcow2}" == 1 ]; then
qcow2="$(basename "${bootimg}" .img)".qcow2 qcow2="$(basename "${bootimg}" .img)".qcow2
qemu-img convert -f raw -O qcow2 "${bootimg}" "${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