Commit | Line | Data |
---|---|---|
01ad1437 | 1 | #!/bin/bash -v |
6a488035 TO |
2 | set -e |
3 | ||
4 | # This is distmaker script for CiviCRM | |
5 | # Author: michau | |
6 | # "Protected by an electric fence and copyright control." | |
7 | # Thanks to Kleptones for moral support when writing this. | |
8 | ||
8eb76391 | 9 | # You need to ensure the following variables are defined. They are traditionally defined |
10 | # in distmaker.conf but you can also defined them as an environment variable or by | |
11 | # calling the script with env DM_REF_CORE=4.7 (for example). | |
6a488035 TO |
12 | # |
13 | # DM_SOURCEDIR=/home/user/svn/civicrm <- sources | |
14 | # DM_GENFILESDIR=/home/user/generated <- generated files | |
15 | # DM_TMPDIR=/tmp <- temporary files (will be deleted afterwards) | |
16 | # DM_TARGETDIR=/tmp/outdir <- target dir for tarballs | |
8eb76391 | 17 | # DM_REF_CORE=master <- Git branch/tag name |
18 | # | |
19 | # Optional variables | |
6a488035 TO |
20 | # DM_PHP=/opt/php5/bin/php <- php5 binary |
21 | # DM_RSYNC=/usr/bin/rsync <- rsync binary | |
22 | # DM_VERSION=trunk.r1234 <- what the version number should be | |
23 | # DM_ZIP=/usr/bin/zip <- zip binary | |
24 | # | |
25 | # | |
26 | # ======================================================== | |
27 | # DO NOT MODIFY BELOW | |
28 | # ======================================================== | |
29 | ||
30 | ||
31 | # Where are we called from? | |
32 | P=`dirname $0` | |
33 | # Current dir | |
34 | ORIGPWD=`pwd` | |
445009ec | 35 | source "$P/dists/common.sh" |
6a488035 TO |
36 | |
37 | # Set no actions by default | |
f07f92fa | 38 | BPACK=0 |
6a488035 TO |
39 | D5PACK=0 |
40 | D56PACK=0 | |
8eb76391 | 41 | D7DIR=0 |
6a488035 TO |
42 | J5PACK=0 |
43 | WP5PACK=0 | |
22e9ee71 | 44 | PATCHPACK=0 |
6a488035 TO |
45 | SK5PACK=0 |
46 | L10NPACK=0 | |
f9128cb9 | 47 | REPOREPORT=0 |
6a488035 TO |
48 | |
49 | # Display usage | |
50 | display_usage() | |
51 | { | |
bcd9e9f5 EM |
52 | echo |
53 | echo "Usage: " | |
54 | echo " distmaker.sh OPTION" | |
55 | echo | |
56 | echo "Options available:" | |
f07f92fa TO |
57 | echo " all - generate all available tarballs" |
58 | echo " l10n - generate internationalization data" | |
59 | echo " Backdrop - generate Backdrop PHP5 module" | |
60 | echo " Drupal|d5 - generate Drupal7 PHP5 module" | |
61 | echo " Drupal6|d5.6 - generate Drupal6 PHP5 module" | |
8eb76391 | 62 | echo " d7_dir - generate Drupal7 PHP5 module, but output to a directory, no tarball" |
f07f92fa TO |
63 | echo " Joomla|j5 - generate Joomla PHP5 module" |
64 | echo " WordPress|wp5 - generate Wordpress PHP5 module" | |
22e9ee71 | 65 | echo " patchset - generate a tarball with patch files" |
f07f92fa | 66 | echo " sk - generate Drupal StarterKit module" |
bcd9e9f5 EM |
67 | echo |
68 | echo "You also need to have distmaker.conf file in place." | |
69 | echo "See distmaker.conf.dist for example contents." | |
8eb76391 | 70 | echo "Alternatively you can set the required variables as " |
71 | echo "environment variables, eg. for your machine or by calling " | |
72 | echo "this script using " | |
73 | echo | |
74 | echo "env DM_TARGETDIR=/path/to/output/dir/for/files/or/tarball distmaker.sh all" | |
bcd9e9f5 | 75 | echo |
8eb76391 | 76 | echo "optional environmentals:" |
77 | echo " DM_SOURCEDIR " | |
78 | echo " DM_GENFILESDIR (default $TMPDIR/genfiles)" | |
79 | echo " DM_TARGETDIR= (default $TMPDIR/civicrm)" | |
80 | echo " DM_OUTPUTDIR= (default $DM_TARGETDIR/civicrm_files)" | |
81 | echo | |
82 | ||
6a488035 TO |
83 | } |
84 | ||
8eb76391 | 85 | THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; |
6a488035 TO |
86 | |
87 | # Check if config is ok. | |
88 | check_conf() | |
89 | { | |
8eb76391 | 90 | if [ -f $P/distmaker.conf ] ; then |
91 | source "$P/distmaker.conf" | |
92 | fi | |
93 | ||
94 | if [ -z $DM_SOURCEDIR ] ; then | |
95 | DM_SOURCEDIR="$THIS_DIR/.."; | |
96 | echo "Setting source dir to $DM_SOURCEDIR"; | |
97 | fi | |
98 | ||
99 | if [ -z $DM_TMPDIR ] && [ -e $TMPDIR ] ; then | |
100 | DM_TMPDIR=$TMPDIR/civicrm | |
101 | fi | |
102 | ||
103 | if [ -z $DM_GENFILESDIR ] && [ -e $TMPDIR ] ; then | |
104 | DM_GENFILESDIR=$TMPDIR/genfiles | |
105 | fi | |
106 | ||
107 | if [ -z $DM_PACKAGESDIR ] ; then | |
108 | DM_PACKAGESDIR="$DM_SOURCEDIR/packages" | |
109 | fi | |
110 | ||
111 | if [ -z $DM_OUTPUTDIR ] ; then | |
112 | DM_OUTPUTDIR="$DM_TARGETDIR/civicrm_files" | |
113 | fi | |
114 | ||
bcd9e9f5 | 115 | # Test for distmaker.conf file availability, cannot proceed without it anyway |
8eb76391 | 116 | if [ -z $DM_GENFILESDIR ] || [ -z $DM_TMPDIR ] || [ -z $DM_TARGETDIR ]; then |
117 | echo; echo "Required variables not defined!"; echo; | |
bcd9e9f5 | 118 | display_usage |
8eb76391 | 119 | echo "your variables" |
120 | echo "DM_SOURCEDIR : $DM_SOURCEDIR"; | |
121 | echo "DM_TARGETDIR : $DM_TARGETDIR (required)"; | |
122 | echo "DM_TMPDIR : $DM_TMPDIR"; | |
123 | echo "DM_GENFILESDIR : $DM_GENFILESDIR"; | |
124 | echo "DM_PACKAGESDIR : $DM_PACKAGESDIR"; | |
125 | echo "Current directory is : $THIS_DIR"; | |
bcd9e9f5 EM |
126 | exit 1 |
127 | else | |
3476a08c | 128 | export DM_SOURCEDIR DM_GENFILESDIR DM_TMPDIR DM_TARGETDIR DM_PHP DM_RSYNC DM_ZIP DM_VERSION DM_REF_CORE DM_REF_DRUPAL DM_REF_DRUPAL6 DM_REF_DRUPAL8 DM_REF_JOOMLA DM_REF_WORDPRESS DM_REF_PACKAGES |
bcd9e9f5 EM |
129 | if [ ! -d "$DM_SOURCEDIR" ]; then |
130 | echo; echo "ERROR! " DM_SOURCEDIR "directory not found!"; echo "(if you get empty directory name, it might mean that one of necessary variables is not set)"; echo; | |
131 | fi | |
132 | for k in "$DM_GENFILESDIR" "$DM_TARGETDIR" "$DM_TMPDIR"; do | |
133 | if [ -z "$k" ] ; then | |
134 | echo; echo "ERROR! " $k "directory not found!"; echo "(if you get empty directory name, it might mean that one of necessary variables is not set)"; echo; | |
135 | exit 1 | |
136 | fi | |
137 | if [ ! -d "$k" ]; then | |
138 | mkdir -p "$k" | |
139 | fi | |
140 | done | |
141 | fi | |
6a488035 TO |
142 | } |
143 | ||
6a488035 TO |
144 | # Let's go. |
145 | ||
146 | check_conf | |
147 | ||
148 | # Figure out what to do | |
149 | case $1 in | |
bcd9e9f5 EM |
150 | # L10N PHP5 |
151 | l10n) | |
152 | echo; echo "Generating L10N module"; echo; | |
153 | L10NPACK=1 | |
154 | ;; | |
155 | ||
f07f92fa TO |
156 | # BACKDROP PHP5 |
157 | Backdrop) | |
158 | echo; echo "Generating Backdrop PHP5 module"; echo; | |
159 | BPACK=1 | |
160 | ;; | |
161 | ||
bcd9e9f5 | 162 | # DRUPAL7 PHP5 |
f07f92fa | 163 | d5|Drupal) |
bcd9e9f5 EM |
164 | echo; echo "Generating Drupal7 PHP5 module"; echo; |
165 | D5PACK=1 | |
166 | ;; | |
167 | ||
8eb76391 | 168 | # Drupal 7 - Output to directory |
169 | d7_dir) | |
170 | echo; echo "Generating Drupal7 Directory"; echo; | |
171 | D7DIR=1 | |
172 | ;; | |
173 | ||
bcd9e9f5 EM |
174 | # DRUPAL7 PHP5 StarterKit package |
175 | sk) | |
176 | echo; echo "Generating Drupal7 PHP5 starter kit minimal module"; echo; | |
177 | SKPACK=1 | |
178 | ;; | |
179 | ||
180 | # DRUPAL6 PHP5 | |
f07f92fa | 181 | d5.6|Drupal6) |
bcd9e9f5 EM |
182 | echo; echo "Generating Drupal6 PHP5 module"; echo; |
183 | D56PACK=1 | |
184 | ;; | |
185 | ||
186 | # JOOMLA PHP5 | |
f07f92fa | 187 | j5|Joomla) |
bcd9e9f5 EM |
188 | echo; echo "Generating Joomla PHP5 module"; echo; |
189 | J5PACK=1 | |
190 | ;; | |
191 | ||
192 | # WORDPRESS PHP5 | |
f07f92fa | 193 | wp5|WordPress) |
bcd9e9f5 EM |
194 | echo; echo "Generating Wordpress PHP5 module"; echo; |
195 | WP5PACK=1 | |
196 | ;; | |
197 | ||
22e9ee71 TO |
198 | ## PATCHSET export |
199 | patchset) | |
200 | echo; echo "Generating patchset"; echo; | |
201 | PATCHPACK=1 | |
202 | ;; | |
203 | ||
f9128cb9 TO |
204 | # REPO REPORT PHP5 |
205 | report) | |
206 | echo; echo "Generating repo report module"; echo; | |
207 | REPOREPORT=1 | |
208 | ;; | |
209 | ||
bcd9e9f5 EM |
210 | # ALL |
211 | all) | |
8eb76391 | 212 | echo; echo "Generating all the tarballs we've got (not the directories). "; echo; |
f07f92fa | 213 | BPACK=1 |
bcd9e9f5 EM |
214 | D5PACK=1 |
215 | D56PACK=1 | |
216 | J5PACK=1 | |
217 | WP5PACK=1 | |
22e9ee71 | 218 | PATCHPACK=1 |
bcd9e9f5 EM |
219 | SKPACK=1 |
220 | L10NPACK=1 | |
f9128cb9 | 221 | REPOREPORT=1 |
bcd9e9f5 EM |
222 | ;; |
223 | ||
224 | # USAGE | |
225 | *) | |
226 | display_usage | |
227 | exit 0 | |
228 | ;; | |
6a488035 TO |
229 | |
230 | esac | |
231 | ||
bed96570 | 232 | ## Make sure we have the right branch or tag |
445009ec | 233 | dm_git_checkout "$DM_SOURCEDIR" "$DM_REF_CORE" |
8eb76391 | 234 | dm_git_checkout "$DM_PACKAGESDIR" "$DM_REF_PACKAGES" |
445009ec | 235 | |
bed96570 | 236 | ## in theory, this shouldn't matter, but GenCode is CMS-dependent, and we've been doing our past builds based on D7 |
c0e8d80b TO |
237 | GENCODE_CMS= |
238 | if [ -d "$DM_SOURCEDIR/backdrop" ]; then | |
239 | dm_git_checkout "$DM_SOURCEDIR/backdrop" "$DM_REF_BACKDROP" | |
240 | GENCODE_CMS=Backdrop | |
241 | fi | |
242 | if [ -d "$DM_SOURCEDIR/drupal" ]; then | |
243 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL" | |
244 | GENCODE_CMS=Drupal | |
245 | fi | |
3476a08c TO |
246 | if [ -d "$DM_SOURCEDIR/drupal-8" ]; then |
247 | dm_git_checkout "$DM_SOURCEDIR/drupal-8" "$DM_REF_DRUPAL8" | |
248 | fi | |
6a488035 | 249 | |
a8fadf7d TO |
250 | ## Get fresh dependencies |
251 | [ -d "$DM_SOURCEDIR/vendor" ] && rm -rf $DM_SOURCEDIR/vendor | |
252 | [ -d "$DM_SOURCEDIR/bower_components" ] && rm -rf $DM_SOURCEDIR/bower_components | |
c84eb16e TO |
253 | dm_generate_vendor "$DM_SOURCEDIR" |
254 | ||
6a488035 TO |
255 | # Before anything - regenerate DAOs |
256 | ||
257 | cd $DM_SOURCEDIR/xml | |
c0e8d80b | 258 | ${DM_PHP:-php} GenCode.php schema/Schema.xml $DM_VERSION $GENCODE_CMS |
6a488035 TO |
259 | |
260 | cd $ORIGPWD | |
261 | ||
262 | if [ "$L10NPACK" = 1 ]; then | |
bcd9e9f5 EM |
263 | echo; echo "Packaging for L10N"; echo; |
264 | bash $P/dists/l10n.sh | |
6a488035 TO |
265 | fi |
266 | ||
f07f92fa TO |
267 | if [ "$BPACK" = 1 ]; then |
268 | echo; echo "Packaging for Backdrop, PHP5 version"; echo; | |
c0e8d80b | 269 | dm_git_checkout "$DM_SOURCEDIR/backdrop" "$DM_REF_BACKDROP" |
f07f92fa TO |
270 | bash $P/dists/backdrop_php5.sh |
271 | fi | |
272 | ||
6a488035 | 273 | if [ "$D56PACK" = 1 ]; then |
bcd9e9f5 EM |
274 | echo; echo "Packaging for Drupal6, PHP5 version"; echo; |
275 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL6" | |
276 | bash $P/dists/drupal6_php5.sh | |
6a488035 TO |
277 | fi |
278 | ||
279 | if [ "$D5PACK" = 1 ]; then | |
bcd9e9f5 EM |
280 | echo; echo "Packaging for Drupal7, PHP5 version"; echo; |
281 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL" | |
282 | bash $P/dists/drupal_php5.sh | |
6a488035 TO |
283 | fi |
284 | ||
8eb76391 | 285 | if [ "$D7DIR" = 1 ]; then |
286 | echo; echo "Packaging for Drupal7, Directory not tarball, PHP5 version"; echo; | |
287 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL" | |
288 | bash $P/dists/drupal7_dir_php5.sh | |
289 | fi | |
290 | ||
6a488035 | 291 | if [ "$SKPACK" = 1 ]; then |
bcd9e9f5 EM |
292 | echo; echo "Packaging for Drupal7, PHP5 StarterKit version"; echo; |
293 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL" | |
294 | bash $P/dists/drupal_sk_php5.sh | |
6a488035 TO |
295 | fi |
296 | ||
297 | if [ "$J5PACK" = 1 ]; then | |
bcd9e9f5 EM |
298 | echo; echo "Packaging for Joomla, PHP5 version"; echo; |
299 | dm_git_checkout "$DM_SOURCEDIR/joomla" "$DM_REF_JOOMLA" | |
300 | bash $P/dists/joomla_php5.sh | |
6a488035 TO |
301 | fi |
302 | ||
303 | if [ "$WP5PACK" = 1 ]; then | |
bcd9e9f5 EM |
304 | echo; echo "Packaging for Wordpress, PHP5 version"; echo; |
305 | dm_git_checkout "$DM_SOURCEDIR/WordPress" "$DM_REF_WORDPRESS" | |
306 | bash $P/dists/wordpress_php5.sh | |
6a488035 TO |
307 | fi |
308 | ||
22e9ee71 TO |
309 | if [ "$PATCHPACK" = 1 ]; then |
310 | echo; echo "Packaging for patchset tarball"; echo; | |
311 | bash $P/dists/patchset.sh | |
312 | fi | |
313 | ||
f9128cb9 TO |
314 | if [ "$REPOREPORT" = 1 ]; then |
315 | echo; echo "Preparing repository report"; echo; | |
f9702176 TO |
316 | env \ |
317 | L10NPACK="$L10NPACK" \ | |
318 | BPACK="$BPACK" \ | |
319 | D56PACK="$D56PACK" \ | |
320 | D5PACK="$D5PACK" \ | |
321 | D7DIR="$D7DIR" \ | |
322 | SKPACK="$SKPACK" \ | |
323 | J5PACK="$J5PACK" \ | |
324 | WP5PACK="$WP5PACK" \ | |
325 | bash $P/dists/repo-report.sh | |
f9128cb9 TO |
326 | fi |
327 | ||
6a488035 TO |
328 | unset DM_SOURCEDIR DM_GENFILESDIR DM_TARGETDIR DM_TMPDIR DM_PHP DM_RSYNC DM_VERSION DM_ZIP |
329 | echo;echo "DISTMAKER Done.";echo; |