Bug 1636240 - Add error trap to update_rnp.sh to revert changes. r=kaie a=wsmwk
authorRob Lemley <rob@thunderbird.net>
Wed, 06 May 2020 15:25:04 -0400
changeset 38143 8d538e189906fbb1d29408184735f3ac4ec52bcb
parent 38142 4b214d7ec3a6489586d335147b1e48ab7f6c4851
child 38144 6b1e598df3175bd2d9cd0893d19a097907971ffe
push id2602
push userkaie@kuix.de
push dateSun, 17 May 2020 18:03:23 +0000
treeherdercomm-beta@f78f85f503c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaie, wsmwk
bugs1636240
Bug 1636240 - Add error trap to update_rnp.sh to revert changes. r=kaie a=wsmwk Trap any errors that happen and run the catch_err function to revert any changes.
third_party/update_rnp.sh
--- a/third_party/update_rnp.sh
+++ b/third_party/update_rnp.sh
@@ -1,14 +1,24 @@
 #!/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 -e
+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
@@ -30,19 +40,16 @@ fi
 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"
 
-# Update the README.rnp file
-# Make a copy in /tmp since macOS sed does not have -i
-
 # 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