feat: Kiwi-build generates sha256sum now #304

Merged
eminguez merged 1 commits from eminguez/suse-edge-factory:kiwi-sha256 into main 2025-11-18 10:23:54 +01:00

View File

@@ -96,6 +96,20 @@ kiwi-ng --temp-dir /tmp/output/tmp-dir --debug --profile $PROFILE \
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo -e "\n\nINFO: Image build successful, generated images are available in the 'output' directory."
# The -n flag is being used to avoid the \n at the end of the line
echo -n "INFO: Generating sha256 checksum file... " && {
# This returns the iso or raw image from the kiwi.result.json file, preferring iso
FILE_PATH=$(python3 -c 'import json, sys; data = json.load(sys.stdin); iso = data.get("installation_image", {}).get("filename"); raw = data.get("disk_image", {}).get("filename"); print(iso if iso else raw)' < /tmp/output/kiwi.result.json)
# Generate the checksum if the file path was successfully extracted
eminguez marked this conversation as resolved Outdated

The container does have python, so we could do something like

cat /tmp/output/kiwi.result.json | python3 -c 'import json,sys;print(json.load(sys.stdin)["filename"])'

Which would probably be more robust - or we could install jq :)

The container does have python, so we could do something like ``` cat /tmp/output/kiwi.result.json | python3 -c 'import json,sys;print(json.load(sys.stdin)["filename"])' ``` Which would probably be more robust - or we could install jq :)

Don't you prefer using awk then? :P

I'll fix it. Thanks for the suggestion!

Don't you prefer using awk then? :P I'll fix it. Thanks for the suggestion!

Done (I guess). PTAL :)

Done (I guess). PTAL :)
if [ -n "$FILE_PATH" ]; then
# The sed trims the full path to just the filename (e.g., "sum filename")
sha256sum "$FILE_PATH" | sed -E 's/\s+.*\/([^/]+)$/ \1/' > "$FILE_PATH.sha256" && echo "done"
else
# Or fail if it is not there
echo "ERROR: Neither ISO nor RAW file path found in JSON."
fi
# Catch-all just in case something fails inside the block
} || echo "ERROR: Command failed during processing."
else
echo -e "\n\nERROR: Failed to build the image, please see above logs."
fi