blob: fa52787886f616b7fa07eb9733122717242758d3 (
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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
# Libiquity firmware distribution
#
# Copyright (C) 2015 Patrick "P. J." McDermott
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
dist_libiquity_get_name()
{
printf 'Libiquity'
return 0
}
dist_libiquity_get_mirrors()
{
cat <<-EOF
http://files.libiquity.com/pub/libreboot/
Libiquity, USA
EOF
return 0
}
dist_libiquity_get_versions()
{
local mirror="${1}"
local board="${2}"
shift 2
local versions=''
local version=
if ! versions="$(dl "${mirror}/Manifest")"; then
err 'Failed to download list of firmware versions'
return 1
fi
IFS="${LF}"
for version in ${versions}; do
unset IFS
case "${version}" in
'libiquity-20150501')
# This version had unique ROM organization.
# Let's not bother supporting it.
continue
;;
taurinus-201506*)
sums='SHA512SUMS'
archive="./rom/libreboot_${version}_${board}"
archive="${archive}.tar.xz"
;;
*)
sums='SHA512SUMS'
archive="./rom/grub/libreboot_${version}"
archive="${archive}_grub_${board}.tar.xz"
;;
esac
if dl "${mirror}/${version}/${sums}" | \
grep -F " ${archive}" >/dev/null 2>&1; then
versions="${versions} ${version}"
fi
done
unset IFS
printf '%s ' ${versions}
return 0
}
dist_libiquity_get_rom_taurinus_201506()
{
local mirror="${1}"
local version="${2}"
local board="${3}"
shift 3
local archive=
local sum=
local arc_sum=
local dir=
local rom=''
local keymaps=''
local i=0
# Download checksums and ROMs archive.
archive="libreboot_${version}_${board}.tar.xz"
if ! sum="$(dl_temp "${mirror}/${version}/SHA512SUMS" 'sums')"; then
err 'Failed to download checksums'
rm_temp 'sums'
return 1
fi
sum="$(grep -F " ./rom/${archive}" "${sum}" | cut -d ' ' -f 1)"
if ! archive="$(dl_temp "${mirror}/${version}/rom/${archive}" \
'roms')"; then
err 'Failed to download ROMs archive'
rm_temp 'sums'
rm_temp 'roms'
return 1
fi
# Verify checksum.
arc_sum="$(${SHA512SUM} "${archive}" | cut -d ' ' -f 1)"
if [ "x${arc_sum}" != "x${sum}" ]; then
err 'ROM archive checksum mismatch'
rm_temp 'sums'
rm_temp 'roms'
return 1
fi
# Select keymap.
dir="${board}"
while read -r rom; do
case "${rom}" in
${dir}/${board}_*_vesafb.rom)
rom="${rom#${dir}/${board}_}"
rom="${rom%_vesafb.rom}"
keymaps="${keymaps} ${rom}"
;;
esac
done <<-EOF
$(unxz -c "${archive}" | tar -t)
EOF
i=$(show_menu 'Select keymap' $(printf '%s\n' ${keymaps} | sort))
i=$(($i + 1))
rom="$(printf '%s ' ${keymaps} | cut -d ' ' -f ${i})"
rom="${dir}/${board}_${rom}_vesafb.rom"
dbg 'Using ROM "%s"' "${rom}"
# Extract ROM.
if ! unxz -c "${archive}" | tar -xO "${rom}" >"$(get_temp_dir)/rom"
then
err 'Failed to extract ROM'
rm_temp 'sums'
rm_temp 'roms'
rm_temp 'rom'
return 1
fi
rm_temp 'sums'
rm_temp 'roms'
return 0
}
dist_libiquity_get_rom_current()
{
local mirror="${1}"
local version="${2}"
local board="${3}"
shift 3
local archive=
local sum=
local arc_sum=
local dir=
local rom=''
local keymaps=''
local i=0
# Download checksums and ROMs archive.
archive="libreboot_${version}_grub_${board}.tar.xz"
if ! sum="$(dl_temp "${mirror}/${version}/SHA512SUMS" 'sums')"; then
err 'Failed to download checksums'
rm_temp 'sums'
return 1
fi
sum="$(grep -F " ./rom/grub/${archive}" "${sum}" | cut -d ' ' -f 1)"
if ! archive="$(dl_temp "${mirror}/${version}/rom/grub/${archive}" \
'roms')"; then
err 'Failed to download ROMs archive'
rm_temp 'sums'
rm_temp 'roms'
return 1
fi
# Verify checksum.
arc_sum="$(${SHA512SUM} "${archive}" | cut -d ' ' -f 1)"
if [ "x${arc_sum}" != "x${sum}" ]; then
err 'ROM archive checksum mismatch'
rm_temp 'sums'
rm_temp 'roms'
return 1
fi
# Select keymap.
dir="libreboot_${version}_grub_${board}"
while read -r rom; do
case "${rom}" in
${dir}/${board}_*_vesafb.rom)
rom="${rom#${dir}/${board}_}"
rom="${rom%_vesafb.rom}"
keymaps="${keymaps} ${rom}"
;;
esac
done <<-EOF
$(unxz -c "${archive}" | tar -t)
EOF
i=$(show_menu 'Select keymap' $(printf '%s\n' ${keymaps} | sort))
i=$(($i + 1))
rom="$(printf '%s ' ${keymaps} | cut -d ' ' -f ${i})"
rom="${dir}/${board}_${rom}_vesafb.rom"
dbg 'Using ROM "%s"' "${rom}"
# Extract ROM.
if ! unxz -c "${archive}" | tar -xO "${rom}" >"$(get_temp_dir)/rom"
then
err 'Failed to extract ROM'
rm_temp 'sums'
rm_temp 'roms'
rm_temp 'rom'
return 1
fi
rm_temp 'sums'
rm_temp 'roms'
return 0
}
dist_libiquity_get_rom()
{
local mirror="${1}"
local version="${2}"
local board="${3}"
shift 3
case "${version}" in
taurinus-201506*)
if dist_libiquity_get_rom_taurinus_201506 "${mirror}" \
"${version}" "${board}"; then
return 0
else
return 1
fi
;;
*)
if dist_libiquity_get_rom_current "${mirror}" \
"${version}" "${board}"; then
return 0
else
return 1
fi
;;
esac
}
|