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/build |
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/build')
25 files changed, 1823 insertions, 0 deletions
diff --git a/resources/scripts/build/boot/roms b/resources/scripts/build/boot/roms new file mode 100755 index 00000000..fb57795c --- /dev/null +++ b/resources/scripts/build/boot/roms @@ -0,0 +1,100 @@ +#!/bin/bash + +# +# helper script: build coreboot images with various payloads +# +# Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org> +# 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/>. +# + +# This script assumes that the working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +projectname="$(cat projectname)" + +listboards() { + for boarddir in resources/coreboot/*; do + if [ ! -d "${boarddir}" ]; then continue; fi + board="${boarddir##resources/coreboot/}" + board="${board%/}" + printf '%s\n' "${board##*/}" + done +} + +help() { + cat <<- EOF + USAGE: ./build boot roms boardname + To build *all* boards, do this: ./build boot roms all + To list *all* boards, do this: ./build boot roms list + + possible values for 'options': + $(listboards) + + Example: ./build boot roms x60 + Example: ./build boot roms x200_8mb x60 + + Refer to the ${projectname} documentation for more information. + EOF +} + +die() { + printf 'Error: %s\n' "${@}" 1>&2 + exit 1 +} + +# Build ROM images for supported boards +buildrom() { + board="$1" + if [ -d "resources/coreboot/${board}/" ]; then + ./build boot roms_helper "${board}" + else + die "\nbuild/roms: target not defined in the build system: %s\n" "${board}" + fi +} + +if [ $# -gt 0 ]; then + firstoption="${1}" + if [ "${firstoption}" = "help" ]; then + help + exit 0 + fi + if [ "${firstoption}" = "list" ]; then + listboards + exit 0 + fi + + printf "Building %s ROM images\n" "${projectname}" + + if [ "${firstoption}" = "all" ]; then + for boardname in $(listboards); do + buildrom "${boardname}" || die "build/roms: something went wrong" + done + else + for board in ${@}; do + buildrom "${board}" || die "build/roms: something went wrong" + done + fi +else + help + exit 1 +fi + + +printf "\n\nDone! Your ROMs are in bin/\n\n" + diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper new file mode 100755 index 00000000..83db0766 --- /dev/null +++ b/resources/scripts/build/boot/roms_helper @@ -0,0 +1,454 @@ +#!/bin/bash + +# helper script: create ROM images for a given mainboard +# +# Copyright (C) 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/>. +# + +# This script assumes that the working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +projectname="$(cat projectname)" + +if (( $# != 1 )); then + printf "Usage: ./build boot roms boardname\n" + printf "Example: ./build boot roms x60\n" + printf "Example: ./build boot roms x60 x200_8mb\n" + printf "Example: ./build boot roms all\n" + printf "You need to specify exactly 1 argument\n" + exit 1 +fi + +board="${1}" + +if [ ! -d "resources/coreboot/${board}" ]; then + printf "build/roms: Target %s does not exist in the %s build system. Skipping build.\n" "${projectname}" "${board}" + exit 1 +fi + +if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then + printf "build/roms: Target %s does not have a board.cfg. Skipping build.\n" "${board}" + exit 1 +fi + +cbtree="undefined" +romtype="normal" # optional parameter in board.cfg. "normal" is default +arch="undefined" +# Disable all payloads by default. +# board.cfg files have to specifically enable [a] payload(s) +payload_grub="n" +payload_grub_withseabios="n" # seabios chainloaded from grub +payload_grub_withtianocore="n" # tianocore chainloaded from grub +payload_seabios="n" +payload_seabios_withgrub="n" # i386-coreboot grub accessible from SeaBIOS boot menu +payload_tianocore="n" +seabios_opromloadonly="0" +# Override the above defaults using board.cfg +source "resources/coreboot/${board}/board.cfg" +if [ "${cbtree}" = "undefined" ]; then + printf "build/roms: Target %s does not define a coreboot tree. Skipping build.\n" "${board}" + exit 1 +fi +if [ "${arch}" = "undefined" ]; then + printf "build/roms: Target %s does not define a CPU type. Skipping build.\n" "${board}" + exit 1 +fi + +if [ "${seabios_opromloadonly}" != "0" ] && \ + [ "${seabios_opromloadonly}" != "1" ]; then + seabios_opromloadonly="0" +fi +if [ "${payload_grub_withseabios}" = "y" ] \ + || [ "${payload_grub_withtianocore}" = "y" ]; then + payload_grub="y" +fi +if [ "${payload_grub_withseabios}" = "y" ]; then + payload_seabios="y" + payload_seabios_withgrub="y" # if grub-first works, then seabios-with-grub will also work +fi +if [ "${payload_seabios_withgrub}" = "y" ]; then + payload_seabios="y" # if seabios-with-grub works, then SeaBIOS-alone should also work +fi +# NOTE: reverse logic must not be applied. If SeaBIOS-with-GRUB works, that doesn't +# necessarily mean GRUB-with-SeaBIOS will work nicely. for example, the board might +# only have an add-on GPU available, where it's recommended to boot SeaBIOS first +if [ "${payload_grub_withtianocore}" = "y" ]; then + payload_tianocore="y" +fi +if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] \ + && [ "${payload_tianocore}" != "y" ]; then + while true; do + for configfile in "resources/coreboot/${board}/config/"*; do + if [ -f "${configfile}" ]; then + printf "ERROR build/roms: Target '%s' does not define a payload. Exiting.\n" "${board}" + exit 1 + fi + done + break + done +fi + +if [ ! -f "memtest86plus/memtest" ]; then + ./build module memtest86plus +fi + +romdir="bin/${board}" +cbdir="coreboot/${board}" +if [ "${board}" != "${cbtree}" ]; then + cbdir="coreboot/${cbtree}" +fi +cbfstool="${cbdir}/util/cbfstool/cbfstool" +corebootrom="${cbdir}/build/coreboot.rom" +seavgabiosrom="payload/seabios/seavgabios.bin" +tianocoreelf="payload/tianocore/tianocore.elf" + +if [ ! -d "${cbdir}" ]; then + ./download coreboot ${cbtree} +fi + +if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then + if [ ! -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ]; then + ( + cd "${cbdir}" + make crossgcc-i386 CPUS=$(nproc) # even for 64-bit machines, coreboot builds + # 32-bit ROM images, so we only need to worry about i386-elf + ) + fi +fi + +if [ "${arch}" != "x86_64" ]; then + payload_tianocore="n" + payload_grub_withtianocore="n" +fi + +if [ ! -f "${cbfstool}" ]; then + ./build module cbutils ${cbtree} +fi + +if [ ! -f "${tianocoreelf}" ]; then + if [ "${payload_tianocore}" = "y" ]; then + ./build payload tianocore + elif [ "${payload_grub}" = "y" ] \ + && [ "${payload_grub_withtianocore}" = "y" ]; then + ./build payload tianocore + fi +fi + +if [ ! -f "${seavgabiosrom}" ] \ + || [ ! -f payload/seabios/seabios_libgfxinit.elf ] \ + || [ ! -f payload/seabios/seabios_vgarom.elf ]; then + if [ "${payload_seabios}" = "y" ]; then + ./build payload seabios + elif [ "${payload_grub}" = "y" ] \ + && [ "${payload_grub_withseabios}" = "y" ]; then + ./build payload seabios + fi +fi + +[ -d "${romdir}/" ] || mkdir -p "${romdir}/" +rm -f "${romdir}"/* + +if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then + if [ -f "payload/grub/grub_usqwerty.cfg" ]; then + grubrefchecksum="$(sha1sum resources/grub/config/grub.cfg)" + grubrefchecksum="${grubrefchecksum% resources/grub/config/grub.cfg}" + grubbuildchecksum="$(sha1sum payload/grub/grub_usqwerty.cfg)" + grubbuildchecksum="${grubbuildchecksum% payload/grub/grub_usqwerty.cfg}" + if [ "${grubrefchecksum}" != "${grubbuildchecksum}" ]; then + rm -Rf payload/grub/ + printf "Changes detected to GRUB. Re-building now:\n" + fi + else + printf "Required GRUB payloads not yet built. Building now:\n" + rm -Rf payload/grub/ # just in case + fi + for keymapfile in resources/grub/keymap/*; do + + if [ ! -f "${keymapfile}" ]; then + continue + fi + + keymap="${keymapfile##*/}" + keymap="${keymap%.gkb}" + + grubelf="payload/grub/grub_${keymap}.elf" + grubcfg="payload/grub/grub_${keymap}.cfg" + grubtestcfg="payload/grub/grub_${keymap}_test.cfg" + + if [ ! -f "${grubelf}" ] || [ ! -f "${grubcfg}" ] || \ + [ ! -f "${grubtestcfg}" ]; then + ./build payload grub + fi + done +fi + +# it is assumed that no other work will be done on the ROM +# after calling this function. therefore this function is "final" +moverom() { + rompath="$1" + newrompath="$2" + cuttype="$3" + + printf "\nCreating new ROM image: %s\n" "${newrompath}" + + if [ "${cuttype}" = "4MiB IFD BIOS region" ]; then + dd if=${rompath} of=${newrompath} bs=1 skip=$[$(stat -c %s ${rompath}) - 0x400000] count=4194304 + else + cp ${rompath} ${newrompath} + fi + + for romsize in 4 8 16; do + if [ "${cuttype}" = "${romsize}MiB ICH9 IFD NOR flash" ]; then + if [ ! -f "descriptors/ich9m/ich9fdgbe_${romsize}m.bin" ]; then + ./build descriptors ich9m + fi + dd if=descriptors/ich9m/ich9fdgbe_${romsize}m.bin of=${newrompath} bs=1 count=12k conv=notrunc + fi + if [ "${cuttype}" = "${romsize}MiB ICH9 IFD NOGBE NOR flash" ]; then + if [ ! -f "descriptors/ich9m/ich9fdnogbe_${romsize}m.bin" ]; then + ./build descriptors ich9m + fi + dd if=descriptors/ich9m/ich9fdnogbe_${romsize}m.bin of=${newrompath} bs=1 count=4k conv=notrunc + fi + done + + if [ "${cuttype}" = "i945 laptop" ]; then + dd if=${newrompath} of=top64k.bin bs=1 skip=$[$(stat -c %s ${newrompath}) - 0x10000] count=64k + dd if=top64k.bin of=${newrompath} bs=1 seek=$[$(stat -c %s ${newrompath}) - 0x20000] count=64k conv=notrunc + rm -f top64k.bin + fi +} + +# expected: configs must not specify a payload +mkCoreboot() { + cbdir="${1}" # e.g. coreboot/default + cbcfgpath="${2}" # e.g. resources/coreboot/x200_8mb/config/libgfxinit_txtmode + if [ ! -f "${cbcfgpath}" ]; then + printf "\nmkCoreboot: Coreboot config '%s' does not exist. Skipping build.\n" \ + "${cbcfgpath}" + return 0 + fi + printf "%s-%s\n" "$(cat projectname)" "$(cat version)" > "${cbdir}/.coreboot-version" + ( + cd "${cbdir}" + make distclean + ) + cp "${cbcfgpath}" "${cbdir}"/.config + ( + cd "${cbdir}" + make -j$(nproc) + ) +} + +mkRomWithTianocoreOnly() { + rompath="${1}" + initmode="${2}" + if [ "${payload_tianocore}" = "y" ] && [ "${arch}" = "x86_64" ]; then + # do not include on 32-bit-only machines. this is 64-bit tianocore + + tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) + cp "${corebootrom}" "${tmprom}" + "${cbfstool}" "${tmprom}" add-payload -f ${tianocoreelf} -n fallback/payload -c lzma + moverom "${tmprom}" "${romdir}/tianocore_${board}_${initmode}.rom" "${romtype}" + rm -f "${tmprom}" + fi +} + +# make a rom in /tmp/ and then print the path of that ROM +make_seabios_rom() { + target_cbrom="${1}" # rom to insert seabios in. this rom won't be touched + # a tmpfile will be made instead + target_seabios_cbfs_path="${2}" # e.g. fallback/payload + target_opromloadonly="${3}" # 0 or 1. if 1, only load but don't execute oproms + target_initmode="${4}" # e.g. libgfxinit + cbfstool_path="${5}" + + if [ "${target_initmode}" = "normal" ]; then + target_seabioself="payload/seabios/seabios_vgarom.elf" + # if normal, etc/pci-optionrom-exec will be set to 2 + else + target_seabioself="payload/seabios/seabios_${target_initmode}.elf" + # if libgfxinit, etc/pci-optionrom-exec will be set to 2 + # if vgarom, etc/pci-optionrom-exec will be set to 0 + fi + target_seavgabios_rom="payload/seabios/seavgabios.bin" + + tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) + + cp "${target_cbrom}" "${tmprom}" + "${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" -n ${target_seabios_cbfs_path} -c lzma + "${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup + if [ "${target_initmode}" = "normal" ] || [ "${target_initmode}" = "libgfxinit" ]; then + "${cbfstool}" "${tmprom}" add-int -i 2 -n etc/pci-optionrom-exec + elif [ "${target_initmode}" = "vgarom" ]; then + "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/pci-optionrom-exec + fi # for undefined modes, don't add this integer. rely on SeaBIOS defaults + "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum + "${cbfstool}" "${tmprom}" add-int -i ${target_opromloadonly} -n etc/only-load-option-roms + + if [ "${target_initmode}" = "libgfxinit" ]; then + "${cbfstool_path}" "${tmprom}" add -f "${target_seavgabios_rom}" -n vgaroms/seavgabios.bin -t raw + fi + + printf "%s\n" "${tmprom}" +} + +# make a rom in /tmp/ and then print the path of that ROM +make_grubrom_from_keymap() { + target_keymap="${1}" + target_cbrom="${2}" + cbfstool_path="${3}" + target_grubelf_cbfs_path="${4}" # e.g. fallback/payload + + grubelf="payload/grub/grub_${target_keymap}.elf" + grubcfg="payload/grub/grub_${target_keymap}.cfg" + grubtestcfg="payload/grub/grub_${target_keymap}_test.cfg" + + tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) + cp "${target_cbrom}" "${tmprom}" + + "${cbfstool_path}" "${tmprom}" add-payload -f "${grubelf}" -n ${target_grubelf_cbfs_path} -c lzma + "${cbfstool_path}" "${tmprom}" add -f "${grubcfg}" -n grub.cfg -t raw + "${cbfstool_path}" "${tmprom}" add -f "${grubtestcfg}" -n grubtest.cfg -t raw + + printf "%s\n" "${tmprom}" +} + +# Make separate ROM images with GRUB payload, for each supported keymap +mkRomsWithGrub() { + tmprompath="${1}" + initmode="${2}" + displaymode="${3}" + firstpayloadname="${4}" # allow values: grub, seabios, seabios_withgrub, seabios_grubfirst + + if [ "${payload_grub_withtianocore}" = "y" ] && [ "${firstpayloadname}" = "grub" ]; then + "${cbfstool}" "${tmprompath}" add-payload -f ${tianocoreelf} -n tianocore.elf -c lzma + fi + + if [ "${payload_grub_withseabios}" = "y" ] && [ "${firstpayloadname}" = "grub" ]; then + mv "$(make_seabios_rom "${tmprompath}" "seabios.elf" "${seabios_opromloadonly}" "${initmode}" "${cbfstool}")" "${tmprompath}" + elif [ "${payload_seabios_withgrub}" ] && [ "${firstpayloadname}" != "grub" ]; then + mv "$(make_seabios_rom "${tmprompath}" "fallback/payload" "${seabios_opromloadonly}" "${initmode}" "${cbfstool}")" "${tmprompath}" + if [ "${firstpayloadname}" = "seabios_grubfirst" ]; then + tmpbootorder=$(mktemp -t coreboot_rom.XXXXXXXXXX) + printf "/rom@img/grub2\n" > "${tmpbootorder}" + "${cbfstool}" "${tmprompath}" add -f "${tmpbootorder}" -n bootorder -t raw + rm -f "${tmpbootorder}" + "${cbfstool}" "${tmprompath}" add-int -i 0 -n etc/show-boot-menu + fi + fi + + for keymapfile in resources/grub/keymap/*; do + + if [ ! -f "${keymapfile}" ]; then + continue + fi + + keymap="${keymapfile##*/}" + keymap="${keymap%.gkb}" + + grub_path_in_cbfs="fallback/payload" + if [ "${firstpayloadname}" != "grub" ]; then + grub_path_in_cbfs="img/grub2" + fi + + tmpgrubrom="$(make_grubrom_from_keymap "${keymap}" "${tmprompath}" "${cbfstool}" "${grub_path_in_cbfs}")" + if [ "${initmode}" = "normal" ]; then + newrompath="${romdir}/${firstpayloadname}_${board}_${initmode}_${keymap}.rom" + else + newrompath="${romdir}/${firstpayloadname}_${board}_${initmode}_${displaymode}_${keymap}.rom" + fi + moverom "${tmpgrubrom}" "${newrompath}" "${romtype}" + rm -f "${tmpgrubrom}" + done +} + +# Main ROM building function. This calls all other functions +mkRoms() { + tianocoreRequiredDisplayMode="${1}" + cbcfgpath="${2}" + displaymode="${3}" + initmode="${4}" + + if [ ! -f "${cbcfgpath}" ]; then + printf "'%s' does not exist. Skipping build for %s %s %s\n" \ + "${cbcfgpath}" "${board}" "${displaymode}" "${initmode}" + return 0 + fi + + mkCoreboot "${cbdir}" "${cbcfgpath}" + + if [ "${displaymode}" = "${tianocoreRequiredDisplayMode}" ]; then + mkRomWithTianocoreOnly "${corebootrom}" "${initmode}" + fi + + if [ "${displaymode}" = "txtmode" ]; then + "${cbfstool}" "${corebootrom}" add-payload -f memtest86plus/memtest -n img/memtest -c lzma + fi + + if [ "${payload_seabios}" = "y" ]; then + if [ "${payload_seabios_withgrub}" = "n" ]; then + tmpseabiosrom="$(make_seabios_rom "${corebootrom}" "fallback/payload" "${seabios_opromloadonly}" "${initmode}" "${cbfstool}")" + if [ "${initmode}" = "normal" ]; then + newrompath="${romdir}/seabios_${board}_${initmode}.rom" + else + newrompath="${romdir}/seabios_${board}_${initmode}_${displaymode}.rom" + fi + + moverom "${tmpseabiosrom}" "${newrompath}" "${romtype}" + rm -f "${tmpseabiosrom}" + else + tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) + cp "${corebootrom}" "${tmprom}" + mkRomsWithGrub "${tmprom}" "${initmode}" "${displaymode}" "seabios_withgrub" + cp "${corebootrom}" "${tmprom}" + mkRomsWithGrub "${tmprom}" "${initmode}" "${displaymode}" "seabios_grubfirst" + rm -f "${tmprom}" + fi + fi + + if [ "${payload_grub}" = "y" ]; then + mkRomsWithGrub "${corebootrom}" "${initmode}" "${displaymode}" "grub" + fi +} + +initmode="libgfxinit" +tianocoreRequiredDisplayMode="corebootfb" +for displaymode in corebootfb txtmode; do + cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}" + mkRoms "${tianocoreRequiredDisplayMode}" "${cbcfgpath}" "${displaymode}" "${initmode}" +done + +initmode="vgarom" +tianocoreRequiredDisplayMode="vesafb" +for displaymode in vesafb txtmode; do + cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}" + mkRoms "${tianocoreRequiredDisplayMode}" "${cbcfgpath}" "${displaymode}" "${initmode}" +done + +initmode="normal" +displaymode="txtmode" +tianocoreRequiredDisplayMode="unsupported" +cbcfgpath="resources/coreboot/${board}/config/${initmode}" +mkRoms "${tianocoreRequiredDisplayMode}" "${cbcfgpath}" "${displaymode}" "${initmode}" + +( +cd "${cbdir}" +make distclean +) diff --git a/resources/scripts/build/clean/cbutils b/resources/scripts/build/clean/cbutils new file mode 100755 index 00000000..b908e1bf --- /dev/null +++ b/resources/scripts/build/clean/cbutils @@ -0,0 +1,47 @@ +#!/bin/bash + +# helper script: clean the dependencies that were built in coreboot +# +# Copyright (C) 2014, 2015, 2016, 2020 Leah Rowe <info@minifree.org> +# 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/>. +# + +# This script assumes that the current working directory is the root + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# clean coreboot utilities (dependencies for 'build'): + +printf "Cleaning the previous build of coreboot and its utilities\n" + +[ ! -d "coreboot/" ] && exit 0 + +for board in coreboot/*; do + if [ "${board##*/}" = "coreboot" ]; then + continue + fi + # Clean coreboot, of course + make -C "${board}/" distclean + + # Clean its utilities as well + for util in {cbfs,ifd,nvram}tool cbmem; do + make -C "${board}/util/${util}/" clean + done + make -C "${board}/payloads/libpayload/" distclean +done + +printf "\n\n" diff --git a/resources/scripts/build/clean/crossgcc b/resources/scripts/build/clean/crossgcc new file mode 100755 index 00000000..a855d203 --- /dev/null +++ b/resources/scripts/build/clean/crossgcc @@ -0,0 +1,44 @@ +#!/bin/bash + +# helper script: clean the crossgcc builds +# +# Copyright (C) 2014, 2015, 2016, 2020 Leah Rowe <info@minifree.org> +# 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/>. +# + +# This script assumes that the current working directory is the root + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# clean coreboot utilities (dependencies for 'build'): + +printf "Cleaning crossgcc builds in all coreboot archives\n" + +[ ! -d "coreboot/" ] && exit 0 + +# clean coreboot and crossgcc (source archives preserved) +for board in coreboot/*; do + if [ "${board##*/}" = "coreboot" ]; then + continue + fi + if [ ! -d "${board}" ]; then + continue + fi + make -C "${board}/" crossgcc-clean +done + +printf "\n\n" diff --git a/resources/scripts/build/clean/flashrom b/resources/scripts/build/clean/flashrom new file mode 100755 index 00000000..2a13bdb2 --- /dev/null +++ b/resources/scripts/build/clean/flashrom @@ -0,0 +1,35 @@ +#!/bin/bash + +# helper script: clean the dependencies that were built in flashrom +# +# Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org> +# 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/>. +# + +# This script assumes that the current working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +printf "Cleaning the previous build of flashrom\n" + +[ ! -d "flashrom/" ] && exit 0 + +# clean flashrom +make -C flashrom clean + +printf "\n\n" diff --git a/resources/scripts/build/clean/grub b/resources/scripts/build/clean/grub new file mode 100755 index 00000000..ec6cab13 --- /dev/null +++ b/resources/scripts/build/clean/grub @@ -0,0 +1,39 @@ +#!/bin/bash + +# helper script: clean the dependencies that were built in GRUB +# +# Copyright (C) 2014, 2015, 2016 Leah Rowe <info@minifree.org> +# 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/>. +# + +# This script assumes that the current working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +printf "Cleaning the previous build of GRUB\n" + +[ ! -d "grub/" ] && exit 0 + +( + cd grub/ + if [ -f Makefile ]; then + make distclean + fi +) + +printf "\n\n" diff --git a/resources/scripts/build/clean/ich9utils b/resources/scripts/build/clean/ich9utils new file mode 100755 index 00000000..c2c0aede --- /dev/null +++ b/resources/scripts/build/clean/ich9utils @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# helper script: clean the previous build of ich9utils +# +# Copyright (C) 2014, 2015, 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/>. +# + +# This script assumes that the current working directory is the root +# of libreboot_src or libreboot git + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# clean ich9deblob utility +# -------------------------------------------------------------------- + +if [ ! -d ich9utils ]; then + exit 0 +fi + +printf "Cleaning the previous build of ich9utils\n" +( +cd "ich9utils/" +make clean +) +rm -Rf descriptors/ +printf "\n\n" diff --git a/resources/scripts/build/clean/memtest86plus b/resources/scripts/build/clean/memtest86plus new file mode 100755 index 00000000..13155496 --- /dev/null +++ b/resources/scripts/build/clean/memtest86plus @@ -0,0 +1,35 @@ +#!/bin/bash + +# helper script: clean the dependencies that were built in memtest86+ +# +# Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org> +# 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/>. +# + +# This script assumes that the current working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +printf "Cleaning the previous build of MemTest86+\n" + +[ ! -d "memtest86plus" ] && exit 0 + +# clean MemTest86+ +make -C memtest86plus clean + +printf "\n\n" diff --git a/resources/scripts/build/clean/payloads b/resources/scripts/build/clean/payloads new file mode 100755 index 00000000..a2abe195 --- /dev/null +++ b/resources/scripts/build/clean/payloads @@ -0,0 +1,30 @@ +#!/bin/bash + +# helper script: nothing to see here, forks! +# +# Copyright (C) 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 + +# clean bucts +# -------------------------------------------------------- + +printf "Cleaning up payloads\n" + +rm -Rf payload/ + diff --git a/resources/scripts/build/clean/rom_images b/resources/scripts/build/clean/rom_images new file mode 100755 index 00000000..abf352d0 --- /dev/null +++ b/resources/scripts/build/clean/rom_images @@ -0,0 +1,31 @@ +#!/bin/bash + +# helper script: delete the ROM images +# +# Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org> +# 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/>. +# + +# This script assumes that the current working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# Delete the ROM images +rm -Rf "bin/" + +printf "Deleted the bin/ directory containing the ROM images.\n\n" diff --git a/resources/scripts/build/clean/seabios b/resources/scripts/build/clean/seabios new file mode 100755 index 00000000..eef72a89 --- /dev/null +++ b/resources/scripts/build/clean/seabios @@ -0,0 +1,37 @@ +#!/bin/bash + +# helper script: clean the dependencies that were built in seabios +# +# Copyright (C) 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 + +# clean bucts +# -------------------------------------------------------- + +printf "Cleaning the previous build of seabios\n" + +rm -f seabios_libgfxinit.elf seavgabios.bin seabios_vgarom.elf + +[ ! -d "seabios/" ] && exit 0 + +( +cd "seabios/" +make distclean +) + diff --git a/resources/scripts/build/clean/tianocore b/resources/scripts/build/clean/tianocore new file mode 100755 index 00000000..a57d986e --- /dev/null +++ b/resources/scripts/build/clean/tianocore @@ -0,0 +1,30 @@ +#!/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/>. +# + +# This script assumes that the current working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +if [ -d "coreboot/default/payloads/external/tianocore/tianocore" ]; then + ( + cd "coreboot/default/payloads/external/tianocore/" + make clean + ) +fi diff --git a/resources/scripts/build/dependencies/arch b/resources/scripts/build/dependencies/arch new file mode 100755 index 00000000..0a09b75a --- /dev/null +++ b/resources/scripts/build/dependencies/arch @@ -0,0 +1,90 @@ +#!/bin/bash + +# arch script: installs build dependencies for Arch Linux +# +# Copyright (C) 2021 Melissa Goad <mszoopers@protonmail.com> +# +# 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 + +if [ $EUID -ne 0 ]; then + printf "This script must be run as root\n" + exit 1 +fi + +# Duplications are intentional. Please do not re-factor. +# +# This is so that they can moved to separate scripts. +# + +pacman -S --needed --noconfirm wget + +# For downloading source code +# ------------------------------------------------------------ + +pacman -S --needed --noconfirm git + +# For building the documentation +# ------------------------------------------------------------ + +pacman -S --needed --noconfirm pandoc + +# For Tianocore and iPXE +# TODO: check whether this is the full list + +pacman -S --needed --noconfirm nasm perl-libwww python2 subversion + +# For building source code: +# ------------------------------------------------------------ + +pacman -S --needed --noconfirm base-devel + +# for running the crostool script (to get mrc.bin file for t440p) +pacman -S --needed --noconfirm sharutils curl parted e2fsprogs unzip + +# for cross-compiling ARM binaries +pacman -S --needed --noconfirm arm-none-eabi-gcc + +# Memtest86+ build dependencies +# ------------------------------------------------------------ + +pacman -S --needed --noconfirm base-devel python2 + +# i945-pwm build dependencies +# ------------------------------------------------------------ + +pacman -S --needed --noconfirm base-devel perl + +# Coreboot build dependencies (also requires build-essential and git) +# ------------------------------------------------------------ + +pacman -S --needed --noconfirm ncurses doxygen acpica gdb flex bison base-devel git openssl gcc-ada + +# GRUB build dependencies (also requires build-essential, bison and flex) +# ------------------------------------------------------------ + +pacman -S --needed --noconfirm bdf-unifont autogen help2man base-devel bison flex ttf-dejavu texinfo rsync python libusb xz gawk device-mapper fuse2 gettext freetype2 + +# BucTS build dependencies (external script) +# ------------------------------------------------------------ + +pacman -S --needed --noconfirm base-devel + +# Flashrom build dependencies (also requires build-essential) +# ------------------------------------------------------------ + +pacman -S --needed --noconfirm libpciaccess pciutils zlib libftdi base-devel libusb diff --git a/resources/scripts/build/dependencies/ubuntu2004 b/resources/scripts/build/dependencies/ubuntu2004 new file mode 100755 index 00000000..df11b313 --- /dev/null +++ b/resources/scripts/build/dependencies/ubuntu2004 @@ -0,0 +1,110 @@ +#!/bin/bash + +# ubuntu2004 script: installs build dependencies for Ubuntu 20.04 +# +# Copyright (C) 2014, 2015 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 + +if [ $EUID -ne 0 ]; then + printf "This script must be run as root\n" + exit 1 +fi + +# Duplications are intentional. Please do not re-factor. +# +# This is so that they can moved to separate scripts. +# + +apt-get -y install wget + +# For downloading source code +# ------------------------------------------------------------ + +apt-get -y install git + +# For building the documentation +# ------------------------------------------------------------ + +apt-get -y install pandoc + +# For Tianocore and iPXE +# TODO: check whether this is the full list + +apt-get -y install uuid-dev nasm + +# For building source code: +# ------------------------------------------------------------ + +apt-get -y install build-essential + +# for running the crostool script (to get mrc.bin file for t440p) +apt-get -y install sharutils curl parted e2fsprogs unzip + +# to use the right software versions and links for compiling +apt-get -y install pkg-config + +# for cross-compiling ARM binaries +apt-get -y install gcc-arm-linux-gnueabi + +[ "$(uname -i)" = x86_64 ] || [ "$(uname -m)" = x86_64 ] +arch=${?} + +# For cross-compiling i686 target on x86_64 host. +if [ "${arch}" -eq 0 ]; then + apt-get -y install gcc-multilib libc6-i386 libc6-dev-i386 + apt-get -y install lib32stdc++6 g++-multilib dh-autoreconf + # recommended, but not sure what for: + apt-get -y install lib32tinfo-dev +fi + +# Memtest86+ build dependencies +# ------------------------------------------------------------ + +apt-get -y install build-essential python2.7 + +# i945-pwm build dependencies +# ------------------------------------------------------------ + +apt-get -y install build-essential perl + +# Coreboot build dependencies (also requires build-essential and git) +# ------------------------------------------------------------ + +apt-get -y install libncurses5-dev doxygen iasl gdb flex bison build-essential git libssl-dev gnat + +# For cross-compiling i686 target on x86_64 host. +[ "${arch}" -eq 0 ] && apt-get -y install lib32ncurses5-dev + +# GRUB build dependencies (also requires build-essential, bison and flex) +# ------------------------------------------------------------ + +apt-get -y install ttf-unifont libopts25 libselinux1-dev autogen m4 autoconf help2man libopts25-dev libfont-freetype-perl automake autotools-dev build-essential bison flex libfuse-dev liblzma-dev gawk libdevmapper-dev libtool libfreetype6-dev + +# BucTS build dependencies (external script) +# ------------------------------------------------------------ + +apt-get -y install build-essential + +# Flashrom build dependencies (also requires build-essential) +# ------------------------------------------------------------ + +apt-get -y install libpci-dev pciutils zlib1g-dev libftdi-dev build-essential libusb-1.0-0-dev libusb-1.0 libusb-1.0-0-dev libusb-dev + +# For cross-compiling i686 target on x86_64 host. +[ "${arch}" -eq 0 ] && apt-get -y install lib32z1-dev diff --git a/resources/scripts/build/descriptors/ich9m b/resources/scripts/build/descriptors/ich9m new file mode 100755 index 00000000..69359988 --- /dev/null +++ b/resources/scripts/build/descriptors/ich9m @@ -0,0 +1,52 @@ +#!/usr/bin/env 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/>. +# + +# This script assumes that the current working directory is the root +# of libreboot_src or libreboot git + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +if [ ! -d ich9utils ]; then + ./download ich9utils +fi +if [ ! -d ich9utils ]; then + printf "build/descriptors/ich9m: no ich9utils directory. Exiting\n" + exit 1 +fi + +if [ ! -f "ich9utils/ich9gen" ]; then + ( + cd ich9utils/ + make clean + make -j$(nproc) + ) +fi +if [ ! -f "ich9utils/ich9gen" ]; then + printf "build/descriptors/ich9m: ich9gen wasn't compiled. Exiting\n" + exit 1 +fi + +[ -d "descriptors/" ] || mkdir -p "descriptors/" +[ -d "descriptors/ich9m/" ] || mkdir -p "descriptors/ich9m/" +rm -f descriptors/ich9m/* + +( + cd descriptors/ich9m/ + ../../ich9utils/ich9gen +) diff --git a/resources/scripts/build/module/cbutils b/resources/scripts/build/module/cbutils new file mode 100755 index 00000000..5198656c --- /dev/null +++ b/resources/scripts/build/module/cbutils @@ -0,0 +1,78 @@ +#!/bin/bash + +# helper script: build various coreboot utilities +# +# 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/>. +# + +# This script assumes that the current working directory is the root + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +printf "Building coreboot utils\n" + +buildutils() { + cbtree="${1}" + if [ ! -d "coreboot/${cbtree}/" ]; then + ./download coreboot $cbtree || return 1 + fi + if [ ! -d "coreboot/${cbtree}/" ]; then + printf "build/cbutils: coreboot/%s not found. Exiting\n" "${cbtree}" + return 1 + fi + for util in {cbfs,ifd}tool; do + ( + cd "coreboot/${cbtree}/util/${util}/" + make -j$(nproc) || return 1 + ) + done + return 0 +} + +buildfromboardconfig() { + board="${1}" + if [ ! -d "resources/coreboot/${board}" ]; then + continue + fi + if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then + continue + fi + cbtree="undefined" + source "resources/coreboot/${board}/board.cfg" + if [ "${cbtree}" = "undefined" ]; then + printf "build/cbutils: improper cbtree definition for '%s'" "${board}" + return 1 + fi + buildutils "${cbtree}" || return 1 + return 0 +} + +if [ $# -gt 0 ]; then + for board in "${@}"; do + buildfromboardconfig ${board} || exit 1 + done +else + for boarddir in resources/coreboot/*; do + if [ ! -d "${boarddir}" ]; then + continue + fi + buildfromboardconfig ${boarddir##*/} || exit 1 + done +fi + +printf "\n\n" +exit 0 diff --git a/resources/scripts/build/module/flashrom b/resources/scripts/build/module/flashrom new file mode 100755 index 00000000..807be1b2 --- /dev/null +++ b/resources/scripts/build/module/flashrom @@ -0,0 +1,40 @@ +#!/bin/bash + +# helper script: builds flashrom source code +# +# Copyright (C) 2014, 2015 <info@minifree.org> +# 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/>. +# + +# This script assumes that the working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# Build "flashrom" (utility for flashing/dumping ROMs) +# -------------------------------------------------------------------- + +if [ ! -d "flashrom/" ]; then + ./download flashrom +fi + +printf "Building flashrom\n" +( +cd "flashrom/" +make clean +make -j$(nproc) +) diff --git a/resources/scripts/build/module/grub b/resources/scripts/build/module/grub new file mode 100755 index 00000000..54696cb4 --- /dev/null +++ b/resources/scripts/build/module/grub @@ -0,0 +1,49 @@ +#!/bin/bash + +# helper script: builds GRUB2 source code +# +# Copyright (C) 2014, 2015, 2020 Leah Rowe <info@minifree.org> +# Copyright (C) 2015, 2016 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/>. +# + +# This script assumes that the working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# Build GRUB2 as coreboot payload + +printf "Building GRUB\n" + +if [ ! -d "grub/" ]; then + ./download grub +fi + +# use a subshell to not end up in grub/ in case of build issues +( +cd grub/ + +# clean up first +[ -d Makefile ] && make distclean + +./bootstrap --gnulib-srcdir=gnulib/ --no-git + +# build +./autogen.sh +./configure --with-platform=coreboot +make -j$(nproc) +) diff --git a/resources/scripts/build/module/ich9utils b/resources/scripts/build/module/ich9utils new file mode 100755 index 00000000..40e1c8e6 --- /dev/null +++ b/resources/scripts/build/module/ich9utils @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# helper script: build ich9utils +# +# Copyright (C) 2014, 2015, 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/>. +# + +# This script assumes that the current working directory is the root +# of libreboot_src or libreboot git + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +if [ ! -d ich9utils ]; then + ./download ich9utils +fi +if [ ! -d ich9utils ]; then + printf "build/module/ich9utils: ich9utils not found. Exiting\n" + exit 1 +fi + +printf "Build ich9utils\n" +( +cd "ich9utils/" +make -j$(nproc) +) +printf "\n\n" diff --git a/resources/scripts/build/module/memtest86plus b/resources/scripts/build/module/memtest86plus new file mode 100755 index 00000000..50f130e9 --- /dev/null +++ b/resources/scripts/build/module/memtest86plus @@ -0,0 +1,37 @@ +#!/bin/bash + +# helper script: builds memtest86+ source code +# +# Copyright (C) 2014, 2015, 2020 Leah Rowe <info@minifree.org> +# 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/>. +# + +# This script assumes that the working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# Build MemTest86+ payload +# -------------------------------------------------------------------- + +printf "Building MemTest86+\n" + +if [ ! -d "memtest86plus/" ]; then + ./download memtest86plus +fi + +make -j$(nproc) -BC memtest86plus diff --git a/resources/scripts/build/payload/grub b/resources/scripts/build/payload/grub new file mode 100755 index 00000000..2a782bec --- /dev/null +++ b/resources/scripts/build/payload/grub @@ -0,0 +1,75 @@ +#!/bin/bash + +# generate GRUB ELF files (coreboot payload) and configuration files +# +# 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 + +# This is where GRUB is expected to be (outside of the grub-assemble, instead in main checkout) +source "resources/grub/modules.list" + +printf "Creating GRUB payloads and configuration files\n" + +if [ ! -d "grub/" ]; then + ./download grub +fi + +if [ ! -f "grub/grub-mkstandalone" ]; then + ./build module grub +fi + +[ ! -d "payload/" ] && mkdir -p payload/ +[ ! -d "payload/grub" ] && mkdir -p payload/grub/ + +rm -f payload/grub/* + +# Separate GRUB payload per keymap. This saves space in the ROM, otherwise +# a lot of space would be used if every keymap was stored in a single image + +for keylayoutfile in resources/grub/keymap/*.gkb; do + if [ ! -f "${keylayoutfile}" ]; then + continue + fi + keymap="${keylayoutfile##resources/grub/keymap/}" + keymap="${keymap%.gkb}" + + grub/grub-mkstandalone \ + --grub-mkimage="grub/grub-mkimage" \ + -O i386-coreboot \ + -o payload/grub/grub_${keymap}.elf \ + -d grub/grub-core/ \ + --fonts= --themes= --locales= \ + --modules="${grub_modules}" \ + --install-modules="${grub_install_modules}" \ + /boot/grub/grub.cfg=resources/grub/config/grub_memdisk.cfg \ + /boot/grub/layouts/${keymap}.gkb=${keylayoutfile} + + + if [ "${keymap}" = "usqwerty" ]; then + cp resources/grub/config/grub.cfg payload/grub/grub_usqwerty.cfg + else + sed "s/usqwerty/${keymap}/" < resources/grub/config/grub.cfg > payload/grub/grub_${keymap}.cfg + fi + + sed "s/grubtest.cfg/grub.cfg/" < payload/grub/grub_${keymap}.cfg > payload/grub/grub_${keymap}_test.cfg + + printf "Generated: 'payload/grub/grub_%s.elf' and configs.'\n" "${keymap}" +done + +printf "Done! Check payload/grub/ to see the files.\n\n" diff --git a/resources/scripts/build/payload/seabios b/resources/scripts/build/payload/seabios new file mode 100755 index 00000000..df7ec6f5 --- /dev/null +++ b/resources/scripts/build/payload/seabios @@ -0,0 +1,63 @@ +#!/bin/bash + +# helper script: builds SeaBIOS source code +# +# Copyright (C) 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 + +# Build SeaBIOS +# --------------------------------------------------------------------- + +printf "Building SeaBIOS payloads and SeaVGABIOS\n" + +[ ! -d "payload/" ] && mkdir -p payload/ +[ ! -d "payload/seabios" ] && mkdir -p payload/seabios/ + +rm -f payload/seabios/* + +if [ ! -d "seabios/" ]; then + ./download seabios +fi + +cd seabios/ + +# for libgfxinit setup: +[[ -f Makefile ]] && make distclean +cp ../resources/seabios/config/libgfxinit .config +make -j$(nproc) +mv out/bios.bin.elf ../payload/seabios/seabios_libgfxinit.elf +mv out/vgabios.bin ../payload/seabios/seavgabios.bin +rm .config + +# for vgarom setup: +[[ -f Makefile ]] && make distclean +cp ../resources/seabios/config/vgarom .config +make -j$(nproc) +mv out/bios.bin.elf ../payload/seabios/seabios_vgarom.elf +rm .config + +# clean it again. gotta keep it clean! +[[ -f Makefile ]] && make distclean + +printf "Done! SeaBIOS files are in payload/seabios/\n\n" + +# done. go back to main directory +cd ../ + +# ------------------- DONE ---------------------- diff --git a/resources/scripts/build/payload/tianocore b/resources/scripts/build/payload/tianocore new file mode 100755 index 00000000..30786216 --- /dev/null +++ b/resources/scripts/build/payload/tianocore @@ -0,0 +1,77 @@ +#!/bin/bash + +# helper script: builds Tianocore source code +# +# Copyright (C) 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 + +printf "Building Tianocore\n" + +[ ! -d "payload/" ] && mkdir -p payload/ +[ ! -d "payload/tianocore/" ] && mkdir -p payload/tianocore/ + +rm -f payload/tianocore/* + +if [ ! -d "coreboot/default/" ]; then + ./download coreboot default + ./build module cbutils default +fi + +if [ ! -d "coreboot/default/util/crossgcc/xgcc/i386-elf" ]; then + ( + cd coreboot/default/ + make crossgcc-i386 CPUS=$(nproc) # tianocore actually uses host gcc, which means + # right now you should be building this on a 64-bit x86 host. + # It does not currently use coreboot crossgcc. However, a dummy coreboot + # ROM is compiled using Tianocore in order to derive tianocore.elf + + # and of course, that implies crossgcc. tianocore is only really use + # on x86, so we only care about i386 crossgcc here + ) +fi + +if [ ! -d "coreboot/default/payloads/external/tianocore/tianocore/" ]; then + ./download tianocore +fi + +( +cd coreboot/default/payloads/external/tianocore/ +make clean +) + +( +cd coreboot/default/ +make distclean +cp ../../resources/tianocore/dummy.coreboot.config .config +make -j$(nproc) +) + +cp coreboot/default/payloads/external/tianocore/tianocore/Build/UEFIPAYLOAD.fd \ + payload/tianocore/tianocore.elf + +( +cd coreboot/default/ +make distclean +) + +( +cd coreboot/default/payloads/external/tianocore/ +make clean +) + diff --git a/resources/scripts/build/release/roms b/resources/scripts/build/release/roms new file mode 100755 index 00000000..a4458f30 --- /dev/null +++ b/resources/scripts/build/release/roms @@ -0,0 +1,70 @@ +#!/bin/bash + +# +# helper script: generate release archive (ROM images) +# +# Copyright (C) 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/>. +# + +# This script assumes that the working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +projectname="$(cat projectname)" + +version="version-unknown" +if [ -f version ]; then + version="$(cat version)" +fi +versiondate="version-date-unknown" +if [ -f versiondate ]; then + versiondate="$(cat versiondate)" +fi + +if [ ! -d "bin/" ]; then + ./build boot roms all +fi + +[ ! -d "release/" ] && \ + mkdir -p release/ +[ ! -d "release/${version}/" ] && \ + mkdir -p "release/${version}/" +[ -d "release/${version}/roms/" ] && \ + rm -Rf "release/${version}/roms/" +[ ! -d "release/${version}/roms/" ] && \ + mkdir -p "release/${version}/roms/" + +printf "Building ROM image archives for version %s\n" "${version}" + +( + cd bin/ + for target in *; do + if [ ! -d "${target}/" ]; then + continue + fi + + printf "Generating release/%s/roms/%s-%s_%s.tar.xz\n" "${projectname}" "${version}" "${version}" "${target##*/}" + printf "%s\n" "${version}" > "${target}/version" + printf "%s\n" "${versiondate}" > "${target}/versiondate" + printf "%s\n" "${projectname}" > "${target}/projectname" + tar -c "${target}/" | xz -9e >"../release/${version}/roms/${projectname}-${version}_${target##*/}.tar.xz" + done +) + +printf "\nROM image release archives available at release/%s/roms/\n\n" "${version}" + diff --git a/resources/scripts/build/release/src b/resources/scripts/build/release/src new file mode 100755 index 00000000..dc8bc75f --- /dev/null +++ b/resources/scripts/build/release/src @@ -0,0 +1,120 @@ +#!/bin/bash + +# +# helper script: generate release archive (source code) +# +# Copyright (C) 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/>. +# + +# This script assumes that the working directory is the root +# of git or release archive + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +projectname="$(cat projectname)" + +version="version-unknown" +if [ -f version ]; then + version="$(cat version)" +fi +versiondate="version-date-unknown" +if [ -f versiondate ]; then + versiondate="$(cat versiondate)" +fi + +reldir="release/${version}" +dirname="${projectname}-${version}_src" +srcdir="${reldir}/${dirname}" + +printf "Building source code archive, version %s\n" "${version}" + +[ ! -d "release/" ] && mkdir -p release/ +[ ! -d "${reldir}/" ] && mkdir -p "${reldir}/" +[ -d "${srcdir}/" ] && \ + rm -Rf "${srcdir}/" +[ -f "${srcdir}.tar.xz" ] && \ + rm -f "${srcdir}.tar.xz/" + +mkdir -p "${srcdir}/" + +printf "%s" "${version}" > "${srcdir}"/version + +modlist="coreboot flashrom grub memtest86plus seabios ich9utils" +dirlist="resources" +filelist="download build README COPYING Makefile" + +if [ ! -d "coreboot/default/payloads/external/tianocore/tianocore" ]; then + ./download tianocore +fi + +for modname in ${modlist}; do + if [ ! -d "${modname}/" ]; then + ./download ${modname} + fi +done + +for dir in ${modlist} ${dirlist}; do + cp -R "${dir}/" "${srcdir}/" +done + +for i in ${filelist}; do + if [ ! -f "${i}" ]; then + printf "build/release/src: ERROR: file '%s' does not exist.\n" "${i}" + rm -Rf "${srcdir}" + exit 1 + fi + cp ${i} "${srcdir}/" +done + +( + cd "${srcdir}/coreboot/" + for i in *; do + [ ! -d "${i}" ] && continue + ( + cd "${i}/" + make distclean + ) + done +) + +( + cd "${srcdir}/" + ./build clean all + + rm -Rf coreboot/coreboot/ + rm -Rf .git* */.git* coreboot/*/.git* coreboot/*/3rdparty/*/.git* + rm -Rf coreboot/*/util/nvidia/cbootimage/.git* + rm -Rf coreboot/*/payloads/external/tianocore/tianocore/.git* + rm -Rf coreboot/*/payloads/external/tianocore/tianocore/CryptoPkg/Library/OpensslLib/openssl/.git* + rm -Rf coreboot/*/payloads/external/tianocore/tianocore/ArmPkg/Library/ArmSoftFloatLib/"berkeley-softfloat-3"/.git* + rm -Rf coreboot/*/payloads/external/tianocore/tianocore/UnitTestFrameworkPkg/Library/CmockaLib/cmocka/.git* + rm -Rf coreboot/*/payloads/external/tianocore/tianocore/MdeModulePkg/Universal/RegularExpressionDxe/oniguruma/.git* + rm -Rf coreboot/*/payloads/external/tianocore/tianocore/MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/.git* + rm -Rf coreboot/*/payloads/external/tianocore/tianocore/BaseTools/Source/C/BrotliCompress/brotli/.git* +) + +( +cd "${reldir}/" +printf "%s\n" "${version}" > "${dirname}/version" +printf "%s\n" "${versiondate}" > "${dirname}/versiondate" +printf "%s\n" "${projectname}" > "${dirname}/projectname" +tar -c "${dirname}/" | xz -9e >"${dirname}.tar.xz" +rm -Rf "${dirname}/" +) + +printf "Source code archive available at %s.tar.xz\n\n" "${srcdir}" + |