tor-browser

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

commit-build-file-changes.sh (3338B)


      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 [ "x$PROCESS_DIR" = "x" ]; then
     16  PROCESS_DIR=third_party/libwebrtc
     17  echo "Default directory: $PROCESS_DIR"
     18 fi
     19 
     20 # All commands should be printed as they are executed
     21 # set -x
     22 
     23 # After this point:
     24 # * eE: All commands should succede.
     25 # * u: All variables should be defined before use.
     26 # * o pipefail: All stages of all pipes should succede.
     27 set -eEuo pipefail
     28 
     29 find_repo_type
     30 echo "repo type: $MOZ_REPO"
     31 
     32 if [ ! -d $PROCESS_DIR ]; then
     33  echo "No directory found for '$PROCESS_DIR'"
     34  exit 1
     35 fi
     36 
     37 if [ "x$MOZ_REPO" == "xgit" ]; then
     38  BUILD_FILE_GIT_SPEC="$PROCESS_DIR/**moz.build"
     39  MOZ_BUILD_CHANGE_CNT=`git status --porcelain "$BUILD_FILE_GIT_SPEC" | wc -l | tr -d " "`
     40 else
     41  MOZ_BUILD_CHANGE_CNT=`hg status --include="**moz.build" $PROCESS_DIR | wc -l | tr -d " "`
     42 fi
     43 echo "MOZ_BUILD_CHANGE_CNT: $MOZ_BUILD_CHANGE_CNT"
     44 if [ "x$MOZ_BUILD_CHANGE_CNT" != "x0" ]; then
     45  if [ "x$MOZ_REPO" == "xgit" ]; then
     46    COMMIT_DESC=`git show --format='%s' --no-patch`
     47  else
     48    CURRENT_COMMIT_SHA=`hg id -i | sed 's/+//'`
     49    COMMIT_DESC=`hg --config alias.log=log log -T '{desc|firstline}' -r $CURRENT_COMMIT_SHA`
     50  fi
     51 
     52  # since we have build file changes, touch the CLOBBER file
     53  cat CLOBBER | grep -E "^#|^$" > CLOBBER.new
     54  mv CLOBBER.new CLOBBER
     55  echo "Modified build files in $PROCESS_DIR - $COMMIT_DESC" >> CLOBBER
     56 
     57  # handle added files
     58  if [ "x$MOZ_REPO" == "xgit" ]; then
     59    ADD_CNT=`git status --porcelain "$BUILD_FILE_GIT_SPEC" | grep "^??" | wc -l | tr -d " " || true`
     60    if [ "x$ADD_CNT" != "x0" ]; then
     61      git status --porcelain "$BUILD_FILE_GIT_SPEC" | grep "^??" | awk '{ print $2; }' | xargs git add
     62    fi
     63  else
     64    ADD_CNT=`hg status --include="**moz.build" -nu $PROCESS_DIR | wc -l | tr -d " "`
     65    if [ "x$ADD_CNT" != "x0" ]; then
     66      hg status --include="**moz.build" -nu $PROCESS_DIR | xargs hg add
     67    fi
     68  fi
     69 
     70  # handle deleted files
     71  if [ "x$MOZ_REPO" == "xgit" ]; then
     72    DEL_CNT=`git status --porcelain "$BUILD_FILE_GIT_SPEC" | grep "^ D" | wc -l | tr -d " " || true`
     73    if [ "x$DEL_CNT" != "x0" ]; then
     74      git status --porcelain "$BUILD_FILE_GIT_SPEC" | grep "^ D" | awk '{ print $2; }' | xargs git rm --quiet
     75    fi
     76  else
     77    DEL_CNT=`hg status --include="**moz.build" -nd $PROCESS_DIR | wc -l | tr -d " "`
     78    if [ "x$DEL_CNT" != "x0" ]; then
     79      hg status --include="**moz.build" -nd $PROCESS_DIR | xargs hg rm
     80    fi
     81  fi
     82 
     83  # handle modified files - mercurial doesn't need this
     84  if [ "x$MOZ_REPO" == "xgit" ]; then
     85    MOD_CNT=`git status --porcelain "$BUILD_FILE_GIT_SPEC" CLOBBER | grep "^ M" | wc -l | tr -d " " || true`
     86    if [ "x$MOD_CNT" != "x0" ]; then
     87      git status --porcelain "$BUILD_FILE_GIT_SPEC" CLOBBER | grep "^ M" | awk '{ print $2; }' | xargs git add
     88    fi
     89  fi
     90 
     91  if [ "x$MOZ_REPO" == "xgit" ]; then
     92    git commit -m "$COMMIT_DESC - moz.build file updates"
     93  else
     94    hg commit -m \
     95      "$COMMIT_DESC - moz.build file updates" \
     96      --include="**moz.build" --include="CLOBBER" $PROCESS_DIR CLOBBER
     97  fi
     98 fi
     99 
    100 echo "Done in $0"