Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-packages/blob/main/scripts/sbom.sh # omega-packages aien-dev/omega-packages Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-packages / scripts / sbom.sh` 64 lines ยท 3849 bytes Raw Blame History 1 #!/bin/sh 2 # sbom.sh TREE OMC -- print a minimal SPDX 2.3 JSON SBOM for omc on stdout. 3 # TREE is the unpacked omega-mv- source that omc was born from (scripts/omc-from-seed.sh). 4 # omc is a static ELF with no runtime dependencies, so the SBOM lists only what it is built from: 5 # the pinned source archive and every seed input named in TREE/seed/challenge/expected.txt, each with 6 # the sha256 measured from TREE. Exit 1 when a measured input disagrees with expected.txt. 7 set -eu 8 here=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd) 9 . "$here/pins.env" 10 [ $# -eq 2 ] || { echo "usage: sbom.sh TREE OMC" >&2; exit 2; } 11 tree=$1 omc=$2 12 exp=$tree/seed/challenge/expected.txt 13 [ -r "$exp" ] || { echo "FAIL no $exp" >&2; exit 1; } 14 osha=$(sha256sum "$omc" | cut -d' ' -f1) 15 [ "$osha" = "$OMC_SHA256" ] || { echo "FAIL omc sha256 $osha, pinned $OMC_SHA256" >&2; exit 1; } 16 created=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y-%m-%dT%H:%M:%SZ) 17 18 files= rels= n=0 19 while read -r kind path sha bytes; do 20 [ "$kind" = input ] || continue 21 got=$(sha256sum "$tree/$path" | cut -d' ' -f1) 22 [ "$got" = "$sha" ] || { echo "FAIL $path sha256 $got, expected.txt $sha" >&2; exit 1; } 23 sha1=$(sha1sum "$tree/$path" | cut -d' ' -f1) 24 n=$((n + 1)) 25 id=SPDXRef-File-seed-$n 26 files="$files${files:+,} 27 {\"SPDXID\": \"$id\", \"fileName\": \"./$path\", \"checksums\": [{\"algorithm\": \"SHA256\", \"checksumValue\": \"$got\"}, {\"algorithm\": \"SHA1\", \"checksumValue\": \"$sha1\"}], \"licenseConcluded\": \"Apache-2.0\", \"copyrightText\": \"NOASSERTION\", \"comment\": \"$bytes bytes; seed-chain input, path inside the omega-mv $OMEGA_MV_COMMIT archive\"}" 28 rels="$rels, 29 {\"spdxElementId\": \"SPDXRef-Package-omc\", \"relationshipType\": \"GENERATED_FROM\", \"relatedSpdxElement\": \"$id\"}" 30 done < "$exp" 31 [ "$n" -gt 0 ] || { echo "FAIL no input rows in $exp" >&2; exit 1; } 32 33 cat < hex1 -> asm2 -> om4 -> omc -> omc -> omc."}, 49 {"SPDXID": "SPDXRef-Package-omega-mv", "name": "omega-mv", "versionInfo": "$OMEGA_MV_COMMIT", 50 "supplier": "Organization: aien-dev", 51 "downloadLocation": "https://github.com/aien-dev/omega-mv/archive/$OMEGA_MV_COMMIT.tar.gz", 52 "filesAnalyzed": false, 53 "checksums": [{"algorithm": "SHA256", "checksumValue": "$OMEGA_MV_TARBALL_SHA256"}], 54 "licenseConcluded": "Apache-2.0", "licenseDeclared": "Apache-2.0", "copyrightText": "NOASSERTION", 55 "comment": "Source archive. The files listed below are its seed-chain inputs, measured from the unpacked archive and checked against seed/challenge/expected.txt."} 56 ], 57 "files": [$files 58 ], 59 "relationships": [ 60 {"spdxElementId": "SPDXRef-DOCUMENT", "relationshipType": "DESCRIBES", "relatedSpdxElement": "SPDXRef-Package-omc"}, 61 {"spdxElementId": "SPDXRef-Package-omc", "relationshipType": "GENERATED_FROM", "relatedSpdxElement": "SPDXRef-Package-omega-mv"}$rels 62 ] 63 } 64 EOF