|
| 1 | +#!/bin/bash |
| 2 | +# A script to generate cabinets for fwupd / LVFS |
| 3 | + |
| 4 | +set -e |
| 5 | + |
| 6 | +function die() { |
| 7 | + echo error: "$@" 1>&2 |
| 8 | + exit 1 |
| 9 | +} |
| 10 | + |
| 11 | +if [ $# -ne 1 ]; then |
| 12 | + die "Incorrect number of input parameters specified: $# (expected: 1)" |
| 13 | +fi |
| 14 | + |
| 15 | +if [ -z $1 ]; then |
| 16 | + die "No input capsule specified" |
| 17 | +fi |
| 18 | + |
| 19 | +if [ ! -f $1 ]; then |
| 20 | + die "File $1 not found" |
| 21 | +fi |
| 22 | + |
| 23 | +if [ ! -f .config ]; then |
| 24 | + die "No '.config' file in current directory" |
| 25 | +fi |
| 26 | + |
| 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 | + |
| 38 | +capsule=$1 |
| 39 | +date=$(stat -c %w $capsule | cut -d ' ' -f 1) |
| 40 | +vendor=$(cat .config | grep -e "CONFIG_VENDOR_.*=y" | cut -d '=' -f 1 | cut -d '_' -f 3- | awk '{ print tolower($0) }') |
| 41 | +version=$(echo $CONFIG_LOCALVERSION | tr -d 'v' | cut -d '-' -f 1) |
| 42 | + |
| 43 | +archive_dir=$(mktemp --tmpdir -d XXXXXXXX) |
| 44 | + |
| 45 | +cat > "${archive_dir}/firmware.metainfo.xml" << EOF |
| 46 | +<?xml version='1.0' encoding='utf-8'?> |
| 47 | +<component type="firmware"> |
| 48 | + <id>com.${vendor}.${CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME}.${CONFIG_MAINBOARD_VERSION}.system.firmware</id> |
| 49 | + <name>${CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME}</name> |
| 50 | + <summary>${CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME} ${CONFIG_MAINBOARD_VERSION} system firmware</summary> |
| 51 | + <description> |
| 52 | + <p>Dasharo ${CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME} ${CONFIG_MAINBOARD_VERSION} system firmware</p> |
| 53 | + </description> |
| 54 | + <provides> |
| 55 | + <firmware type="flashed">${CONFIG_DRIVERS_EFI_MAIN_FW_GUID}</firmware> |
| 56 | + </provides> |
| 57 | + <url type="homepage">https://docs.dasharo.com/</url> |
| 58 | + <metadata_license>CC0-1.0</metadata_license> |
| 59 | + <project_license>LicenseRef-proprietary</project_license> |
| 60 | + <categories> |
| 61 | + <category>X-System</category> |
| 62 | + </categories> |
| 63 | + <custom> |
| 64 | + <value key="LVFS::VersionFormat">quad</value> |
| 65 | + <value key="LVFS::VersionFormat">dell-bios-msb</value> |
| 66 | + <value key="LVFS::UpdateProtocol">org.uefi.capsule</value> |
| 67 | + </custom> |
| 68 | + <releases> |
| 69 | + <release version="${version}" date="${date}" tag="${CONFIG_LOCALVERSION}" urgency="high"> |
| 70 | + <checksum filename="firmware.bin" target="content"/> |
| 71 | + </release> |
| 72 | + </releases> |
| 73 | +</component> |
| 74 | +
|
| 75 | +EOF |
| 76 | + |
| 77 | +cp $capsule $archive_dir/firmware.bin |
| 78 | + |
| 79 | +pushd $archive_dir &> /dev/null |
| 80 | +fwupdtool build-cabinet $capsule.cab firmware.bin firmware.metainfo.xml |
| 81 | +popd &> /dev/null |
| 82 | + |
| 83 | +cp $archive_dir/$capsule.cab ./ |
| 84 | + |
| 85 | +echo "File $capsule.cab created" |
| 86 | + |
| 87 | +rm -r $archive_dir |
0 commit comments