File: signing-template.generate

package info (click to toggle)
grub2 2.06-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 63,180 kB
  • sloc: ansic: 410,027; asm: 16,253; sh: 9,855; cpp: 2,049; makefile: 1,552; python: 1,468; sed: 427; lex: 393; yacc: 268; awk: 79; lisp: 50; perl: 31
file content (49 lines) | stat: -rwxr-xr-x 1,366 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
set -e -u

pkg_base="${1?:missing binary package name}"
pkg_unsigned="${pkg_base}-bin"
pkg_signed="${pkg_base}-signed"
pkg_tmpl="${pkg_signed}-template"

distribution="$(dpkg-parsechangelog -S Distribution)"
urgency="$(dpkg-parsechangelog -S Urgency)"
date="$(dpkg-parsechangelog -S Date)"
version_binary="$(dpkg-parsechangelog -S Version)"
version_mangled="$(dpkg-parsechangelog -S Version | tr '-' '+')"

subst () {
	sed \
		-e "s/@pkg_unsigned@/${pkg_unsigned}/g" \
		-e "s/@pkg_signed@/${pkg_signed}/g" \
		-e "s/@pkg_tmpl@/${pkg_tmpl}/g" \
		-e "s/@efi@/${SB_EFI_NAME}/g" \
		-e "s/@efi_platform@/${SB_PLATFORM}/g" \
		-e "s/@arch@/${DEB_HOST_ARCH}/g" \
		-e "s/@version_binary@/${version_binary}/g" \
		-e "s/@version_mangled@/${version_mangled}/g" \
		-e "s/@distribution@/${distribution}/g" \
		-e "s/@urgency@/${urgency}/g" \
		-e "s/@date@/${date}/g" \
		"$@"
}

template='./debian/signing-template'
pkg_dir="debian/${pkg_tmpl}/usr/share/code-signing/${pkg_tmpl}"
pkg_deb="${pkg_dir}/source-template/debian"

install -m 0755 -d "${pkg_dir}"
subst < ./debian/signing-template.json.in > "${pkg_dir}/files.json"

find "${template}" -type f -printf '%P\n' |
while read path
do
	src="${template}/${path}"
	dst="${pkg_deb}/${path}"

	install -m 0755 -d "${dst%/*}"
	subst < "${src}" > "${dst%.in}"
	chmod --reference="${src}" "${dst%.in}"
done

exit 0