tor-browser

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

verify_vendoring.sh (3913B)


      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 # After this point:
     17 # * eE: All commands should succeed.
     18 # * u: All variables should be defined before use.
     19 # * o pipefail: All stages of all pipes should succeed.
     20 set -eEuo pipefail
     21 
     22 echo "MOZ_LIBWEBRTC_SRC: $MOZ_LIBWEBRTC_SRC"
     23 echo "MOZ_LIBWEBRTC_BRANCH: $MOZ_LIBWEBRTC_BRANCH"
     24 echo "MOZ_FASTFORWARD_BUG: $MOZ_FASTFORWARD_BUG"
     25 
     26 # CURRENT_SHA=`hg id -r . | awk '{ print $1; }'`
     27 # echo "CURRENT_SHA: $CURRENT_SHA"
     28 
     29 find_repo_type
     30 echo "repo type: $MOZ_REPO"
     31 
     32 # we grab the entire firstline description for convenient logging
     33 if [ "x$MOZ_REPO" == "xgit" ]; then
     34 LAST_PATCHSTACK_UPDATE_COMMIT=`git log --max-count 1 --oneline \
     35    'third_party/libwebrtc/moz-patch-stack/*.patch'`
     36 else
     37 # note: we reverse the output and use tail -1 rather than using head -1
     38 # because head fails in this context.
     39 LAST_PATCHSTACK_UPDATE_COMMIT=`hg log -r ::. --template "{node|short} {desc|firstline}\n" \
     40    --include "third_party/libwebrtc/moz-patch-stack/*.patch" | tail -1`
     41 fi
     42 echo "LAST_PATCHSTACK_UPDATE_COMMIT: $LAST_PATCHSTACK_UPDATE_COMMIT"
     43 
     44 LAST_PATCHSTACK_UPDATE_COMMIT_SHA=`echo $LAST_PATCHSTACK_UPDATE_COMMIT \
     45    | awk '{ print $1; }'`
     46 echo "LAST_PATCHSTACK_UPDATE_COMMIT_SHA: $LAST_PATCHSTACK_UPDATE_COMMIT_SHA"
     47 
     48 # grab the oldest, non "Vendor from libwebrtc" line
     49 if [ "x$MOZ_REPO" == "xgit" ]; then
     50 CANDIDATE_COMMITS=`git log --reverse --format='%h' --invert-grep \
     51    --grep="Vendor libwebrtc" $LAST_PATCHSTACK_UPDATE_COMMIT_SHA..HEAD -- third_party/libwebrtc \
     52    | awk 'BEGIN { ORS=" " }; { print $1; }'`
     53 else
     54 CANDIDATE_COMMITS=`hg log --template "{node|short} {desc|firstline}\n" \
     55    -r "children($LAST_PATCHSTACK_UPDATE_COMMIT_SHA)::. - desc('re:(Vendor libwebrtc)')" \
     56    --include "third_party/libwebrtc/" | awk 'BEGIN { ORS=" " }; { print $1; }'`
     57 fi
     58 echo "CANDIDATE_COMMITS:"
     59 echo "$CANDIDATE_COMMITS"
     60 
     61 EXTRACT_COMMIT_RANGE="{start-commit-sha}::."
     62 if [ "x$CANDIDATE_COMMITS" != "x" ]; then
     63  EXTRACT_COMMIT_RANGE="$CANDIDATE_COMMITS"
     64  echo "EXTRACT_COMMIT_RANGE: $EXTRACT_COMMIT_RANGE"
     65 fi
     66 
     67 ./mach python $SCRIPT_DIR/vendor-libwebrtc.py \
     68        --from-local $MOZ_LIBWEBRTC_SRC \
     69        --commit $MOZ_LIBWEBRTC_BRANCH \
     70        libwebrtc
     71 
     72 # echo "exiting early for testing repo detection"
     73 # exit
     74 
     75 if [ "x$MOZ_REPO" == "xgit" ]; then
     76 git restore -q \
     77    'third_party/libwebrtc/**/moz.build' \
     78    third_party/libwebrtc/README.mozilla.last-vendor
     79 else
     80 hg revert -q \
     81   --include "third_party/libwebrtc/**moz.build" \
     82   --include "third_party/libwebrtc/README.mozilla.last-vendor" \
     83   third_party/libwebrtc
     84 fi
     85 
     86 ERROR_HELP=$"
     87 ***
     88 There are changes detected after vendoring libwebrtc from our local copy
     89 of the git repo containing our patch-stack:
     90 $MOZ_LIBWEBRTC_SRC
     91 
     92 Typically this is due to changes made in mercurial to files residing
     93 under third_party/libwebrtc that have not been reflected in
     94 moz-libwebrtc git repo's patch-stack.
     95 
     96 The following commands should help remedy the situation:
     97  ./mach python $SCRIPT_DIR/extract-for-git.py $EXTRACT_COMMIT_RANGE
     98  mv mailbox.patch $MOZ_LIBWEBRTC_SRC
     99  (cd $MOZ_LIBWEBRTC_SRC && \\
    100   git am mailbox.patch)
    101 
    102 After adding the new changes from mercurial to the moz-libwebrtc
    103 patch stack, you should re-run this command to verify vendoring:
    104  bash $0
    105 "
    106 if [ "x$MOZ_REPO" == "xgit" ]; then
    107 FILE_CHANGE_CNT=`git status --short third_party/libwebrtc | wc -l | tr -d " "`
    108 else
    109 FILE_CHANGE_CNT=`hg status third_party/libwebrtc | wc -l | tr -d " "`
    110 fi
    111 echo "FILE_CHANGE_CNT: $FILE_CHANGE_CNT"
    112 if [ "x$FILE_CHANGE_CNT" != "x0" ]; then
    113  echo "$ERROR_HELP"
    114  exit 1
    115 fi
    116 
    117 
    118 echo "Done - vendoring has been verified."