forked from raspberrypi/rpi-eeprom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-release
executable file
·95 lines (79 loc) · 2.77 KB
/
make-release
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
# Generates three variants of the rpi-eeprom-recovery.zip file for
# SD, USB and NETWORK priority matching the raspi-config options,
# plus a default (same as SD)
set -e
script_dir=$(cd "$(dirname "$0")" && pwd)
tmp_dir=""
die() {
echo "$@" >&2
exit 1
}
cleanup() {
if [ -d "${tmp_dir}" ]; then
rm -rf "${tmp_dir}"
fi
tmp_dir=""
}
gen_release() {
config="${1}"
out="${2}"
[ -f "${config}" ] || die "File not found \"${config}\""
(
tmp_dir="$(mktemp -d --tmpdir tmp.rpi-eeprom.XXXXXXXXXX)"
cd "${tmp_dir}"
cp "${script_dir}/README-${bcm_chip}.txt" README.txt
cp "${firmware_dir}/recovery.bin" .
if [ ${bcm_chip} = 2711 ]; then
cp "${firmware_dir}/vl805-${vl805_version}.bin" vl805.bin
sha256sum vl805.bin | awk '{print $1}' > vl805.sig
fi
"${script_dir}/../rpi-eeprom-config" \
--config "${config}" --out pieeprom.bin \
"${firmware_dir}/pieeprom-${pieeprom_version}.bin" || die "Failed to create updated EEPROM config with \"${config}\""
${script_dir}/../rpi-eeprom-digest -i pieeprom.bin -o pieeprom.sig
echo "Creating ${out}"
zip "${out}" *
cleanup
)
}
usage() {
cat <<EOF
make-release <firmware_status> <pieeprom_version> <vl805_version> <config_dir> <output_dir> <output_basename>
Example: make-release critical 2020-09-03 000138a1 . release rpi-boot-eeprom-recovery
EOF
exit
}
trap cleanup EXIT
firmware_status="${1}"
pieeprom_version="${2}"
vl805_version="${3}"
config_dir="${4}"
output_dir="${5}"
output_basename="${6}"
bcm_chip="${7}"
[ -n "${firmware_status}" ] || usage
[ -n "${pieeprom_version}" ] || usage
[ -n "${config_dir}" ] || usage
[ -n "${output_dir}" ] || usage
[ -n "${output_basename}" ] || usage
[ -n "${bcm_chip}" ] || usage
firmware_dir=${script_dir}/../firmware-${bcm_chip}/${firmware_status}
[ -d "${firmware_dir}" ] || (echo "${firmware_dir} doesn't exist" && exit 1)
[ -f "${firmware_dir}/pieeprom-${pieeprom_version}.bin" ] || (echo "${firmware_status}/pieeprom-${pieeprom_version}.bin doesn't exist" && exit 1)
if [ "${bcm_chip}" = 2711 ]; then
[ -f "${firmware_dir}/vl805-${vl805_version}.bin" ] || (echo "${firmware_status}/vl805-${vl805_version}.bin doesn't exist" && exit 1)
[ -d "${config_dir}" ] || (echo "${config_dir} doesn't exist" && exit 1)
tag="${pieeprom_version}-${bcm_chip}-vl805-${vl805_version}"
else
tag="${pieeprom_version}-${bcm_chip}"
fi
# use realpath to ensure paths are absolute
config_dir=$(realpath "${config_dir}")
output_dir=$(realpath "${output_dir}")
rm -rf "${output_dir}"
mkdir "${output_dir}"
# Build the different boot priority flavours
for variant in sd usb network; do
gen_release "${config_dir}/boot-conf-${variant}.txt" "${output_dir}/${output_basename}-${tag}-${variant}.zip"
done