Skip to content

Commit 2018c10

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 370a7dc commit 2018c10

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

capsule_cabinet.sh

Lines changed: 22 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,25 @@ 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 $decode_dir/config
74+
75+
# import coreboot's config file replacing $(...) with ${...}
76+
while read -r line; do
77+
if ! eval "$line"; then
78+
die "failed to source 'config'"
79+
fi
80+
done <<< "$(sed 's/\$(\([^)]\+\))/${\1}/g' $decode_dir/config)"
81+
82+
rm -r $decode_dir
83+
84+
if [ "$CONFIG_DRIVERS_EFI_UPDATE_CAPSULES" != y ]; then
85+
die "Current board configuration lacks support of update capsules"
86+
fi
87+
7788
cp $capsule $archive_dir/firmware.bin
7889

7990
pushd $archive_dir &> /dev/null

0 commit comments

Comments
 (0)