Merge pull request #4938 from eileenmcnaughton/minor-tidies
[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 D5PACK=0
35 D56PACK=0
36 J5PACK=0
37 WP5PACK=0
38 SK5PACK=0
39 L10NPACK=0
40
41 # Display usage
42 display_usage()
43 {
44 echo
45 echo "Usage: "
46 echo " distmaker.sh OPTION"
47 echo
48 echo "Options available:"
49 echo " all - generate all available tarballs"
50 echo " l10n - generate internationalization data"
51 echo " d5 - generate Drupal7 PHP5 module"
52 echo " d5.6 - generate Drupal6 PHP5 module"
53 echo " j5 - generate Joomla PHP5 module"
54 echo " wp5 - generate Wordpress PHP5 module"
55 echo " sk - generate Drupal StarterKit module"
56 echo
57 echo "You also need to have distmaker.conf file in place."
58 echo "See distmaker.conf.dist for example contents."
59 echo
60 }
61
62
63 # Check if config is ok.
64 check_conf()
65 {
66 # Test for distmaker.conf file availability, cannot proceed without it anyway
67 if [ ! -f $P/distmaker.conf ] ; then
68 echo; echo "ERROR! No distmaker.conf file available!"; echo;
69 display_usage
70 exit 1
71 else
72 source "$P/distmaker.conf"
73 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
74 if [ ! -d "$DM_SOURCEDIR" ]; then
75 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;
76 fi
77 for k in "$DM_GENFILESDIR" "$DM_TARGETDIR" "$DM_TMPDIR"; do
78 if [ -z "$k" ] ; then
79 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;
80 exit 1
81 fi
82 if [ ! -d "$k" ]; then
83 mkdir -p "$k"
84 fi
85 done
86 fi
87 }
88
89 # Check if PHP4 converstion happened
90 check_php4()
91 {
92 if [ ! $PHP4GENERATED = 1 ]; then
93 echo; echo "ERROR! Cannot package PHP4 version without running conversion!"; echo;
94 exit 1
95 fi
96 }
97
98 # Let's go.
99
100 check_conf
101
102 # Figure out what to do
103 case $1 in
104 # L10N PHP5
105 l10n)
106 echo; echo "Generating L10N module"; echo;
107 L10NPACK=1
108 ;;
109
110 # DRUPAL7 PHP5
111 d5)
112 echo; echo "Generating Drupal7 PHP5 module"; echo;
113 D5PACK=1
114 ;;
115
116 # DRUPAL7 PHP5 StarterKit package
117 sk)
118 echo; echo "Generating Drupal7 PHP5 starter kit minimal module"; echo;
119 SKPACK=1
120 ;;
121
122 # DRUPAL6 PHP5
123 d5.6)
124 echo; echo "Generating Drupal6 PHP5 module"; echo;
125 D56PACK=1
126 ;;
127
128 # JOOMLA PHP5
129 j5)
130 echo; echo "Generating Joomla PHP5 module"; echo;
131 J5PACK=1
132 ;;
133
134 # WORDPRESS PHP5
135 wp5)
136 echo; echo "Generating Wordpress PHP5 module"; echo;
137 WP5PACK=1
138 ;;
139
140 # ALL
141 all)
142 echo; echo "Generating all we've got."; echo;
143 D5PACK=1
144 D56PACK=1
145 J5PACK=1
146 WP5PACK=1
147 SKPACK=1
148 L10NPACK=1
149 ;;
150
151 # USAGE
152 *)
153 display_usage
154 exit 0
155 ;;
156
157 esac
158
159 ## Make sure we have the right branch or tag
160 dm_git_checkout "$DM_SOURCEDIR" "$DM_REF_CORE"
161 dm_git_checkout "$DM_SOURCEDIR/packages" "$DM_REF_PACKAGES"
162
163 ## in theory, this shouldn't matter, but GenCode is CMS-dependent, and we've been doing our past builds based on D7
164 dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL"
165
166 ## Get latest dependencies
167 dm_generate_vendor "$DM_SOURCEDIR"
168 dm_generate_bower "$DM_SOURCEDIR"
169
170 # Before anything - regenerate DAOs
171
172 cd $DM_SOURCEDIR/xml
173 ${DM_PHP:-php} GenCode.php schema/Schema.xml $DM_VERSION
174
175 cd $ORIGPWD
176
177 if [ "$L10NPACK" = 1 ]; then
178 echo; echo "Packaging for L10N"; echo;
179 bash $P/dists/l10n.sh
180 fi
181
182 if [ "$D56PACK" = 1 ]; then
183 echo; echo "Packaging for Drupal6, PHP5 version"; echo;
184 dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL6"
185 bash $P/dists/drupal6_php5.sh
186 fi
187
188 if [ "$D5PACK" = 1 ]; then
189 echo; echo "Packaging for Drupal7, PHP5 version"; echo;
190 dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL"
191 bash $P/dists/drupal_php5.sh
192 fi
193
194 if [ "$SKPACK" = 1 ]; then
195 echo; echo "Packaging for Drupal7, PHP5 StarterKit version"; echo;
196 dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL"
197 bash $P/dists/drupal_sk_php5.sh
198 fi
199
200 if [ "$J5PACK" = 1 ]; then
201 echo; echo "Packaging for Joomla, PHP5 version"; echo;
202 dm_git_checkout "$DM_SOURCEDIR/joomla" "$DM_REF_JOOMLA"
203 bash $P/dists/joomla_php5.sh
204 fi
205
206 if [ "$WP5PACK" = 1 ]; then
207 echo; echo "Packaging for Wordpress, PHP5 version"; echo;
208 dm_git_checkout "$DM_SOURCEDIR/WordPress" "$DM_REF_WORDPRESS"
209 bash $P/dists/wordpress_php5.sh
210 fi
211
212 unset DM_SOURCEDIR DM_GENFILESDIR DM_TARGETDIR DM_TMPDIR DM_PHP DM_RSYNC DM_VERSION DM_ZIP
213 echo;echo "DISTMAKER Done.";echo;