summaryrefslogtreecommitdiff
path: root/get-git
blob: afccc6cda1d87d0d13af58f52d1d475248bd5f26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
# Compiz/Compcomm get-git
# Copyright (c) 2007 Kristian LyngstĂžl <kristian@bohemians.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
#
# This script attempts to get all compcomm/compiz sources you need,
# build them and install them.

SUPRESS="true" ## set to false to display compile-stuff.

# Needed for premerge plugins
ITEMS="compcomm/libraries/bcop" 
# The beryl plugins, ported to compiz
ITEMS="$ITEMS compcomm/plugins/beryl-premerge"
# Emerald window decorator
ITEMS="$ITEMS compcomm/decorators/emerald compcomm/decorators/emerald-themes"
# Animation
ITEMS="$ITEMS compcomm/plugins/animation"

### CCS
# (formerly libbs), you can safly comment out this and use ini or gconf
ITEMS="$ITEMS compcomm/compiz-configuration-system/libraries/ccs-lib"

# Uncomment one of these to use gconf or kconf backend for ccs
#ITEMS="$ITEMS compcomm/compiz-configuration-system/libraries/ccs-backend-gconf"
#ITEMS="$ITEMS compcomm/compiz-configuration-system/libraries/ccs-backend-kconfig"

ITEMS="$ITEMS compcomm/compiz-configuration-system/tools/ccs-settings compcomm/compiz-configuration-system/bindings/ccs-python"

### CCS ends here

# My (==Kristian's) compiz-scripts. Includes this script and a compiz-manager 
# to start compiz and a decorator. Feedback on these scripts are much 
# appreaciated.

ITEMS="$ITEMS users/kristian/compiz-scripts"

# Add aditional items here if you need them.

# Repository
REPO="git://anongit.opencompositing.org/"
# For developers, you may have to add your username.
#REPO="git+ssh://git.opencompositing.org/git/" 

# Compiz repo. "compiz" is appended.
COMPIZ="git://git.freedesktop.org/git/xorg/app/"

# Arguments for compiz' autogen.sh.  You shouldn't need this. I do.
COMPIZARGS="--disable-inotify --disable-fuse"

# Uncomment and set to your preffered location if you want a different
# prefix. Or export it before starting this script.
# PREFIX="/dev/random"

# Add arguments to pass to autogen.sh here. Note that this is NOT passed
# when building the core compiz package.
GENERICARGS=""

###############################################################
## No further tinkering should be necesarry beyond this comment

DEFPREFIX="/usr/local"
MYPREFIX=${PREFIX:-$DEFPREFIX}

# Check for git
if [ -z "$(which git-clone)" ]; then
	echo "You must have GIT installed to use this script. Install the git-core package."
	exit 1;
fi
if [ -z "$(which git-pull)" ]; then
	echo "You must have GIT installed to use this script. Install the git-core package."
	exit 1;
fi

# Asks if we want to bail out.
function bail_ask
{
	echo "$1"
	echo  -n "Abort?"
	read -p " [Y/n]: " -n1 continue;
	if [ "$(echo $continue | tr [:upper:] [:lower:])" = "y" -o "$continue" = "" ]; then
		echo 
		exit 3;
	fi
	echo
}

# Checks if a local directory for $1 exist (last part of it), 
# if it does; attempts to git-pull, otherwise git clone.
function get_repo
{
	b=`echo $1 | sed 's/.*\///g'`
	here=$PWD
	if [ -d $b ]; then
		cd $b
		echo "Updating $b";
		if [ $SUPRESS = "true" ]; then
			git-pull > /dev/null
		else
			git-pull
		fi
		cd $here
	else
		echo "Cloning $b";
		git-clone $2$1
	fi
}

# Get compiz
get_repo "compiz" $COMPIZ 

# Get everything else
for a in $ITEMS ; do
	get_repo $a $REPO
done

# Builds $1 if autogen.sh exist.
function build 
{
	if [ ! -f $1/autogen.sh ]; then
		echo "Don't know how to build $1 (no autogen.sh). Skipping.";
		return;
	fi
	if [ ! -d $1 ]; then
		echo "$1 isn't a directory. Bailing out.";
		return 1;
	fi
	OLDPWD=$PWD
	cd $1
	echo "Building $1: ./autogen.sh $2"
	if [ $SUPRESS = "true" ]; then
		./autogen.sh $2 > /dev/null
	else
		./autogen.sh $2
	fi
	if [ $? -ne 0 ]; then
		echo "$1's autogen.sh reports errors. Bailing.";
		cd $OLDPWD
		return 1
	fi

	echo "Building $1: make"
	if [ $SUPRESS = "true" ]; then
		make > /dev/null
	else
		make
	fi
	if [ $? -ne 0 ]; then 
		echo "$1's make returned errors. Bailing.";
		cd $OLDPWD
		return 1
	fi

	echo "Building $1: sudo make install"
	if [ $SUPRESS = "true" ]; then
		sudo make install > /dev/null
	else
		sudo make install
	fi
	if [ $? -ne 0 ]; then
		echo "$1's sudo make install returned an error and might not work.";
		cd $OLDPWD
		return 1
	fi
	cd $OLDPWD
}

# Build compiz first, and no need to continue if it fails.
if ! build compiz "$COMPIZARGS --prefix=$MYPREFIX"; then
	echo "Failed to build compiz. No reason to continue.";
	exit 2;
fi

# Build everything else now.
for a in $ITEMS; do
	b=`echo $a | sed 's/.*\///g'`
	if ! build $b "$GENERICARGS --prefix=$MYPREFIX"; then 
		bail_ask "Failed to build $b !"
	fi
done