diff options
author | Leah Rowe <leah@libreboot.org> | 2021-05-18 13:56:12 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2021-05-18 13:56:12 +0100 |
commit | 89517ed6b9e89321e1387ed8f534d7f080ffdf57 (patch) | |
tree | 6f2085cb89b035d3cb62ad49b470a514672102d6 /resources/scripts/download |
libreboot!
this is forked from the "libre" branch in osboot, which is itself a libre,
deblobbed fork of osboot, a blobbed up fork of libreboot
libreboot needed to be purged clean. this is the new libreboot development
repository. the old one has been abandoned
Diffstat (limited to 'resources/scripts/download')
-rwxr-xr-x | resources/scripts/download/coreboot | 226 | ||||
-rwxr-xr-x | resources/scripts/download/flashrom | 51 | ||||
-rwxr-xr-x | resources/scripts/download/grub | 57 | ||||
-rwxr-xr-x | resources/scripts/download/ich9utils | 49 | ||||
-rwxr-xr-x | resources/scripts/download/memtest86plus | 68 | ||||
-rwxr-xr-x | resources/scripts/download/seabios | 67 | ||||
-rwxr-xr-x | resources/scripts/download/tianocore | 33 |
7 files changed, 551 insertions, 0 deletions
diff --git a/resources/scripts/download/coreboot b/resources/scripts/download/coreboot new file mode 100755 index 00000000..781c54ca --- /dev/null +++ b/resources/scripts/download/coreboot @@ -0,0 +1,226 @@ +#!/bin/bash + +# helper script: download coreboot +# +# Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org> +# +# 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/>. +# + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# set this when you want to modify each coreboot tree +# for example, you want to test custom patches +# NODELETE= ./download coreboot +deleteblobs="true" +[ "x${NODELETE+set}" = 'xset' ] && deleteblobs="false" + +# Error handling is extreme in this script. +# This script handles the internet, and Git. Both are inherently unreliable. + +[[ -f build_error ]] && rm -f build_error + +rm -f resources/coreboot/*/seen + +downloadfor() { + + board="${1}" + cbtree="undefined" + cbrevision="undefined" + + # The loop will always exit, but this while loop is crafted + # such that a tree referencing a tree that references another tree is possible + # (and so on) + while true; do + cbrevision="undefined" + cbtree="undefined" + + if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then + printf "ERROR: download/coreboot: board.cfg does not exist for '%s'\n" "${board}" + return 1 + fi + + if [ -f "resources/coreboot/${board}/seen" ]; then + printf "ERROR: download/coreboot: logical loop; '%s' board.cfg refers to another tree, which ultimately refers back to '%s'.\n" "${board}" "${board}" + return 1 + fi + + # This is to override $cbrevision and $cbtree + source "resources/coreboot/${board}/board.cfg" || touch ../build_error + if [ -f build_error ]; then + printf "ERROR: download/coreboot: problem sourcing %s/board.cfg\n" "${board}" + return 1 + fi + touch "resources/coreboot/${board}/seen" + + if [ "${board}" != "${cbtree}" ]; then + board="${cbtree}" + else + if [ "${cbtree}" = "undefined" ]; then + printf "ERROR: download/coreboot: tree name undefined for '%s\n'" "${board}" + return 1 + fi + + if [ "${cbrevision}" = "undefined" ]; then + printf "ERROR: download/coreboot: commit ID undefined for '%s'\n" "${board}" + return 1 + fi + break + fi + done + + rm -f resources/coreboot/*/seen + + if [ -d "coreboot/${cbtree}" ]; then + printf "REMARK: download/coreboot: directory for '%s' already exists. Skipping setup.\n" "${cbtree}" + if [ "${cbtree}" != "${1}" ]; then + printf "(for board: '${1}')\n" + fi + return 0 + fi + + if [ ! -d coreboot ]; then + mkdir "coreboot/" + fi + if [ ! -d coreboot ]; then + printf "ERROR: download/coreboot: directory not created. Check file system permissions\n" + return 1 + fi + + cd "coreboot/" + + if [ ! -d coreboot/.git ] && [ -d coreboot ]; then + rm -Rf coreboot/ + fi + + if [ ! -d coreboot ]; then + printf "Download coreboot from upstream:\n" + git clone https://review.coreboot.org/coreboot || rm -Rf coreboot + if [ ! -d coreboot ]; then + printf "WARNING: Upstream failed. Trying backup github repository:\n" + git clone https://github.com/coreboot/coreboot.git || rm -Rf coreboot + fi + if [ ! -d coreboot ]; then + printf "ERROR: download/coreboot: Problem with git-clone. Network issue?\n" + cd ../; return 1 + fi + else + ( cd coreboot/; git pull || touch ../build_error ) + if [ -f ../build_error ]; then + printf "ERROR: download/coreboot: Problem with git-pull. Network issue?\n" + cd ../; return 1 + fi + fi + + cp -R coreboot "${cbtree}" || touch ../build_error + if [ -d ../build_error ]; then + printf "ERROR: download/coreboot: Unable to copy directory. Check file system permissions or free space.\n" + rm -Rf "${cbtree}/" + cd ../; return 1 + fi + + cd ${cbtree}/ + + git reset --hard ${cbrevision} || touch ../../build_error + if [ -f ../../build_error ]; then + printf "ERROR: download/coreboot: Unable to reset to commit ID/tag '%s' for board '%s' on tree '%s'\n" "${cbrevision}" "${1}" "${cbtree}" + cd ../../; return 1 + fi + + git submodule update --init || touch ../../build_error + if [ -f ../../build_error ]; then + printf "ERROR: download/coreboot: Unable to update submodules for tree '%s'\n" "${cbtree}" + cd ../../; return 1 + fi + + for patch in ../../resources/coreboot/${cbtree}/patches/*.patch; do + if [ ! -f "${patch}" ]; then + continue + fi + + git am "${patch}" || touch ../../build_error + if [ -f ../../build_error ]; then + printf "ERROR: download/coreboot: Unable to apply patch '%s' for board '%s' on tree '%s'" "${patch}" "${1}" "${cbtree}" + git am --abort + cd ../../; return 1 + fi + done + + # extra.sh could be used to patch submodules, if you wanted to + # It's impossible to predict what submodules will be available, and + # it's rare that you'd want to patch them, so this is handled by + # extra.sh on a per-board basis + # In fact, extra.sh can be used for anything you want. + if [ -f "../../resources/coreboot/${board}/extra.sh" ]; then + "../../resources/coreboot/${board}/extra.sh" || touch ../../build_error + if [ -f ../../build_error ]; then + cd ../../; return 1 + fi + return 0 + else + cd ../../ + return 0 + fi +} + +printf "Downloading coreboot and (if exist in build system) applying patches\n" + +if [ $# -gt 0 ]; then + for board in "${@}"; do + rm -f resources/coreboot/*/seen + downloadfor "${board}" + if [ -f build_error ]; then break; fi + done +else + for board in resources/coreboot/*; do + rm -f resources/coreboot/*/seen + if [ ! -d "${board}/" ]; then + continue + fi + downloadfor "${board##*/}" + if [ -f build_error ]; then break; fi + done +fi + +rm -f resources/coreboot/*/seen + +rm -f "build_error" +printf "\n\n" +if [ "${deleteblobs}" = "true" ]; then + rm -Rf coreboot/coreboot/ + rm -Rf coreboot/.git* coreboot/*/.git* coreboot/*/3rdparty/*/.git* + rm -Rf coreboot/*/util/nvidia/cbootimage/.git* + for cbdir in coreboot/*; do + if [ ! -d "${cbdir}" ]; then continue; fi + cbtree="${cbdir##coreboot/}" + cbtree="${cbtree%/}" + if [ ! -d "coreboot/${cbtree}" ]; then continue; fi + bloblist="resources/coreboot/${cbtree}/blobs.list" + if [ -f "${bloblist}" ]; then + for blobfile in $(cat "${bloblist}"); do + printf "Deleting blob: 'coreboot/%s/%s'\n" "${cbtree}" "${blobfile}" + rm -f "coreboot/${cbtree}/${blobfile}" + done + fi + rmlist="resources/coreboot/${cbtree}/rm.list" + if [ -f "${rmlist}" ]; then + for rmentry in $(cat "${rmlist}"); do + printf "Deleting directory to save space: 'coreboot/%s/%s'\n" "${cbtree}" "${rmentry}" + rm -Rf "coreboot/${cbtree}/${rmentry}" + done + fi + done +fi +exit 0 diff --git a/resources/scripts/download/flashrom b/resources/scripts/download/flashrom new file mode 100755 index 00000000..66afe585 --- /dev/null +++ b/resources/scripts/download/flashrom @@ -0,0 +1,51 @@ +#!/bin/bash + +# helper script: downloads flashrom and patches it +# +# Copyright (C) 2014, 2015, 2020, 2021 Leah Rowe <info@minifree.org> +# +# 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/>. +# + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# Get flashrom at the last previously tested revision + +# Remove the old version that may still exist: +# ------------------------------------------------------------------------------ + +printf "Downloading flashrom\n" + +rm -Rf "flashrom/" + +# Get flashrom +# ------------------------------------------------------------------------------ + +# download it using git +git clone https://review.coreboot.org/flashrom.git + +if [ ! -d "flashrom" ]; then + printf "flashrom not downloaded; check network connection?\n\n" + exit 1 +fi + +( +cd "flashrom/" + +# reset to known revision +git reset --hard v1.2 +) + +printf "\n\n" diff --git a/resources/scripts/download/grub b/resources/scripts/download/grub new file mode 100755 index 00000000..9d74c568 --- /dev/null +++ b/resources/scripts/download/grub @@ -0,0 +1,57 @@ +#!/bin/bash + +# helper script: Downloads GRUB and patches it. +# +# Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org> +# +# 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/>. +# + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# Remove the old version that may still exist +# ------------------------------------------------------------------------------ + +printf "Downloading GRUB\n" + +rm -Rf "grub/" + +# Get latest GRUB +# ------------------------------------------------------------------------------ + +# download it using git +git clone git://git.savannah.gnu.org/grub.git || git clone http://git.savannah.gnu.org/r/grub.git + +if [ ! -d "grub" ]; then + printf "grub not downloaded; check network connection?\n\n" + exit 1 +fi + +( +# modifications are required +cd "grub/" +# reset to known revision +git reset --hard c0e647eb0e2bd09315612446cb4d90f7f75cb44c + +git clone git://git.sv.gnu.org/gnulib gnulib +cd gnulib/ + +# NOTE: when updating this, make sure it's the version specified +# in bootstrap.conf on that version of GRUB, as specified above +git reset --hard d271f868a8df9bbec29049d01e056481b7a1a263 +rm -Rf .git* +) + +printf "\n\n" diff --git a/resources/scripts/download/ich9utils b/resources/scripts/download/ich9utils new file mode 100755 index 00000000..34f02685 --- /dev/null +++ b/resources/scripts/download/ich9utils @@ -0,0 +1,49 @@ +#!/bin/bash + +# helper script: downloads ich9utils +# +# Copyright (C) 2021 Leah Rowe <info@minifree.org> +# +# 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/>. +# + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +printf "Downloading ich9utils\n" + +if [ -d ich9utils ]; then + printf "ich9utils already downloaded. skipping\n" + exit 0 +fi + +# Get flashrom +# ------------------------------------------------------------------------------ + +# download it using git +git clone https://notabug.org/osboot/ich9utils.git + +if [ ! -d "ich9utils" ]; then + printf "ich9utils not downloaded; check network connection?\n\n" + exit 1 +fi + +( +cd "ich9utils/" + +# reset to known revision +git reset --hard 53749b0c6f7c5778bdd1ec2b91cd230626752579 +) + +printf "\n\n" diff --git a/resources/scripts/download/memtest86plus b/resources/scripts/download/memtest86plus new file mode 100755 index 00000000..df06f68e --- /dev/null +++ b/resources/scripts/download/memtest86plus @@ -0,0 +1,68 @@ +#!/bin/bash + +# helper script: Downloads MemTest86+ and patches it +# +# Copyright (C) 2014, 2015, 2020, 2021 Leah Rowe <info@minifree.org> +# Copyright (C) 2015 Joseph Michael Thompson <jmt@josepht.me> +# Copyright (C) 2015 Klemens Nanni <contact@autoboot.org> +# +# 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/>. +# + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# Get the last version of MemTest86+ used, apply patches, build it. + +# Remove the old version that may exist +# ------------------------------------------------------------------------------ + +printf "Downloading MemTest86+\n" + +rm -Rf "memtest86plus/" + +# Get latest memtest86+: +# ------------------------------------------------------------------------------ + +# download it using wget +wget http://memtest.org/download/5.31b/memtest86+-5.31b.tar.gz + +if [ "$(sha512sum memtest86+-5.31b.tar.gz | cut -c1-128)" = "ad5891fd0c430ce7a5d0cde2d10dee20b66ad8060d47c3e70e038461d9cde3a78dfc13442b5b09da7c662741945a670353c72dbc08fd5ee8bae82256001a9541" ]; then + printf "Valid checksum for memtest86plus\n" +else + rm -f "memtest86+-5.31b.tar.gz" + printf "Invalid checksum for memtest86plus, or memtest86plus not downloaded\n" + exit 1 +fi + +# extract it +tar -xzf "memtest86+-5.31b.tar.gz" + +# delete the tar file (no longer needed) +rm -f "memtest86+-5.31b.tar.gz" + +# make direcotory name consistent +mv "memtest86+-5.31b/" "memtest86plus/" + +# Apply necessary patches +# ------------------------------------------------------------------------------ + +( +cd "memtest86plus/" +for patch in ../resources/memtest86plus/patch/*; do + patch < "${patch}" +done +) + +printf "\n\n" diff --git a/resources/scripts/download/seabios b/resources/scripts/download/seabios new file mode 100755 index 00000000..f6fc2070 --- /dev/null +++ b/resources/scripts/download/seabios @@ -0,0 +1,67 @@ +#!/bin/bash +# +# Copyright (C) 2015, 2016, 2021 Leah Rowe <info@minifree.org> +# +# 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/>. +# + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# Get SeaBIOS, revert to commit last used and apply patches. + +# Remove the old version that may still exist +# ------------------------------------------------------------------------------ + +printf "Downloading SeaBIOS\n" + +rm -f build_error + +rm -rf "seabios/" + +# Get latest SeaBIOS +# ------------------------------------------------------------------------------ + +# download it using git +git clone https://git.seabios.org/seabios.git + +if [ ! -d "seabios" ]; then + printf "seabios not downloaded; check network connection?\n\n" + exit 1 +fi + +( +# modifications are required +cd "seabios/" + +# Reset to the last commit that was tested (we use stable releases for seabios) +# ------------------------------------------------------------------------------ + +git reset --hard b0d61ecef66eb05bd7a4eb7ada88ec5dab06dfee + +for patchfile in ../resources/seabios/patches/*.patch; do + git am "${patchfile}" || touch ../build_error + if [ -f ../build_error ]; then + git am --abort + break + fi +done +) + +if [ -f build_error ]; then + rm -f build_error + exit 1 +fi + +exit 0 diff --git a/resources/scripts/download/tianocore b/resources/scripts/download/tianocore new file mode 100755 index 00000000..3a84dcf1 --- /dev/null +++ b/resources/scripts/download/tianocore @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Copyright (C) 2020 Leah Rowe <info@minifree.org> +# +# 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/>. +# + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +printf "Downloading Tianocore\n" + +if [ ! -d "coreboot/default/" ]; then + ./download coreboot default +fi + +( + cd "coreboot/default/payloads/external/tianocore/" + rm -Rf tianocore + make download && make update +) + |