Skip to content

Commit dc4919d

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ć <[email protected]>
1 parent 4a20083 commit dc4919d

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

capsule_cabinet.sh

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

44
set -e
55

6+
edk_workspace=${EDK_WORKSPACE:-payloads/external/edk2/workspace/Dasharo}
7+
edk_tools=${edk_workspace}/BaseTools/BinWrappers/PosixLike
8+
69
function die() {
710
echo error: "$@" 1>&2
811
exit 1
@@ -24,17 +27,6 @@ if [ ! -f .config ]; then
2427
die "No '.config' file in current directory"
2528
fi
2629

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-
3830
capsule=$1
3931
date=$(stat -c %w $capsule | cut -d ' ' -f 1)
4032
vendor=$(cat .config | grep -e "CONFIG_VENDOR_.*=y" | cut -d '=' -f 1 | cut -d '_' -f 3- | awk '{ print tolower($0) }')
@@ -74,6 +66,24 @@ cat > "${archive_dir}/firmware.metainfo.xml" << EOF
7466
7567
EOF
7668

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

7989
pushd $archive_dir &> /dev/null

0 commit comments

Comments
 (0)