more tidy ups
[civicrm-core.git] / distmaker / distmaker.sh
CommitLineData
01ad1437 1#!/bin/bash -v
6a488035
TO
2set -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?
28P=`dirname $0`
29# Current dir
30ORIGPWD=`pwd`
445009ec 31source "$P/dists/common.sh"
6a488035
TO
32
33# Set no actions by default
34D5PACK=0
35D56PACK=0
36J5PACK=0
37WP5PACK=0
38SK5PACK=0
39L10NPACK=0
40
41# Display usage
42display_usage()
43{
bcd9e9f5
EM
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
6a488035
TO
60}
61
62
63# Check if config is ok.
64check_conf()
65{
bcd9e9f5
EM
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
6a488035
TO
87}
88
89# Check if PHP4 converstion happened
90check_php4()
91{
bcd9e9f5
EM
92 if [ ! $PHP4GENERATED = 1 ]; then
93 echo; echo "ERROR! Cannot package PHP4 version without running conversion!"; echo;
94 exit 1
95 fi
6a488035
TO
96}
97
98# Let's go.
99
100check_conf
101
102# Figure out what to do
103case $1 in
bcd9e9f5
EM
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 ;;
6a488035
TO
156
157esac
158
bed96570 159## Make sure we have the right branch or tag
445009ec 160dm_git_checkout "$DM_SOURCEDIR" "$DM_REF_CORE"
161dm_git_checkout "$DM_SOURCEDIR/packages" "$DM_REF_PACKAGES"
162
bed96570 163## in theory, this shouldn't matter, but GenCode is CMS-dependent, and we've been doing our past builds based on D7
445009ec 164dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL"
6a488035 165
c84eb16e
TO
166## Get latest dependencies
167dm_generate_vendor "$DM_SOURCEDIR"
1446640b 168dm_generate_bower "$DM_SOURCEDIR"
c84eb16e 169
6a488035
TO
170# Before anything - regenerate DAOs
171
172cd $DM_SOURCEDIR/xml
e00b8b13 173${DM_PHP:-php} GenCode.php schema/Schema.xml $DM_VERSION
6a488035
TO
174
175cd $ORIGPWD
176
177if [ "$L10NPACK" = 1 ]; then
bcd9e9f5
EM
178 echo; echo "Packaging for L10N"; echo;
179 bash $P/dists/l10n.sh
6a488035
TO
180fi
181
182if [ "$D56PACK" = 1 ]; then
bcd9e9f5
EM
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
6a488035
TO
186fi
187
188if [ "$D5PACK" = 1 ]; then
bcd9e9f5
EM
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
6a488035
TO
192fi
193
194if [ "$SKPACK" = 1 ]; then
bcd9e9f5
EM
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
6a488035
TO
198fi
199
200if [ "$J5PACK" = 1 ]; then
bcd9e9f5
EM
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
6a488035
TO
204fi
205
206if [ "$WP5PACK" = 1 ]; then
bcd9e9f5
EM
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
6a488035
TO
210fi
211
212unset DM_SOURCEDIR DM_GENFILESDIR DM_TARGETDIR DM_TMPDIR DM_PHP DM_RSYNC DM_VERSION DM_ZIP
213echo;echo "DISTMAKER Done.";echo;