Debian Codegraph @

debian/extra/gen-signing-template

raw
1 #!/bin/bash
2
3 set -euE
4
5 export DEB_VERSION="$1"
6 export DEB_HOST_ARCH="$2"
7 export TEMPLATE_EFI_ARCH="$3"
8
9 # Upstream builds on OBS do not have these dependencies available
10 TEMPLATE_BUILD_DEPS=$(
11 case "${DEB_BUILD_PROFILES:-}" in
12 *pkg.systemd.upstream*) echo "dh-signobs,";;
13 *) echo "sbsigntool, systemd-boot-efi (= ${DEB_VERSION})," ;;
14 esac
15 )
16 export TEMPLATE_BUILD_DEPS
17
18 DISTRIBUTION="$(dpkg-parsechangelog -SDistribution)"
19 URGENCY="high"
20 MAINT="$(dpkg-parsechangelog -SMaintainer)"
21 DATE="$(dpkg-parsechangelog -SDate)"
22
23 DEB_VERSION_MANGLED="$(echo "$DEB_VERSION" | sed -re 's/-/\+/;s/\+(b[[:digit:]]+)$/.\1/')"
24 DEB_VERSION_SOURCE="$(echo "$DEB_VERSION" | sed -re 's/\+b[[:digit:]]+$//')"
25 export DEB_VERSION_SOURCE
26 SIGN_TEMPLATE_DIR="debian/systemd-boot-efi-${DEB_HOST_ARCH}-signed-template/usr/share/code-signing/systemd-boot-efi-${DEB_HOST_ARCH}-signed-template"
27 SIGN_SOURCE_DIR="${SIGN_TEMPLATE_DIR}/source-template/debian"
28 FILE=usr/lib/systemd/boot/efi/systemd-boot${TEMPLATE_EFI_ARCH}.efi
29
30 for i in $(find debian/signing-template -type f -printf '%P\n'); do
31 mkdir -p "$SIGN_SOURCE_DIR/$(dirname "$i")"
32 envsubst < "debian/signing-template/$i" > "$SIGN_SOURCE_DIR/$i"
33 done
34
35 (
36 echo "systemd-boot-efi-${DEB_HOST_ARCH}-signed (${DEB_VERSION_MANGLED}) ${DISTRIBUTION}; urgency=${URGENCY}"
37 echo
38 echo " * Sign EFI binaries from systemd-boot-efi ${DEB_VERSION}"
39 dpkg-parsechangelog -SChanges | sed -rne 's/^.$//p' -e '/^ /p'
40 echo
41 echo " -- ${MAINT} ${DATE}"
42 ) > "$SIGN_SOURCE_DIR/changelog"
43
44 jq -n --arg file "${FILE}" '
45 {
46 "packages": {
47 "systemd-boot-efi": {
48 "trusted_certs": [],
49 "files": [
50 {"sig_type": "efi", "file": $file}
51 ]
52 }
53 }
54 }' > "$SIGN_TEMPLATE_DIR/files.json"