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 these packages as shown:
10#   sudo apt-get install wkhtmltopdf
11#   pip install Jinja2
12#   pip install markdown
13#   pip install pytidylib
14#
15
16positional=()
17while [[ $# -gt 0 ]]
18do
19key="$1"
20
21case $key in
22    -v|--version)
23    version="$2"
24    shift # past argument
25    shift # past value
26    ;;
27    -b|--branch)
28    branch="$2"
29    shift # past argument
30    shift # past value
31    ;;
32    --default)
33    default=YES
34    shift # past argument
35    ;;
36    *)    # unknown option
37    positional+=("$1") # save it in an array for later
38    shift # past argument
39    ;;
40esac
41done
42set -- "${positional[@]}" # restore positional parameters
43
44if  [ -z "${version}" ];
45then
46  read -p "Version number: " version
47fi
48
49if  [ -z "${branch+x}" ];
50then
51  read -p "AOSP branch name for revision history: " branch
52fi
53
54echo "version = ${version}"
55echo "branch = ${branch}"
56
57current_date=$(date "+%m-%d")
58echo "Current Date : $current_date"
59
60filename="android-${version}-cdd-${current_date}"
61echo "$filename"
62
63
64python make_cdd.py --version $version --branch $branch --output $filename;
65
66mkdir -p /tmp/$filename
67
68wkhtmltopdf -B 1in -T 1in -L .75in -R .75in page $filename.html --footer-html source/android-cdd-footer.html /tmp/$filename/$filename-body.pdf
69wkhtmltopdf -s letter -B 0in -T 0in -L 0in -R 0in cover source/android-cdd-cover.html /tmp/$filename/$filename-cover.pdf
70
71
72mv $filename.html /tmp/$filename
73mv $filename-devsite.html /tmp/$filename
74
75echo ""
76echo "The generated files have been placed in the /tmp/$filename directory."
77echo "Please copy them to your Google Drive or another more permanent location."
78echo ""
79