summaryrefslogtreecommitdiff
path: root/resources/scripts/build/release/roms
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2022-12-05 02:21:28 +0000
committerLeah Rowe <leah@libreboot.org>2022-12-05 02:21:28 +0000
commita7ea70c77afa3b58b1c8850b0b6cf72a60015595 (patch)
treebf7dc0f8bcad4172f40e9993d6a6d72b8cee4515 /resources/scripts/build/release/roms
parent0c334380637652ae917404e7f404f54df55d54bf (diff)
build/release/roms: delete ME/MRC firmware in ROMs
Diffstat (limited to 'resources/scripts/build/release/roms')
-rwxr-xr-xresources/scripts/build/release/roms84
1 files changed, 68 insertions, 16 deletions
diff --git a/resources/scripts/build/release/roms b/resources/scripts/build/release/roms
index d0ed093c..730efb4f 100755
--- a/resources/scripts/build/release/roms
+++ b/resources/scripts/build/release/roms
@@ -3,7 +3,7 @@
#
# helper script: generate release archive (ROM images)
#
-# Copyright (C) 2020,2021 Leah Rowe <info@minifree.org>
+# Copyright (C) 2020,2021,2022 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
@@ -37,7 +37,8 @@ if [ -f versiondate ]; then
fi
if [ ! -d "bin/" ]; then
- ./build boot roms release
+ printf "build/release/roms: no ROMs built yet. Exiting.\n"
+ exit 1
fi
[ ! -d "release/" ] && \
@@ -51,20 +52,71 @@ fi
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" "${version}" "${projectname}" "${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
-)
+for romdir in bin/*; do
+ target="${romdir##*/}"
+
+ echo ${target}
+ if [ ! -d "${romdir}/" ]; then
+ continue
+ fi
+
+ CONFIG_HAVE_MRC="y"
+ CONFIG_HAVE_ME_BIN="y"
+ grep "CONFIG_HAVE_ME_BIN=y" "resources/coreboot/${target}/config/"* || CONFIG_HAVE_ME_BIN="n"
+ grep "CONFIG_HAVE_MRC=y" "resources/coreboot/${target}/config/"* || CONFIG_HAVE_MRC="n"
+
+ # remove ME/MRC from ROM images
+ if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
+ if [ ! -d coreboot/default ]; then
+ ./download coreboot default || exit 1
+ fi
+
+ ifdtooldir="coreboot/default/util/ifdtool"
+ ifdtool="${ifdtooldir}/ifdtool"
+ if [ ! -f "${ifdtool}" ]; then
+ make -BC "${ifdtooldir}" || exit 1
+ fi
+
+ cbfstooldir="coreboot/default/util/cbfstool"
+ cbfstool="${cbfstooldir}/cbfstool"
+ if [ ! -f "${cbfstool}" ]; then
+ make -BC "${cbfstooldir}" || exit 1
+ fi
+
+ rm -Rf "${romdir}_tmp" # dirty hack, to reduce disk io later
+ # rather than using /tmp, which might not be tmpfs
+ mkdir "${romdir}_tmp"
+
+ for romfile in "${romdir}"/*.rom
+ do
+ if [ ! -f "${romfile}" ]
+ then
+ continue
+ fi
+ ${ifdtool} --nuke me "${romfile}" || exit 1
+ mv "${romfile}" "${romdir}_tmp"/
+ mv "${romfile}.new" "${romfile}"
+
+ if [ "${CONFIG_HAVE_MRC}" = "y" ]
+ then
+ ${cbfstool} "${romfile}" remove -n mrc.bin || exit 1
+ ${cbfstool} "${romfile}" print
+ fi
+ done
+ fi
+
+ printf "Generating release/%s/roms/%s-%s_%s.tar.xz\n" "${version}" "${projectname}" "${version}" "${target##*/}"
+ printf "%s\n" "${version}" > "${romdir}/version"
+ printf "%s\n" "${versiondate}" > "${romdir}/versiondate"
+ printf "%s\n" "${projectname}" > "${romdir}/projectname"
+ tar -c "${romdir}/" | xz -9e >"release/${version}/roms/${projectname}-${version}_${target##*/}.tar.xz"
+
+ if [ -d "${romdir}_tmp" ]
+ then
+ rm -Rf "${romdir}"
+ mv "${romdir}_tmp" "${romdir}"
+ fi
+done
printf "\nROM image release archives available at release/%s/roms/\n\n" "${version}"