Skip to content

Commit 8f364db

Browse files
committed
capsule_cabinet.sh: make it work independent of .config
Extract the coreboot config from the capsule itself, in order to be able to use the script on any coreboot capsules. Upstream-Status: Inappropriate [Dasharo downstream] Change-Id: I49f2fb91423b912d98d55ca5e0e008b483d1322c Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
1 parent 4a20083 commit 8f364db

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

capsule_cabinet.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
set -e
55

6+
edk_workspace=payloads/external/edk2/workspace
7+
edk_tools=${edk_workspace}/Dasharo/BaseTools/BinWrappers/PosixLike
8+
edk_scripts=${edk_workspace}/Dasharo/BaseTools/Scripts
9+
610
function die() {
711
echo error: "$@" 1>&2
812
exit 1
@@ -24,17 +28,6 @@ if [ ! -f .config ]; then
2428
die "No '.config' file in current directory"
2529
fi
2630

27-
# import coreboot's config file replacing $(...) with ${...}
28-
while read -r line; do
29-
if ! eval "$line"; then
30-
die "failed to source '.config'"
31-
fi
32-
done <<< "$(sed 's/\$(\([^)]\+\))/${\1}/g' .config)"
33-
34-
if [ "$CONFIG_DRIVERS_EFI_UPDATE_CAPSULES" != y ]; then
35-
die "Current board configuration lacks support of update capsules"
36-
fi
37-
3831
capsule=$1
3932
date=$(stat -c %w $capsule | cut -d ' ' -f 1)
4033
vendor=$(cat .config | grep -e "CONFIG_VENDOR_.*=y" | cut -d '=' -f 1 | cut -d '_' -f 3- | awk '{ print tolower($0) }')
@@ -74,6 +67,29 @@ cat > "${archive_dir}/firmware.metainfo.xml" << EOF
7467
7568
EOF
7669

70+
if [ -d capsule_tmp ]; then
71+
rm -r capsule_tmp
72+
elif [ -f capsule_tmp ]; then
73+
rm capsule_tmp
74+
fi
75+
mkdir capsule_tmp
76+
if ! "${edk_tools}/GenerateCapsule" --decode $capsule --output capsule_tmp/capsule; then
77+
die "GenerateCapsule --decode failed!"
78+
fi
79+
cbfstool capsule_tmp/capsule.Payload.1.bin extract -r COREBOOT -n config -f config
80+
rm -r capsule_tmp
81+
82+
# import coreboot's config file replacing $(...) with ${...}
83+
while read -r line; do
84+
if ! eval "$line"; then
85+
die "failed to source 'config'"
86+
fi
87+
done <<< "$(sed 's/\$(\([^)]\+\))/${\1}/g' config)"
88+
89+
if [ "$CONFIG_DRIVERS_EFI_UPDATE_CAPSULES" != y ]; then
90+
die "Current board configuration lacks support of update capsules"
91+
fi
92+
7793
cp $capsule $archive_dir/firmware.bin
7894

7995
pushd $archive_dir &> /dev/null

0 commit comments

Comments
 (0)