diff options
author | Leah Rowe <leah@libreboot.org> | 2023-12-30 13:08:29 +0000 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-12-30 13:53:45 +0000 |
commit | eb3a8e2b53ab2a81847a154d86e84b7e9fff0bb8 (patch) | |
tree | 569a4116a29077544af560d7e69c872ba53bec3a | |
parent | 34ded35fa616a323f582d3e942d7b49ac9beeef4 (diff) |
unify script/update/trees and script/build/grub
the script can now also handle autoconf build systems,
whereas this could previously only be done for grub.
with this change, the overall sloccount is also lower
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-x | include/option.sh | 5 | ||||
-rwxr-xr-x | script/build/grub | 81 | ||||
-rwxr-xr-x | script/build/roms | 44 | ||||
-rwxr-xr-x | script/update/trees | 30 |
4 files changed, 73 insertions, 87 deletions
diff --git a/include/option.sh b/include/option.sh index 8367d447..7c434444 100755 --- a/include/option.sh +++ b/include/option.sh @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-3.0-only # SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com> # SPDX-FileCopyrightText: 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com> -# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org> +# SPDX-FileCopyrightText: 2020-2023 Leah Rowe <leah@libreboot.org> vendir="vendorfiles" appdir="${vendir}/app" @@ -9,6 +9,9 @@ cbdir="src/coreboot/default" cbcfgsdir="config/coreboot" ifdtool="cbutils/default/ifdtool" cbfstool="cbutils/default/cbfstool" +grubcfgsdir="config/grub" +layoutdir="/boot/grub/layouts" +. "${grubcfgsdir}/modules.list" eval "$(setvars "" CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \ CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 \ diff --git a/script/build/grub b/script/build/grub deleted file mode 100755 index 3313684d..00000000 --- a/script/build/grub +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env sh -# SPDX-License-Identifier: GPL-3.0-or-later -# SPDX-FileCopyrightText: 2014,2015,2020,2021,2023 Leah Rowe <leah@libreboot.org> - -set -u -e - -. "include/err.sh" - -elfdir="elf/grub" -grubcfgsdir="config/grub" -layoutdir="/boot/grub/layouts" - -. "${grubcfgsdir}/modules.list" - -main() -{ - handle_dependencies - build_keymap_configs - build_grub_payload - printf "GRUB files now available under directory: %s\n" "${elfdir}" -} - -handle_dependencies() -{ - [ -d "src/grub" ] || x_ ./update trees -f grub - [ -f "src/grub/grub-mkstandalone" ] || build_grub_utils - x_ mkdir -p "${elfdir}" - rm -f "${elfdir}/"* || err "!rm elf, handle_, ${elfdir}/" -} - -build_grub_utils() -{ - ( - x_ cd "src/grub" - [ ! -d Makefile ] || x_ make distclean - x_ ./bootstrap --gnulib-srcdir=gnulib/ --no-git - x_ ./autogen.sh - x_ ./configure --with-platform=coreboot - make -j$(nproc) FS_PAYLOAD_MODULES="" || err "!mk grub utils" - ) || err "grub build error" -} - -build_keymap_configs() -{ - for keylayoutfile in "${grubcfgsdir}/keymap/"*.gkb; do - [ -f "${keylayoutfile}" ] || continue - keymap="${keylayoutfile##"${grubcfgsdir}/keymap/"}" - keymap="${keymap%.gkb}" - printf "keymap %s\n" "${keymap}" > \ - "${elfdir}/keymap_${keymap}.cfg" || err "!insert keymap" - done -} - -build_grub_payload() -{ - ./src/grub/grub-mkstandalone \ - --grub-mkimage="src/grub/grub-mkimage" \ - -O i386-coreboot \ - -o "${elfdir}/grub.elf" \ - -d "src/grub/grub-core/" \ - --fonts= --themes= --locales= \ - --modules="${grub_modules}" \ - --install-modules="${grub_install_modules}" \ - "${layoutdir}/colemak.gkb=${grubcfgsdir}/keymap/colemak.gkb" \ - "${layoutdir}/deqwertz.gkb=${grubcfgsdir}/keymap/deqwertz.gkb" \ - "${layoutdir}/esqwerty.gkb=${grubcfgsdir}/keymap/esqwerty.gkb" \ - "${layoutdir}/frazerty.gkb=${grubcfgsdir}/keymap/frazerty.gkb" \ - "${layoutdir}/frdvbepo.gkb=${grubcfgsdir}/keymap/frdvbepo.gkb" \ - "${layoutdir}/itqwerty.gkb=${grubcfgsdir}/keymap/itqwerty.gkb" \ - "${layoutdir}/svenska.gkb=${grubcfgsdir}/keymap/svenska.gkb" \ - "${layoutdir}/trqwerty.gkb=${grubcfgsdir}/keymap/trqwerty.gkb" \ - "${layoutdir}/ukdvorak.gkb=${grubcfgsdir}/keymap/ukdvorak.gkb" \ - "${layoutdir}/ukqwerty.gkb=${grubcfgsdir}/keymap/ukqwerty.gkb" \ - "${layoutdir}/usdvorak.gkb=${grubcfgsdir}/keymap/usdvorak.gkb" \ - "${layoutdir}/usqwerty.gkb=${grubcfgsdir}/keymap/usqwerty.gkb" \ - "/boot/grub/grub.cfg=${grubcfgsdir}/config/grub_memdisk.cfg" \ - "/boot/grub/grub_default.cfg=${grubcfgsdir}/config/grub.cfg" || \ - err "build_grub_elf: cannot build grub payload (grub-mkstandalone)" -} - -main $@ diff --git a/script/build/roms b/script/build/roms index 95b697ec..35373594 100755 --- a/script/build/roms +++ b/script/build/roms @@ -165,7 +165,49 @@ build_dependency_grub() rebuild_grub="y" done [ -n "${_keyboard}" ] && keymaps="${kmapdir}/${_keyboard}.gkb" - [ "${rebuild_grub}" = "y" ] && x_ ./build grub; return 0 + [ "$rebuild_grub" = "y" ] || return 0 + x_ ./update trees -b grub + remkdir elf/grub + build_keymap_configs + build_grub_payload +} + +build_keymap_configs() +{ + for keylayoutfile in "${grubcfgsdir}/keymap/"*.gkb; do + [ -f "${keylayoutfile}" ] || continue + keymap="${keylayoutfile##"${grubcfgsdir}/keymap/"}" + keymap="${keymap%.gkb}" + printf "keymap %s\n" "${keymap}" > \ + "elf/grub/keymap_${keymap}.cfg" || err "!insert keymap" + done +} + +build_grub_payload() +{ + ./src/grub/grub-mkstandalone \ + --grub-mkimage="src/grub/grub-mkimage" \ + -O i386-coreboot \ + -o "elf/grub/grub.elf" \ + -d "src/grub/grub-core/" \ + --fonts= --themes= --locales= \ + --modules="${grub_modules}" \ + --install-modules="${grub_install_modules}" \ + "${layoutdir}/colemak.gkb=${grubcfgsdir}/keymap/colemak.gkb" \ + "${layoutdir}/deqwertz.gkb=${grubcfgsdir}/keymap/deqwertz.gkb" \ + "${layoutdir}/esqwerty.gkb=${grubcfgsdir}/keymap/esqwerty.gkb" \ + "${layoutdir}/frazerty.gkb=${grubcfgsdir}/keymap/frazerty.gkb" \ + "${layoutdir}/frdvbepo.gkb=${grubcfgsdir}/keymap/frdvbepo.gkb" \ + "${layoutdir}/itqwerty.gkb=${grubcfgsdir}/keymap/itqwerty.gkb" \ + "${layoutdir}/svenska.gkb=${grubcfgsdir}/keymap/svenska.gkb" \ + "${layoutdir}/trqwerty.gkb=${grubcfgsdir}/keymap/trqwerty.gkb" \ + "${layoutdir}/ukdvorak.gkb=${grubcfgsdir}/keymap/ukdvorak.gkb" \ + "${layoutdir}/ukqwerty.gkb=${grubcfgsdir}/keymap/ukqwerty.gkb" \ + "${layoutdir}/usdvorak.gkb=${grubcfgsdir}/keymap/usdvorak.gkb" \ + "${layoutdir}/usqwerty.gkb=${grubcfgsdir}/keymap/usqwerty.gkb" \ + "/boot/grub/grub.cfg=${grubcfgsdir}/config/grub_memdisk.cfg" \ + "/boot/grub/grub_default.cfg=${grubcfgsdir}/config/grub.cfg" || \ + err "build_grub_elf: cannot build grub payload (grub-mkstandalone)" } build_dependency_uboot() diff --git a/script/update/trees b/script/update/trees index 556181ed..9d1e89ff 100755 --- a/script/update/trees +++ b/script/update/trees @@ -33,6 +33,7 @@ main() done [ -z "$_f" ] && err "missing flag (-m/-u/-b/-c/-x/-f/-s/-l/-n)" [ -z "$project" ] && err "project name not specified" + elfdir="elf/${project}" check_project @@ -63,7 +64,6 @@ build_projects() build_targets() { - elfdir="elf/${project}" [ "$elfdir" = "elf/coreboot" ] && \ elfdir="elf/coreboot_nopayload_DO_NOT_FLASH" @@ -204,17 +204,39 @@ handle_makefile() run_make_command() { - [ -f "${codedir}/Makefile" ] || [ -f "${codedir}/makefile" ] || \ - [ -f "${codedir}/GNUmakefile" ] || return 1 + [ -z "$mode" ] && check_autoconf "$codedir" + check_makefile "$codedir" || return 1 + [ "$project" = "coreboot" ] && [ -z "$mode" ] && \ x_ printf "%s\n" "${version%%-*}" \ > "${codedir}/.coreboot-version" - x_ make $mode -j$(nproc) -C "$codedir" + make $mode -j$(nproc) FS_PAYLOAD_MODULES="" -C "$codedir" || \ + err "run_make $codedir: !make $mode" + [ "$mode" != "clean" ] && return 0 make -C "$codedir" distclean 2>/dev/null || : } +check_autoconf() +{ + ( + _cfgopt="" + cd "${codedir}" || err "!cd $codedir" + [ "$project" = "grub" ] && _cfgopt="--gnulib-srcdir=gnulib/ --no-git" + [ -f "bootstrap" ] && x_ ./bootstrap $_cfgopt + [ -f "autogen.sh" ] && x_ ./autogen.sh + [ "$project" = "grub" ] && _cfgopt="--with-platform=coreboot" + [ -f "configure" ] && x_ ./configure $_cfgopt; return 0 + ) || err "can't bootstrap project: $codedir" +} + +check_makefile() +{ + [ -f "${1}/Makefile" ] || [ -f "${1}/makefile" ] || \ + [ -f "${1}/GNUmakefile" ] || return 1; return 0 +} + copy_elf() { while read -r f; do |