Mercurial > bins
comparison install.sh @ 0:a84c32f131df 1.1.29
Import vendor version
author | Peter Gervai <grin@grin.hu> |
---|---|
date | Wed, 15 Oct 2008 23:28:56 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a84c32f131df |
---|---|
1 #!/bin/sh | |
2 # -*-ksh-*- | |
3 | |
4 # This is the BINS install procedure. | |
5 # Run it as root to install BINS system wide | |
6 # or run it with your user to install it only for this user | |
7 | |
8 # PREFIX, RC and DESTDIR environment variables can be set to choose | |
9 # installation paths | |
10 | |
11 # $Id: install.sh,v 1.34 2005/08/24 21:29:44 jerome Exp $ | |
12 | |
13 set -o errexit | |
14 set -o nounset | |
15 | |
16 langs="fr de pl it ru es zh_TW nl ja eo fi hu ca" | |
17 templates="swigs joi satyap marc petrus mwolson martin" | |
18 | |
19 DESTDIR="${DESTDIR:-}" # prefix to append to the install dirs | |
20 # this is used by the Mandrake and Debian packages | |
21 PREFIX="${PREFIX:-/usr/local}" | |
22 ETC="${ETC:-/etc}" | |
23 RC="${RC:-/etc/bins}" | |
24 GLOBAL_RC="$RC" | |
25 | |
26 DESTDIR=`echo "$DESTDIR"|sed 's%/$%%'` | |
27 PREFIX=$DESTDIR/`echo "$PREFIX"|sed 's%^/%%'` | |
28 PREFIX=`echo "$PREFIX"|sed 's%/$%%'` | |
29 ETC=$DESTDIR/`echo "$ETC"|sed 's%^/%%'` | |
30 ETC=`echo "$ETC"|sed 's%/$%%'` | |
31 RC=$DESTDIR/`echo "$RC"|sed 's%^/%%'` | |
32 RC=`echo "$RC"|sed 's%/$%%'` | |
33 | |
34 BIN="$PREFIX/bin" | |
35 SHARE="$PREFIX/share" | |
36 DATA="$SHARE/bins" | |
37 GLADE="$DATA" | |
38 LOCALE="$SHARE/locale" | |
39 MAN="$PREFIX/man/man1" | |
40 | |
41 cd `dirname $0` | |
42 | |
43 cat <<!EoF | |
44 | |
45 This will install BINS program and configuration files in the following paths : | |
46 PREFIX = $PREFIX | |
47 BIN = $BIN | |
48 SHARE = $GLADE | |
49 MAN = $MAN | |
50 LOCALE = $LOCALE | |
51 RC = $RC | |
52 | |
53 ***************************** WARNING ******************************** | |
54 Note that this may replace your old programs, configuration files and | |
55 HTML templates by new ones, so you should backup them if you have | |
56 modified something for personalization. | |
57 ********************************************************************** | |
58 | |
59 Press Enter to go on or Crtl-C to stop now... | |
60 !EoF | |
61 | |
62 read dummy | |
63 | |
64 install_binaries() | |
65 { | |
66 mkdir -p $BIN 2>/dev/null || true | |
67 if [ -w $BIN ] ; then | |
68 echo "Installing program files in $BIN" | |
69 # bins_cleanupgallery anti_bins | |
70 cp bins bins_edit bins-edit-gui $BIN | |
71 chmod a+rx $BIN/bins | |
72 chmod a+rx $BIN/bins_edit | |
73 chmod a+rx $BIN/bins_cleanupgallery | |
74 chmod a+rx $BIN/bins-edit-gui | |
75 chmod a+rx $BIN/anti_bins | |
76 # perl -pi -e "s{/usr/local/share}{$SHARE}g" \ | |
77 # $BIN/bins $BIN/bins_edit $BIN/bins-edit-gui | |
78 # perl -pi -e "s{/etc/bins}{$RC}g" \ | |
79 # $BIN/bins $BIN/bins_edit $BIN/bins-edit-gui | |
80 return 0 | |
81 else | |
82 echo "Cannot write to $BIN directory." | |
83 return 1 | |
84 fi | |
85 } | |
86 | |
87 install_config() | |
88 { | |
89 mkdir -p $RC 2>/dev/null || true | |
90 if [ -w $RC ]; then | |
91 echo "Installing configuration file in $RC" | |
92 cp binsrc $RC | |
93 for T in $templates | |
94 do | |
95 if [ -d "$RC/templates.$T" ]; then | |
96 echo "Removing old template.$T in $RC" | |
97 rm -Rf "$RC/templates.$T" | |
98 fi | |
99 done | |
100 chmod -R a+r $RC/* | |
101 else | |
102 echo "Cannot write to $RC." | |
103 return 1 | |
104 fi | |
105 } | |
106 | |
107 install_data() | |
108 { | |
109 mkdir -p $DATA 2>/dev/null || true | |
110 if [ -w $DATA ]; then | |
111 for T in $templates | |
112 do | |
113 echo "Installing default HTML templates in $DATA/templates.$T" | |
114 if [ ! -d $DATA/templates.$T ] ; then | |
115 mkdir $DATA/templates.$T | |
116 fi | |
117 cp templates.$T/*.html $DATA/templates.$T | |
118 if ls templates.$T/*.js >/dev/null 2>&1 ; then | |
119 cp templates.$T/*.js $DATA/templates.$T | |
120 fi | |
121 if [ -d templates.$T/static ] ; then | |
122 cp -R templates.$T/static $DATA/templates.$T | |
123 fi | |
124 done | |
125 chmod -R a+r $DATA/* | |
126 return 0 | |
127 else | |
128 echo "Cannot write to $DATA." | |
129 return 1 | |
130 fi | |
131 } | |
132 | |
133 | |
134 # program files | |
135 set +o errexit | |
136 install_binaries | |
137 if [ "$?" -eq "1" ] ; then | |
138 BIN=~/bin | |
139 echo "Trying $BIN..." | |
140 install_binaries | |
141 if [ "$?" -eq "1" ] ; then | |
142 echo "Error: unable to find a directory to write program files, aborting." | |
143 exit 2 | |
144 fi | |
145 fi | |
146 | |
147 # config file | |
148 install_config | |
149 if [ "$?" -eq "1" ] ; then | |
150 RC=~/.bins | |
151 echo "Trying $RC..." | |
152 install_config | |
153 if [ "$?" -eq "1" ] ; then | |
154 echo "Error: unable to find a directory to write configuration file, aborting." | |
155 exit 2 | |
156 fi | |
157 fi | |
158 | |
159 # templates | |
160 install_data | |
161 if [ "$?" -eq "1" ] ; then | |
162 DATA=~/.bins | |
163 echo "Trying $DATA..." | |
164 install_data | |
165 if [ "$?" -eq "1" ] ; then | |
166 echo "Error: unable to find a directory to write templates, aborting." | |
167 exit 2 | |
168 fi | |
169 fi | |
170 set -o errexit | |
171 | |
172 # additionnal files | |
173 mkdir -p $GLADE 2>/dev/null || true | |
174 if [ -w $GLADE ] ; then | |
175 echo "Installing additionnal files in $GLADE" | |
176 cp bins-edit-gui.glade $GLADE | |
177 fi | |
178 | |
179 # man pages | |
180 mkdir -p $MAN 2>/dev/null || true | |
181 if [ -w $MAN ] ; then | |
182 echo "Installing man page in $MAN" | |
183 cp doc/*.1 $MAN | |
184 fi | |
185 | |
186 # bash completion | |
187 if [ -w $ETC/bash_completion.d ] ; then | |
188 echo "Installing bash completion system wide." | |
189 cp -f bash_completion $ETC/bash_completion.d/bins | |
190 else | |
191 mkdir ~/.bash_completion 2>/dev/null || true | |
192 if [ -w ~/.bash_completion ] ; then | |
193 echo "Installing bash completion for user `whoami`." | |
194 cp -f bash_completion ~/.bash_completion/bins | |
195 fi | |
196 fi | |
197 | |
198 # I18N files | |
199 mkdir -p $LOCALE 2>/dev/null || true | |
200 if [ -w $LOCALE ] ; then | |
201 echo "Installing internationalization messages files." | |
202 for L in $langs | |
203 do | |
204 mkdir -p $LOCALE/$L/LC_MESSAGES 2>/dev/null || true | |
205 cp intl/$L.mo $LOCALE/$L/LC_MESSAGES/bins.mo | |
206 if [ -f intl/gui-$L.mo ]; then | |
207 cp intl/gui-$L.mo $LOCALE/$L/LC_MESSAGES/bins-edit-gui.mo | |
208 fi | |
209 done | |
210 else | |
211 cat <<!EoF | |
212 | |
213 ***************************** Warning ********************************** | |
214 Cannot install internationalization messages files and additional | |
215 files. If you want to generate HTML albums in non-english langage, | |
216 use bins-edit-gui or install the man pages, then you must run this | |
217 install program as root. | |
218 ************************************************************************ | |
219 | |
220 !EoF | |
221 fi | |
222 | |
223 set +o errexit | |
224 # set directory paths in source code | |
225 echo -n "setting directory paths in programs :" | |
226 for FILE in "$BIN/bins" "$BIN/bins_edit" "$BIN/bins-edit-gui" | |
227 do | |
228 echo -n " $FILE" | |
229 ed "$FILE" <<EoF 2>/dev/null | |
230 1,\$s%/usr/local/share%$SHARE%g | |
231 1,\$s%/etc/bins%$GLOBAL_RC%g | |
232 wq | |
233 EoF | |
234 done | |
235 echo . | |
236 echo | |
237 echo "Installation complete" |