| #! /bin/bash |
| |
| set -euo pipefail |
| |
| ANC_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)" |
| SRC_DIR="${ANC_DIR}/src" |
| REPO="third_party/boringssl" |
| |
| fatal() { |
| echo "error: $1" |
| echo "usage: check-integration [integration-repo]" |
| echo |
| echo "Displays current revisions of the BoringSSL repositories. Checks whether the" |
| echo "mirror of upstream matches the revision listed in README.fuchsia in the" |
| echo "ancillary repo. Also checks if the revisions of both the upstream and ancillary" |
| echo "repos match what is listed in the 'integration-repo' manifest. The" |
| echo "'integration-repo' defaults to '\$FUCHSIA_DIR/integration'." |
| exit 1 |
| } |
| |
| # Get the Jiri integration manifest for BoringSSL |
| manifest= |
| if [[ $# -gt 1 ]] ; then |
| fatal "too many arugments" |
| elif [[ $# -eq 1 ]] ; then |
| manifest="$1/fuchsia/${REPO}/boringssl" |
| elif [[ -z "${FUCHSIA_DIR:-}" ]] ; then |
| fatal "FUCHSIA_DIR not set; have you run 'fx set'?" |
| else |
| manifest="${FUCHSIA_DIR}/integration/${REPO}/boringssl" |
| fi |
| if [[ ! -r "${manifest}" ]] ; then |
| fatal "unable to read '${manifest}'" |
| fi |
| |
| # Collect all the revisions |
| anc_git="$(cd ${ANC_DIR} && git rev-list HEAD --max-count=1)" |
| src_git="$(cd ${SRC_DIR} && git rev-list HEAD --max-count=1)" |
| doc_rev="$(grep ${REPO} ${ANC_DIR}/README.fuchsia | sed "s/.*boringssl...//; s/.$//")" |
| anc_int="$(jiri manifest -element=${REPO} -template=\"{{.Revision}}\" ${manifest} | tr -d '"')" |
| src_int="$(jiri manifest -element=${REPO}/src -template=\"{{.Revision}}\" ${manifest} | tr -d '"')" |
| |
| # Display the revisions and compare |
| echo |
| echo "Upstream mirror (${REPO}/src):" |
| echo " git revision: ${src_git}" |
| echo " in README.fuchsia: ${doc_rev}" |
| echo " in integration: ${src_int}" |
| |
| echo |
| echo "Ancillary sources (${REPO}):" |
| echo " git revision: ${anc_git}" |
| echo " in integration: ${anc_int}" |
| |
| echo |
| if [[ "${src_git}" != "${doc_rev}" ]] ; then |
| echo "[!] ${ANC_DIR}/README.fuchsia doesn't match ${SRC_DIR}" |
| echo " BoringSSL is in an inconsistent state; use 'go run roll_boringssl.go'" |
| elif [[ "${src_git}" != "${src_int}" ]] || [[ "${anc_git}" != "${anc_int}" ]] ; then |
| echo "[-] ${manifest} is out-of-date." |
| echo " A roll of the integration repo is needed or pending. Check 'fx pending-commits'" |
| else |
| echo "[+] ${manifest} is up-to-date." |
| fi |