-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_release.sh
291 lines (227 loc) · 6.52 KB
/
make_release.sh
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/bin/sh
# Generic shell script for building SquirrelMail plugin release
#
# Copyright (c) 2004-2012 Paul Lesniewski <[email protected]>
# Licensed under the GNU GPL. For full terms see the file COPYING.
#
#######################################################
#
# CONFIGURATION
#
# Relative paths to any and all configuration files
# for this plugin: these files will NOT be included
# in the release package built by this script; they
# should be given as relative paths and filenames from
# the plugin's own directory - for example, if you
# have a config.php file in the main plugin directory
# and a special_config.php file in a "data" subdirectory,
# this should be set as follows:
#
# CONFIG_FILES=( config.php data/special_config.php )
#
# Note that you can also use this setting to exclude
# entire subdirectories while creating the release
# package. Here is an example that skips any files
# inside a subdirectory called "cache_files" and
# completely removes a subdirectory called "tmp", as
# well as the standard config.php file:
#
# CONFIG_FILES=( config.php tmp cache_files/* )
#
#
CONFIG_FILES=( config.php )
#
# END CONFIGURATION
#
#######################################################
# avoid all kinds of potential problems; only allow
# this to be run from directory where it resides
#
if [ "$0" != "./make_release.sh" ]; then
echo
echo "Please do not run from remote directory"
echo
exit 1
fi
# grab name of package being built from directory name
#
#
PACKAGE=`echo "$PWD" | sed s/.*\\\///`
# get "pretty name" from version file
#
if [ ! -e version ]; then
echo
echo "No version file found. Please create before making release"
echo
exit 2
fi
PRETTY_NAME=`head -1 version`
# announce ourselves
#
echo
echo "Creating Release Package for $PRETTY_NAME"
echo
# grab old version number straight from the php code
#
OLD_VERSION=`echo "<?php define('SQ_INCOMPATIBLE', 'INCOMPATIBLE'); include_once('setup.php'); echo "$PACKAGE"_version(); ?>" | php -q`
REQ_SM_VERSION=`echo "<?php define('SQ_INCOMPATIBLE', 'INCOMPATIBLE'); include_once('setup.php'); \\$info = "$PACKAGE"_info(); echo \\$info['required_sm_version']; ?>" | php -q`
# check for the standard files...
#
if [ ! -e README ]; then
echo
echo "No README file found. Please create before making release"
echo
exit 3
fi
if [ ! -e docs/README ]; then
echo
echo "No docs/README file found. Please create before making release"
echo
exit 3
fi
if [ ! -e docs/INSTALL ]; then
echo
echo "No docs/INSTALL file found. Please create before making release"
echo
exit 4
fi
if [ ! -e locale/getpot ]; then
echo
echo "No locale/getpot file found. Please create before making release"
echo
exit 5
fi
if [ ! -e locale/$PACKAGE.pot ]; then
echo
echo "No locale/$PACKAGE.pot file found. Please create before making release"
echo
exit 5
fi
# just copy index.php and COPYING automatically if not found
#
if [ ! -e docs/COPYING ]; then
echo "No docs/COPYING file found. Grabbing one from ../../doc"
cp ../../doc/COPYING ./docs/
fi
if [ ! -e index.php ]; then
echo "No index.php file found. Grabbing one from ../"
cp ../index.php .
fi
if [ ! -e docs/index.php ]; then
echo "No docs/index.php file found. Grabbing one from ../"
cp ../index.php ./docs/
fi
if [ ! -e templates/index.php ]; then
echo "No templates/index.php file found. Grabbing one from ../"
cp ../index.php ./templates/
fi
if [ ! -e templates/default/index.php ]; then
echo "No templates/default/index.php file found. Grabbing one from ../"
cp ../index.php ./templates/default/
fi
if [ ! -e data/index.php ]; then
echo "No data/index.php file found. Grabbing one from ../"
cp ../index.php ./data/
fi
if [ ! -e locale/index.php ]; then
echo "No locale/index.php file found. Grabbing one from ../"
cp ../index.php ./locale/
fi
# Make our own docs/.htaccess, templates/.htaccess and locale/.htaccess if needed
#
if [ ! -e docs/.htaccess ]; then
echo "No docs/.htaccess file found. Creating..."
echo "Deny from All" > ./docs/.htaccess
fi
if [ ! -e templates/.htaccess ]; then
echo "No templates/.htaccess file found. Creating..."
echo "Deny from All" > ./templates/.htaccess
fi
if [ ! -e data/.htaccess ]; then
echo "No data/.htaccess file found. Creating..."
echo "Deny from All" > ./data/.htaccess
fi
if [ ! -e locale/.htaccess ]; then
echo "No locale/.htaccess file found. Creating..."
echo "Deny from All" > ./locale/.htaccess
fi
# remove any previous tarballs
#
while test 1; do
echo
echo -n "Remove all .tar.gz files? (y/[n]): "
read REPLY
if test -z $REPLY; then
REPLY="n"
break
fi
if test $REPLY = "y"; then
break
fi
if test $REPLY = "n"; then
break
fi
done
if [ "$REPLY" = "y" ]; then
rm -f *.tar.gz
fi
# get new version number if needed
#
if [ ! -z "$REQ_SM_VERSION" ] ; then
OLD_FULL_VERSION=$OLD_VERSION-$REQ_SM_VERSION
else
OLD_FULL_VERSION=$OLD_VERSION
fi
echo
read -p "Enter Version Number [$OLD_VERSION]: " VERSION
if [ -z "$VERSION" ] ; then
VERSION=$OLD_VERSION;
# VERSION=$OLD_FULL_VERSION;
fi
PURE_VERSION=`echo "$VERSION" | sed 's/-.*//'`
if [ ! -z "$REQ_SM_VERSION" ] ; then
FINAL_VERSION="$PURE_VERSION-$REQ_SM_VERSION"
else
FINAL_VERSION="$PURE_VERSION"
fi
# remove tarball we are building if present
#
echo
echo "Removing $PACKAGE-$FINAL_VERSION.tar.gz"
rm -f $PACKAGE-$FINAL_VERSION.tar.gz
# replace version number in info function in setup.php
# NOTE that this requires specific syntax in setup.php
# for the <package>_info() function which should be
# a line that looks like:
# 'version' => '<version>',
#
if test -e setup.php; then
echo "Replacing version in setup.php (info function)"
sed -e "s/'version' => '$OLD_VERSION',/'version' => '$PURE_VERSION',/" setup.php > setup.php.tmp
mv setup.php.tmp setup.php
fi
# update version number in version file too
#
echo "Replacing version in version file"
echo "$PRETTY_NAME" > version
echo $PURE_VERSION >> version
# Build tar command; exclude config and other irrelevant files
#
TAR_COMMAND="tar -c -z -v --exclude CVS --exclude .svn"
J=0
while [ "$J" -lt ${#CONFIG_FILES[@]} ]; do
echo "Excluding ${CONFIG_FILES[$J]}"
TAR_COMMAND="$TAR_COMMAND --exclude ${CONFIG_FILES[$J]}"
J=`expr $J + 1`
done
TAR_COMMAND="$TAR_COMMAND -f $PACKAGE-$FINAL_VERSION.tar.gz $PACKAGE"
# make tarball
#
echo "Creating $PACKAGE-$FINAL_VERSION.tar.gz"
cd ../
$TAR_COMMAND
mv $PACKAGE-$FINAL_VERSION.tar.gz $PACKAGE
cd $PACKAGE
echo
echo "Finished"
echo