Skip to content

Commit

Permalink
example-setup/update-platform: retrieve platform details
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Ott <[email protected]>
  • Loading branch information
smo4201 committed Jul 25, 2024
1 parent 9f49559 commit 16adc1f
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions example-setup/update-platform
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ fi

echo "Using ${data} as directory for local data"

# Retrieve high level details
set +e
firmware="Lenovo"
bootloader=$(grub-install --version)
kernel=$(uname -r)
os=$(lsb_release -sd 2>/dev/null)
set -e

# Replace existing app description in the device description (will be added through
# update-app-manifest scripts)
json=$(cat "${input}/device.description.json")
Expand All @@ -34,17 +42,31 @@ printf "%s\n" "${json}" > "${input}/device.description.json"
# Parse the values of the RTM PCRs from the kernel's binary bios measurements as reference values
referenceValues=$(sudo parse-srtm-pcrs -p 0,1,2,3,4,5,6,7 -f json -e)

# Replace existing reference values with new reference values in the RTM Manifest
# Load RTM manifest
json=$(cat "${input}/rtm.manifest.json")

# Insert high-level details
json=$(echo "${json}" | jq ".details.firmware = \"${firmware}\"")
json=$(echo "${json}" | jq ".details.bootloader = \"${bootloader}\"")

# Replace existing reference values with new reference values in the RTM Manifest
json=$(echo "${json}" | jq 'del(.referenceValues[])')
json=$(echo "${json}" | jq --argjson ver "${referenceValues}" '.referenceValues += $ver')

# Save the RTM manifest
printf "%s\n" "${json}" > "${input}/rtm.manifest.json"

# Parse the values of the OS PCRs from the kernel's binary bios measurements as reference values
referenceValues=$(sudo parse-srtm-pcrs -p 8,9,12,13,14,15 -f json -e)

# Replace existing reference values with new reference values in the RTM Manifest
# Load OS manifest
json=$(cat "${input}/os.manifest.json")

# Insert high-level details
json=$(echo "${json}" | jq ".details.kernel = \"${kernel}\"")
json=$(echo "${json}" | jq ".details.os = \"${os}\"")

# Replace existing reference values with new reference values in the OS Manifest
json=$(echo "${json}" | jq 'del(.referenceValues[])')
json=$(echo "${json}" | jq --argjson ver "${referenceValues}" '.referenceValues += $ver')
printf "%s\n" "${json}" > "${input}/os.manifest.json"
Expand Down

0 comments on commit 16adc1f

Please sign in to comment.