Debian Codegraph @

debian/signing-template.generate

raw
1 #!/bin/sh
2 set -e -u
3
4 distribution="$(dpkg-parsechangelog -S Distribution)"
5 urgency="$(dpkg-parsechangelog -S Urgency)"
6 date="$(dpkg-parsechangelog -S Date)"
7 version_binary="$(dpkg-parsechangelog -S Version)"
8 version_mangled="$(dpkg-parsechangelog -S Version | tr '-' '+')"
9 pkg_name="shim-helpers-${DEB_HOST_ARCH}-signed-template"
10 final_pkg_name="${pkg_name%-template}"
11
12 subst () {
13 sed \
14 -e "s/@efi@/${EFI_ARCH}/g" \
15 -e "s/@arch@/${DEB_HOST_ARCH}/g" \
16 -e "s/@version_binary@/${version_binary}/g" \
17 -e "s/@version_mangled@/${version_mangled}/g" \
18 -e "s/@distribution@/${distribution}/g" \
19 -e "s/@urgency@/${urgency}/g" \
20 -e "s/@date@/${date}/g" \
21 -e "s/@final_pkg_name@/${final_pkg_name}/g" \
22 "$@"
23 }
24
25 template='./debian/signing-template'
26 pkg_dir="debian/${pkg_name}/usr/share/code-signing/${pkg_name}"
27 pkg_deb="${pkg_dir}/source-template/debian"
28
29 install -m 0755 -d "${pkg_dir}"
30 subst < ./debian/signing-template.json.in > "${pkg_dir}/files.json"
31
32 find "${template}" -type f -printf '%P\n' |
33 while read path
34 do
35 src="${template}/${path}"
36 dst=$(echo "${pkg_deb}/${path}" | subst)
37
38 install -m 0755 -d "${dst%/*}"
39 subst < "${src}" > "${dst%.in}"
40 chmod --reference="${src}" "${dst%.in}"
41 done
42
43 exit 0