fast-forward-libwebrtc.sh (5013B)
1 #!/bin/bash 2 3 function show_error_msg() 4 { 5 echo "*** ERROR *** $? line $1 $0 did not complete successfully!" 6 echo "$ERROR_HELP" 7 } 8 ERROR_HELP="" 9 10 # Print an Error message if `set -eE` causes the script to exit due to a failed command 11 trap 'show_error_msg $LINENO' ERR 12 13 source dom/media/webrtc/third_party_build/use_config_env.sh 14 15 # If DEBUG_GEN is set all commands should be printed as they are executed 16 if [ ! "x$DEBUG_GEN" = "x" ]; then 17 set -x 18 fi 19 20 if [ "x$MOZ_LIBWEBRTC_SRC" = "x" ]; then 21 echo "MOZ_LIBWEBRTC_SRC is not defined, see README.md" 22 exit 23 fi 24 25 if [ -d $MOZ_LIBWEBRTC_SRC ]; then 26 echo "MOZ_LIBWEBRTC_SRC is $MOZ_LIBWEBRTC_SRC" 27 else 28 echo "Path $MOZ_LIBWEBRTC_SRC is not found, see README.md" 29 exit 30 fi 31 32 if [ "x$MOZ_LIBWEBRTC_BRANCH" = "x" ]; then 33 echo "MOZ_LIBWEBRTC_BRANCH is not defined, see README.md" 34 exit 35 fi 36 37 RESUME_FILE=$STATE_DIR/fast_forward.resume 38 RESUME="" 39 if [ -f $RESUME_FILE ]; then 40 RESUME=`tail -1 $RESUME_FILE` 41 fi 42 43 GIT_IS_REBASING=`cd $MOZ_LIBWEBRTC_SRC && git status | grep "interactive rebase in progress" | wc -l | tr -d " " || true` 44 if [ "x$GIT_IS_REBASING" != "x0" ]; then 45 echo "There is currently a git rebase operation in progress at $MOZ_LIBWEBRTC_SRC." 46 echo "Please resolve the rebase before attempting to continue the fast-forward" 47 echo "operation." 48 exit 1 49 fi 50 51 find_repo_type 52 echo "repo type: $MOZ_REPO" 53 54 if [ "x$RESUME" = "x" ]; then 55 SKIP_TO="run" 56 # Check for modified files and abort if present. 57 if [ "x$MOZ_REPO" = "xgit" ]; then 58 MODIFIED_FILES=`git status --porcelain third_party/libwebrtc` 59 else 60 MODIFIED_FILES=`hg status --exclude "third_party/libwebrtc/**.orig" third_party/libwebrtc` 61 fi 62 if [ "x$MODIFIED_FILES" = "x" ]; then 63 # Completely clean the checkout before proceeding 64 if [ "x$MOZ_REPO" = "xgit" ]; then 65 git restore --staged :/ 66 git restore :/ 67 git clean -fd 68 else 69 hg update -C -r . 70 hg purge 71 fi 72 else 73 echo "There are modified files in the checkout. Cowardly aborting!" 74 echo "$MODIFIED_FILES" 75 exit 1 76 fi 77 else 78 SKIP_TO=$RESUME 79 if [ "x$MOZ_REPO" = "xgit" ]; then 80 git restore third_party/libwebrtc/README.mozilla.last-vendor &> /dev/null 81 else 82 hg revert -C third_party/libwebrtc/README.mozilla.last-vendor &> /dev/null 83 fi 84 fi 85 86 find_base_commit 87 find_next_commit 88 89 # After this point: 90 # * eE: All commands should succeed. 91 # * u: All variables should be defined before use. 92 # * o pipefail: All stages of all pipes should succeed. 93 set -eEuo pipefail 94 95 echo " MOZ_LIBWEBRTC_BASE: $MOZ_LIBWEBRTC_BASE" 96 echo "MOZ_LIBWEBRTC_NEXT_BASE: $MOZ_LIBWEBRTC_NEXT_BASE" 97 echo " RESUME: $RESUME" 98 echo "SKIP_TO: $SKIP_TO" 99 100 REBASE_HELP=$" 101 The rebase operation onto $MOZ_LIBWEBRTC_NEXT_BASE has failed. Please 102 resolve all the rebase conflicts. To fix this issue, you will need to 103 jump to the github repo at $MOZ_LIBWEBRTC_SRC . 104 When the github rebase is complete, re-run the script to resume the 105 fast-forward process. 106 " 107 function rebase_mozlibwebrtc_stack { 108 echo "-------" 109 echo "------- Rebase $MOZ_LIBWEBRTC_BRANCH to $MOZ_LIBWEBRTC_NEXT_BASE" 110 echo "-------" 111 ERROR_HELP=$REBASE_HELP 112 ( cd $MOZ_LIBWEBRTC_SRC && \ 113 git checkout -q $MOZ_LIBWEBRTC_BRANCH && \ 114 git rebase $MOZ_LIBWEBRTC_NEXT_BASE \ 115 &> $LOG_DIR/log-rebase-moz-libwebrtc.txt \ 116 ) 117 ERROR_HELP="" 118 } 119 120 function write_commit_message_file { 121 echo "-------" 122 echo "------- Write commit message file ($TMP_DIR/commit_msg.txt)" 123 echo "-------" 124 UPSTREAM_LONG_SHA=`cd $MOZ_LIBWEBRTC_SRC && \ 125 git show --format='%H' --no-patch $MOZ_LIBWEBRTC_NEXT_BASE` 126 echo "Bug $MOZ_FASTFORWARD_BUG - Vendor libwebrtc from $MOZ_LIBWEBRTC_NEXT_BASE" \ 127 > $TMP_DIR/commit_msg.txt 128 echo "" >> $TMP_DIR/commit_msg.txt 129 if [ -f $STATE_DIR/$MOZ_LIBWEBRTC_NEXT_BASE.no-op-cherry-pick-msg ]; then 130 cat $STATE_DIR/$MOZ_LIBWEBRTC_NEXT_BASE.no-op-cherry-pick-msg >> $TMP_DIR/commit_msg.txt 131 echo "" >> $TMP_DIR/commit_msg.txt 132 fi 133 echo "Upstream commit: https://webrtc.googlesource.com/src/+/$UPSTREAM_LONG_SHA" >> $TMP_DIR/commit_msg.txt 134 (cd $MOZ_LIBWEBRTC_SRC && \ 135 git show --name-only $MOZ_LIBWEBRTC_NEXT_BASE | grep "^ ") >> $TMP_DIR/commit_msg.txt 136 } 137 138 if [ $SKIP_TO = "run" ]; then 139 echo "resume2" > $RESUME_FILE 140 rebase_mozlibwebrtc_stack; 141 fi 142 143 if [ $SKIP_TO = "resume2" ]; then SKIP_TO="run"; fi 144 if [ $SKIP_TO = "run" ]; then 145 echo "resume3" > $RESUME_FILE 146 write_commit_message_file; 147 fi 148 149 if [ $SKIP_TO = "resume3" ]; then SKIP_TO="run"; fi 150 if [ $SKIP_TO = "run" ]; then 151 ./mach python dom/media/webrtc/third_party_build/vendor_and_commit.py \ 152 --repo-path $MOZ_LIBWEBRTC_SRC \ 153 --script-path $SCRIPT_DIR \ 154 --commit-msg-path $TMP_DIR/commit_msg.txt \ 155 --commit-sha $MOZ_LIBWEBRTC_NEXT_BASE 156 fi 157 158 echo "" > $RESUME_FILE 159 160 # now that we've committed the vendored code, we can delete the 161 # no-op commit tracking file if it exists. 162 if [ -f $STATE_DIR/$MOZ_LIBWEBRTC_NEXT_BASE.no-op-cherry-pick-msg ]; then 163 rm $STATE_DIR/$MOZ_LIBWEBRTC_NEXT_BASE.no-op-cherry-pick-msg 164 fi