diff options
author | Leah Rowe <leah@libreboot.org> | 2023-08-31 22:00:13 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-08-31 23:30:56 +0100 |
commit | 225e2609fa758a366238afcb57ab6581496e0399 (patch) | |
tree | aba5d759e17585479e1ecdf7f4d771c19068997b /script/build/release/roms | |
parent | bf774acf1df0e3a8743eb5d55dd47fc8957ff41a (diff) |
only remove microcode in build/release/roms
libreboot's build system, lbmk, *is* available to use
in releases aswell (use the _src tarball), but it is
mostly intended for development, in lbmk.git
well, there's not much point wasting time / disk space
generating no-microcode roms within lbmk
they should be generated only at release time, alongside
the default ones
this patch implements that, thus speeding up the build
process and saving disk usage during development
the other alternative was to add a new option in
build/boot/roms, -m, that would opt in to removing them,
but this is extra complexity for something that is ill
advised and only provided to appease certain people
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/build/release/roms')
-rwxr-xr-x | script/build/release/roms | 86 |
1 files changed, 64 insertions, 22 deletions
diff --git a/script/build/release/roms b/script/build/release/roms index 572ceca2..fa27c031 100755 --- a/script/build/release/roms +++ b/script/build/release/roms @@ -34,6 +34,7 @@ CONFIG_KBC1126_FIRMWARE="" CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="" ifdtool="cbutils/${tree}/ifdtool" cbfstool="cbutils/${tree}/cbfstool" +microcode_required="y" main() { @@ -42,6 +43,7 @@ main() init_check for romdir in bin/*; do + [ -d "${romdir}" ] || continue make_archive "${romdir}" done @@ -74,11 +76,25 @@ init_check() make_archive() { - romdir=${1} - target="${romdir##*/}" + builddir="${1}" + romdir="$(mktemp -d -t coreboot_rom.XXXXXXXXXX)" || \ + err "make_archive: cannot create tmpdir" + rm -Rf "${romdir}" || err "make_archive: can't remove tmpdir" + target="${builddir##*/}" + romdir="${romdir}/bin/${target}" + mkdir -p "${romdir}" || \ + err "make_archive: can't mkdir tmpdir" + cp "${builddir}"/* "${romdir}" || \ + err "make_archive: cannot copy ROM images directory -> ${romdir}" echo ${target} - [ -d "${romdir}/" ] || continue + + [ -f "resources/coreboot/${target}/target.cfg" ] || \ + err "make_archive: ${target}: target.cfg is missing" + + . "resources/coreboot/${target}/target.cfg" + [ "${microcode_required}" = "y" ] || \ + [ "${microcode_required}" = "n" ] || microcode_required="y" CONFIG_HAVE_MRC="y" CONFIG_HAVE_ME_BIN="y" @@ -97,7 +113,8 @@ make_archive() # remove ME/MRC/EC firmware from ROM images if [ "${CONFIG_HAVE_ME_BIN}" = "y" ] || \ - [ "${target}" = "e6400nvidia_4mb" ]; then + [ "${target}" = "e6400nvidia_4mb" ] || \ + [ "${microcode_required}" = "n" ]; then strip_archive "${romdir}" fi @@ -110,15 +127,17 @@ make_archive() printf "%s\n" "${projectname}" > "${romdir}/projectname" || \ err "make_archive: can't create ${romdir}/projectname" - f="release/${version}/roms/${projectname}-${version}_${target##*/}" - tar -c "${romdir}/" | xz -9e > "${f}.tar.xz" || \ - err "make_archive: can't create ${f}.tar.xz" - - if [ -d "${romdir}_tmp" ]; then - rm -Rf "${romdir}" || err "make_archive: !rm -Rf ${romdir}" - mv "${romdir}_tmp" "${romdir}" || \ - err "make_archive: !mv \"${romdir}_tmp\" \"${romdir}\"" - fi + archivename="${projectname}-${version}_${target##*/}" + f="release/${version}/roms/${archivename}" + ( + cd "${romdir%/bin/${target}}" || err "make_archive: can't cd to tmpdir" + tar -c "bin/${target}/" | xz -9e > "${archivename}.tar.xz" || \ + err "make_archive:cant make ${projectname}-${version}_${target##*/}" + ) + cp "${romdir%/bin/${target}}/${archivename}.tar.xz" "${f}.tar.xz" || \ + err "make_archive: can't copy tarball" + rm -Rf "${romdir%/bin/${target}}" || \ + err "make_archive: can't delete tmpdir" } strip_archive() @@ -131,10 +150,17 @@ strip_archive() ./build coreboot utils ${tree} || \ err "strip_archive: coreboot/${tree}: can't build utils" - # dirty hack, to reduce disk io later - # rather than using /tmp, which might not be tmpfs - rm -Rf "${romdir}_tmp" || err "strip_archive: !rm -Rf ${romdir}_tmp" - mkdir "${romdir}_tmp" || err "strip_archive: !mkdir ${romdir}_tmp" + if [ "${microcode_required}" = "n" ]; then + for romfile in "${romdir}"/*.rom; do + [ -f "${romfile}" ] || continue + strip_ucode "${romfile}" + done + for romfile in "${romdir}"/*.tmprom; do + [ -f "${romfile}" ] || continue + mv "${romfile}" "${romfile%.tmprom}.rom" || \ + err "can't make no-u rom: ${romfile%.tmprom}.rom" + done + fi # Hash the rom before removing blobs rm -f "${romdir}/blobhashes" || \ @@ -149,10 +175,30 @@ strip_archive() ) for romfile in "${romdir}"/*.rom; do + [ -f "${romfile}" ] || continue strip_rom_image "${romfile}" done } +strip_ucode() +{ + romfile=${1} + + _newrom_b="${romfile%.rom}_nomicrocode.tmprom" + cp "${romfile}" "${_newrom_b}" || \ + err "strip_rom_image: cp \"${romfile}\" \"${_newrom_b}\"" + microcode_present="y" + "${cbfstool}" "${_newrom_b}" remove -n \ + cpu_microcode_blob.bin 2>/dev/null || microcode_present="n" + if [ "${microcode_present}" = "n" ]; then + printf "REMARK: '%s' already lacks microcode\n" \ + "${romfile}" + printf "Renaming default ROM file instead.\n" + mv "${romfile}" "${_newrom_b}" || \ + err "strip_rom_image: can't rename no-u ${romfile}" + fi +} + strip_rom_image() { romfile=${1} @@ -160,12 +206,8 @@ strip_rom_image() [ -f "${romfile}" ] || return 0 if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then - "${ifdtool}" --nuke me "${romfile}" || \ + "${ifdtool}" --nuke me "${romfile}" -O "${romfile}" || \ err "strip_rom_images: ${romfile}: cannot nuke Intel ME" - mv "${romfile}" "${romdir}_tmp" || \ - err "strip_rom_images: !mv ${romfile} ${romdir}_tmp" - mv "${romfile}.new" "${romfile}" || \ - err "strip_rom_images: !mv ${romfile}.new ${romfile}" fi if [ "${CONFIG_HAVE_MRC}" = "y" ]; then |