summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Lindholm <leif.lindholm@linaro.org>2019-01-30 16:33:59 +0000
committerLeif Lindholm <leif.lindholm@linaro.org>2019-01-30 16:33:59 +0000
commit27207a83aefc88526466fb2dcba50470cb92974d (patch)
treebe96a42560145fb5300c11eb7495a775e79276d2
parent80bf2d2b8744e6b8110fe2d430638916dc3554a6 (diff)
add setup-environment.sh
Add new script and template files to quickly do some sanity checks and configure git correctly for TianoCore development. Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
-rw-r--r--git-config/git.template4
-rw-r--r--git-config/sort.order8
-rwxr-xr-xsetup-environment.sh153
3 files changed, 165 insertions, 0 deletions
diff --git a/git-config/git.template b/git-config/git.template
new file mode 100644
index 0000000..19849fe
--- /dev/null
+++ b/git-config/git.template
@@ -0,0 +1,4 @@
+
+
+Contributed-under: TianoCore Contribution Agreement 1.1
+Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
diff --git a/git-config/sort.order b/git-config/sort.order
new file mode 100644
index 0000000..7cc162a
--- /dev/null
+++ b/git-config/sort.order
@@ -0,0 +1,8 @@
+*.dec
+*.dsc.inc
+*.dsc
+*.fdf
+*.inf
+*.h
+*.vfr
+*.c
diff --git a/setup-environment.sh b/setup-environment.sh
new file mode 100755
index 0000000..08f967e
--- /dev/null
+++ b/setup-environment.sh
@@ -0,0 +1,153 @@
+#!/bin/bash
+
+CONFIGDIR=~/.tianocore
+SRCDIR=`dirname $0`
+
+FORCE=false
+NUMWARNINGS=0
+
+SCRIPTNAME=`basename $0`
+
+printusage()
+{
+ echo "$SCRIPTNAME - initialize and verifyTianoCore development environment"
+ echo "Verifies git configuration, installs git hooks, etc."
+ echo "To be executed from one of your cloned git directories"
+ echo
+ echo "usage: $SCRIPTNAME [-f]"
+ echo
+ echo " -f Force sucessful completion for non-typical situations"
+}
+
+while [ $# -ge 1 ]; do
+ case $1 in
+ -f)
+ FORCE=true
+ ;;
+ *)
+ echo "Unknown parameter '$1' - aborting"
+ echo
+ printusage
+ exit 1
+ ;;
+ esac
+
+ shift
+done
+
+checkrepo()
+{
+ if [ ! -d .git ]; then
+ echo "$PWD is not a git repository" >&2
+ exit 1
+ fi
+
+ ORIGINPATTERN=".*://github.com/tianocore/.*"
+ if [ -z `git remote get-url origin | grep -i "$ORIGINPATTERN"` ]; then
+ echo
+ echo "origin is not github.com/tianocore/ - is this intentional?"
+ if [ $FORCE == "true" ]; then
+ return
+ fi
+ echo "Aborting - Override with -f to force."
+ echo
+ fi
+}
+
+checkgitconfig()
+{
+ checkrepo
+
+ GITUSER=`git config user.name`
+ GITEMAIL=`git config user.email`
+ if [ -z "$GITUSER" -o -z "$GITEMAIL" ]; then
+ echo "git user and/or email not configured"
+ echo "please run"
+ echo " git config --global user.name=<your name as displayed in email clients>"
+ echo " git config --global user.email=<your email address>"
+ echo "(omit the '--global' if using different name/email for other development)"
+ exit 1
+ fi
+
+ git config sendemail.smtpserver >/dev/null
+ if [ $? -ne 0 ]; then
+ echo "WARNING: no SMTP server configured, git send-email will not work!"
+ NUMWARNINGS=$(($NUMWARNINGS + 1))
+ fi
+}
+
+# checkmakedir <directory>
+checkmakedir()
+{
+ if [ ! -d "$1" ]; then
+ echo "Creating $1"
+ mkdir "$1"
+ fi
+}
+
+# checkcopyfile <source file> <destination file>
+checkcopyfile()
+{
+ if [ -e $2 ]; then
+ if cmp -s "$1" "$2"; then
+ echo " Not overwriting existing identical file '$2'"
+ return
+ else
+ echo " Updating '$2'"
+ fi
+ fi
+
+ if [ $FORCE == "true" ]; then
+ COPYFLAGS=
+ else
+ COPYFLAGS=-i
+ fi
+ cp -p $COPYFLAGS "$1" "$2"
+}
+
+copyfiles()
+{
+ echo "Installing GIT hooks:"
+ for file in $SRCDIR/git-hooks/*; do
+ checkcopyfile $file .git/hooks/`basename $file`
+ done
+ echo "done."
+
+ echo
+
+ checkmakedir "$CONFIGDIR"
+ echo "Installing TianoCore templates and configuration:"
+ for file in $SRCDIR/git-config/*; do
+ checkcopyfile $file $CONFIGDIR/`basename $file`
+ done
+ echo "done."
+}
+
+configuregit()
+{
+ GITTEMPLATE=`git config commit.template`
+ if [ -z $GITTEMPLATE ]; then
+ git config --add commit.template $CONFIGDIR/git.template
+ elif [ $GITTEMPLATE != $CONFIGDIR/git.template ]; then
+ echo "WARNING: commit.template already configured in other location than '$GITTEMPLATE'"
+ NUMWARNINGS=$(($NUMWARNINGS + 1))
+ fi
+
+ ORDERFILE=`git config diff.orderfile`
+ if [ -z $ORDERFILE ]; then
+ git config --add diff.orderfile $CONFIGDIR/sort.order
+ elif [ $ORDERFILE != $CONFIGDIR/sort.order ]; then
+ echo "WARNING: diff.orderfile already configured in other location than '$ORDERFILE'"
+ NUMWARNINGS=$(($NUMWARNINGS + 1))
+ fi
+}
+
+checkgitconfig
+copyfiles
+configuregit
+
+echo
+echo "Successfully installed/updated configuration!"
+if [ $NUMWARNINGS -gt 0 ]; then
+ echo "(with $NUMWARNINGS warnings)"
+fi