#!/bin/bash function show_error_msg() { echo "*** ERROR *** $? line $1 $0 did not complete successfully!" echo "$ERROR_HELP" } ERROR_HELP="" # Print an Error message if `set -eE` causes the script to exit due to a failed command trap 'show_error_msg $LINENO' ERR source dom/media/webrtc/third_party_build/use_config_env.sh echo "MOZ_LIBWEBRTC_SRC: $MOZ_LIBWEBRTC_SRC" # After this point: # * eE: All commands should succeed. # * u: All variables should be defined before use. # * o pipefail: All stages of all pipes should succeed. set -eEuo pipefail CURRENT_DIR=`pwd` cd $MOZ_LIBWEBRTC_SRC MANUAL_INTERVENTION_COMMIT_FILE="$TMP_DIR/manual_commits.txt" rm -f $MANUAL_INTERVENTION_COMMIT_FILE # find the last upstream commit used by the previous update, so we don't # accidentally grab release branch commits that were added after we started # the previous update. LAST_UPSTREAM_COMMIT_SHA=`tail -1 $CURRENT_DIR/third_party/libwebrtc/README.mozilla.last-vendor` echo "previous update's last commit: $LAST_UPSTREAM_COMMIT_SHA" # Find the common commit between our previous work branch and trunk CURRENT_RELEASE_BASE=`git merge-base $LAST_UPSTREAM_COMMIT_SHA master` # Write no-op files for the cherry-picked release branch commits. For more # details on what this is doing, see make_upstream_revert_noop.sh. COMMIT_RANGE="$CURRENT_RELEASE_BASE..$LAST_UPSTREAM_COMMIT_SHA" echo "" echo "Libwebrtc release branch commits are usually cherry-picked from upcoming" echo "commits. Since these upcoming commits will result in near-zero files" echo "changed, hopefully exactly 0, we need to build no-op commit files" echo "so that processing doesn't stop unnecessarily when running the" echo "fast-forward process." echo "Previous update (Bug $MOZ_PRIOR_FASTFORWARD_BUG) release branch commits:" # might be nice to indent this output for better readability git log $COMMIT_RANGE --oneline COMMITS=`git log -r $COMMIT_RANGE --format='%h'` for commit in $COMMITS; do echo "Processing release branch commit $commit for no-op handling" # Don't process the commit if the commit message is missing the customary # line that shows which upstream commit is being cherry-picked. CNT=`git show $commit | grep "cherry picked from commit" | wc -l | tr -d " " || true` if [ $CNT != 1 ]; then # record the commit to list at the end of this script as # 'needing intervention' echo " no cherry-pick info found, skipping commit $commit" echo "$commit" >> $MANUAL_INTERVENTION_COMMIT_FILE continue fi CHERRY_PICK_COMMIT=`git show $commit | grep "cherry picked from commit" | tr -d "()" | awk '{ print $5; }'` # I didn't think this was possible due to the automated tooling on # Google's end, but upstream commit # 847fe7905954f3ae883de2936415ff567aa9039b lists that it cherry-picks # 602b06b1125ea4d107fbfbda7d314b4157c4c74b. However, # 602b06b1125ea4d107fbfbda7d314b4157c4c74b doesn't exist in the repo. # That means we need to verify that we have a valid commit before # processing further. If not found we'll add it to the list of # commits that need manual intervention/verification. CHERRY_PICK_COMMIT_FOUND=`(git cat-file -e $CHERRY_PICK_COMMIT && echo "commit-found") || true` if [ "x$CHERRY_PICK_COMMIT_FOUND" != "xcommit-found" ]; then # record the commit to list at the end of this script as # 'needing intervention' echo " cherry-pick sha ($CHERRY_PICK_COMMIT) in commit message," echo " but, the sha is not found in the libwebrtc repo." echo " skipping commit $commit" echo "$commit" >> $MANUAL_INTERVENTION_COMMIT_FILE continue fi SHORT_SHA=`git show --name-only $CHERRY_PICK_COMMIT --format='%h' | head -1` echo " commit $commit cherry-picks $SHORT_SHA" echo "We already cherry-picked this when we vendored $commit." \ > $STATE_DIR/$SHORT_SHA.no-op-cherry-pick-msg done # This section checks for commits that may have been cherry-picked in # more than one release branch. An example of multiple cherry-picks # across release branches can be seen when starting the following # updates: # Bug 1934695 - updated default_config_env for v132 # Bug 1903098 - updated default_config_env for v126 (this is moz # cherry-pick that is then cherry-picked in the upcoming release # branch) TARGET_RELEASE_BASE=`git merge-base $MOZ_TARGET_UPSTREAM_BRANCH_HEAD master` COMMIT_RANGE="$TARGET_RELEASE_BASE..$MOZ_TARGET_UPSTREAM_BRANCH_HEAD" echo "" echo "Occasionally, successive libwebrtc release branches need to cherry-pick" echo "the same _far_ upstream commit. We need to examine the upcoming release" echo "branch commits for our new v$MOZ_NEXT_LIBWEBRTC_MILESTONE update." echo "Upcoming (Bug $MOZ_FASTFORWARD_BUG) release branch commits:" # might be nice to indent this output for better readability git log $COMMIT_RANGE --oneline # Convert the files that we've already generated for no-op detection into # something that we can use as a regular expression for searching. KNOWN_NO_OP_COMMITS=`cd $STATE_DIR ; \ ls *.no-op-cherry-pick-msg \ | sed 's/\.no-op-cherry-pick-msg//' \ | paste -sd '|' /dev/stdin` NEW_COMMITS=`git log -r $COMMIT_RANGE --format='%h'` for commit in $NEW_COMMITS; do echo "Processing next release branch commit $commit for no-op handling" # Don't process the commit if the commit message is missing the customary # line that shows which upstream commit is being cherry-picked. CNT=`git show $commit | grep "cherry picked from commit" | wc -l | tr -d " " || true` if [ $CNT != 1 ]; then # record the commit to list at the end of this script as # 'needing intervention' echo " no cherry-pick info found, skipping commit $commit" echo "$commit" >> $MANUAL_INTERVENTION_COMMIT_FILE continue fi CHERRY_PICK_COMMIT=`git show $commit | grep "cherry picked from commit" | tr -d "()" | awk '{ print $5; }'` # I didn't think this was possible due to the automated tooling on # Google's end, but upstream commit # 847fe7905954f3ae883de2936415ff567aa9039b lists that it cherry-picks # 602b06b1125ea4d107fbfbda7d314b4157c4c74b. However, # 602b06b1125ea4d107fbfbda7d314b4157c4c74b doesn't exist in the repo. # That means we need to verify that we have a valid commit before # processing further. If not found we'll add it to the list of # commits that need manual intervention/verification. CHERRY_PICK_COMMIT_FOUND=`(git cat-file -e $CHERRY_PICK_COMMIT && echo "commit-found") || true` if [ "x$CHERRY_PICK_COMMIT_FOUND" != "xcommit-found" ]; then # record the commit to list at the end of this script as # 'needing intervention' echo " cherry-pick sha ($CHERRY_PICK_COMMIT) found in commit" echo " message, but the sha is not found in the libwebrtc repo." echo " skipping commit $commit" echo "$commit" >> $MANUAL_INTERVENTION_COMMIT_FILE continue fi SHORT_SHA=`git show --name-only $CHERRY_PICK_COMMIT --format='%h' | head -1` # The trick here is that we only want to include no-op processing for the # commits that appear both here _and_ in the previous release's cherry-pick # commits. We check the known list of no-op commits to see if it was # cherry picked in the previous release branch and then create another # file for the new release branch commit that will ultimately be a no-op. if [[ "$SHORT_SHA" =~ ^($KNOWN_NO_OP_COMMITS)$ ]]; then echo " commit $commit cherry-picks $SHORT_SHA" cp $STATE_DIR/$SHORT_SHA.no-op-cherry-pick-msg $STATE_DIR/$commit.no-op-cherry-pick-msg fi done if [ ! -f $MANUAL_INTERVENTION_COMMIT_FILE ]; then echo "" echo "No commits require manual intervention" exit fi echo $" Each of the following commits requires manual intervention to verify the source of the cherry-pick or there may be errors reported during the fast-forward processing. Without this intervention, the common symptom is that the vendored commit file count (0) will not match the upstream commit file count. In some cases, these commits may be listed because invalid cherry-pick info (not simply missing info) is present in the commit message. " for commit in `cat $MANUAL_INTERVENTION_COMMIT_FILE`; do SUMMARY=`git show --oneline --name-only $commit | head -1` echo " '$SUMMARY'" done echo $" To manually create the no-op tracking files needed, run the following command (in bash) for each commit in question: ( export FUTURE_UPSTREAM_COMMIT=\"{short-sha-of-upstream-commit}\" ; \\ export ALREADY_USED_COMMIT=\"{short-sha-of-already-used-commit}\" ; \\ echo \"We already cherry-picked this when we vendored \$ALREADY_USED_COMMIT.\" \\ > $STATE_DIR/\$FUTURE_UPSTREAM_COMMIT.no-op-cherry-pick-msg ) "