diff options
Diffstat (limited to 'resources/scripts/helpers/build/module/coreboot')
-rwxr-xr-x | resources/scripts/helpers/build/module/coreboot | 157 |
1 files changed, 154 insertions, 3 deletions
diff --git a/resources/scripts/helpers/build/module/coreboot b/resources/scripts/helpers/build/module/coreboot index d3e86cd2..5788343a 100755 --- a/resources/scripts/helpers/build/module/coreboot +++ b/resources/scripts/helpers/build/module/coreboot @@ -30,7 +30,160 @@ set -u -e printf "Building the utilities in coreboot\n" -# clean coreboot and crossgcc (source archives preserved) +for payloads in resources/libreboot/config/*; do + + if [ ! -d "${payloads}/" ]; then + continue + fi + + payload="${payloads##*/}" + + for boardconfig in resources/libreboot/config/${payload}/*; do + + if [ ! -d "${boardconfig}/" ]; then + continue + fi + + boardname="${boardconfig##*/}" + cbrevision=$(cat "${boardconfig}/cbrevision") + vbootrevision=$(cat "${boardconfig}/vbootrevision") + + reused_coreboot_patches="resources/libreboot/patch/coreboot/${cbrevision}/${payload}/${boardname}/reused.list" + reused_vboot_patches="resources/libreboot/patch/vboot/${vbootrevision}/${payload}/${boardname}/reused.list" + for reused_patches in "${reused_coreboot_patches}" "${reused_vboot_patches}"; do + if [ -f "${reused_patches}" ]; then + for patch in $(cat "${reused_patches}"); do + if [ ! -f "./${patch}" ]; then + printf "%s listed in %s does not exist\n" "${patch}" "${reused_patches}" + exit 1 + fi + done + fi + done + + done +done + +# sanity check (check for invalid paths in the reused.list patch lists before proceeding) +# in ascending filename order, apply patches from a directory +apply_patches_from_directory() { + patch_directory="${1}" # directory containing the patch files + + if [ -d "${patch_directory}" ]; then + for patch in ${patch_directory}/*.patch; do + + if [ "${patch##*/}" = "*.patch" ]; then # oh so ugly + continue # ugly ugly ugly ugly ugly + fi # most hideous thing you've ever seen + + git am "${patch}" || return 1 + done + fi +} +# files listed in the file (if found) are absolute paths, relative to the root of the libreboot src directory +# the file lists patches patches that should be applied +apply_patches_from_file() { + patch_list="${1}" # file listing the paths to all the patches + libreboot_src_root="${2}" # path to the root of the libreboot_src directory + + if [ -f "${patch_list}" ]; then + for patchname in $(cat "${patch_list}"); do + git am "${libreboot_src_root}/${patchname}" || return 1 + done + fi +} + +create_branch() { + branchname="${1}" + git branch ${branchname} + git checkout ${branchname} + git checkout master +} + +# use git-init on everything +# this is so that we can then apply patche +# for these revisions of vboot and coreboot +for i in coreboot/*; do + if [ ! -d "${i}/" ]; then + continue + fi + for revision in ${i}/*; do + if [ ! -d "${revision}/" ]; then + continue + fi + ( + cd "${revision}/" + git init + git add -A . + git commit -m "coreboot revision ${revision##*/}" + cd "3rdparty/vboot/" + git init + git add -A . + git commit -m "coreboot revision ${revision##*/}" + ) + done +done + +for payloads in resources/libreboot/config/*; do + + if [ ! -d "${payloads}/" ]; then + continue + fi + + payload="${payloads##*/}" + + for boardconfig in resources/libreboot/config/${payload}/*; do + + if [ ! -d "${boardconfig}/" ]; then + continue + fi + + boardname="${boardconfig##*/}" + cbrevision=$(cat "${boardconfig}/cbrevision") + vbootrevision=$(cat "${boardconfig}/vbootrevision") + branchname="${payload}_${boardname}" + + # the same vboot revision is always used for coreboot revision, + # so we don't need to wworry about checking for that here + + # patch that version + ( + + cd "coreboot/${cbrevision}/${cbrevision}/" + create_branch ${branchname} + + git checkout ${branchname} + + # apply patches (coreboot, common to all systems using this revision) + apply_patches_from_directory "../../../resources/libreboot/patch/common/coreboot/${cbrevision}" + # apply patches re-used from other boards, before applying main patches (common patches for similar boards) + apply_patches_from_file "../../../resources/libreboot/patch/coreboot/${cbrevision}/${payload}/${boardname}/reused.list" ../../.. + # apply patches (coreboot, machine-specific for this revision) + apply_patches_from_directory "../../../resources/libreboot/patch/coreboot/${cbrevision}/${payload}/${boardname}" + + git checkout master + + cd "3rdparty/vboot/" + # reset to known revision (vboot) + create_branch ${branchname} + + git checkout ${branchname} + + # apply patches (vboot, common to all systems using this revision) + apply_patches_from_directory "../../../../../resources/libreboot/patch/common/vboot/${vbootrevision}" + # apply patches re-used from other boards, before applying main patches (common patches for similar boards) + apply_patches_from_file "../../../../../resources/libreboot/patch/vboot/${vbootrevision}/${payload}/${boardname}/reused.list" ../../../../.. + # apply patches (vboot, machine-specific for this revision) + apply_patches_from_directory "../../../../../resources/libreboot/patch/vboot/${vbootrevision}/${payload}/${boardname}" + + git checkout master + + ) + done +done + +# build coreboot utilities (in each revision) and +# create symlinks to the crossgcc archive for payload in coreboot/*; do for board in "${payload}/"*; do @@ -40,8 +193,6 @@ for payload in coreboot/*; do done # create symlink to crossgcc ( - boardconfig_path="resources/libreboot/config/${payload##*/}/${board##*/}" - cbrevision="$(cat "${boardconfig_path}/cbrevision")" cd "${board}/util/" ln -s "../../../../crossgcc/util/crossgcc/" crossgcc ) |