summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-10-28 15:08:30 (EDT)
committer P. J. McDermott <pj@pehjota.net>2015-10-28 15:08:30 (EDT)
commit6f7f552f9edfde7b13cdb54ec4c9c8d9786750d1 (patch)
tree297d2b8c22a6c9cbcd0f4fc35a8ac7d99086f110 /src
parentb53001535e6947d85f83638eaa17bcc73e0f6497 (diff)
downloadfirman.sh-6f7f552f9edfde7b13cdb54ec4c9c8d9786750d1.zip
firman.sh-6f7f552f9edfde7b13cdb54ec4c9c8d9786750d1.tar.gz
firman.sh-6f7f552f9edfde7b13cdb54ec4c9c8d9786750d1.tar.bz2
dist_get_rom(): New function
Diffstat (limited to 'src')
-rw-r--r--src/dist.sh2
-rw-r--r--src/dist/libiquity.sh169
-rw-r--r--src/dist/libreboot.sh169
3 files changed, 339 insertions, 1 deletions
diff --git a/src/dist.sh b/src/dist.sh
index 9293dc9..b958489 100644
--- a/src/dist.sh
+++ b/src/dist.sh
@@ -15,7 +15,7 @@
# 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_functions='get_mirrors get_versions'
+dist_functions='get_mirrors get_versions get_rom'
dist_get_name()
{
diff --git a/src/dist/libiquity.sh b/src/dist/libiquity.sh
index 05d004a..e6acd46 100644
--- a/src/dist/libiquity.sh
+++ b/src/dist/libiquity.sh
@@ -67,3 +67,172 @@ dist_libiquity_get_versions()
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'
+ 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'
+ 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' ${keymaps})
+ i=$(($i + 1))
+ rom="$(printf '%s ' ${keymaps} | cut -d ' ' -f ${i})"
+ rom="${dir}/${board}_${rom}_vesafb.rom"
+ info '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'
+ 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'
+ 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'
+ 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' ${keymaps})
+ i=$(($i + 1))
+ rom="$(printf '%s ' ${keymaps} | cut -d ' ' -f ${i})"
+ rom="${dir}/${board}_${rom}_vesafb.rom"
+ info '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'
+ 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
+}
diff --git a/src/dist/libreboot.sh b/src/dist/libreboot.sh
index 46f99f9..5ddcb8a 100644
--- a/src/dist/libreboot.sh
+++ b/src/dist/libreboot.sh
@@ -81,3 +81,172 @@ dist_libreboot_get_versions()
printf '%s ' ${versions}
return 0
}
+
+dist_libreboot_get_rom_20150518()
+{
+ 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_${board}.tar.xz"
+ if ! sum="$(dl_temp "${mirror}/${version}/sha512sum.txt" 'sums')"; then
+ err 'Failed to download checksums'
+ rm_temp 'sums'
+ 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'
+ 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' ${keymaps})
+ i=$(($i + 1))
+ rom="$(printf '%s ' ${keymaps} | cut -d ' ' -f ${i})"
+ rom="${dir}/${board}_${rom}_vesafb.rom"
+ info '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'
+ fi
+
+ rm_temp 'sums'
+ rm_temp 'roms'
+
+ return 0
+}
+
+dist_libreboot_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'
+ 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'
+ 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' ${keymaps})
+ i=$(($i + 1))
+ rom="$(printf '%s ' ${keymaps} | cut -d ' ' -f ${i})"
+ rom="${dir}/${board}_${rom}_vesafb.rom"
+ info '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'
+ fi
+
+ rm_temp 'sums'
+ rm_temp 'roms'
+
+ return 0
+}
+
+dist_libreboot_get_rom()
+{
+ local mirror="${1}"
+ local version="${2}"
+ local board="${3}"
+ shift 3
+
+ case "${version}" in
+ '20150518')
+ if dist_libreboot_get_rom_20150518 "${mirror}" \
+ "${version}" "${board}"; then
+ return 0
+ else
+ return 1
+ fi
+ ;;
+ *)
+ if dist_libreboot_get_rom_current "${mirror}" \
+ "${version}" "${board}"; then
+ return 0
+ else
+ return 1
+ fi
+ ;;
+ esac
+}