#!/usr/bin/env bash # The common script is only meant to be included from other LLVM helper scripts if [[ $LLVM_SRC = '' ]]; then echo "Please, define \$LLVM_SRC" exit -1 fi if [[ $LLVM_BLD = '' ]]; then echo "Please, define \$LLVM_BLD" exit -1 fi if [[ $LLVM_GITRW = '' ]]; then echo "Please, define \$LLVM_GITRW" exit -1 fi if [[ $LLVM_GITRW = 'yes' ]]; then if [[ $LLVM_SVNUSER = '' ]] || [[ $LLVM_GITUSER = '' ]]; then echo "Please, define \$LLVM_GITUSER and \$LLVM_SVNUSER when using GITRW=yes" echo "GITUSER is your Linaro git user, SVNUSER is your LLVM commit user" exit 1 fi fi get_branch() { branch=`git rev-parse --abbrev-ref HEAD` if [[ $? != 0 ]]; then local dir=`pwd` echo "Source dir '$dir' is not in a git repository" 1>&2 exit -1 fi echo $branch } get_branches() { branches=`git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)'` if [[ $? != 0 ]]; then local dir=`pwd` echo "Source dir '$dir' is not in a git repository" 1>&2 exit -1 fi echo $branches } safe_run() { "$@" if [[ $? != 0 ]]; then echo "'$@' failed, bailing out" exit 1 fi } is_git() { test -d `git rev-parse --show-toplevel`/.git } is_git_svn() { test -f `git rev-parse --show-toplevel`/.git/svn/.metadata }