1dcb3fd79SLei YU#!/bin/bash 2dcb3fd79SLei YUset -eo pipefail 3dcb3fd79SLei YU 4dcb3fd79SLei YUhelp=$'Generate Tarball with PNOR image and MANIFEST Script 5dcb3fd79SLei YU 6dcb3fd79SLei YUGenerates a PNOR SquashFS image from the PNOR image for VPNOR, 7dcb3fd79SLei YUOr use a static layout raw PNOR image, 8dcb3fd79SLei YUCreates a MANIFEST for image verification and recreation 9dcb3fd79SLei YUPackages the image and MANIFEST together in a tarball 10dcb3fd79SLei YU 11dcb3fd79SLei YUusage: generate-tar [OPTION] <PNOR FILE>... 12dcb3fd79SLei YU 13dcb3fd79SLei YUOptions: 14dcb3fd79SLei YU-i, --image <squashfs|static> 15dcb3fd79SLei YUGenerate SquashFS image or use static PNOR 16dcb3fd79SLei YU-f, --file <file> Specify destination file. Defaults to 177bd45a30SAdriana Kobylak$(pwd)/<PNOR FILE>.pnor.<image_type>.tar[.gz] if 18dcb3fd79SLei YUunspecified. 19dcb3fd79SLei YU(For example, 20dcb3fd79SLei YU * "generate-tar -i squashfs my.pnor" would generate 217bd45a30SAdriana Kobylak $(pwd)/my.pnor.squashfs.tar 22dcb3fd79SLei YU * "generate-tar -i static my.pnor" would generate 237bd45a30SAdriana Kobylak$(pwd)/my.pnor.static.tar.gz) 24dcb3fd79SLei YU-s, --sign <path> Sign the image. The optional path argument specifies 25dcb3fd79SLei YUthe private key file. Defaults to the bash variable 26dcb3fd79SLei YUPRIVATE_KEY_PATH if available, or else uses the 27dcb3fd79SLei YUopen-source private key in this script. 28647d6134SLei YU-m, --machine <name> Optionally specify the target machine name of this 29647d6134SLei YUimage. 30dcb3fd79SLei YU-h, --help Display this help text and exit. 31dcb3fd79SLei YU' 32dcb3fd79SLei YU 33dcb3fd79SLei YUprivate_key=$'-----BEGIN PRIVATE KEY----- 34*cb3de146SRashmica GuptaMIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggkqAgEAAoICAQDO7vWM6ZOylO6T 35*cb3de146SRashmica GuptalxDiRWgKCFauAxMVM4A7NmgZxfV73xqTzAtIzzF9CIKUEhqMT4LhNy1rU2oUUivH 36*cb3de146SRashmica Gupta4BZO2oC6yFafEPVla2oYAeWtXJmQTixYgJplKQCtLzFtb57DQJpl9Od0RVFC61yg 37*cb3de146SRashmica Gupta4LihsiENnRjncLPP7OkL68ssiELu+WxazDtewmVYQEHOMWQa2zDh9yrWsblLAyo4 38*cb3de146SRashmica GuptagsG9rdwWjqIUnZkoeJuT7zks4Jes4qAtQUuZhCxMcvwvOq8od3e4nLVFnyUOGMpE 39*cb3de146SRashmica GuptajdDDGddKh5e+9BJGqkfsLCT9UFTYi62Ifuxl1Gp963cZLapJS0CneHIrG3gapiCO 40*cb3de146SRashmica Guptaea4TH/xySfts2jpl7DnEIUo3Qs0rZrOLQDLVVXvRJvHdsVoZcSRCD8Jf0YTQ6tT7 41*cb3de146SRashmica Guptaj3ejUOH8j3DGkgKRHGtH7yyCgmDyPYVQdEu3q4E1NBwODAyxppYGBqkwpSGRnf6q 42*cb3de146SRashmica GuptaE6i5rQJuoPCm3rb9ZmoHVzeb8HW3ofYfNnZNuae/2LdEtJ/cFs8ILXP5AKiaKpmS 43*cb3de146SRashmica GuptaH4GB8GUcgRMITGI1pcXhevO2wHi0ReJkme+m5GpuVIg9LpTs6YvvNoFeu6ux7up/ 44*cb3de146SRashmica GuptaTjTa+Zdy3tLUZvvIIlS2Asu32uiGBFjZ2WiLeHq+ScaDsSyEJQkoYLqv+3MoPKhy 45*cb3de146SRashmica GuptaiX4yanZCwG3yx68RDe9qQBt6WXqAEwIDAQABAoICAA6OxAqKQiA9lv0eEwuAC34t 46*cb3de146SRashmica GuptaMP/j6ntC2MIRpUgu44K34tRD9gVEwjwEFb+Z+HEnhNMYQSM8RomwcDELBDa+63B4 47*cb3de146SRashmica GuptaeJOPK1xbrqaKt6A3E/yRa1A8l+AG/uuwFr+WqyocSOBkVsYYvEtDaIxO0t5ZPDcL 48*cb3de146SRashmica Guptadr2NcbDuf0Sd7XiwC1lphaRrmr+jWGLZfmellN/IzMsQytw4u4rZ6aX5GO0hpoqV 49*cb3de146SRashmica GuptatTRTE/vDZFqHaVPNZw48ET2tysY9hKpKKpCeBcWIhg0gRSZlOEOiHdStz2JyVnGB 50*cb3de146SRashmica GuptaUX0XCZQcFZw5TM7fUGC9jtM77qCJTYaXQpUsX77xQtalRA7hS1VAm6i6SbNBvE4j 51*cb3de146SRashmica Guptale2JWBmOCbh9A/Dqnxh/3R2ZpsbffMG3O4KLkObquP8QGsItxwZYm4Bo37/HS6ki 52*cb3de146SRashmica Gupta1Ilym014DUT1+mTybi+2TjlPgh2LeECo1lbgFRJ/p9Vs7TJV2jeVPKDHF72cVvp2 53*cb3de146SRashmica GuptaLy6dGQVtBPz7/HpvxwYA5TJstNWgiU1sZPwgVzhgeZEKt5DO3Da6DVoXt96/tHk4 54*cb3de146SRashmica Gupta577MA9P4qYLJldq5rfFW3IeyGUjLZ1yLmmDWj2Hz2IQe/YqrHHQH5UO6xxhrjuCa 55*cb3de146SRashmica GuptaFrAOv7wJxmmbhZ9AptmR0PnmTU79LM8gxyNY9nn0R+XMJd/3UvrrjzJWw+LUGdhC 56*cb3de146SRashmica GuptazG0pF0JGMb71wHwlmmUpAoIBAQDyUHAcpgWtCl70qVpHnAG6WnsRP6ZS0dtBjqnN 57*cb3de146SRashmica Guptal9GachlNLOyQHfKcs7Vj7dkrcumSTbZ7zzgsazQcwfJMEvVq2RS8iTrtKAq+yYmj 58*cb3de146SRashmica GuptauejaJ3gAuiaU5Shv9PL+P25zGlwJtqEADYjiSrzO1ZRgM1M31tlH7f0wjYIrV6LP 59*cb3de146SRashmica Gupta5P5HYFVDFujsiWY9oUZ+PFaCWPRQ2P47zF3ocbiqD9TbFSwNfq5B2WPLCURExQAh 60*cb3de146SRashmica GuptaXT/GH8Devz2M79CWKjvDMQutZ8dcLZx6JNhpre5JoNbAxE2u9jIM++srSb41zArE 61*cb3de146SRashmica Gupta2lcy2tqNAWJV5jhFz5DZ451kvz7AKLaehWYj7D+TvX4V4UwpAoIBAQDanvWQCoop 62*cb3de146SRashmica GuptaLoh5s5tYwHB/iFE+jzVvyrytfRcDIjrBaCDCQrObgh/fllk44h9DpKHbM4nYlMpU 63*cb3de146SRashmica GuptaGXOsQCVkE/SiJakzeXfoecCJ3ebp+mlBILs79AWlfETJFLx1FKJQOQoraoICVFxx 64*cb3de146SRashmica GuptajcI/OvGlABRLvRYhNnq22//IgLlyKWfO0yS6FASIjriIjDwibKZqHt+DJ98Lv2d+ 65*cb3de146SRashmica Gupta1fsOw/Ai7e2e3nK0+2vmXusZAwpcPuTYb+5LOnHE7GbPecuM22BSTiUAekoHq3/k 66*cb3de146SRashmica GuptafdYw+od4B4BJB0bAnRVu7y+TQXRkZ462RvP05AYXUzudjknv48mFuBslrybr3f50 67*cb3de146SRashmica GuptaaIwtFADeJrHbAoIBAQCYcEwnabaWZrjX+BZoiFd58eQMNNugrI7fzi06vrDJFdCf 68*cb3de146SRashmica GuptaAY0NGRoAxPlvFTmTIOaZ+LO9bd5r60FMeiLBAwhLoKdv+HEOsysXXVhunM1FOKFA 69*cb3de146SRashmica Gupta69rLvuJSlGmt0x/b35BZOABPNTSRD+15vVlrr75BmbL1kl2/BrcGJ0qwuOHS62KY 70*cb3de146SRashmica GuptaIziDXejpCqV7UuAlfmqs1eYSnn3RdoFy0yTYcphVIQXlPSqPl5PQI5LyamRtcpp2 71*cb3de146SRashmica GuptaRx8ko9W4MneIUzmCbJA5iCQxny5aRWZsAXg4qwYn9JAGJRGMGQdFdsirkKRcxNvK 72*cb3de146SRashmica Gupta6zz+xydNm8gHmy7wK3QBlVtVnJxmKwDQI9zHTQYJAoIBAQDVKrXJ81zv9r1/3U8V 73*cb3de146SRashmica Gupta5N5MnACL/VtfW9FJYHU1ywR7XSrEAAHdGa42dwUcX++YJ0ji0YgRNFNsWTzesdVD 74*cb3de146SRashmica GuptalemsyQgIduIiPcUtKL9lWZOTu3SVasSurVLstllj1/DERDnUR4/o8ZUJ6+2Bddn0 75*cb3de146SRashmica GuptaxvUDPKX9UH+rGSx4tnscA5+CnYJsJeSdunvYONTRxBsn0l6iJhhn/gPOOpsHtKnL 76*cb3de146SRashmica GuptahS9y/vfd3GFDST33L23EsFa3a7xwgdY460D8AIgnGij7V9Lgel0AyYp0ovZc34uD 77*cb3de146SRashmica Guptaz9yYWI32dbRWbMZ40RPKaudOeDSbjlMaH0A7ymfxjqwKxI9D2VscFWNs4hv8QErw 78*cb3de146SRashmica GuptaUc6NAoIBAQCmWWyARU/x4m7K4vNAWjD2Qx6R7PAdLs/6ZBqWw0RSpRHlYr73Qggw 79*cb3de146SRashmica GuptadCK+LrsR0O7y1KW2WUfrJmzHEdFQEYcZ1vZWeN85dMLVhYmazSXlaIegRE4FmMUa 80*cb3de146SRashmica GuptaDbzViUJA60Y4D/l6QWqdhxdZZe81QgqyLPXAv/e5esxRIi8yvEYhCx4pq7QtWYBm 81*cb3de146SRashmica GuptatvQnPaZd8emlKARivF2ecGDlWzhf4NotDDtFRT4jOHZKUC58uVjbiXJ445Vimqlb 82*cb3de146SRashmica GuptaDa7noVGwDQ93Ib1qyAilzFY5gWDeMyCnSQpnlVRHQ/8vlwLDsZs1kVau6k8WlcpM 83*cb3de146SRashmica GuptaJbmuCRNy7YvALVTzyQsQ4yw87BoONt1L 84dcb3fd79SLei YU-----END PRIVATE KEY----- 85dcb3fd79SLei YU' 86dcb3fd79SLei YU 87dcb3fd79SLei YU# Reference the ffs structures at: 88dcb3fd79SLei YU# https://github.com/open-power/hostboot/blob/master/src/usr/pnor/common/ffs_hb.H 89dcb3fd79SLei YU# https://github.com/open-power/hostboot/blob/master/src/usr/pnor/ffs.h 907bd45a30SAdriana Kobylakffs_entry_size=128 917bd45a30SAdriana Kobylakvercheck_offset=112 92dcb3fd79SLei YUdo_sign=false 937bd45a30SAdriana KobylakPRIVATE_KEY_PATH=${PRIVATE_KEY_PATH:-} 94dcb3fd79SLei YUprivate_key_path="${PRIVATE_KEY_PATH}" 95dcb3fd79SLei YUimage_type="" 96dcb3fd79SLei YUoutfile="" 97dcb3fd79SLei YUdeclare -a partitions=() 98dcb3fd79SLei YUtocfile="pnor.toc" 99647d6134SLei YUmachine_name="" 100dcb3fd79SLei YU 101dcb3fd79SLei YUwhile [[ $# -gt 0 ]]; do 102dcb3fd79SLei YU key="$1" 103dcb3fd79SLei YU case $key in 104dcb3fd79SLei YU -i|--image) 105dcb3fd79SLei YU image_type="$2" 106dcb3fd79SLei YU shift 2 107dcb3fd79SLei YU ;; 108dcb3fd79SLei YU -f|--file) 109dcb3fd79SLei YU outfile="$2" 110dcb3fd79SLei YU shift 2 111dcb3fd79SLei YU ;; 112dcb3fd79SLei YU -s|--sign) 113dcb3fd79SLei YU do_sign=true 1147bd45a30SAdriana Kobylak if [[ -n "${2}" && "${2}" != -* ]]; then 115dcb3fd79SLei YU private_key_path="$2" 116dcb3fd79SLei YU shift 2 117dcb3fd79SLei YU else 118dcb3fd79SLei YU shift 1 119dcb3fd79SLei YU fi 120dcb3fd79SLei YU ;; 121647d6134SLei YU -m|--machine) 122647d6134SLei YU machine_name="$2" 123647d6134SLei YU shift 2 124647d6134SLei YU ;; 125dcb3fd79SLei YU -h|--help) 126dcb3fd79SLei YU echo "$help" 127dcb3fd79SLei YU exit 128dcb3fd79SLei YU ;; 129dcb3fd79SLei YU *) 130dcb3fd79SLei YU pnorfile="$1" 131dcb3fd79SLei YU shift 1 132dcb3fd79SLei YU ;; 133dcb3fd79SLei YU esac 134dcb3fd79SLei YUdone 135dcb3fd79SLei YU 136dcb3fd79SLei YUif [ ! -f "${pnorfile}" ]; then 137dcb3fd79SLei YU echo "Please enter a valid PNOR file." 138dcb3fd79SLei YU echo "$help" 139dcb3fd79SLei YU exit 1 140dcb3fd79SLei YUfi 141dcb3fd79SLei YU 142dcb3fd79SLei YUif [[ "${image_type}" == "squashfs" ]]; then 143dcb3fd79SLei YU echo "Will generate squashfs image for VPNOR" 144dcb3fd79SLei YUelif [[ "${image_type}" == "static" ]]; then 145dcb3fd79SLei YU echo "Will use static image for PNOR" 146dcb3fd79SLei YUelse 147dcb3fd79SLei YU echo "Please specify the image type, \"squashfs\" or \"static\"" 148dcb3fd79SLei YU echo 149dcb3fd79SLei YU echo "$help" 150dcb3fd79SLei YU exit 1 151dcb3fd79SLei YUfi 152dcb3fd79SLei YU 153dcb3fd79SLei YUif [[ -z $outfile ]]; then 154dcb3fd79SLei YU if [[ ${pnorfile##*.} == "pnor" ]]; then 1557bd45a30SAdriana Kobylak outfile=$(pwd)/${pnorfile##*/}.$image_type.tar 156dcb3fd79SLei YU else 1577bd45a30SAdriana Kobylak outfile=$(pwd)/${pnorfile##*/}.pnor.$image_type.tar 158dcb3fd79SLei YU fi 159dcb3fd79SLei YU if [[ "${image_type}" == "static" ]]; then 160dcb3fd79SLei YU # Append .gz so the tarball is compressed 161dcb3fd79SLei YU outfile=$outfile.gz 162dcb3fd79SLei YU fi 163dcb3fd79SLei YUelse 164dcb3fd79SLei YU if [[ $outfile != /* ]]; then 1657bd45a30SAdriana Kobylak outfile=$(pwd)/$outfile 166dcb3fd79SLei YU fi 167dcb3fd79SLei YUfi 168dcb3fd79SLei YU 169dcb3fd79SLei YU 1707bd45a30SAdriana Kobylakscratch_dir=$(mktemp -d) 17100d8ade5SLei YU# Remove the temp directory on exit. 17200d8ade5SLei YU# The files in the temp directory may contain read-only files, so add 17300d8ade5SLei YU# --interactive=never to skip the prompt. 1747bd45a30SAdriana Kobylaktrap '{ rm -r --interactive=never ${scratch_dir}; }' EXIT 175dcb3fd79SLei YU 176dcb3fd79SLei YUif [[ "${do_sign}" == true ]]; then 177dcb3fd79SLei YU if [[ -z "${private_key_path}" ]]; then 178dcb3fd79SLei YU private_key_path=${scratch_dir}/OpenBMC.priv 179dcb3fd79SLei YU echo "${private_key}" > "${private_key_path}" 180dcb3fd79SLei YU echo "Image is NOT secure!! Signing with the open private key!" 181dcb3fd79SLei YU else 182dcb3fd79SLei YU if [[ ! -f "${private_key_path}" ]]; then 183dcb3fd79SLei YU echo "Couldn't find private key ${private_key_path}." 184dcb3fd79SLei YU exit 1 185dcb3fd79SLei YU fi 186dcb3fd79SLei YU 187dcb3fd79SLei YU echo "Signing with ${private_key_path}." 188dcb3fd79SLei YU fi 189dcb3fd79SLei YU 190dcb3fd79SLei YU public_key_file=publickey 191dcb3fd79SLei YU public_key_path=${scratch_dir}/$public_key_file 1927bd45a30SAdriana Kobylak openssl pkey -in "${private_key_path}" -pubout -out "${public_key_path}" 193dcb3fd79SLei YUfi 194dcb3fd79SLei YU 195dcb3fd79SLei YUecho "Parsing PNOR TOC..." 196dcb3fd79SLei YU 197851bc064SAdriana Kobylakpnor_dir="${scratch_dir}/pnor" 1987bd45a30SAdriana Kobylakmkdir "${pnor_dir}" 199851bc064SAdriana Kobylak 2007bd45a30SAdriana Kobylakpflash --partition=part --read="${pnor_dir}"/part -F "${pnorfile}" 2017bd45a30SAdriana Kobylakpflash --partition=VERSION --read="${pnor_dir}"/VERSION -F "${pnorfile}" 2027bd45a30SAdriana Kobylakversion_size=$(wc -c "${pnor_dir}"/VERSION | cut -d' ' -f 1) 2037bd45a30SAdriana Kobylakmagic_number=$(xxd -p -l 4 "${pnor_dir}"/VERSION) 204dcb3fd79SLei YU# Check if VERSION is signed. A signed version partition will have an extra 205dcb3fd79SLei YU# 4K header starting with the magic number 0x17082011, see: 206dcb3fd79SLei YU# https://github.com/open-power/skiboot/blob/master/libstb/container.h#L47 2077bd45a30SAdriana Kobylakif [ "$version_size" == "8192" ] && [ "$magic_number" == "17082011" ]; then 208dcb3fd79SLei YU # Advance past the STB header (4K, indexed from 1) 2097bd45a30SAdriana Kobylak cp "${pnor_dir}"/VERSION "${pnor_dir}"/VERSION_FULL 2107bd45a30SAdriana Kobylak tail --bytes=+4097 "${pnor_dir}"/VERSION_FULL > "${pnor_dir}"/VERSION 211dcb3fd79SLei YUfi 212dcb3fd79SLei YU{ 2137bd45a30SAdriana Kobylak version=$(head -n 1 "${pnor_dir}"/VERSION) 214dcb3fd79SLei YU echo "version=$version" 2157bd45a30SAdriana Kobylak # shellcheck disable=SC2005,SC2046 # Need the echo to remove new lines, same 2167bd45a30SAdriana Kobylak # reason for not quoting the tail command 2177bd45a30SAdriana Kobylak extended_version=$(echo $(tail -n +2 "${pnor_dir}"/VERSION)|tr ' ' ',') 218dcb3fd79SLei YU echo "extended_version=$extended_version" 2197bd45a30SAdriana Kobylak while read -r line; do 220dcb3fd79SLei YU if [[ $line == "ID="* ]]; then 221dcb3fd79SLei YU # This line looks like 222dcb3fd79SLei YU # "ID=05 MVPD 000d9000..00169000 (actual=00090000) [ECC]" 223dcb3fd79SLei YU read -r -a fields <<< "$line" 224dcb3fd79SLei YU 225dcb3fd79SLei YU id=${fields[0]##*=} 2267bd45a30SAdriana Kobylak offset=$((ffs_entry_size * 10#${id} + vercheck_offset)) 2277bd45a30SAdriana Kobylak vercheck=$(xxd -p -l 0x1 -seek ${offset} "${pnor_dir}"/part) 2287bd45a30SAdriana Kobylak # shellcheck disable=SC2155 # Need the export in the same line to avoid 2297bd45a30SAdriana Kobylak # pflash error 2307bd45a30SAdriana Kobylak export flags=$(pflash --detail=$((10#$id)) -F "${pnorfile}" | grep "\[" | 231dcb3fd79SLei YU sed 's/....$//' | tr '\n' ',' | sed 's/.$//') 232dcb3fd79SLei YU if [[ $flags != "" ]]; then 233dcb3fd79SLei YU flags=,$flags 234dcb3fd79SLei YU fi 235dcb3fd79SLei YU 2367bd45a30SAdriana Kobylak if [[ $(echo "$flags" | grep "READONLY") == "" && 2377bd45a30SAdriana Kobylak $(echo "$flags" | grep "PRESERVED") == "" ]]; then 238dcb3fd79SLei YU flags=$flags,READWRITE 239dcb3fd79SLei YU fi 240dcb3fd79SLei YU 241dcb3fd79SLei YU # Need the partition ID, name, start location, end location, and flags 242dcb3fd79SLei YU echo "partition${id}=${fields[1]},${fields[2]/../,},${vercheck}${flags}" 243dcb3fd79SLei YU 244dcb3fd79SLei YU # Save the partition name 2457bd45a30SAdriana Kobylak partitions+=("${fields[1]}") 246dcb3fd79SLei YU fi 247dcb3fd79SLei YU # Don't need the BACKUP_PART partition 2487bd45a30SAdriana Kobylak done < <(pflash --info -F "${pnorfile}" | grep -v "BACKUP") 2497bd45a30SAdriana Kobylak} > "${pnor_dir}"/${tocfile} 250dcb3fd79SLei YU 251dcb3fd79SLei YUfor partition in "${partitions[@]}"; do 252dcb3fd79SLei YU echo "Reading ${partition}..." 2537bd45a30SAdriana Kobylak pflash --partition="${partition}" \ 2547bd45a30SAdriana Kobylak --read="${pnor_dir}"/"${partition}" \ 2557bd45a30SAdriana Kobylak -F "${pnorfile}" 256dcb3fd79SLei YUdone 257dcb3fd79SLei YU 258dcb3fd79SLei YUmanifest_location="MANIFEST" 259dcb3fd79SLei YUfiles_to_sign="$manifest_location $public_key_file" 260dcb3fd79SLei YU 261dcb3fd79SLei YU# Go to scratch_dir 262dcb3fd79SLei YU 263dcb3fd79SLei YUif [[ "${image_type}" == "squashfs" ]]; then 264dcb3fd79SLei YU echo "Creating SquashFS image..." 265851bc064SAdriana Kobylak # Prepare pnor file in ${pnor_dir} 266851bc064SAdriana Kobylak cd "${pnor_dir}" 26785f25407SAdriana Kobylak # Set permissions of partition files to read only 2687bd45a30SAdriana Kobylak chmod 440 -- * 269095b1a02SAdriana Kobylak # shellcheck disable=SC2048,SC2086 # Do not quote partitions since it lists 270095b1a02SAdriana Kobylak # multiple files and mksquashfs would assume to be a single file name within 271095b1a02SAdriana Kobylak # quotes 2727bd45a30SAdriana Kobylak mksquashfs ${tocfile} ${partitions[*]} "${scratch_dir}"/pnor.xz.squashfs -all-root 273dcb3fd79SLei YU cd "${scratch_dir}" 274dcb3fd79SLei YU files_to_sign+=" pnor.xz.squashfs" 275dcb3fd79SLei YUelse 2767bd45a30SAdriana Kobylak cp "${pnorfile}" "${scratch_dir}" 277dcb3fd79SLei YU cd "${scratch_dir}" 2787bd45a30SAdriana Kobylak files_to_sign+=" $(basename "${pnorfile}")" 279dcb3fd79SLei YUfi 280dcb3fd79SLei YU 281dcb3fd79SLei YUecho "Creating MANIFEST for the image" 282dcb3fd79SLei YUecho -e "purpose=xyz.openbmc_project.Software.Version.VersionPurpose.Host\nversion=$version\n\ 283dcb3fd79SLei YUextended_version=$extended_version" >> $manifest_location 284dcb3fd79SLei YU 2857bd45a30SAdriana Kobylakif [[ -n "${machine_name}" ]]; then 286647d6134SLei YU echo -e "MachineName=${machine_name}" >> $manifest_location 287647d6134SLei YUfi 288647d6134SLei YU 289dcb3fd79SLei YUif [[ "${do_sign}" == true ]]; then 290dcb3fd79SLei YU private_key_name=$(basename "${private_key_path}") 291dcb3fd79SLei YU key_type="${private_key_name%.*}" 292dcb3fd79SLei YU echo KeyType="${key_type}" >> $manifest_location 293dcb3fd79SLei YU echo HashType="RSA-SHA256" >> $manifest_location 294dcb3fd79SLei YU 295dcb3fd79SLei YU for file in $files_to_sign; do 2967bd45a30SAdriana Kobylak openssl dgst -sha256 -sign "${private_key_path}" -out "${file}.sig" "$file" 297dcb3fd79SLei YU done 298dcb3fd79SLei YU 299dcb3fd79SLei YU additional_files="*.sig" 300dcb3fd79SLei YUfi 301dcb3fd79SLei YU 302dcb3fd79SLei YUif [[ "${image_type}" == "squashfs" ]]; then 303dcb3fd79SLei YU echo "Generating tarball to contain the SquashFS image and its MANIFEST" 3047bd45a30SAdriana Kobylak # shellcheck disable=SC2086 # Do not quote the files variables since they list 3057bd45a30SAdriana Kobylak # multiple files and tar would assume to be a single file name within quotes 3067bd45a30SAdriana Kobylak tar -cvf "$outfile" $files_to_sign $additional_files 307dcb3fd79SLei YU echo "SquashFSTarball at ${outfile}" 308dcb3fd79SLei YUelse 3097bd45a30SAdriana Kobylak # shellcheck disable=SC2086 # Do not quote the files variables since they list 3107bd45a30SAdriana Kobylak # multiple files and tar would assume to be a single file name within quotes 3117bd45a30SAdriana Kobylak tar -czvf "$outfile" $files_to_sign $additional_files 312dcb3fd79SLei YU echo "Static layout tarball at $outfile" 313dcb3fd79SLei YUfi 314