Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # The common script is only meant to be included from other LLVM helper scripts |
| 4 | |
| 5 | if [[ $LLVM_SRC = '' ]]; then |
| 6 | echo "Please, define \$LLVM_SRC" |
| 7 | exit -1 |
| 8 | fi |
| 9 | if [[ $LLVM_BLD = '' ]]; then |
| 10 | echo "Please, define \$LLVM_BLD" |
| 11 | exit -1 |
| 12 | fi |
| 13 | if [[ $LLVM_GITRW = '' ]]; then |
| 14 | echo "Please, define \$LLVM_GITRW" |
| 15 | exit -1 |
| 16 | fi |
Renato Golin | 7c10e6e | 2016-05-12 16:20:10 +0100 | [diff] [blame] | 17 | if [[ $LLVM_GITUSER = '' ]]; then |
| 18 | echo "Please, define \$LLVM_GITUSER to access Linaro's Git server" |
| 19 | exit 1 |
| 20 | fi |
| 21 | if [[ $LLVM_GITRW = 'yes' ]] && [[ $LLVM_SVNUSER = '' ]]; then |
| 22 | echo "Please, define \$LLVM_SVNUSER when using GITRW=yes" |
| 23 | echo "SVNUSER is your upstream LLVM commit user" |
| 24 | exit 1 |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 25 | fi |
| 26 | |
| 27 | get_branch() { |
| 28 | branch=`git rev-parse --abbrev-ref HEAD` |
| 29 | if [[ $? != 0 ]]; then |
| 30 | local dir=`pwd` |
| 31 | echo "Source dir '$dir' is not in a git repository" 1>&2 |
| 32 | exit -1 |
| 33 | fi |
| 34 | echo $branch |
| 35 | } |
| 36 | |
| 37 | get_branches() { |
| 38 | branches=`git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)'` |
| 39 | if [[ $? != 0 ]]; then |
| 40 | local dir=`pwd` |
| 41 | echo "Source dir '$dir' is not in a git repository" 1>&2 |
| 42 | exit -1 |
| 43 | fi |
| 44 | echo $branches |
| 45 | } |
| 46 | |
| 47 | safe_run() { |
Diana Picus | 416bc4f | 2016-04-22 16:47:57 +0300 | [diff] [blame] | 48 | "$@" |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 49 | if [[ $? != 0 ]]; then |
Diana Picus | 416bc4f | 2016-04-22 16:47:57 +0300 | [diff] [blame] | 50 | echo "'$@' failed, bailing out" |
Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 51 | exit 1 |
| 52 | fi |
| 53 | } |
| 54 | |
| 55 | is_git() { |
| 56 | test -d `git rev-parse --show-toplevel`/.git |
| 57 | } |
| 58 | |
| 59 | is_git_svn() { |
| 60 | test -f `git rev-parse --show-toplevel`/.git/svn/.metadata |
| 61 | } |