summaryrefslogtreecommitdiff
path: root/util/grubpo/grubpo.sh
blob: 87abc7354f04e9d67fe580ab88649853eee85d0d (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh

# SPDX-License-Identifier: MIT

# Copyright (c) 2026 Leah Rowe

set -u -e

urlmain="https://www.mirrorservice.org/sites/libreboot.org/release/misc/grub"
urlbkup="https://mirror.math.princeton.edu/pub/libreboot/misc/grub"

# script to grab GNU gettext po files from translationproject.org -
# i noticed that the grub bootstrap script grabs these at build time,
# without actually checking signatures, and they could change on the
# server upstream at any time

# this means that the GRUB build process is currently non-deterministic,
# which is a violation of libreboot policy.

tmpdir="`mktemp -d`"
tmpmod="`mktemp -d`"

mkdir -p "$tmpdir" "$tmpmod" || exit 1

(
cd "$tmpdir" || exit 1
wget --mirror --level=1 -nd -nv -A.po -P 'po/.reference' \
    https://translationproject.org/latest/grub/ || \
    exit 1
find -type f > "$tmpmod/tmplist" || exit 1
while read -r f; do
	printf "%s\n" "${f#./}" >> "$tmpmod/module.list"

	# now make the actual config files, but don't use
	# the main upstream, because those files can change
	# at any time. we will, over time, manually update
	# our mirrors

	pkgname="${f##*/}"
	[ -z "$pkgname" ] && printf "ERR\n" && exit 1

	pkgsum="`sha512sum "$f" | awk '{print $1}'`"

	mkdir -p "$tmpmod/$pkgname" || exit 1

	printf "# SPDX-License-Identifier: GPL-3.0-or-later\n\n" >> \
	    "$tmpmod/$pkgname/module.cfg" || exit 1

	printf "subcurl=\"%s/%s\"\n" "$urlmain" "$pkgname" >> \
	    "$tmpmod/$pkgname/module.cfg" || exit 1
	printf "subcurl_bkup=\"%s/%s\"\n" "$urlbkup" "$pkgname" >> \
	    "$tmpmod/$pkgname/module.cfg" || exit 1
	printf "subhash=\"%s\"\n" "$pkgsum" >> "$tmpmod/$pkgname/module.cfg"

done < "$tmpmod/tmplist" || exit 1; :
mv "$tmpmod/tmplist" "$tmpdir" || exit 1
)

printf "tmpdir for modules: '%s'\n" "$tmpmod"

rm -f "module.list" || exit 1

printf "Check directory for lbmk files: '%s'\n" "$tmpmod"
printf "This directory has the PO files: '%s'\n" "$tmpdir"

exit 0