Commit | Line | Data |
---|---|---|
69ff4a4a | 1 | #!/bin/bash |
2 | ||
fa379693 | 3 | ## Delete/create a dir |
4 | ## usage: dm_reset_dirs <path1> <path2> ... | |
5 | function dm_reset_dirs() { | |
6 | for d in "$@" ; do | |
7 | [ -d "$d" ] && rm -rf "$d" | |
8 | done | |
9 | ||
10 | mkdir -p "$@" | |
11 | } | |
12 | ||
69ff4a4a | 13 | ## Copy files from one dir into another dir |
14 | ## usage: dm_install_dir <from-dir> <to-dir> | |
15 | function dm_install_dir() { | |
16 | local from="$1" | |
17 | local to="$2" | |
18 | ||
19 | if [ ! -d "$to" ]; then | |
20 | mkdir -p "$to" | |
21 | fi | |
e365b6e5 | 22 | $DM_RSYNC -avC --exclude=.git --exclude=.svn "$from/./" "$to/./" |
69ff4a4a | 23 | } |
24 | ||
25 | ## Copy listed files | |
26 | ## usage: dm_install_files <from-dir> <to-dir> <file1> <file2>... | |
27 | function dm_install_files() { | |
28 | local from="$1" | |
29 | shift | |
30 | local to="$1" | |
31 | shift | |
32 | ||
33 | for file in "$@" ; do | |
34 | [ -f "$from/$file" ] && cp -f "$from/$file" "$to/$file" | |
35 | done | |
36 | } | |
37 | ||
38 | ## usage: dm_remove_files <directory> <file1> <file2>... | |
39 | function dm_remove_files() { | |
40 | local tgt="$1" | |
41 | shift | |
42 | ||
43 | for file in "$@" ; do | |
44 | [ -f "$tgt/$file" ] && rm -f "$tgt/$file" | |
45 | done | |
46 | } | |
47 | ||
48 | ## Copy all core files | |
49 | ## usage: dm_install_core <core_repo_path> <to_path> | |
50 | function dm_install_core() { | |
51 | local repo="$1" | |
52 | local to="$2" | |
53 | ||
8c70cd69 | 54 | for dir in css i js PEAR templates bin CRM api extern Reports install settings Civi partials node_modules bower_components ; do |
69ff4a4a | 55 | [ -d "$repo/$dir" ] && dm_install_dir "$repo/$dir" "$to/$dir" |
56 | done | |
57 | ||
58 | dm_install_files "$repo" "$to" {agpl-3.0,agpl-3.0.exception,gpl,README,CONTRIBUTORS}.txt | |
59 | ||
60 | mkdir -p "$to/sql" | |
61 | pushd "$repo" >> /dev/null | |
61101c01 | 62 | dm_install_files "$repo" "$to" sql/civicrm*.mysql sql/case_sample*.mysql |
69ff4a4a | 63 | ## TODO: for master, remove counties.US.SQL.gz |
64 | popd >> /dev/null | |
65 | ||
66 | if [ -d $to/bin ] ; then | |
67 | rm -f $to/bin/setup.sh | |
68 | rm -f $to/bin/setup.php4.sh | |
69 | rm -f $to/bin/setup.bat | |
70 | fi | |
71 | ||
72 | set +e | |
73 | rm -rf $to/sql/civicrm_*.??_??.mysql | |
74 | set -e | |
75 | } | |
9f0ca23d | 76 | |
77 | ## Copy all packages | |
78 | ## usage: dm_install_packages <packages_repo_path> <to_path> | |
79 | function dm_install_packages() { | |
80 | local repo="$1" | |
81 | local to="$2" | |
82 | ||
83 | local excludes_rsync="" | |
84 | for exclude in .git .svn _ORIGINAL_ SeleniumRC PHPUnit PhpDocumentor SymfonyComponents amavisd-new git-footnote ; do | |
85 | excludes_rsync="--exclude=${exclude} ${excludes_rsync}" | |
86 | done | |
87 | ||
e365b6e5 | 88 | ## Note: These small folders have items that previously were not published, |
89 | ## but there's no real cost to including them, and excluding them seems | |
90 | ## likely to cause confusion as the codebase evolves: | |
91 | ## packages/Files packages/PHP packages/Text | |
92 | ||
9f0ca23d | 93 | [ ! -d "$to" ] && mkdir "$to" |
e365b6e5 | 94 | $DM_RSYNC -avC $excludes_rsync --include=core "$repo/./" "$to/./" |
9f0ca23d | 95 | } |
7082ee3c | 96 | |
97 | ## Copy Drupal-integration module | |
98 | ## usage: dm_install_drupal <drupal_repo_path> <to_path> | |
99 | function dm_install_drupal() { | |
100 | local repo="$1" | |
101 | local to="$2" | |
bf20507d | 102 | dm_install_dir "$repo" "$to" |
7082ee3c | 103 | |
104 | # set full version in .info files | |
105 | local MODULE_DIRS=`find "$to" -type f -name "*.info"` | |
106 | for INFO in $MODULE_DIRS; do | |
107 | if [ $(uname) = "Darwin" ]; then | |
108 | ## BSD sed | |
109 | sed -i '' "s/version = [1-9.]*/version = $DM_VERSION/g" $INFO | |
110 | else | |
111 | ## GNU sed | |
112 | sed -i'' "s/version = [1-9.]*/version = $DM_VERSION/g" $INFO | |
113 | fi | |
114 | done | |
115 | } | |
30a50cd8 | 116 | |
274ebc9e | 117 | ## Copy Joomla-integration module |
118 | ## usage: dm_install_joomla <joomla_repo_path> <to_path> | |
119 | function dm_install_joomla() { | |
120 | local repo="$1" | |
121 | local to="$2" | |
bf20507d | 122 | dm_install_dir "$repo" "$to" |
80def6a8 | 123 | |
124 | ## Before this change, the zip file included the joomla-integration | |
125 | ## modules twice. The two were basically identical -- except that | |
126 | ## one included .gitignore and the omitted it. We'll now omit it | |
127 | ## consistently. | |
128 | rm -f "$to/.gitignore" | |
274ebc9e | 129 | } |
130 | ||
8d32d903 | 131 | ## usage: dm_install_l10n <l10n_repo_path> <to_path> |
132 | function dm_install_l10n() { | |
133 | local repo="$1" | |
134 | local to="$2" | |
135 | dm_install_dir "$repo" "$to" | |
136 | } | |
137 | ||
c84eb16e TO |
138 | ## Copy composer's "vendor" folder |
139 | ## usage: dm_install_vendor <from_path> <to_path> | |
140 | function dm_install_vendor() { | |
141 | local repo="$1" | |
142 | local to="$2" | |
143 | ||
144 | local excludes_rsync="" | |
145 | for exclude in .git .svn {T,t}est{,s} {D,d}oc{,s} {E,e}xample{,s} ; do | |
146 | excludes_rsync="--exclude=${exclude} ${excludes_rsync}" | |
147 | done | |
148 | ||
149 | ## Note: These small folders have items that previously were not published, | |
150 | ## but there's no real cost to including them, and excluding them seems | |
151 | ## likely to cause confusion as the codebase evolves: | |
152 | ## packages/Files packages/PHP packages/Text | |
153 | ||
154 | [ ! -d "$to" ] && mkdir "$to" | |
155 | $DM_RSYNC -avC $excludes_rsync --include=core "$repo/./" "$to/./" | |
156 | } | |
157 | ||
9003e8e1 | 158 | ## usage: dm_install_wordpress <wp_repo_path> <to_path> |
159 | function dm_install_wordpress() { | |
160 | local repo="$1" | |
161 | local to="$2" | |
d0f95878 | 162 | |
163 | if [ ! -d "$to" ]; then | |
164 | mkdir -p "$to" | |
165 | fi | |
166 | $DM_RSYNC -avC \ | |
167 | --exclude=.git \ | |
168 | --exclude=.svn \ | |
169 | --exclude=civicrm.config.php.wordpress \ | |
170 | --exclude=.gitignore \ | |
171 | --exclude=civicrm \ | |
172 | "$repo/./" "$to/./" | |
173 | ## Need --exclude=civicrm for self-building on WP site | |
9003e8e1 | 174 | } |
175 | ||
c84eb16e TO |
176 | ## Generate the composer "vendor" folder |
177 | ## usage: dm_generate_vendor <repo_path> | |
178 | function dm_generate_vendor() { | |
179 | local repo="$1" | |
180 | pushd "$repo" | |
181 | composer install | |
182 | popd | |
183 | } | |
184 | ||
30a50cd8 | 185 | ## Generate civicrm-version.php |
186 | ## usage: dm_generate_version <file> <ufname> | |
187 | function dm_generate_version() { | |
188 | local to="$1" | |
189 | local ufname="$2" | |
190 | ||
191 | # final touch | |
192 | echo "<?php | |
193 | function civicrmVersion( ) { | |
194 | return array( 'version' => '$DM_VERSION', | |
195 | 'cms' => '$ufname', | |
196 | 'revision' => '$DM_REVISION' ); | |
197 | } | |
198 | " > "$to" | |
199 | } | |
445009ec | 200 | |
201 | ## Perform a hard checkout on a given report | |
202 | ## usage: dm_git_checkout <repo_path> <tree-ish> | |
203 | function dm_git_checkout() { | |
204 | pushd "$1" | |
205 | git checkout . | |
206 | git checkout "$2" | |
207 | popd | |
208 | } | |
8c70cd69 PH |
209 | |
210 | ## Install npm packages | |
211 | ## usage: dm_npm_install <path> | |
212 | function dm_npm_install() { | |
213 | pushd "$1" | |
214 | $DM_NPM install | |
215 | popd | |
216 | } |