Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions capsule_cabinet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

set -e

edk_workspace=${EDK_WORKSPACE:-payloads/external/edk2/workspace/Dasharo}
edk_tools=${edk_workspace}/BaseTools/BinWrappers/PosixLike

function die() {
echo error: "$@" 1>&2
exit 1
Expand All @@ -24,17 +27,6 @@ if [ ! -f .config ]; then
die "No '.config' file in current directory"
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existence of .config is checked here.


# import coreboot's config file replacing $(...) with ${...}
while read -r line; do
if ! eval "$line"; then
die "failed to source '.config'"
fi
done <<< "$(sed 's/\$(\([^)]\+\))/${\1}/g' .config)"

if [ "$CONFIG_DRIVERS_EFI_UPDATE_CAPSULES" != y ]; then
die "Current board configuration lacks support of update capsules"
fi

capsule=$1
date=$(stat -c %w $capsule | cut -d ' ' -f 1)
vendor=$(cat .config | grep -e "CONFIG_VENDOR_.*=y" | cut -d '=' -f 1 | cut -d '_' -f 3- | awk '{ print tolower($0) }')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.config is used here.

Expand Down Expand Up @@ -74,6 +66,25 @@ cat > "${archive_dir}/firmware.metainfo.xml" << EOF

EOF

decode_dir=$(mktemp --tmpdir -d XXXXXXXX)
if ! "${edk_tools}/GenerateCapsule" --decode $capsule --output $decode_dir/capsule; then
die "GenerateCapsule --decode failed!"
fi
cbfstool $decode_dir/capsule.Payload.1.bin extract -r COREBOOT -n config -f $decode_dir/config

# import coreboot's config file replacing $(...) with ${...}
while read -r line; do
if ! eval "$line"; then
die "failed to source 'config'"
fi
done <<< "$(sed 's/\$(\([^)]\+\))/${\1}/g' $decode_dir/config)"

rm -r $decode_dir

if [ "$CONFIG_DRIVERS_EFI_UPDATE_CAPSULES" != y ]; then
die "Current board configuration lacks support of update capsules"
fi

cp $capsule $archive_dir/firmware.bin

pushd $archive_dir &> /dev/null
Expand Down
Loading