third_party/update_rnp.sh
author Magnus Melin <mkmelin+mozilla@iki.fi>
Thu, 14 May 2020 12:58:52 +0300
changeset 38251 b5cb669844cd935d3ed531893c40391b45948b3b
parent 38204 de5c89a17b436079f55f774e96d459fe7c662124
child 39210 948eac10600f3b01040d96d39a9c97ca221cbc76
permissions -rwxr-xr-x
Bug 1627649 - Unable to use WebSocket in Thunderbird. r=benc DONTBUILD

#!/bin/bash
# This script is in the public domain.
# Script to update the in-tree copy of rnp from github
# Run this within the comm/third_party directory of the source tree.

set -eE
trap 'catch_err $? $LINENO' ERR

function catch_err() {
  echo "Error! $1 at $2"
  echo "Reverting changes."
  hg revert -C rnp/. README.rnp
  # Remove any added files
  hg purge rnp/.
}


if [[ ! -f rnp/moz.build ]]; then
  echo "Missing rnp directory in current path."
  exit 1
fi
if [[ ! -f ../../mach ]]; then
  echo "Cannot find mach at ../../mach"
  exit 1
fi
if [[ -n "$1" ]]; then
  CHECKOUT_REV="$1"
fi
THIRDROC="../../mach python -m thirdroc"

MY_TEMP_DIR=$(mktemp -d -t rnp_update.XXXXXX) || exit 1

RNPgit="${MY_TEMP_DIR}/rnp"
git clone https://github.com/rnpgp/rnp "${RNPgit}"
if [[ -n "${CHECKOUT_REV}" ]]; then
  git -C "${RNPgit}" checkout "${CHECKOUT_REV}"
fi

# Get the latest release from the list of tags
TAGLIST=$(git -C "${RNPgit}" tag --list v[0-9]*)

LATEST_VERSION=$($THIRDROC latest_version $TAGLIST)
REVISION=$(git -C "${RNPgit}" rev-parse --verify HEAD)
TIMESTAMP=$(git -C "${RNPgit}" show -s --format=%ct)

BUGREPORT="https://bugzilla.mozilla.org/enter_bug.cgi?product=Thunderbird"

# Cleanup rnp checkout
rm -rf ${RNPgit}/{.git,.github,.cirrus.yml,.clang-format,.gitignore}
rm -rf ${RNPgit}/{_config.yml,docker.sh,ci,cmake,git-hooks,travis.sh}
rm -rf ${RNPgit}/{Brewfile,CMakeLists.txt}

# Do the switch
rm -rf rnp
mv "${RNPgit}" rnp
# Build version.h/config.h.in
$THIRDROC rnp_source_update rnp/ \
  "${LATEST_VERSION}" \
  "${REVISION}" \
  "${TIMESTAMP}" \
  "${BUGREPORT}"

# Restore moz.build
hg revert rnp/moz.build rnp/Makefile.in rnp/module.ver rnp/rnp.symbols

rm -rf "${MY_TEMP_DIR}"
hg addremove rnp

echo ""
echo "RNP source has been updated. Don't forget to commit the changes"
echo "after reviewing the differences."