Merge pull request #6421 from lcdservices/CRM-16968
[civicrm-core.git] / distmaker / distmaker.sh
1 #!/bin/bash -v
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
9 # Make sure that you have distmaker.conf file
10 # in the same directory containing following lines:
11 #
12 # DM_SOURCEDIR=/home/user/svn/civicrm <- sources
13 # DM_GENFILESDIR=/home/user/generated <- generated files
14 # DM_TMPDIR=/tmp <- temporary files (will be deleted afterwards)
15 # DM_TARGETDIR=/tmp/outdir <- target dir for tarballs
16 # DM_PHP=/opt/php5/bin/php <- php5 binary
17 # DM_RSYNC=/usr/bin/rsync <- rsync binary
18 # DM_VERSION=trunk.r1234 <- what the version number should be
19 # DM_ZIP=/usr/bin/zip <- zip binary
20 #
21 #
22 # ========================================================
23 # DO NOT MODIFY BELOW
24 # ========================================================
25
26
27 # Where are we called from?
28 P=`dirname $0`
29 # Current dir
30 ORIGPWD=`pwd`
31 source "$P/dists/common.sh"
32
33 # Set no actions by default
34 BPACK=0
35 D5PACK=0
36 D56PACK=0
37 J5PACK=0
38 WP5PACK=0
39 SK5PACK=0
40 L10NPACK=0
41
42 # Display usage
43 display_usage()
44 {
45 echo
46 echo "Usage: "
47 echo " distmaker.sh OPTION"
48 echo
49 echo "Options available:"
50 echo " all - generate all available tarballs"
51 echo " l10n - generate internationalization data"
52 echo " Backdrop - generate Backdrop PHP5 module"
53 echo " Drupal|d5 - generate Drupal7 PHP5 module"
54 echo " Drupal6|d5.6 - generate Drupal6 PHP5 module"
55 echo " Joomla|j5 - generate Joomla PHP5 module"
56 echo " WordPress|wp5 - generate Wordpress PHP5 module"
57 echo " sk - generate Drupal StarterKit module"
58 echo
59 echo "You also need to have distmaker.conf file in place."
60 echo "See distmaker.conf.dist for example contents."
61 echo
62 }
63
64
65 # Check if config is ok.
66 check_conf()
67 {
68 # Test for distmaker.conf file availability, cannot proceed without it anyway
69 if [ ! -f $P/distmaker.conf ] ; then
70 echo; echo "ERROR! No distmaker.conf file available!"; echo;
71 display_usage
72 exit 1
73 else
74 source "$P/distmaker.conf"
75 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_JOOMLA DM_REF_WORDPRESS DM_REF_PACKAGES
76 if [ ! -d "$DM_SOURCEDIR" ]; then
77 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;
78 fi
79 for k in "$DM_GENFILESDIR" "$DM_TARGETDIR" "$DM_TMPDIR"; do
80 if [ -z "$k" ] ; then
81 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;
82 exit 1
83 fi
84 if [ ! -d "$k" ]; then
85 mkdir -p "$k"
86 fi
87 done
88 fi
89 }
90
91 # Check if PHP4 converstion happened
92 check_php4()
93 {
94 if [ ! $PHP4GENERATED = 1 ]; then
95 echo; echo "ERROR! Cannot package PHP4 version without running conversion!"; echo;
96 exit 1
97 fi
98 }
99
100 # Let's go.
101
102 check_conf
103
104 # Figure out what to do
105 case $1 in
106 # L10N PHP5
107 l10n)
108 echo; echo "Generating L10N module"; echo;
109 L10NPACK=1
110 ;;
111
112 # BACKDROP PHP5
113 Backdrop)
114 echo; echo "Generating Backdrop PHP5 module"; echo;
115 BPACK=1
116 ;;
117
118 # DRUPAL7 PHP5
119 d5|Drupal)
120 echo; echo "Generating Drupal7 PHP5 module"; echo;
121 D5PACK=1
122 ;;
123
124 # DRUPAL7 PHP5 StarterKit package
125 sk)
126 echo; echo "Generating Drupal7 PHP5 starter kit minimal module"; echo;
127 SKPACK=1
128 ;;
129
130 # DRUPAL6 PHP5
131 d5.6|Drupal6)
132 echo; echo "Generating Drupal6 PHP5 module"; echo;
133 D56PACK=1
134 ;;
135
136 # JOOMLA PHP5
137 j5|Joomla)
138 echo; echo "Generating Joomla PHP5 module"; echo;
139 J5PACK=1
140 ;;
141
142 # WORDPRESS PHP5
143 wp5|WordPress)
144 echo; echo "Generating Wordpress PHP5 module"; echo;
145 WP5PACK=1
146 ;;
147
148 # ALL
149 all)
150 echo; echo "Generating all we've got."; echo;
151 BPACK=1
152 D5PACK=1
153 D56PACK=1
154 J5PACK=1
155 WP5PACK=1
156 SKPACK=1
157 L10NPACK=1
158 ;;
159
160 # USAGE
161 *)
162 display_usage
163 exit 0
164 ;;
165
166 esac
167
168 ## Make sure we have the right branch or tag
169 dm_git_checkout "$DM_SOURCEDIR" "$DM_REF_CORE"
170 dm_git_checkout "$DM_SOURCEDIR/packages" "$DM_REF_PACKAGES"
171
172 ## in theory, this shouldn't matter, but GenCode is CMS-dependent, and we've been doing our past builds based on D7
173 GENCODE_CMS=
174 if [ -d "$DM_SOURCEDIR/backdrop" ]; then
175 dm_git_checkout "$DM_SOURCEDIR/backdrop" "$DM_REF_BACKDROP"
176 GENCODE_CMS=Backdrop
177 fi
178 if [ -d "$DM_SOURCEDIR/drupal" ]; then
179 dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL"
180 GENCODE_CMS=Drupal
181 fi
182
183 ## Get latest dependencies
184 dm_generate_vendor "$DM_SOURCEDIR"
185 dm_generate_bower "$DM_SOURCEDIR"
186
187 # Before anything - regenerate DAOs
188
189 cd $DM_SOURCEDIR/xml
190 ${DM_PHP:-php} GenCode.php schema/Schema.xml $DM_VERSION $GENCODE_CMS
191
192 cd $ORIGPWD
193
194 if [ "$L10NPACK" = 1 ]; then
195 echo; echo "Packaging for L10N"; echo;
196 bash $P/dists/l10n.sh
197 fi
198
199 if [ "$BPACK" = 1 ]; then
200 echo; echo "Packaging for Backdrop, PHP5 version"; echo;
201 dm_git_checkout "$DM_SOURCEDIR/backdrop" "$DM_REF_BACKDROP"
202 bash $P/dists/backdrop_php5.sh
203 fi
204
205 if [ "$D56PACK" = 1 ]; then
206 echo; echo "Packaging for Drupal6, PHP5 version"; echo;
207 dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL6"
208 bash $P/dists/drupal6_php5.sh
209 fi
210
211 if [ "$D5PACK" = 1 ]; then
212 echo; echo "Packaging for Drupal7, PHP5 version"; echo;
213 dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL"
214 bash $P/dists/drupal_php5.sh
215 fi
216
217 if [ "$SKPACK" = 1 ]; then
218 echo; echo "Packaging for Drupal7, PHP5 StarterKit version"; echo;
219 dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL"
220 bash $P/dists/drupal_sk_php5.sh
221 fi
222
223 if [ "$J5PACK" = 1 ]; then
224 echo; echo "Packaging for Joomla, PHP5 version"; echo;
225 dm_git_checkout "$DM_SOURCEDIR/joomla" "$DM_REF_JOOMLA"
226 bash $P/dists/joomla_php5.sh
227 fi
228
229 if [ "$WP5PACK" = 1 ]; then
230 echo; echo "Packaging for Wordpress, PHP5 version"; echo;
231 dm_git_checkout "$DM_SOURCEDIR/WordPress" "$DM_REF_WORDPRESS"
232 bash $P/dists/wordpress_php5.sh
233 fi
234
235 unset DM_SOURCEDIR DM_GENFILESDIR DM_TARGETDIR DM_TMPDIR DM_PHP DM_RSYNC DM_VERSION DM_ZIP
236 echo;echo "DISTMAKER Done.";echo;