blob: 662033c62e7e9809a386e92611658c71b9bd51ac [file] [log] [blame]
Gilles Peskine0f4df8f2021-01-18 20:31:07 +01001#!/bin/sh
2
3set -eu
4
5usage () {
6 cat <<EOF
7Usage: $0 PATH_TO_PSA_CRYPTO_API_TREE
8Update the rendered copy of the PSA Cryptography API specification.
9
101. Check out the desired version of the PSA Crypto API specification.
11 git clone https://github.com/ARMmbed/psa-crypto-api
12 git checkout <TAG>
132. Build the specification.
14 cd psa-crypto-api
15 sudo docker build -t psa_api - <psa-crypto-api/scripts/Dockerfile
Gilles Peskinedf93ecd2022-04-12 18:01:11 +020016 sudo docker run -i -t -u \$(id -u):\$(id -g) -v \$PWD:/var/lib/builds psa_api -c make
Gilles Peskine0f4df8f2021-01-18 20:31:07 +010017 cd ..
183. Copy the rendered files.
19 $0 psa-crypto-api
Gilles Peskineb92fd9c2022-04-12 18:28:42 +0200204. If this is a new numbered version:
21 edit docs/psa/index.md # Add the new version
22 make
23 ln -snf <VERSION> docs/latest
245. Commit the changes.
Gilles Peskinec2db5f02021-01-18 20:36:53 +010025 git add docs/html docs/PSA_Cryptography_API_Specification.pdf
26 git commit
Gilles Peskine0f4df8f2021-01-18 20:31:07 +010027EOF
28}
29
30if [ $# -ne 1 ] || [ "$1" = "--help" ]; then
31 usage
32 exit $(($# != 1))
33fi
34
Gilles Peskine4519de72022-04-07 13:44:25 +020035version=$(sed -n 's/^\(Version[^0-9A-Za-z][^0-9A-Za-z]*\)//p; T; q' "$1/sphinx-build/html/index.html")
36if [ -z "$version" ]; then
37 echo >&2 "Fatal error: unable to determine the version."
38 exit 1
39fi
40if [ ! -d "docs/$version" ]; then
41 mkdir "docs/$version"
42 cat <<EOF
43NOTE: Please update "Past versions" in docs/psa/index.md to add $version
44 then run make.
45
46NOTE: You may need to update the "latest" symbolic link.
47 ln -snf "$version" docs/latest
48EOF
49fi
50
51rsync -a --delete "$1/sphinx-build/html" "docs/$version/"
52rsync -a "$1/sphinx-build/latex/psa_crypto_api.pdf" "docs/$version/PSA_Cryptography_API_Specification.pdf"