From fd29c8fd1a962ff1e12a97ad1199e83d98c6390c Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 20 Jul 2024 03:22:28 +0100 Subject: quackboot (same idea as klompboot), from audit6 this is based directly on the audit6 final revision. same idea as klompboot. remove u-boot and arm support, remove pico-serprog, remove support for making release archives, and basically see how small the build system can possible get. quackboot *beats* the very first klompboot, at 790 lines, because klompboot 1 was just over 800 lines. klompboot 2 was 701 lines. vendor file logic is about 200 sloc so the next klompboot will be about 600 lines. this is the very first quackboot. Signed-off-by: Leah Rowe --- include/git.sh | 4 - include/lib.sh | 76 +----------------- include/rom.sh | 105 ++++++------------------- include/vendor.sh | 225 ++++++------------------------------------------------ 4 files changed, 54 insertions(+), 356 deletions(-) (limited to 'include') diff --git a/include/git.sh b/include/git.sh index f8441f33..77256df0 100644 --- a/include/git.sh +++ b/include/git.sh @@ -62,10 +62,6 @@ git_prep() [ "$project" = "coreboot" ] && [ -n "$xtree" ] && [ $# -gt 2 ] && \ [ "$xtree" != "$tree" ] && link_crossgcc "$_loc" - [ "$XBMK_RELEASE" = "y" ] && \ - [ "$_loc" != "$XBMK_CACHE/repo/$project" ] && \ - rmgit "$tmpgit" - move_repo "$_loc" } diff --git a/include/lib.sh b/include/lib.sh index 2cd8c0d7..ffb41451 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -3,14 +3,12 @@ # Copyright (c) 2022 Ferass El Hafidi # Copyright (c) 2020-2024 Leah Rowe +export LOCALVERSION="-quackboot-69" export LC_COLLATE=C export LC_ALL=C _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0" -kbnotice="Insert a .gkb file from config/data/grub/keymap/ as keymap.gkb \ -if you want a custom keymap in GRUB; use cbfstool from elf/cbfstool." -ifdtool="elf/ifdtool/default/ifdtool" cbfstool="elf/cbfstool/default/cbfstool" tmpgit="$PWD/tmp/gitclone" grubdata="config/data/grub" @@ -36,18 +34,12 @@ chkvars() done; return 0 } -eval `setvars "" _nogit board xbmk_parent versiondate projectsite projectname \ - aur_notice configdir datadir version relname` - -for fv in projectname projectsite version versiondate; do - eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :" -done; chkvars projectname projectsite +eval `setvars "" board xbmk_parent aur_notice configdir datadir` setcfg() { [ $# -gt 1 ] && printf "e \"%s\" f missing && return %s;\n" "$1" "$2" - [ $# -gt 1 ] || \ - printf "e \"%s\" f not && %s \"Missing config\";\n" "$1" "$err" + [ $# -gt 1 ] || printf "e \"%s\" f not && %s \"!f cfg\";\n" "$1" "$err" printf ". \"%s\" || %s \"Could not read config\";\n" "$1" "$err" } @@ -96,11 +88,6 @@ fi [ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache" [ -f "$XBMK_CACHE" ] && $err "cachedir '$XBMK_CACHE' exists but it's a file" -# if "y": a coreboot target won't be built if target.cfg says release="n" -# (this is used to exclude certain build targets from releases) -[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n" -[ "$XBMK_RELEASE" = "y" ] || export XBMK_RELEASE="n" - [ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1 expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \ 1>/dev/null 2>/dev/null || export XBMK_THREADS=1 # user gave a non-integer @@ -109,24 +96,6 @@ x_() { [ $# -lt 1 ] || $@ || $err "Unhandled non-zero exit: $@"; return 0 } -[ -e ".git" ] || [ -f "version" ] || printf "unknown\n" > version || \ - $err "Cannot generate unknown version file" -[ -e ".git" ] || [ -f "versiondate" ] || printf "1716415872\n" > versiondate \ - || $err "Cannot generate unknown versiondate file" - -version_="$version" -[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \ - version="git-$(git rev-parse HEAD 2>&1)" || version="$version_" -versiondate_="$versiondate" -[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \ - --pretty='%ct' HEAD)" || versiondate="$versiondate_" -for p in projectname version versiondate projectsite; do - chkvars "$p" - eval "x_ printf \"%s\\n\" \"\$$p\" > $p" -done -relname="$projectname-$version" -export LOCALVERSION="-$projectname-${version%%-*}" - check_defconfig() { [ -d "$1" ] || $err "Target '$1' not defined." @@ -141,42 +110,6 @@ remkdir() mkdir -p "$1" || $err "remkdir: !mkdir -p \"$1\"" } -mkrom_tarball() -{ - printf "%s\n" "$version" > "$1/version" || $err "$1 !version" - printf "%s\n" "$versiondate" > "$1/versiondate" || $err "$1 !vdate" - printf "%s\n" "$projectname" > "$1/projectname" || $err "$1 !pname" - - mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz" - x_ rm -Rf "$1" -} - -mktarball() -{ - [ "${2%/*}" = "$2" ] || \ - mkdir -p "${2%/*}" || $err "mk, !mkdir -p \"${2%/*}\"" - printf "\nCreating archive: %s\n\n" "$2" - tar -c "$1" | xz -T$XBMK_THREADS -9e > "$2" || $err "mktarball 2, $1" - mksha512sum "$2" "${2##*/}.sha512" -} - -mksha512sum() -{ - ( - [ "${1%/*}" != "$1" ] && x_ cd "${1%/*}" - sha512sum ./"${1##*/}" >> "$2" || $err "!sha512sum \"$1\" > \"$2\"" - ) || $err "failed to create tarball checksum" -} - -rmgit() -{ - ( - cd "$1" || $err "!cd gitrepo $1" - find . -name ".git" -exec rm -Rf {} + || $err "!rm .git $1" - find . -name ".gitmodules" -exec rm -Rf {} + || $err "!rm .gitmod $1" - ) || $err "Cannot remove .git/.gitmodules in $1" -} - # return 0 if project is single-tree, otherwise 1 # e.g. coreboot is multi-tree, so 1 singletree() @@ -208,8 +141,7 @@ download() vendor_checksum() { [ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1 - printf "Bad checksum for file: %s\n" "$2" 1>&2 - rm -f "$2" || : + printf "Bad checksum for file: %s\n" "$2" 1>&2; rm -f "$2" || : } cbfs() diff --git a/include/rom.sh b/include/rom.sh index ed3dddf2..c0e5f8c5 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -6,32 +6,12 @@ # Copyright (c) 2022-2023 Alper Nebi Yasak # Copyright (c) 2023 Riku Viitanen -mkserprog() -{ - [ "$_f" = "-d" ] && return 0 # dry run - basename -as .h "$serdir/"*.h > "$TMPDIR/ser" || $err "!mk $1 $TMPDIR" - - while read -r sertarget; do - [ "$1" = "rp2040" ] && x_ cmake -DPICO_BOARD="$sertarget" \ - -DPICO_SDK_PATH="$picosdk" -B "$sersrc/build" "$sersrc" \ - && x_ cmake --build "$sersrc/build" - [ "$1" = "stm32" ] && x_ make -C "$sersrc" \ - libopencm3-just-make BOARD=$sertarget && x_ make -C \ - "$sersrc" BOARD=$sertarget; x_ mkdir -p "bin/serprog_$1" - x_ mv "$serx" "bin/serprog_$1/serprog_$sertarget.${serx##*.}" - done < "$TMPDIR/ser" - - [ "$XBMK_RELEASE" = "y" ] && mkrom_tarball "bin/serprog_$1"; return 0 -} - mkpayload_grub() { eval `setvars "" grub_modules grub_install_modules` $dry eval `setcfg "$grubdata/module/$tree"` - - $dry x_ rm -f "$srcdir/grub.elf" - - $dry "$srcdir/grub-mkstandalone" --grub-mkimage="$srcdir/grub-mkimage" \ + $dry x_ rm -f "$srcdir/grub.elf"; $dry \ + "$srcdir/grub-mkstandalone" --grub-mkimage="$srcdir/grub-mkimage" \ -O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \ --fonts= --themes= --locales= --modules="$grub_modules" \ --install-modules="$grub_install_modules" \ @@ -43,68 +23,49 @@ mkpayload_grub() mkvendorfiles() { - check_coreboot_utils "$tree" - printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \ - $err "!mk $srcdir .coreboot-version" - [ -z "$mode" ] && [ "$target" != "$tree" ] && \ - x_ ./vendor download $target; return 0 + check_cbfstool "$tree"; printf "69\n" > "$srcdir/.coreboot-version" \ + || $err "!cbver $srcdir"; [ -z "$mode" ] && \ + [ "$target" != "$tree" ] && x_ ./vendor download $target; return 0 } -check_coreboot_utils() +check_cbfstool() { - for util in cbfstool ifdtool; do - [ "$badhash" = "n" ] || rm -f "elf/$util/$1/$util" || \ - $err "!rm badelf elf/$util/$1/$util" - e "elf/$util/$1/$util" f && continue - - utilelfdir="elf/$util/$1" - utilsrcdir="src/coreboot/$1/util/$util" - - utilmode="" && [ -n "$mode" ] && utilmode="clean" - x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs - [ -z "$mode" ] && [ ! -f "$utilelfdir/$util" ] && \ - x_ mkdir -p "$utilelfdir" && \ - x_ cp "$utilsrcdir/$util" "elf/$util/$1" - [ -z "$mode" ] || x_ rm -Rf "$utilelfdir"; continue - done; return 0 + [ "$badhash" = "n" ] || rm -f "elf/cbfstool/$1/cbfstool" || \ + $err "!rm badelf elf/cbfstool/$1/cbfstool" + e "elf/cbfstool/$1/cbfstool" f && return 0 + + utilelfdir="elf/cbfstool/$1" + utilsrcdir="src/coreboot/$1/util/cbfstool" + + utilmode="" && [ -n "$mode" ] && utilmode="clean" + x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs + [ -z "$mode" ] && [ ! -f "$utilelfdir/cbfstool" ] && \ + x_ mkdir -p "$utilelfdir" && \ + x_ cp "$utilsrcdir/cbfstool" "elf/cbfstool/$1" + [ -z "$mode" ] || x_ rm -Rf "$utilelfdir"; : } mkcorebootbin() { [ "$target" = "$tree" ] && return 0 - tmprom="$srcdir/build/coreboot.rom" - initmode="${defconfig##*/}"; displaymode="${initmode##*_}" - initmode="${initmode%%_*}" + tmprom="$srcdir/build/coreboot.rom"; initmode="${defconfig##*/}"; + displaymode="${initmode##*_}"; initmode="${initmode%%_*}" [ -n "$displaymode" ] && displaymode="_$displaymode" cbfstool="elf/cbfstool/$tree/cbfstool" - [ -n "$uboot_config" ] || uboot_config="default" - [ "$payload_uboot" = "y" ] || payload_seabios="y" - [ "$payload_grub" = "y" ] && payload_seabios="y" - [ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "y" ] && \ - $dry $err "$target: U-Boot and SeaBIOS/GRUB are both enabled." - [ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata" - [ -n "$grubtree" ] || grubtree="default" grubelf="elf/grub/$grubtree/payload/grub.elf" [ "$payload_memtest" = "y" ] || payload_memtest="n" [ "$(uname -m)" = "x86_64" ] || payload_memtest="n" - if grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then - [ "$payload_seabios" = "y" ] && pname="seabios" && \ - $dry add_seabios - [ "$payload_uboot" = "y" ] && pname="uboot" && $dry add_uboot - else - pname="custom" # coreboot's build system added payloads - fi + + pname="custom" && grep "CONFIG_PAYLOAD_NONE=y" "$defconfig" && \ + pname="seabios"; $dry add_seabios + newrom="bin/$target/${pname}_${target}_$initmode$displaymode.rom" $dry x_ mkdir -p "${newrom%/*}"; $dry x_ mv "$tmprom" "$newrom" - - [ "$XBMK_RELEASE" = "y" ] || return 0 - $dry mksha512sum "$newrom" "vendorhashes"; $dry ./vendor inject \ - -r "$newrom" -b "$target" -n nuke || $err "!nuke $newrom" } add_seabios() @@ -134,19 +95,3 @@ add_grub() cbfs "$tmprom" "$TMPDIR/tmpcfg" scan.cfg raw cbfs "$tmprom" "$grubdata/bootorder" bootorder raw } - -add_uboot() -{ - ubdir="elf/u-boot/$target/$uboot_config" - ubootelf="$ubdir/u-boot.elf" && [ ! -f "$ubootelf" ] && \ - ubootelf="$ubdir/u-boot" - [ -f "$ubootelf" ] || $err "cb/$target: Can't find u-boot" - - cbfs "$tmprom" "$ubootelf" "fallback/payload" -} - -mkcoreboottar() -{ - [ "$target" = "$tree" ] && return 0; [ "$XBMK_RELEASE" = "y" ] && \ - [ "$release" != "n" ] && $dry mkrom_tarball "bin/$target"; return 0 -} diff --git a/include/vendor.sh b/include/vendor.sh index ace3f7ce..ca37e989 100644 --- a/include/vendor.sh +++ b/include/vendor.sh @@ -7,21 +7,19 @@ e6400_unpack="$PWD/src/bios_extract/dell_inspiron_1100_unpacker.py" me7updateparser="$PWD/util/me7_update_parser/me7_update_parser.py" pfs_extract="$PWD/src/biosutilities/Dell_PFS_Extract.py" uefiextract="$PWD/elf/uefitool/uefiextract" -vendir="vendorfiles" -appdir="$vendir/app" +appdir="vendorfiles/app" cbcfgsdir="config/coreboot" eval `setvars "" EC_url_bkup EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \ E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \ E6400_VGA_romname CONFIG_HAVE_MRC SCH5545EC_DL_url_bkup SCH5545EC_DL_hash \ - mecleaner kbc1126_ec_dump MRC_refcode_cbtree new_mac _dl SCH5545EC_DL_url \ - CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_ME_BIN archive EC_url boarddir rom \ + mecleaner kbc1126_ec_dump MRC_refcode_cbtree _dl SCH5545EC_DL_url _7ztest \ + CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_ME_BIN EC_url CONFIG_REFCODE_BLOB_FILE \ CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE _dest tree CONFIG_GBE_BIN_PATH \ - CONFIG_KBC1126_FW1_OFFSET CONFIG_KBC1126_FW2 CONFIG_KBC1126_FW2_OFFSET \ + CONFIG_KBC1126_FW1_OFFSET CONFIG_KBC1126_FW2 CONFIG_KBC1126_FW2_OFFSET rom \ CONFIG_VGA_BIOS_FILE CONFIG_VGA_BIOS_ID CONFIG_KBC1126_FW1 cbdir DL_url \ - CONFIG_INCLUDE_SMSC_SCH5545_EC_FW CONFIG_SMSC_SCH5545_EC_FW_FILE nukemode \ - CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE CONFIG_HAVE_REFCODE_BLOB cbfstoolref \ - CONFIG_REFCODE_BLOB_FILE vrelease verify _7ztest` + CONFIG_INCLUDE_SMSC_SCH5545_EC_FW CONFIG_SMSC_SCH5545_EC_FW_FILE boarddir \ + CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE CONFIG_HAVE_REFCODE_BLOB cbfstoolref` vendor_download() { @@ -31,6 +29,20 @@ vendor_download() board="$1" && readcfg && readkconfig && bootstrap && getfiles; return 0 } +readcfg() +{ + boarddir="$cbcfgsdir/$board" + eval `setcfg "$boarddir/target.cfg"`; chkvars vcfg tree + + cbdir="src/coreboot/$tree" + cbfstool="elf/cbfstool/$tree/cbfstool" + mecleaner="$PWD/$cbdir/util/me_cleaner/me_cleaner.py" + kbc1126_ec_dump="$PWD/$cbdir/util/kbc1126/kbc1126_ec_dump" + cbfstool="elf/cbfstool/$tree/cbfstool" + + x_ ./update trees -d coreboot $tree +} + readkconfig() { check_defconfig "$boarddir" 1>"$TMPDIR/vendorcfg.list" && return 1 @@ -91,9 +103,7 @@ fetch() extract_archive "$_dl" "$appdir" || [ "$dl_type" = "e6400vga" ] || \ $err "mkdirs $_dest $dl_type: !extract" - eval "extract_$dl_type" - set -u -e - + eval "extract_$dl_type"; set -u -e e "$_dest" f missing && $err "!extract_$dl_type"; return 0 } @@ -107,8 +117,7 @@ extract_intel_me() e "$_me" f && return 0 - sdir="$(mktemp -d)" - [ -z "$sdir" ] && return 0 + sdir="$(mktemp -d)"; [ -z "$sdir" ] && return 0 mkdir -p "$sdir" || $err "extract_intel_me: !mkdir -p \"$sdir\"" set +u +e @@ -149,8 +158,7 @@ extract_kbc1126ec() { e "$kbc1126_ec_dump" f missing && $err "$cbdir: kbc1126 util missing" ( - x_ cd "$appdir/" - mv Rompaq/68*.BIN ec.bin || : + x_ cd "$appdir/"; mv Rompaq/68*.BIN ec.bin || : if [ ! -f "ec.bin" ]; then unar -D ROM.CAB Rom.bin || unar -D Rom.CAB Rom.bin || \ unar -D 68*.CAB Rom.bin || $err "can't extract Rom.bin" @@ -168,16 +176,14 @@ extract_kbc1126ec() extract_e6400vga() { - set +u +e - chkvars E6400_VGA_offset E6400_VGA_romname + set +u +e; chkvars E6400_VGA_offset E6400_VGA_romname tail -c +$E6400_VGA_offset "$_dl" | gunzip > "$appdir/bios.bin" || : ( x_ cd "$appdir" [ -f "bios.bin" ] || $err "extract_e6400vga: can't extract bios.bin" "$e6400_unpack" bios.bin || printf "TODO: fix dell extract util\n" ) || $err "can't extract e6400 vga rom" - cp "$appdir/$E6400_VGA_romname" "$_dest" || \ - $err "extract_e6400vga $board: can't copy vga rom to $_dest" + cp "$appdir/$E6400_VGA_romname" "$_dest" || $err "64 !cp $board $_dest" } extract_sch5545ec() @@ -192,184 +198,3 @@ extract_sch5545ec() "$uefiextract" "$_bios" || $err "sch5545 !extract" cp "$_sch5545ec_fw" "$_dest" || $err "$_dest: !sch5545 copy" } - -vendor_inject() -{ - set +u +e - - [ $# -lt 1 ] && $err "No options specified." - [ "$1" = "listboards" ] && eval "ls -1 config/coreboot || :; exit 0" - - archive="$1" - - while getopts n:r:b:m: option; do - case "$option" in - n) nukemode="$OPTARG" ;; - r) rom="$OPTARG" ;; - b) board="$OPTARG" ;; - m) new_mac="$OPTARG"; chkvars new_mac ;; - *) : ;; - esac - done - - check_board || return 0 - [ "$nukemode" = "nuke" ] || x_ ./vendor download $board - [ "$vrelease" != "y" ] && patch_rom "$rom" - [ "$vrelease" = "y" ] && patch_release_roms - - [ "$nukemode" = "nuke" ] && return 0 - printf "Friendly reminder (this is *not* an error message):\n" - printf "Make sure the files were inserted. ALSO:\n%s\n" "$kbnotice" -} - -check_board() -{ - failcheck="y" && check_release "$archive" && failcheck="n" - if [ "$failcheck" = "y" ]; then - [ -f "$rom" ] || $err "check_board \"$rom\": invalid path" - [ -z "${rom+x}" ] && $err "check_board: no rom specified" - [ -n "${board+x}" ] || board="$(detect_board "$rom")" - else - vrelease="y"; board="$(detect_board "$archive")" - fi - readcfg || return 1; return 0 -} - -check_release() -{ - [ -f "$archive" ] || return 1 - [ "${archive##*.}" = "xz" ] || return 1 - printf "%s\n" "Release archive $archive detected" -} - -# This function tries to determine the board from the filename of the rom. -# It will only succeed if the filename is not changed from the build/download -detect_board() -{ - path="$1" - filename="$(basename "$path")" - case "$filename" in - grub_*|seagrub_*|custom_*) - board="$(echo "$filename" | cut -d '_' -f2-3)" ;; - seabios_withgrub_*) - board="$(echo "$filename" | cut -d '_' -f3-4)" ;; - *.tar.xz) - _stripped_prefix="${filename#*_}" - board="${_stripped_prefix%.tar.xz}" ;; - *) $err "detect_board $filename: could not detect board type" - esac; printf "%s\n" "$board" -} - -readcfg() -{ - if [ "$board" = "serprog_rp2040" ] || \ - [ "$board" = "serprog_stm32" ]; then - return 1 - fi - boarddir="$cbcfgsdir/$board" - eval `setcfg "$boarddir/target.cfg"` - chkvars vcfg tree - - cbdir="src/coreboot/$tree" - cbfstool="elf/cbfstool/$tree/cbfstool" - mecleaner="$PWD/$cbdir/util/me_cleaner/me_cleaner.py" - kbc1126_ec_dump="$PWD/$cbdir/util/kbc1126/kbc1126_ec_dump" - cbfstool="elf/cbfstool/$tree/cbfstool" - ifdtool="elf/ifdtool/$tree/ifdtool" - - x_ ./update trees -d coreboot $tree -} - -patch_release_roms() -{ - remkdir "tmp/romdir" - tar -xf "$archive" -C "tmp/romdir" || \ - $err "patch_release_roms: !tar -xf \"$archive\" -C \"tmp/romdir\"" - - for x in "tmp/romdir/bin/"*/*.rom ; do - patch_rom "$x" - done - - ( - cd "tmp/romdir/bin/"* || $err "patch roms: !cd tmp/romdir/bin/*" - - # NOTE: For compatibility with older rom releases, defer to sha1 - [ "$verify" != "y" ] || [ "$nukemode" = "nuke" ] || \ - sha512sum --status -c vendorhashes || \ - sha1sum --status -c vendorhashes || sha512sum --status -c \ - blobhashes || sha1sum --status -c blobhashes || \ - $err "patch_release_roms: ROMs did not match expected hashes" - ) || $err "can't verify vendor hashes" - - [ -n "$new_mac" ] && for x in "tmp/romdir/bin/"*/*.rom ; do - [ -f "$x" ] && modify_gbe "$x" - done - - x_ mkdir -p bin/release - mv tmp/romdir/bin/* bin/release/ || $err "$board: !mv release roms" -} - -patch_rom() -{ - rom="$1" - - . "$(check_defconfig "$boarddir")" 2>/dev/null || exit 0 - - [ "$CONFIG_HAVE_MRC" = "y" ] && inject "mrc.bin" "$CONFIG_MRC_FILE" \ - "mrc" "0xfffa0000" - [ -n "$CONFIG_HAVE_REFCODE_BLOB" ] && inject "fallback/refcode" \ - "$CONFIG_REFCODE_BLOB_FILE" "stage" - [ "$CONFIG_HAVE_ME_BIN" = "y" ] && inject IFD "$CONFIG_ME_BIN_PATH" me - [ "$CONFIG_KBC1126_FIRMWARE" = "y" ] && inject ecfw1.bin \ - "$CONFIG_KBC1126_FW1" raw "$CONFIG_KBC1126_FW1_OFFSET" && inject \ - ecfw2.bin "$CONFIG_KBC1126_FW2" raw "$CONFIG_KBC1126_FW2_OFFSET" - [ -n "$CONFIG_VGA_BIOS_FILE" ] && [ -n "$CONFIG_VGA_BIOS_ID" ] && \ - inject "pci$CONFIG_VGA_BIOS_ID.rom" \ - "$CONFIG_VGA_BIOS_FILE" "optionrom" - [ "$CONFIG_INCLUDE_SMSC_SCH5545_EC_FW" = "y" ] && \ - [ -n "$CONFIG_SMSC_SCH5545_EC_FW_FILE" ] && \ - inject sch5545_ecfw.bin "$CONFIG_SMSC_SCH5545_EC_FW_FILE" raw - [ -n "$new_mac" ] && [ "$vrelease" != "y" ] && modify_gbe "$rom" - - printf "ROM image successfully patched: %s\n" "$rom" -} - -inject() -{ - [ $# -lt 3 ] && $err "$@, $rom: usage: inject name path type (offset)" - [ "$2" = "/dev/null" ] && return 0; verify="y" - - eval `setvars "" cbfsname _dest _t _offset` - cbfsname="$1"; _dest="${2##*../}"; _t="$3" - - [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ] && \ - $err "inject $@, $rom: offset passed, but empty (not defined)" - - e "$_dest" f n && [ "$nukemode" != "nuke" ] && $err "!inject $dl_type" - - if [ "$cbfsname" = "IFD" ]; then - [ "$nukemode" = "nuke" ] || "$ifdtool" -i $_t:$_dest "$rom" \ - -O "$rom" || $err "failed: inject '$_t' '$_dest' on '$rom'" - [ "$nukemode" != "nuke" ] || "$ifdtool" --nuke $_t "$rom" \ - -O "$rom" || $err "$rom: can't nuke $_t in IFD"; return 0 - elif [ "$nukemode" = "nuke" ]; then - "$cbfstool" "$rom" remove -n "$cbfsname" || \ - $err "inject $rom: can't remove $cbfsname"; return 0 - fi - [ "$_t" != "stage" ] || "$cbfstool" "$rom" add-stage -f \ - "$_dest" -n "$cbfsname" -t stage -c lzma || $err "$rom: !add ref" - [ "$_t" = "stage" ] || "$cbfstool" "$rom" add -f "$_dest" \ - -n "$cbfsname" -t $_t $_offset || $err "$rom !add $_t ($_dest)" -} - -modify_gbe() -{ - chkvars CONFIG_GBE_BIN_PATH - - e "${CONFIG_GBE_BIN_PATH##*../}" f n && $err "missing gbe file" - x_ make -C util/nvmutil - - x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "$TMPDIR/gbe" - x_ "util/nvmutil/nvm" "$TMPDIR/gbe" setmac $new_mac - x_ "$ifdtool" -i GbE:"$TMPDIR/gbe" "$1" -O "$1" -} -- cgit v1.2.1