message: [Build] Update genbuild.sh script
  Fix git's rev-list call
  Add proper copyright headers from upstream
  Check that the script is in the git tree
diff: #!/bin/sh
  +# Copyright (c) 2012-2016 The Bitcoin Core developers
  +# Distributed under the MIT software license, see the accompanying
  +# file COPYING or http://www.opensource.org/licenses/mit-license.php.
  +
  +export LC_ALL=C
  if [ $# -gt 1 ]; then
  - cd "$2"
  + cd "$2" || exit 1
  fi
  if [ $# -gt 0 ]; then
  FILE="$1"
  @@ -13,16 +18,20 @@ else
  exit 1
  fi
  +git_check_in_repo() {
  + ! { git status --porcelain -uall --ignored "$@" 2>/dev/null || echo '??'; } | grep -q '?'
  +}
  +
  DESC=""
  SUFFIX=""
  LAST_COMMIT_DATE=""
  -if [ -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
  +if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" -a -e "$(which git 2>/dev/null)" -a "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ] && git_check_in_repo share/genbuild.sh; then
  # clean 'dirty' status of touched files that haven't been modified
  git diff >/dev/null 2>/dev/null
  # if latest commit is tagged and not dirty, then override using the tag name
  RAWDESC=$(git describe --abbrev=0 2>/dev/null)
  - if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC)" ]; then
  + if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then
  git diff-index --quiet HEAD -- && DESC=$RAWDESC
  fi
  