#!/bin/sh # License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. # # Verify the pinned inputs of a device: the DTB and the initramfs must be the # ones the baseline was built from. A device without a pin is not checked. # # Usage: check.sh DEVICEDIR INITRAMFS set -eu . "$(dirname "$0")/lib.sh" [ $# -eq 2 ] || { echo "usage: $0 DEVICEDIR INITRAMFS" >&2; exit 2; } load_device "$1" initramfs=$2 pin() { # pin NAME FILE EXPECTED [ -n "$3" ] || return 0 _got=$(sha256sum "$2" | cut -c1-16) [ "$_got" = "$3" ] || die "$1 is $_got, pinned $3 ($2)" } # a DTB built from the kernel tree (KERNEL_DTB) is pinned by the tree's # commit and patches, a binary one (DTB) by its hash [ -z "${DTB:-}" ] || pin dtb "$DTB" "${DTB_SHA256_PREFIX:-}" pin initramfs "$initramfs" "${INITRAMFS_SHA256_PREFIX:-}" echo "pins ok"