Gina Dimino | 391dde6 | 2017-11-15 13:48:52 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Build the CDD HTML and PDF from the source files. |
| 4 | # From the root directory run: |
| 5 | # ./cdd_gen.sh --version xx --branch xx |
| 6 | # |
| 7 | # where version is the version number and branch is the name of the AOSP branch. |
| 8 | # |
| 9 | # To run this script, you must install the jinja2 and wkhtmltopdf packages |
| 10 | # using the apt-get install command. |
| 11 | # |
| 12 | |
| 13 | POSITIONAL=() |
| 14 | while [[ $# -gt 0 ]] |
| 15 | do |
| 16 | key="$1" |
| 17 | |
| 18 | case $key in |
| 19 | -v|--version) |
| 20 | VERSION="$2" |
| 21 | shift # past argument |
| 22 | shift # past value |
| 23 | ;; |
| 24 | -b|--branch) |
| 25 | BRANCH="$2" |
| 26 | shift # past argument |
| 27 | shift # past value |
| 28 | ;; |
| 29 | --default) |
| 30 | DEFAULT=YES |
| 31 | shift # past argument |
| 32 | ;; |
| 33 | *) # unknown option |
| 34 | POSITIONAL+=("$1") # save it in an array for later |
| 35 | shift # past argument |
| 36 | ;; |
| 37 | esac |
| 38 | done |
| 39 | set -- "${POSITIONAL[@]}" # restore positional parameters |
| 40 | |
| 41 | echo "VERSION = ${VERSION}" |
| 42 | echo "BRANCH = ${BRANCH}" |
| 43 | |
| 44 | current_time=$(date "+%m.%d-%H.%M") |
| 45 | echo "Current Time : $current_time" |
| 46 | |
| 47 | filename="android-${VERSION}-cdd-${current_time}" |
| 48 | echo "$filename" |
| 49 | |
| 50 | if [ -z "${VERSION+x}" ] || [ -z "${BRANCH+x}" ]; |
| 51 | then |
| 52 | echo "No variables!" |
| 53 | python make_cdd.py --output $filename; |
| 54 | else |
| 55 | echo "Variables!" |
| 56 | python make_cdd.py --version $VERSION --branch $BRANCH --output $filename; |
| 57 | fi |
| 58 | |
| 59 | wkhtmltopdf -B 1in -T 1in -L .75in -R .75in page $filename.html --footer-html source/android-cdd-footer.html /tmp/$filename-body.pdf |
| 60 | wkhtmltopdf -s letter -B 0in -T 0in -L 0in -R 0in cover source/android-cdd-cover.html /tmp/$filename-cover.pdf |