Skip to content

Commit

Permalink
os-helpers: add a helper function to generate fingerprint files
Browse files Browse the repository at this point in the history
This function will be re-used as it's called from the HUP hooks and
from the flasher image for secure boot devices that split boot
partitions.

Change-type: patch
Signed-off-by: Alex Gonzalez <alexg@balena.io>
  • Loading branch information
alexgg committed May 11, 2024
1 parent eafbc41 commit 487b4f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ do_install() {
${WORKDIR}/safe_reboot \
${D}${libexecdir}
sed -i "s,@@BALENA_CONF_UNIT_STORE@@,${BALENA_CONF_UNIT_STORE},g" ${D}${libexecdir}/os-helpers-config
sed -i -e "s,@@BALENA_FINGERPRINT_FILENAME@@,${BALENA_FINGERPRINT_FILENAME},g" -e "s,@@BALENA_FINGERPRINT_EXT@@,${BALENA_FINGERPRINT_EXT},g" ${D}${libexecdir}/os-helpers-fs
}

FILES:${PN}-fs = "${libexecdir}/os-helpers-fs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,24 @@ wait4udev() {

return 0
}

# Generates a fingerprint file on the fly for boot partitions,
# ignoring config.json files.
# Arguments:
# Directoty path - trailing slashes are removed
# Output:
# A ${BALENA_FINGERPRINT_FILENAME}/${BALENA_FINGERPRINT_EXT} file where
# entries have no path prefix.
generate_bootpart_fingerprint() {
FSDIR="${1%/}"
tmpfp=$(mktemp)
info "Generating fingerprint file for $FSDIR"
rm -rf ${FSDIR}/@@BALENA_FINGERPRINT_FILENAME@@.@@BALENA_FINGERPRINT_EXT@@
find ${FSDIR} -xdev -type f \
! -name @@BALENA_FINGERPRINT_FILENAME@@.@@BALENA_FINGERPRINT_EXT@@ \
! -name config.json \
-exec md5sum {} \; | sed "s#${FSDIR}/##g" | \
sort -k2 > "${tmpfp}"
mv "${tmpfp}" ${FSDIR}/@@BALENA_FINGERPRINT_FILENAME@@.@@BALENA_FINGERPRINT_EXT@@
sync -f "${FSDIR}"
}

0 comments on commit 487b4f4

Please sign in to comment.