| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Helper script - generate a DBX file for inclusion into a shim build |
| 4 |
# |
| 5 |
# Takes an input file (e.g. debian-dbx.hashes) with data in the form |
| 6 |
# |
| 7 |
# <hex-encoded sha256 checksums> <arch> |
| 8 |
# |
| 9 |
# and generates a siglist of the hashes for just the architecture we |
| 10 |
# want. No point including all the hashes for all the arches, it just |
| 11 |
# bloats things and slows things down. |
| 12 |
|
| 13 |
set -e |
| 14 |
|
| 15 |
ARCH=$1 |
| 16 |
IN=$2 |
| 17 |
OUT=$3 |
| 18 |
|
| 19 |
DEBIAN_UUID="fa31923d-6047-40bf-81d0-e63edefcf194" |
| 20 |
|
| 21 |
# This needs to be fixed to make builds reproducible, of course. If |
| 22 |
# you're deriving from Debian, please generate your own. |
| 23 |
UUID="$DEBIAN_UUID" |
| 24 |
|
| 25 |
rm -f $OUT |
| 26 |
if [ -x /usr/bin/efisiglist ] ; then |
| 27 |
# Older versions of the pesign package included the efisiglist |
| 28 |
# utility. If we have that, use it. |
| 29 |
for HASH in $(grep -E "[[:xdigit:]]{32} $ARCH" < $IN | \ |
| 30 |
awk '{print $1}' | sort | uniq); do |
| 31 |
echo " Adding $HASH to dbx list" |
| 32 |
efisiglist -o $OUT -a -h $HASH |
| 33 |
done |
| 34 |
else |
| 35 |
# It appears we don't have efisiglist, so use efisecdb |
| 36 |
# instead. It's a little more awkward to drive. |
| 37 |
INTMP="" # First pass |
| 38 |
for HASH in $(grep -E "[[:xdigit:]]{32} $ARCH" < $IN | \ |
| 39 |
awk '{print $1}' | sort | uniq); do |
| 40 |
echo " Adding $HASH to dbx list" |
| 41 |
efisecdb -g "$UUID" -a -t sha256 -h $HASH $INTMP -o $OUT |
| 42 |
|
| 43 |
# Subsequent passes need to read the previous output as input |
| 44 |
# each time, and won't overwrite the output. |
| 45 |
mv -f $OUT $OUT.in |
| 46 |
INTMP="-i $OUT.in" |
| 47 |
done |
| 48 |
if [ -f $OUT.in ]; then |
| 49 |
mv -f $OUT.in $OUT |
| 50 |
fi |
| 51 |
fi |
| 52 |
|
| 53 |
# If we have an empty hashes file, create an empty DBX file |
| 54 |
touch $OUT |