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 | |
44 | SK5PACK=0 | |
45 | L10NPACK=0 | |
f9128cb9 | 46 | REPOREPORT=0 |
6a488035 TO |
47 | |
48 | # Display usage | |
49 | display_usage() | |
50 | { | |
bcd9e9f5 EM |
51 | echo |
52 | echo "Usage: " | |
53 | echo " distmaker.sh OPTION" | |
54 | echo | |
55 | echo "Options available:" | |
f07f92fa TO |
56 | echo " all - generate all available tarballs" |
57 | echo " l10n - generate internationalization data" | |
58 | echo " Backdrop - generate Backdrop PHP5 module" | |
59 | echo " Drupal|d5 - generate Drupal7 PHP5 module" | |
60 | echo " Drupal6|d5.6 - generate Drupal6 PHP5 module" | |
8eb76391 | 61 | echo " d7_dir - generate Drupal7 PHP5 module, but output to a directory, no tarball" |
f07f92fa TO |
62 | echo " Joomla|j5 - generate Joomla PHP5 module" |
63 | echo " WordPress|wp5 - generate Wordpress PHP5 module" | |
64 | echo " sk - generate Drupal StarterKit module" | |
bcd9e9f5 EM |
65 | echo |
66 | echo "You also need to have distmaker.conf file in place." | |
67 | echo "See distmaker.conf.dist for example contents." | |
8eb76391 | 68 | echo "Alternatively you can set the required variables as " |
69 | echo "environment variables, eg. for your machine or by calling " | |
70 | echo "this script using " | |
71 | echo | |
72 | echo "env DM_TARGETDIR=/path/to/output/dir/for/files/or/tarball distmaker.sh all" | |
bcd9e9f5 | 73 | echo |
8eb76391 | 74 | echo "optional environmentals:" |
75 | echo " DM_SOURCEDIR " | |
76 | echo " DM_GENFILESDIR (default $TMPDIR/genfiles)" | |
77 | echo " DM_TARGETDIR= (default $TMPDIR/civicrm)" | |
78 | echo " DM_OUTPUTDIR= (default $DM_TARGETDIR/civicrm_files)" | |
79 | echo | |
80 | ||
6a488035 TO |
81 | } |
82 | ||
8eb76391 | 83 | THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; |
6a488035 TO |
84 | |
85 | # Check if config is ok. | |
86 | check_conf() | |
87 | { | |
8eb76391 | 88 | if [ -f $P/distmaker.conf ] ; then |
89 | source "$P/distmaker.conf" | |
90 | fi | |
91 | ||
92 | if [ -z $DM_SOURCEDIR ] ; then | |
93 | DM_SOURCEDIR="$THIS_DIR/.."; | |
94 | echo "Setting source dir to $DM_SOURCEDIR"; | |
95 | fi | |
96 | ||
97 | if [ -z $DM_TMPDIR ] && [ -e $TMPDIR ] ; then | |
98 | DM_TMPDIR=$TMPDIR/civicrm | |
99 | fi | |
100 | ||
101 | if [ -z $DM_GENFILESDIR ] && [ -e $TMPDIR ] ; then | |
102 | DM_GENFILESDIR=$TMPDIR/genfiles | |
103 | fi | |
104 | ||
105 | if [ -z $DM_PACKAGESDIR ] ; then | |
106 | DM_PACKAGESDIR="$DM_SOURCEDIR/packages" | |
107 | fi | |
108 | ||
109 | if [ -z $DM_OUTPUTDIR ] ; then | |
110 | DM_OUTPUTDIR="$DM_TARGETDIR/civicrm_files" | |
111 | fi | |
112 | ||
bcd9e9f5 | 113 | # Test for distmaker.conf file availability, cannot proceed without it anyway |
8eb76391 | 114 | if [ -z $DM_GENFILESDIR ] || [ -z $DM_TMPDIR ] || [ -z $DM_TARGETDIR ]; then |
115 | echo; echo "Required variables not defined!"; echo; | |
bcd9e9f5 | 116 | display_usage |
8eb76391 | 117 | echo "your variables" |
118 | echo "DM_SOURCEDIR : $DM_SOURCEDIR"; | |
119 | echo "DM_TARGETDIR : $DM_TARGETDIR (required)"; | |
120 | echo "DM_TMPDIR : $DM_TMPDIR"; | |
121 | echo "DM_GENFILESDIR : $DM_GENFILESDIR"; | |
122 | echo "DM_PACKAGESDIR : $DM_PACKAGESDIR"; | |
123 | echo "Current directory is : $THIS_DIR"; | |
bcd9e9f5 EM |
124 | exit 1 |
125 | else | |
3476a08c | 126 | 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 |
127 | if [ ! -d "$DM_SOURCEDIR" ]; then |
128 | 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; | |
129 | fi | |
130 | for k in "$DM_GENFILESDIR" "$DM_TARGETDIR" "$DM_TMPDIR"; do | |
131 | if [ -z "$k" ] ; then | |
132 | 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; | |
133 | exit 1 | |
134 | fi | |
135 | if [ ! -d "$k" ]; then | |
136 | mkdir -p "$k" | |
137 | fi | |
138 | done | |
139 | fi | |
6a488035 TO |
140 | } |
141 | ||
6a488035 TO |
142 | # Let's go. |
143 | ||
144 | check_conf | |
145 | ||
146 | # Figure out what to do | |
147 | case $1 in | |
bcd9e9f5 EM |
148 | # L10N PHP5 |
149 | l10n) | |
150 | echo; echo "Generating L10N module"; echo; | |
151 | L10NPACK=1 | |
152 | ;; | |
153 | ||
f07f92fa TO |
154 | # BACKDROP PHP5 |
155 | Backdrop) | |
156 | echo; echo "Generating Backdrop PHP5 module"; echo; | |
157 | BPACK=1 | |
158 | ;; | |
159 | ||
bcd9e9f5 | 160 | # DRUPAL7 PHP5 |
f07f92fa | 161 | d5|Drupal) |
bcd9e9f5 EM |
162 | echo; echo "Generating Drupal7 PHP5 module"; echo; |
163 | D5PACK=1 | |
164 | ;; | |
165 | ||
8eb76391 | 166 | # Drupal 7 - Output to directory |
167 | d7_dir) | |
168 | echo; echo "Generating Drupal7 Directory"; echo; | |
169 | D7DIR=1 | |
170 | ;; | |
171 | ||
bcd9e9f5 EM |
172 | # DRUPAL7 PHP5 StarterKit package |
173 | sk) | |
174 | echo; echo "Generating Drupal7 PHP5 starter kit minimal module"; echo; | |
175 | SKPACK=1 | |
176 | ;; | |
177 | ||
178 | # DRUPAL6 PHP5 | |
f07f92fa | 179 | d5.6|Drupal6) |
bcd9e9f5 EM |
180 | echo; echo "Generating Drupal6 PHP5 module"; echo; |
181 | D56PACK=1 | |
182 | ;; | |
183 | ||
184 | # JOOMLA PHP5 | |
f07f92fa | 185 | j5|Joomla) |
bcd9e9f5 EM |
186 | echo; echo "Generating Joomla PHP5 module"; echo; |
187 | J5PACK=1 | |
188 | ;; | |
189 | ||
190 | # WORDPRESS PHP5 | |
f07f92fa | 191 | wp5|WordPress) |
bcd9e9f5 EM |
192 | echo; echo "Generating Wordpress PHP5 module"; echo; |
193 | WP5PACK=1 | |
194 | ;; | |
195 | ||
f9128cb9 TO |
196 | # REPO REPORT PHP5 |
197 | report) | |
198 | echo; echo "Generating repo report module"; echo; | |
199 | REPOREPORT=1 | |
200 | ;; | |
201 | ||
bcd9e9f5 EM |
202 | # ALL |
203 | all) | |
8eb76391 | 204 | echo; echo "Generating all the tarballs we've got (not the directories). "; echo; |
f07f92fa | 205 | BPACK=1 |
bcd9e9f5 EM |
206 | D5PACK=1 |
207 | D56PACK=1 | |
208 | J5PACK=1 | |
209 | WP5PACK=1 | |
210 | SKPACK=1 | |
211 | L10NPACK=1 | |
f9128cb9 | 212 | REPOREPORT=1 |
bcd9e9f5 EM |
213 | ;; |
214 | ||
215 | # USAGE | |
216 | *) | |
217 | display_usage | |
218 | exit 0 | |
219 | ;; | |
6a488035 TO |
220 | |
221 | esac | |
222 | ||
bed96570 | 223 | ## Make sure we have the right branch or tag |
445009ec | 224 | dm_git_checkout "$DM_SOURCEDIR" "$DM_REF_CORE" |
8eb76391 | 225 | dm_git_checkout "$DM_PACKAGESDIR" "$DM_REF_PACKAGES" |
445009ec | 226 | |
bed96570 | 227 | ## in theory, this shouldn't matter, but GenCode is CMS-dependent, and we've been doing our past builds based on D7 |
c0e8d80b TO |
228 | GENCODE_CMS= |
229 | if [ -d "$DM_SOURCEDIR/backdrop" ]; then | |
230 | dm_git_checkout "$DM_SOURCEDIR/backdrop" "$DM_REF_BACKDROP" | |
231 | GENCODE_CMS=Backdrop | |
232 | fi | |
233 | if [ -d "$DM_SOURCEDIR/drupal" ]; then | |
234 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL" | |
235 | GENCODE_CMS=Drupal | |
236 | fi | |
3476a08c TO |
237 | if [ -d "$DM_SOURCEDIR/drupal-8" ]; then |
238 | dm_git_checkout "$DM_SOURCEDIR/drupal-8" "$DM_REF_DRUPAL8" | |
239 | fi | |
6a488035 | 240 | |
a8fadf7d TO |
241 | ## Get fresh dependencies |
242 | [ -d "$DM_SOURCEDIR/vendor" ] && rm -rf $DM_SOURCEDIR/vendor | |
243 | [ -d "$DM_SOURCEDIR/bower_components" ] && rm -rf $DM_SOURCEDIR/bower_components | |
c84eb16e TO |
244 | dm_generate_vendor "$DM_SOURCEDIR" |
245 | ||
6a488035 TO |
246 | # Before anything - regenerate DAOs |
247 | ||
248 | cd $DM_SOURCEDIR/xml | |
c0e8d80b | 249 | ${DM_PHP:-php} GenCode.php schema/Schema.xml $DM_VERSION $GENCODE_CMS |
6a488035 TO |
250 | |
251 | cd $ORIGPWD | |
252 | ||
253 | if [ "$L10NPACK" = 1 ]; then | |
bcd9e9f5 EM |
254 | echo; echo "Packaging for L10N"; echo; |
255 | bash $P/dists/l10n.sh | |
6a488035 TO |
256 | fi |
257 | ||
f07f92fa TO |
258 | if [ "$BPACK" = 1 ]; then |
259 | echo; echo "Packaging for Backdrop, PHP5 version"; echo; | |
c0e8d80b | 260 | dm_git_checkout "$DM_SOURCEDIR/backdrop" "$DM_REF_BACKDROP" |
f07f92fa TO |
261 | bash $P/dists/backdrop_php5.sh |
262 | fi | |
263 | ||
6a488035 | 264 | if [ "$D56PACK" = 1 ]; then |
bcd9e9f5 EM |
265 | echo; echo "Packaging for Drupal6, PHP5 version"; echo; |
266 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL6" | |
267 | bash $P/dists/drupal6_php5.sh | |
6a488035 TO |
268 | fi |
269 | ||
270 | if [ "$D5PACK" = 1 ]; then | |
bcd9e9f5 EM |
271 | echo; echo "Packaging for Drupal7, PHP5 version"; echo; |
272 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL" | |
273 | bash $P/dists/drupal_php5.sh | |
6a488035 TO |
274 | fi |
275 | ||
8eb76391 | 276 | if [ "$D7DIR" = 1 ]; then |
277 | echo; echo "Packaging for Drupal7, Directory not tarball, PHP5 version"; echo; | |
278 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL" | |
279 | bash $P/dists/drupal7_dir_php5.sh | |
280 | fi | |
281 | ||
6a488035 | 282 | if [ "$SKPACK" = 1 ]; then |
bcd9e9f5 EM |
283 | echo; echo "Packaging for Drupal7, PHP5 StarterKit version"; echo; |
284 | dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL" | |
285 | bash $P/dists/drupal_sk_php5.sh | |
6a488035 TO |
286 | fi |
287 | ||
288 | if [ "$J5PACK" = 1 ]; then | |
bcd9e9f5 EM |
289 | echo; echo "Packaging for Joomla, PHP5 version"; echo; |
290 | dm_git_checkout "$DM_SOURCEDIR/joomla" "$DM_REF_JOOMLA" | |
291 | bash $P/dists/joomla_php5.sh | |
6a488035 TO |
292 | fi |
293 | ||
294 | if [ "$WP5PACK" = 1 ]; then | |
bcd9e9f5 EM |
295 | echo; echo "Packaging for Wordpress, PHP5 version"; echo; |
296 | dm_git_checkout "$DM_SOURCEDIR/WordPress" "$DM_REF_WORDPRESS" | |
297 | bash $P/dists/wordpress_php5.sh | |
6a488035 TO |
298 | fi |
299 | ||
f9128cb9 TO |
300 | if [ "$REPOREPORT" = 1 ]; then |
301 | echo; echo "Preparing repository report"; echo; | |
f9702176 TO |
302 | env \ |
303 | L10NPACK="$L10NPACK" \ | |
304 | BPACK="$BPACK" \ | |
305 | D56PACK="$D56PACK" \ | |
306 | D5PACK="$D5PACK" \ | |
307 | D7DIR="$D7DIR" \ | |
308 | SKPACK="$SKPACK" \ | |
309 | J5PACK="$J5PACK" \ | |
310 | WP5PACK="$WP5PACK" \ | |
311 | bash $P/dists/repo-report.sh | |
f9128cb9 TO |
312 | fi |
313 | ||
6a488035 TO |
314 | unset DM_SOURCEDIR DM_GENFILESDIR DM_TARGETDIR DM_TMPDIR DM_PHP DM_RSYNC DM_VERSION DM_ZIP |
315 | echo;echo "DISTMAKER Done.";echo; |