# Libreboot project 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 . dist_libreboot_get_name() { printf 'Libreboot project' return 0 } dist_libreboot_get_mirrors() { cat <<-EOF http://mirrors.mit.edu/libreboot/ MIT, USA http://www.mirrorservice.org/sites/libreboot.org/release/ University of Kent, UK http://elgrande74.net/libreboot/ elgrande74.net, France http://mirror.linux.ro/libreboot/ linux.ro, Romania http://ginette.swordarmor.fr/libreboot/ swordarmor.fr, France http://libreboot.nedson.net/ nedson.net, Canada http://mirror.helium.in-berlin.de/libreboot/ in-berlin.de, Germany http://mirror.se.partyvan.eu/pub/libreboot/ partyvan.eu, Sweden EOF return 0 } dist_libreboot_get_versions() { local mirror="${1}" local board="${2}" shift 2 local version= local versions='' while read -r version; do case "${version}" in 201[34]* | 20150[1-4]*) # These versions had ROMs in X60_binary.tar.gz, # libreboot_bin.tar.gz, or libreboot_bin.tar.xz # files. These are unsupported for now. continue ;; '20150518') sums='sha512sum.txt' archive="./rom/libreboot_${board}.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 <<-EOF 20150518 $(: Hardcode this list until a manifest is available) EOF 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' $(printf '%s\n' ${keymaps} | sort)) 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' $(printf '%s\n' ${keymaps} | sort)) 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 }