blob: 0e92ffcef4a6a67ca69ec43fe9f83899d2a392c3 [file] [log] [blame]
Tacit Sawk26293bb2011-06-14 10:51:43 +10001#!/bin/bash
Vincent Driessen4f0f5392010-07-10 17:05:27 +02002
3# git-flow make-less installer for *nix systems, by Rick Osborne
4# Based on the git-flow core Makefile:
5# http://github.com/nvie/gitflow/blob/master/Makefile
6
7# Licensed under the same restrictions as git-flow:
8# http://github.com/nvie/gitflow/blob/develop/LICENSE
9
10# Does this need to be smarter for each host OS?
11if [ -z "$INSTALL_PREFIX" ] ; then
12 INSTALL_PREFIX="/usr/local/bin"
13fi
14
15if [ -z "$REPO_NAME" ] ; then
16 REPO_NAME="gitflow"
17fi
18
19if [ -z "$REPO_HOME" ] ; then
20 REPO_HOME="http://github.com/nvie/gitflow.git"
21fi
22
23EXEC_FILES="git-flow"
24SCRIPT_FILES="git-flow-init git-flow-feature git-flow-hotfix git-flow-release git-flow-support git-flow-version gitflow-common gitflow-shFlags"
25SUBMODULE_FILE="gitflow-shFlags"
26
27echo "### gitflow no-make installer ###"
28
29case "$1" in
30 uninstall)
31 echo "Uninstalling git-flow from $INSTALL_PREFIX"
32 if [ -d "$INSTALL_PREFIX" ] ; then
33 for script_file in $SCRIPT_FILES $EXEC_FILES ; do
34 echo "rm -vf $INSTALL_PREFIX/$script_file"
35 rm -vf "$INSTALL_PREFIX/$script_file"
36 done
37 else
38 echo "The '$INSTALL_PREFIX' directory was not found."
39 echo "Do you need to set INSTALL_PREFIX ?"
40 fi
41 exit
42 ;;
43 help)
44 echo "Usage: [environment] gitflow-installer.sh [install|uninstall]"
45 echo "Environment:"
46 echo " INSTALL_PREFIX=$INSTALL_PREFIX"
47 echo " REPO_HOME=$REPO_HOME"
48 echo " REPO_NAME=$REPO_NAME"
49 exit
50 ;;
51 *)
52 echo "Installing git-flow to $INSTALL_PREFIX"
James Moran0c320622011-07-26 10:39:35 -040053 if [ -d "$REPO_NAME" -a -d "$REPO_NAME/.git" ] ; then
Vincent Driessen4f0f5392010-07-10 17:05:27 +020054 echo "Using existing repo: $REPO_NAME"
55 else
56 echo "Cloning repo from GitHub to $REPO_NAME"
57 git clone "$REPO_HOME" "$REPO_NAME"
58 fi
59 if [ -f "$REPO_NAME/$SUBMODULE_FILE" ] ; then
60 echo "Submodules look up to date"
61 else
62 echo "Updating submodules"
63 lastcwd=$PWD
64 cd "$REPO_NAME"
65 git submodule init
66 git submodule update
67 cd "$lastcwd"
68 fi
69 install -v -d -m 0755 "$INSTALL_PREFIX"
70 for exec_file in $EXEC_FILES ; do
71 install -v -m 0755 "$REPO_NAME/$exec_file" "$INSTALL_PREFIX"
72 done
73 for script_file in $SCRIPT_FILES ; do
74 install -v -m 0644 "$REPO_NAME/$script_file" "$INSTALL_PREFIX"
75 done
76 exit
77 ;;
78esac