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 | |
dd627407 |
54 | for dir in css i js PEAR templates bin CRM api extern Reports install settings Civi partials ; 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 | |
9003e8e1 |
138 | ## usage: dm_install_wordpress <wp_repo_path> <to_path> |
139 | function dm_install_wordpress() { |
140 | local repo="$1" |
141 | local to="$2" |
d0f95878 |
142 | |
143 | if [ ! -d "$to" ]; then |
144 | mkdir -p "$to" |
145 | fi |
146 | $DM_RSYNC -avC \ |
147 | --exclude=.git \ |
148 | --exclude=.svn \ |
149 | --exclude=civicrm.config.php.wordpress \ |
150 | --exclude=.gitignore \ |
151 | --exclude=civicrm \ |
152 | "$repo/./" "$to/./" |
153 | ## Need --exclude=civicrm for self-building on WP site |
9003e8e1 |
154 | } |
155 | |
30a50cd8 |
156 | ## Generate civicrm-version.php |
157 | ## usage: dm_generate_version <file> <ufname> |
158 | function dm_generate_version() { |
159 | local to="$1" |
160 | local ufname="$2" |
161 | |
162 | # final touch |
163 | echo "<?php |
164 | function civicrmVersion( ) { |
165 | return array( 'version' => '$DM_VERSION', |
166 | 'cms' => '$ufname', |
167 | 'revision' => '$DM_REVISION' ); |
168 | } |
169 | " > "$to" |
170 | } |
445009ec |
171 | |
172 | ## Perform a hard checkout on a given report |
173 | ## usage: dm_git_checkout <repo_path> <tree-ish> |
174 | function dm_git_checkout() { |
175 | pushd "$1" |
176 | git checkout . |
177 | git checkout "$2" |
178 | popd |
179 | } |