From 0848622799b8c627cd650d848ffa7d592d80b26d Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 17 Aug 2023 11:41:58 +0100 Subject: remove download scripts, consolidate into script most of them were just calling the gitclone script, so remove them. the grub script was treating gnulib as a dependency. i've now added the ability to grab 1 dependency, in the gitclone script (it should be expanded later to support multiple dependencies) the gitclone script has been renamed to "fetch". the "fetch_trees" script does more or less the same thing, but calls "fetch" and handles multiple revisions if a project needs that this is more efficient, and slightly reduces the code size of lbmk! Signed-off-by: Leah Rowe --- Makefile | 5 +- download | 1 - fetch | 134 +++++++++++++++++++ fetch_trees | 6 +- gitclone | 123 ----------------- lbmk | 3 - resources/git/revisions | 3 +- resources/scripts/build/module/bios_extract | 2 +- resources/scripts/build/module/flashrom | 2 +- resources/scripts/build/module/grub | 2 +- resources/scripts/build/module/memtest86plus | 2 +- resources/scripts/build/module/uefitool | 2 +- resources/scripts/build/payload/grub | 2 +- resources/scripts/build/payload/seabios | 2 +- resources/scripts/build/release/src | 18 +-- resources/scripts/modify/seabios/configs | 2 +- resources/scripts/update/blobs/download | 10 +- resources/scripts/update/blobs/extract | 6 +- resources/scripts/update/blobs/mrc | 186 ++++++++++++++++++++++++++ resources/scripts/update/module/bios_extract | 22 --- resources/scripts/update/module/biosutilities | 22 --- resources/scripts/update/module/flashrom | 24 ---- resources/scripts/update/module/grub | 32 ----- resources/scripts/update/module/me_cleaner | 25 ---- resources/scripts/update/module/memtest86plus | 32 ----- resources/scripts/update/module/mrc | 186 -------------------------- resources/scripts/update/module/seabios | 29 ---- resources/scripts/update/module/uefitool | 22 --- resources/scripts/update/seabios/configs | 2 +- 29 files changed, 352 insertions(+), 555 deletions(-) delete mode 120000 download create mode 100755 fetch delete mode 100755 gitclone create mode 100755 resources/scripts/update/blobs/mrc delete mode 100755 resources/scripts/update/module/bios_extract delete mode 100755 resources/scripts/update/module/biosutilities delete mode 100755 resources/scripts/update/module/flashrom delete mode 100755 resources/scripts/update/module/grub delete mode 100755 resources/scripts/update/module/me_cleaner delete mode 100755 resources/scripts/update/module/memtest86plus delete mode 100755 resources/scripts/update/module/mrc delete mode 100755 resources/scripts/update/module/seabios delete mode 100755 resources/scripts/update/module/uefitool diff --git a/Makefile b/Makefile index e4fbb0d9..0570d017 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ .POSIX: -#.PHONY: all check download modules ich9m-descriptors payloads roms release \ +#.PHONY: all check modules ich9m-descriptors payloads roms release \ # clean crossgcc-clean install-dependencies-ubuntu \ # install-dependencies-debian install-dependencies-arch \ # install-dependencies-void install-dependencies-fedora38 \ @@ -33,9 +33,6 @@ all: roms -download: - ./download all - modules: ./build module all diff --git a/download b/download deleted file mode 120000 index 012b4ec0..00000000 --- a/download +++ /dev/null @@ -1 +0,0 @@ -lbmk \ No newline at end of file diff --git a/fetch b/fetch new file mode 100755 index 00000000..502c0f76 --- /dev/null +++ b/fetch @@ -0,0 +1,134 @@ +#!/usr/bin/env sh + +# SPDX-FileCopyrightText: 2022 Caleb La Grange +# SPDX-FileCopyrightText: 2022 Ferass El Hafidi +# SPDX-FileCopyrightText: 2023 Leah Rowe +# SPDX-License-Identifier: GPL-3.0-only + +name="" +revision="" +location="" +url="" +bkup_url="" +tmp_dir="" +depend="" + +main() +{ + if [ -z "${1+x}" ]; then + err 'Error: name not set' + fi + + name=${1} + + read_config + verify_config + + clone_project + + # dependencies are downloaded *after* + # to account for cases like gnulib in grub where + # the dependency (gnulib) goes inside the main repo (grub) + if [ "${depend}" != "" ]; then + ./fetch ${depend} || exit 1 + fi + + # clean in case of failure + rm -Rf ${tmp_dir} >/dev/null 2>&1 || exit 1 +} + +read_config() +{ + awkstr=" /\{.*${name}.*}{/ {flag=1;next} /\}/{flag=0} flag { print }" + while read -r line ; do + set ${line} >/dev/null 2>&1 + case ${line} in + rev:*) + revision=${2} + ;; + loc:*) + location=${2} + ;; + url:*) + url=${2} + ;; + bkup_url:*) + bkup_url=${2} + ;; + depend:*) + depend=${2} + ;; + esac + done << EOF + $(eval "awk '${awkstr}' resources/git/revisions") +EOF +} + +verify_config() +{ + if [ -z "${revision+x}" ]; then + err 'Error: revision not set' + elif [ -z "${location+x}" ]; then + err 'Error: location not set' + elif [ -z "${url+x}" ]; then + err 'Error: url not set' + fi +} + +clone_project() +{ + tmp_dir=$(mktemp -dt "${name}_XXXXX") + + git clone ${url} ${tmp_dir} || git clone ${bkup_url} ${tmp_dir} \ + || err "ERROR: could not download ${name}" + + ( + cd ${tmp_dir} || err "tmpdir not created" + git reset --hard ${revision} || err "Cannot reset revision" + ) + + patch_project + + if [ -d "${location}" ]; then + rm -Rf ${location} || err "Cannot remove directory '${location}'" + fi + mv ${tmp_dir} ${location} && return 0 + + printf "ERROR: Could not copy temp file to destination.\n" + err " ${tmp_dir} > ${location} check permissions" +} + +patch_project() +{ + patchdir="resources/${name}/patches" + + for patchfile in ${PWD}/${patchdir}/*.patch ; do + if [ ! -f "${patchfile}" ]; then + continue + fi + ( + cd ${tmp_dir} || err "tmpdir not created" + git am ${patchfile} || err "Cannot patch project: $name" + ) + done +} + +usage() +{ + cat <<- EOF + Usage: ./fetch [name] + + Options: + name: Module name as specified in resources/git/revisions + EOF +} + +err() +{ + printf "${@}\n" + usage + rm -Rf ${tmp_dir} >/dev/null 2>&1 + exit 1 +} + +main $@ diff --git a/fetch_trees b/fetch_trees index 37ff0928..19112a2e 100755 --- a/fetch_trees +++ b/fetch_trees @@ -78,7 +78,7 @@ download_for_target() return 0 fi - gitclone_from_upstream || exit 1 + fetch_from_upstream || exit 1 prepare_new_tree "${1}" "${tree}" "${rev}" \ || exit 1 @@ -133,7 +133,7 @@ check_config_for_target() touch "${cfgsdir}/${_target}/seen" } -gitclone_from_upstream() +fetch_from_upstream() { [ ! -d "${project}" ] && \ mkdir -p "${project}" @@ -141,7 +141,7 @@ gitclone_from_upstream() return 1 [ -d "${project}/${project}" ] && \ return 0 - ./gitclone ${project} || \ + ./fetch ${project} || \ return 1 } diff --git a/gitclone b/gitclone deleted file mode 100755 index 6bb52ef9..00000000 --- a/gitclone +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env sh - -# SPDX-FileCopyrightText: 2022 Caleb La Grange -# SPDX-FileCopyrightText: 2022 Ferass El Hafidi -# SPDX-FileCopyrightText: 2023 Leah Rowe -# SPDX-License-Identifier: GPL-3.0-only - -name="" -revision="" -location="" -url="" -bkup_url="" -tmp_dir="" - -main() -{ - if [ -z "${1+x}" ]; then - err 'Error: name not set' - fi - - name=${1} - - read_config - verify_config - - clone_project - - # clean in case of failure - rm -Rf ${tmp_dir} >/dev/null 2>&1 || exit 1 -} - -read_config() -{ - awkstr=" /\{.*${name}.*}{/ {flag=1;next} /\}/{flag=0} flag { print }" - while read -r line ; do - set ${line} >/dev/null 2>&1 - case ${line} in - rev:*) - revision=${2} - ;; - loc:*) - location=${2} - ;; - url:*) - url=${2} - ;; - bkup_url:*) - bkup_url=${2} - ;; - esac - done << EOF - $(eval "awk '${awkstr}' resources/git/revisions") -EOF -} - -verify_config() -{ - if [ -z "${revision+x}" ]; then - err 'Error: revision not set' - elif [ -z "${location+x}" ]; then - err 'Error: location not set' - elif [ -z "${url+x}" ]; then - err 'Error: url not set' - fi -} - -clone_project() -{ - tmp_dir=$(mktemp -dt "${name}_XXXXX") - - git clone ${url} ${tmp_dir} || git clone ${bkup_url} ${tmp_dir} \ - || err "ERROR: could not download ${name}" - - ( - cd ${tmp_dir} || err "tmpdir not created" - git reset --hard ${revision} || err "Cannot reset revision" - ) - - patch_project - - if [ -d "${location}" ]; then - rm -Rf ${location} || err "Cannot remove directory '${location}'" - fi - mv ${tmp_dir} ${location} && return 0 - - printf "ERROR: Could not copy temp file to destination.\n" - err " ${tmp_dir} > ${location} check permissions" -} - -patch_project() -{ - patchdir="resources/${name}/patches" - - for patchfile in ${PWD}/${patchdir}/*.patch ; do - if [ ! -f "${patchfile}" ]; then - continue - fi - ( - cd ${tmp_dir} || err "tmpdir not created" - git am ${patchfile} || err "Cannot patch project: $name" - ) - done -} - -usage() -{ - cat <<- EOF - Usage: ./gitclone [name] - - Options: - name: Module name as specified in resources/git/revisions - EOF -} - -err() -{ - printf "${@}\n" - usage - rm -Rf ${tmp_dir} >/dev/null 2>&1 - exit 1 -} - -main $@ diff --git a/lbmk b/lbmk index e0b950e3..c4bc3f3e 100755 --- a/lbmk +++ b/lbmk @@ -33,9 +33,6 @@ main() { if [ "${0##*/}" = "lbmk" ]; then die "Do not run the lbmk script directly!" - elif [ "${0##*/}" = "download" ]; then - ./update module $@ || exit 1 - exit 0 elif [ "${0##*/}" = "blobutil" ]; then ./update blobs $@ || exit 1 exit 0 diff --git a/resources/git/revisions b/resources/git/revisions index 13063a4c..edd076b2 100644 --- a/resources/git/revisions +++ b/resources/git/revisions @@ -3,7 +3,7 @@ # Project name is enclosed by curly braces '{}' information about the # project relevant to osbmk is stored between the subsequent curly # braces. This file is used by the gitcheck script as well as the -# gitclone script. Each entry must include: revision 'rev', location +# fetch script. Each entry must include: revision 'rev', location # 'loc', and the git url 'url'. Bkup_url is optional. {coreboot}{ @@ -25,6 +25,7 @@ loc: grub url: git://git.savannah.gnu.org/grub.git bkup_url: http://git.savannah.gnu.org/r/grub.git + depend: gnulib } {gnulib}{ diff --git a/resources/scripts/build/module/bios_extract b/resources/scripts/build/module/bios_extract index 77677fa1..8a40b5a0 100755 --- a/resources/scripts/build/module/bios_extract +++ b/resources/scripts/build/module/bios_extract @@ -25,7 +25,7 @@ set -u -e # -------------------------------------------------------------------- if [ ! -d "bios_extract/" ]; then - ./download bios_extract + ./fetch bios_extract fi printf "Building bios_extract\n" diff --git a/resources/scripts/build/module/flashrom b/resources/scripts/build/module/flashrom index 37f57ce0..a4dbe35d 100755 --- a/resources/scripts/build/module/flashrom +++ b/resources/scripts/build/module/flashrom @@ -29,7 +29,7 @@ set -u -e # -------------------------------------------------------------------- if [ ! -d "flashrom/" ]; then - ./download flashrom + ./fetch flashrom fi printf "Building flashrom\n" diff --git a/resources/scripts/build/module/grub b/resources/scripts/build/module/grub index 5cf58a67..edad6b2a 100755 --- a/resources/scripts/build/module/grub +++ b/resources/scripts/build/module/grub @@ -27,7 +27,7 @@ main() printf "Building GRUB\n" if [ ! -d "grub/" ]; then - ./download grub || exit 1 + ./fetch grub || exit 1 fi build_grub diff --git a/resources/scripts/build/module/memtest86plus b/resources/scripts/build/module/memtest86plus index 7fc46be9..45727b77 100755 --- a/resources/scripts/build/module/memtest86plus +++ b/resources/scripts/build/module/memtest86plus @@ -31,7 +31,7 @@ set -u -e printf "Building MemTest86+\n" if [ ! -d "memtest86plus/" ]; then - ./download memtest86plus + ./fetch memtest86plus fi make -j$(nproc) -BC memtest86plus diff --git a/resources/scripts/build/module/uefitool b/resources/scripts/build/module/uefitool index 6adf1de2..891d8bf8 100755 --- a/resources/scripts/build/module/uefitool +++ b/resources/scripts/build/module/uefitool @@ -24,7 +24,7 @@ set -u -e main() { if [ ! -d "uefitool" ]; then - ./download uefitool || fail "cannot download uefitool" + ./fetch uefitool || fail "cannot download uefitool" fi printf "Building uefitool (UEFIExtract)\n" diff --git a/resources/scripts/build/payload/grub b/resources/scripts/build/payload/grub index 23765f47..0734f8a9 100755 --- a/resources/scripts/build/payload/grub +++ b/resources/scripts/build/payload/grub @@ -31,7 +31,7 @@ main() printf "Creating GRUB payloads and configuration files\n" [ ! -d "grub/" ] && \ - ./download grub + ./fetch grub [ ! -f "grub/grub-mkstandalone" ] && \ ./build module grub [ ! -d "payload/" ] && \ diff --git a/resources/scripts/build/payload/seabios b/resources/scripts/build/payload/seabios index f822a019..43973109 100755 --- a/resources/scripts/build/payload/seabios +++ b/resources/scripts/build/payload/seabios @@ -53,7 +53,7 @@ check_dependencies() rm -f ${payloaddir}/* || exit 1 if [ ! -d "seabios/" ]; then - ./download seabios || exit 1 + ./fetch seabios || exit 1 fi } diff --git a/resources/scripts/build/release/src b/resources/scripts/build/release/src index 95c0036f..2b985156 100755 --- a/resources/scripts/build/release/src +++ b/resources/scripts/build/release/src @@ -23,14 +23,14 @@ set -u -e projectname="$(cat projectname)" -trees_gitclone_list="coreboot u-boot" -simple_gitclone_list="flashrom grub memtest86plus seabios me_cleaner uefitool" -simple_gitclone_list="${simple_gitclone_list} bios_extract biosutilities" +trees_fetch_list="coreboot u-boot" +simple_fetch_list="flashrom grub memtest86plus seabios me_cleaner uefitool" +simple_fetch_list="${simple_fetch_list} bios_extract biosutilities" dirlist="resources util" # do not add blobs directory here. it's handled below -filelist="lbmk blobutil modify download build README.md COPYING Makefile update" -filelist="${filelist} version versiondate projectname .gitcheck gitclone" +filelist="lbmk blobutil modify build README.md COPYING Makefile update" +filelist="${filelist} version versiondate projectname .gitcheck fetch" filelist="${filelist} fetch_trees" version="version-unknown" @@ -77,19 +77,19 @@ create_release_directory() download_modules() { - for modname in ${trees_gitclone_list}; do + for modname in ${trees_fetch_list}; do [ ! -d "${modname}" ] && \ ./fetch_trees ${modname} done - for modname in ${simple_gitclone_list}; do + for modname in ${simple_fetch_list}; do [ ! -d "${modname}/" ] && \ - ./download ${modname} + ./fetch ${modname} done } copy_files() { - for dir in ${simple_gitclone_list} ${dirlist}; do + for dir in ${simple_fetch_list} ${dirlist}; do cp -R "${dir}/" "${srcdir}/" done diff --git a/resources/scripts/modify/seabios/configs b/resources/scripts/modify/seabios/configs index 614a4371..fa3d1372 100755 --- a/resources/scripts/modify/seabios/configs +++ b/resources/scripts/modify/seabios/configs @@ -30,7 +30,7 @@ main() download_seabios() { if [ ! -d "seabios" ]; then - ./download seabios + ./fetch seabios fi if [ ! -d "seabios" ]; then printf "error: Failed to download SeaBIOS. " diff --git a/resources/scripts/update/blobs/download b/resources/scripts/update/blobs/download index b4b74c1b..0a28778a 100755 --- a/resources/scripts/update/blobs/download +++ b/resources/scripts/update/blobs/download @@ -184,7 +184,7 @@ build_dependencies() { if [ ! -d me_cleaner ]; then printf "downloading me_cleaner\n" - ./download me_cleaner || fail "could not download me_cleaner" + ./fetch me_cleaner || fail "could not download me_cleaner" fi if [ ! -d ${cbdir} ]; then printf "downloading coreboot\n" @@ -193,17 +193,17 @@ build_dependencies() fi if [ ! -d bios_extract ]; then printf "downloading bios_extract\n" - ./download bios_extract \ + ./fetch bios_extract \ || fail "could not download bios_extract" fi if [ ! -d biosutilities ]; then printf "downloading biosutilities\n" - ./download biosutilities \ + ./fetch biosutilities \ || fail "could not download biosutilities" fi if [ ! -d uefitool ]; then printf "download uefitool (for UEFIExtract)\n" - ./download uefitool \ + ./fetch uefitool \ || fail "could not download uefitool" fi if [ ! -f uefitool/uefiextract ]; then @@ -239,7 +239,7 @@ download_blobs() download_e6400vga || _failed="${_failed} e6400vga" ;; *MRC*) - ./download mrc || _failed="${_failed} mrc" + ./update blobs mrc || _failed="${_failed} mrc" ;; esac done diff --git a/resources/scripts/update/blobs/extract b/resources/scripts/update/blobs/extract index 63d09c02..5ac8e91c 100755 --- a/resources/scripts/update/blobs/extract +++ b/resources/scripts/update/blobs/extract @@ -58,10 +58,10 @@ build_dependencies() { if [ ! -d me_cleaner ]; then printf "downloading me_cleaner\n" - ./download me_cleaner || fail 'could not download me_cleaner' + ./fetch me_cleaner || fail 'could not download me_cleaner' else printf "me_cleaner already downloaded. Skipping.\n" - printf "run ./download me_cleaner to manually overwrite\n" + printf "run ./fetch me_cleaner to manually overwrite\n" fi if [ ! -d ${cbdir} ]; then @@ -90,7 +90,7 @@ extract_blobs() if [ "$CONFIG_HAVE_MRC" = "y" ]; then printf 'haswell board detected, downloading mrc\n' - ./download mrc || fail "could not download mrc" + ./update blobs mrc || fail "could not download mrc" fi _me_destination=${CONFIG_ME_BIN_PATH#../../} diff --git a/resources/scripts/update/blobs/mrc b/resources/scripts/update/blobs/mrc new file mode 100755 index 00000000..84e79f62 --- /dev/null +++ b/resources/scripts/update/blobs/mrc @@ -0,0 +1,186 @@ +#!/usr/bin/env sh + +# Download Intel MRC images +# +# 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, version 2 of the License. +# +# 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 . +# + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e +export PATH="${PATH}:/sbin" + +# This file is forked from util/chromeos/crosfirmware.sh in coreboot cfc26ce278 +# Changes to it in *this version* are copyright 2021 and 2023 Leah Rowe, under +# the same license as above. + +# use updated manifest from wayback machine, when updating mrc.bin, +# and update the other variables below accordingly. current manifest used: +# https://web.archive.org/web/20210211071412/https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf + +# the wayback machine is used so that we get the same manifest. google +# does not seem to version the manifest, but archives are available + +# variables taken from that manifest: + +_board="peppy" +_file="chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin" +_url="https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin.zip" +_url2="https://web.archive.org/web/20200516070928/https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin.zip" +_sha1sum="cd5917cbe7f821ad769bf0fd87046898f9e175c8" +_mrc_complete_hash="d18de1e3d52c0815b82ea406ca07897c56c65696" +_mrc_complete="mrc/haswell/mrc.bin" + +cbdir="coreboot/default" +cbfstool="cbutils/default/cbfstool" + +sname="" + +main() +{ + sname=${0} + printf "Downloading Intel MRC blobs\n" + + check_existing && exit 0 + build_dependencies || fail "could not build dependencies" + fetch_mrc || fail "could not fetch mrc.bin" +} + +check_existing() +{ + if [ ! -f ${_mrc_complete} ]; then + return 1 + fi + printf 'found existing mrc.bin, checking its hash\n' + if [ "$(sha1sum ${_mrc_complete} | awk '{print $1}')" \ + = "${_mrc_complete_hash}" ]; then + printf 'checksums matched, skipping downloading\n' + return 0 + else + printf 'hashes did not match, starting over\n' + return 1 + fi +} + +build_dependencies() +{ + if [ ! -d "${cbdir}/" ]; then + ./fetch_trees coreboot default || return 1 + fi + ./build module cbutils default || return 1 + return 0 +} + +fetch_mrc() +{ + mkdir -p mrc/haswell/ || return 1 + + ( + cd mrc/haswell/ + + download_image ${_url} ${_file} ${_sha1sum} + if [ ! -f ${_file} ]; then + download_image ${_url2} ${_file} ${_sha1sum} + fi + if [ ! -f $_file ]; then + fail "%{_file} not downloaded / verification failed." + fi + + extract_partition ROOT-A ${_file} root-a.ext2 + extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board} + + extract_coreboot chromeos-firmwareupdate-${_board} + + ../../${cbfstool} coreboot-*.bin extract -f mrc.bin \ + -n mrc.bin -r RO_SECTION \ + || fail "Could not fetch mrc.bin" + rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \ + "${_file}" "root-a.ext2" + + printf "\n\nmrc.bin saved to ${_mrc_complete}\n\n" + ) + + return 0 +} + +download_image() +{ + url=${1} + _file=${2} + _sha1sum=${3} + + echo "Downloading recovery image" + curl "$url" > "$_file.zip" + if [ "$(sha1sum ${_file}.zip | awk '{print $1}')" = "${_sha1sum}" ] + then + unzip -q "${_file}.zip" + rm "${_file}.zip" + echo "Checksum verification passed for recovery image." + return 0 + else + rm "${_file}.zip" + echo "Bad checksum. Recovery image deleted." + return 1 + fi +} + +extract_partition() +{ + NAME=${1} + FILE=${2} + ROOTFS=${3} + _bs=1024 + + echo "Extracting ROOT-A partition" + ROOTP=$( printf "unit\nB\nprint\nquit\n" | \ + parted ${FILE} 2>/dev/null | grep ${NAME} ) + + START=$(( $( echo ${ROOTP} | cut -f2 -d\ | tr -d "B" ) )) + SIZE=$(( $( echo ${ROOTP} | cut -f4 -d\ | tr -d "B" ) )) + + dd if=${FILE} of=${ROOTFS} bs=${_bs} skip=$(( ${START} / ${_bs} )) \ + count=$(( ${SIZE} / ${_bs} )) > /dev/null +} + +extract_shellball() +{ + ROOTFS=${1} + SHELLBALL=${2} + + echo "Extracting chromeos-firmwareupdate" + printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \ + | debugfs ${ROOTFS} > /dev/null 2>&1 +} + +extract_coreboot() +{ + _shellball=${1} + _unpacked=$( mktemp -d ) + + echo "Extracting coreboot image" + sh ${_shellball} --unpack ${_unpacked} > /dev/null + + _version=$( cat ${_unpacked}/VERSION | grep BIOS\ version: | \ + cut -f2 -d: | tr -d \ ) + + cp ${_unpacked}/bios.bin coreboot-${_version}.bin + rm -r "${_unpacked}" +} + +fail() +{ + printf "%s: ERROR: %s\n" + ${sname} ${1} + exit 1 +} + +main $@ diff --git a/resources/scripts/update/module/bios_extract b/resources/scripts/update/module/bios_extract deleted file mode 100755 index 1688aabe..00000000 --- a/resources/scripts/update/module/bios_extract +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright (C) 2023 Leah Rowe -# -# 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 . -# - -[ "x${DEBUG+set}" = 'xset' ] && set -v -set -u -e - -./gitclone bios_extract diff --git a/resources/scripts/update/module/biosutilities b/resources/scripts/update/module/biosutilities deleted file mode 100755 index c6de36b1..00000000 --- a/resources/scripts/update/module/biosutilities +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright (C) 2023 Leah Rowe -# -# 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 . -# - -[ "x${DEBUG+set}" = 'xset' ] && set -v -set -u -e - -./gitclone biosutilities diff --git a/resources/scripts/update/module/flashrom b/resources/scripts/update/module/flashrom deleted file mode 100755 index def33ffb..00000000 --- a/resources/scripts/update/module/flashrom +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env sh - -# helper script: downloads flashrom and patches it -# -# Copyright (C) 2014, 2015, 2020, 2021 Leah Rowe -# -# 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 . -# - -[ "x${DEBUG+set}" = 'xset' ] && set -v -set -u -e - -./gitclone flashrom diff --git a/resources/scripts/update/module/grub b/resources/scripts/update/module/grub deleted file mode 100755 index ff1ce55c..00000000 --- a/resources/scripts/update/module/grub +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env sh - -# helper script: Downloads GRUB and patches it. -# -# Copyright (C) 2014,2015,2016,2020,2021,2023 Leah Rowe -# -# -# 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 . -# - -[ "x${DEBUG+set}" = 'xset' ] && set -v -set -u -e - -./gitclone grub -./gitclone gnulib || rm -Rf grub/ -if [ ! -d grub ]; then - printf "%s: Could not download grub and gnulib\n" ${0} - exit 1 -else - exit 0 -fi diff --git a/resources/scripts/update/module/me_cleaner b/resources/scripts/update/module/me_cleaner deleted file mode 100755 index 93173257..00000000 --- a/resources/scripts/update/module/me_cleaner +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright (C) 2020 Leah Rowe -# -# 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 . -# - -# This script assumes that the working directory is the -# root of retroboot_src or retroboot git. - -[ "x${DEBUG+set}" = 'xset' ] && set -v -set -u -e - -./gitclone me_cleaner diff --git a/resources/scripts/update/module/memtest86plus b/resources/scripts/update/module/memtest86plus deleted file mode 100755 index e4106f38..00000000 --- a/resources/scripts/update/module/memtest86plus +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env sh - -# helper script: Downloads MemTest86+ and patches it -# -# Copyright (C) 2014, 2015, 2020, 2021 Leah Rowe -# Copyright (C) 2015 Joseph Michael Thompson -# Copyright (C) 2015 Klemens Nanni -# -# 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 . -# - -[ "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" -./gitclone memtest86plus diff --git a/resources/scripts/update/module/mrc b/resources/scripts/update/module/mrc deleted file mode 100755 index 84e79f62..00000000 --- a/resources/scripts/update/module/mrc +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env sh - -# Download Intel MRC images -# -# 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, version 2 of the License. -# -# 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 . -# - -[ "x${DEBUG+set}" = 'xset' ] && set -v -set -u -e -export PATH="${PATH}:/sbin" - -# This file is forked from util/chromeos/crosfirmware.sh in coreboot cfc26ce278 -# Changes to it in *this version* are copyright 2021 and 2023 Leah Rowe, under -# the same license as above. - -# use updated manifest from wayback machine, when updating mrc.bin, -# and update the other variables below accordingly. current manifest used: -# https://web.archive.org/web/20210211071412/https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf - -# the wayback machine is used so that we get the same manifest. google -# does not seem to version the manifest, but archives are available - -# variables taken from that manifest: - -_board="peppy" -_file="chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin" -_url="https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin.zip" -_url2="https://web.archive.org/web/20200516070928/https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin.zip" -_sha1sum="cd5917cbe7f821ad769bf0fd87046898f9e175c8" -_mrc_complete_hash="d18de1e3d52c0815b82ea406ca07897c56c65696" -_mrc_complete="mrc/haswell/mrc.bin" - -cbdir="coreboot/default" -cbfstool="cbutils/default/cbfstool" - -sname="" - -main() -{ - sname=${0} - printf "Downloading Intel MRC blobs\n" - - check_existing && exit 0 - build_dependencies || fail "could not build dependencies" - fetch_mrc || fail "could not fetch mrc.bin" -} - -check_existing() -{ - if [ ! -f ${_mrc_complete} ]; then - return 1 - fi - printf 'found existing mrc.bin, checking its hash\n' - if [ "$(sha1sum ${_mrc_complete} | awk '{print $1}')" \ - = "${_mrc_complete_hash}" ]; then - printf 'checksums matched, skipping downloading\n' - return 0 - else - printf 'hashes did not match, starting over\n' - return 1 - fi -} - -build_dependencies() -{ - if [ ! -d "${cbdir}/" ]; then - ./fetch_trees coreboot default || return 1 - fi - ./build module cbutils default || return 1 - return 0 -} - -fetch_mrc() -{ - mkdir -p mrc/haswell/ || return 1 - - ( - cd mrc/haswell/ - - download_image ${_url} ${_file} ${_sha1sum} - if [ ! -f ${_file} ]; then - download_image ${_url2} ${_file} ${_sha1sum} - fi - if [ ! -f $_file ]; then - fail "%{_file} not downloaded / verification failed." - fi - - extract_partition ROOT-A ${_file} root-a.ext2 - extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board} - - extract_coreboot chromeos-firmwareupdate-${_board} - - ../../${cbfstool} coreboot-*.bin extract -f mrc.bin \ - -n mrc.bin -r RO_SECTION \ - || fail "Could not fetch mrc.bin" - rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \ - "${_file}" "root-a.ext2" - - printf "\n\nmrc.bin saved to ${_mrc_complete}\n\n" - ) - - return 0 -} - -download_image() -{ - url=${1} - _file=${2} - _sha1sum=${3} - - echo "Downloading recovery image" - curl "$url" > "$_file.zip" - if [ "$(sha1sum ${_file}.zip | awk '{print $1}')" = "${_sha1sum}" ] - then - unzip -q "${_file}.zip" - rm "${_file}.zip" - echo "Checksum verification passed for recovery image." - return 0 - else - rm "${_file}.zip" - echo "Bad checksum. Recovery image deleted." - return 1 - fi -} - -extract_partition() -{ - NAME=${1} - FILE=${2} - ROOTFS=${3} - _bs=1024 - - echo "Extracting ROOT-A partition" - ROOTP=$( printf "unit\nB\nprint\nquit\n" | \ - parted ${FILE} 2>/dev/null | grep ${NAME} ) - - START=$(( $( echo ${ROOTP} | cut -f2 -d\ | tr -d "B" ) )) - SIZE=$(( $( echo ${ROOTP} | cut -f4 -d\ | tr -d "B" ) )) - - dd if=${FILE} of=${ROOTFS} bs=${_bs} skip=$(( ${START} / ${_bs} )) \ - count=$(( ${SIZE} / ${_bs} )) > /dev/null -} - -extract_shellball() -{ - ROOTFS=${1} - SHELLBALL=${2} - - echo "Extracting chromeos-firmwareupdate" - printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \ - | debugfs ${ROOTFS} > /dev/null 2>&1 -} - -extract_coreboot() -{ - _shellball=${1} - _unpacked=$( mktemp -d ) - - echo "Extracting coreboot image" - sh ${_shellball} --unpack ${_unpacked} > /dev/null - - _version=$( cat ${_unpacked}/VERSION | grep BIOS\ version: | \ - cut -f2 -d: | tr -d \ ) - - cp ${_unpacked}/bios.bin coreboot-${_version}.bin - rm -r "${_unpacked}" -} - -fail() -{ - printf "%s: ERROR: %s\n" - ${sname} ${1} - exit 1 -} - -main $@ diff --git a/resources/scripts/update/module/seabios b/resources/scripts/update/module/seabios deleted file mode 100755 index 666c32ae..00000000 --- a/resources/scripts/update/module/seabios +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright (C) 2015, 2016, 2021 Leah Rowe -# -# 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 . -# - -[ "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" - -./gitclone seabios diff --git a/resources/scripts/update/module/uefitool b/resources/scripts/update/module/uefitool deleted file mode 100755 index cd376895..00000000 --- a/resources/scripts/update/module/uefitool +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh -# -# Copyright (C) 2023 Leah Rowe -# -# 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 . -# - -[ "x${DEBUG+set}" = 'xset' ] && set -v -set -u -e - -./gitclone uefitool diff --git a/resources/scripts/update/seabios/configs b/resources/scripts/update/seabios/configs index c40ed2d2..8e8377bb 100755 --- a/resources/scripts/update/seabios/configs +++ b/resources/scripts/update/seabios/configs @@ -28,7 +28,7 @@ set -u -e printf "Updating seabios configs\n" if [ ! -d "seabios" ]; then - ./download seabios + ./fetch seabios fi if [ ! -d "seabios" ]; then -- cgit v1.2.1