tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

prep_repo.sh (5613B)


      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 export HGPLAIN=1
     15 
     16 if [ "x$ALLOW_RERUN" = "x" ]; then
     17  ALLOW_RERUN="0"
     18 fi
     19 
     20 echo "MOZ_LIBWEBRTC_SRC: $MOZ_LIBWEBRTC_SRC"
     21 echo "MOZ_LIBWEBRTC_BRANCH: $MOZ_LIBWEBRTC_BRANCH"
     22 echo "MOZ_FASTFORWARD_BUG: $MOZ_FASTFORWARD_BUG"
     23 echo "ALLOW_RERUN: $ALLOW_RERUN"
     24 
     25 ERROR_HELP=$"
     26 A copy of moz-libwebrtc already exists at $MOZ_LIBWEBRTC_SRC
     27 While this script is not technically idempotent, it will try.
     28 However, the safest way forward is to start fresh by running:
     29    rm -rf $STATE_DIR && \\
     30    bash $0
     31 
     32 If you are sure you want to reuse the existing directory, run:
     33    ALLOW_RERUN=1 bash $0
     34 "
     35 if [ -d $MOZ_LIBWEBRTC_SRC ] && [ "x$ALLOW_RERUN" != "x1" ]; then
     36  echo "$ERROR_HELP"
     37  exit 1
     38 fi
     39 ERROR_HELP=""
     40 
     41 # After this point:
     42 # * eE: All commands should succeed.
     43 # * u: All variables should be defined before use.
     44 # * o pipefail: All stages of all pipes should succeed.
     45 set -eEuo pipefail
     46 
     47 # wipe resume_state for new run
     48 rm -f $STATE_DIR/resume_state
     49 
     50 # If there is no cache file for the branch-head lookups done in
     51 # update_default_config.sh, go ahead and copy our small pre-warmed
     52 # version.
     53 if [ ! -f $STATE_DIR/milestone.cache ]; then
     54  cp $SCRIPT_DIR/pre-warmed-milestone.cache $STATE_DIR/milestone.cache
     55 fi
     56 
     57 # If there is no .mozconfig file, copy a basic one from default_mozconfig
     58 if [ ! -f .mozconfig ]; then
     59  cp $SCRIPT_DIR/default_mozconfig .mozconfig
     60 fi
     61 
     62 # fetch the github repro
     63 ./mach python $SCRIPT_DIR/fetch_github_repo.py \
     64    --repo-path $MOZ_LIBWEBRTC_SRC \
     65    --state-path $STATE_DIR
     66 
     67 CURRENT_DIR=`pwd`
     68 cd $MOZ_LIBWEBRTC_SRC
     69 
     70 # clear any possible previous patches
     71 rm -f *.patch
     72 
     73 # create a new work branch and "export" a new patch stack to rebase
     74 # find the common commit between our upstream release branch and trunk
     75 PREVIOUS_RELEASE_BRANCH_BASE=`git merge-base branch-heads/$MOZ_PRIOR_UPSTREAM_BRANCH_HEAD_NUM master`
     76 echo "PREVIOUS_RELEASE_BRANCH_BASE: $PREVIOUS_RELEASE_BRANCH_BASE"
     77 
     78 NEXT_RELEASE_BRANCH_BASE=`git merge-base $MOZ_TARGET_UPSTREAM_BRANCH_HEAD master`
     79 echo "NEXT_RELEASE_BRANCH_BASE: $NEXT_RELEASE_BRANCH_BASE"
     80 
     81 ERROR_HELP=$"
     82 The previous release branch base ($PREVIOUS_RELEASE_BRANCH_BASE)
     83 and the next release branch base ($NEXT_RELEASE_BRANCH_BASE) are the
     84 same and should not be.  This indicates a problem in the git repo at
     85 $MOZ_LIBWEBRTC_SRC.
     86 At the least it likely means that 'master' is older than the two
     87 release branches.  Investigation is necessary.
     88 "
     89 if [ "x$PREVIOUS_RELEASE_BRANCH_BASE" == "x$NEXT_RELEASE_BRANCH_BASE" ]; then
     90  echo "$ERROR_HELP"
     91  exit 1
     92 fi
     93 ERROR_HELP=""
     94 
     95 # create a new branch at the common commit and checkout the new branch
     96 ERROR_HELP=$"
     97 Unable to create branch '$MOZ_LIBWEBRTC_BRANCH'.  This probably means
     98 that prep_repo.sh is being called on a repo that already has a patch
     99 stack in progress.  If you're sure you want to do this, the following
    100 commands will allow the process to continue:
    101  ( cd $MOZ_LIBWEBRTC_SRC && \\
    102    git checkout $MOZ_LIBWEBRTC_BRANCH && \\
    103    git checkout -b $MOZ_LIBWEBRTC_BRANCH-old && \\
    104    git branch -D $MOZ_LIBWEBRTC_BRANCH ) && \\
    105  ALLOW_RERUN=1 bash $0
    106 "
    107 git branch $MOZ_LIBWEBRTC_BRANCH $PREVIOUS_RELEASE_BRANCH_BASE
    108 ERROR_HELP=""
    109 git checkout $MOZ_LIBWEBRTC_BRANCH
    110 
    111 # find the last upstream commit used by the previous update, so we don't
    112 # accidentally grab release branch commits that were added after we started
    113 # the previous update.
    114 LAST_UPSTREAM_COMMIT_SHA=`tail -1 $CURRENT_DIR/third_party/libwebrtc/README.mozilla.last-vendor`
    115 echo "previous update's last commit: $LAST_UPSTREAM_COMMIT_SHA"
    116 
    117 # Check that the previous libwebrtc update run actually had release
    118 # branch commits.  If it did, our LAST_UPSTREAM_COMMIT_SHA will be
    119 # different than the PREVIOUS_RELEASE_BRANCH_BASE (which we convert to a
    120 # short sha).  If the two shas are the same, meaning there where no
    121 # fixes on the upstream's release branch, we have no work to do here.
    122 # An example of this if occurance is v136 update.
    123 PREV_REL_BRANCH_SHORT_SHA=`git rev-parse --short $PREVIOUS_RELEASE_BRANCH_BASE`
    124 if [ "x$PREV_REL_BRANCH_SHORT_SHA" != "x$LAST_UPSTREAM_COMMIT_SHA" ]; then
    125  # make sure we're starting with a clean tmp directory
    126  rm -f $TMP_DIR/*.patch $TMP_DIR/*.patch.bak
    127 
    128  # grab the patches for all the commits in chrome's release branch for libwebrtc
    129  git format-patch -o $TMP_DIR -k $PREVIOUS_RELEASE_BRANCH_BASE..$LAST_UPSTREAM_COMMIT_SHA
    130  # tweak the release branch commit summaries to show they were cherry picked
    131  sed -i.bak -e "/^Subject: / s/^Subject: /Subject: (cherry-pick-branch-heads\/$MOZ_PRIOR_UPSTREAM_BRANCH_HEAD_NUM) /" $TMP_DIR/*.patch
    132  git am $TMP_DIR/*.patch # applies to branch mozpatches
    133  rm $TMP_DIR/*.patch $TMP_DIR/*.patch.bak
    134 fi
    135 
    136 # we don't use restore_patch_stack.py here because it would overwrite the patches
    137 # from the previous release branch we just added in the above step.
    138 
    139 # grab all the moz patches and apply
    140 git am $CURRENT_DIR/third_party/libwebrtc/moz-patch-stack/*.patch
    141 
    142 cd $CURRENT_DIR
    143 
    144 # cp all the no-op files to STATE_DIR
    145 NO_OP_FILE_COUNT=`ls third_party/libwebrtc/moz-patch-stack \
    146    | grep "no-op-cherry-pick-msg" | wc -l | tr -d " " || true`
    147 if [ "x$NO_OP_FILE_COUNT" != "x0" ]; then
    148  cp $CURRENT_DIR/third_party/libwebrtc/moz-patch-stack/*.no-op-cherry-pick-msg \
    149     $STATE_DIR
    150 fi
    151 
    152 bash $SCRIPT_DIR/verify_vendoring.sh || exit 1