distmaker - Extract function dm_install_core()
authortotten@civicrm.org <Tim Otten>
Sat, 21 Jun 2014 10:13:24 +0000 (03:13 -0700)
committertotten@civicrm.org <Tim Otten>
Sun, 22 Jun 2014 07:53:52 +0000 (00:53 -0700)
Conflicts:
distmaker/dists/drupal6_php5.sh
distmaker/dists/drupal_php5.sh
distmaker/dists/drupal_sk_php5.sh
distmaker/dists/joomla_php5.sh
distmaker/dists/wordpress_php5.sh

distmaker/dists/common.sh [new file with mode: 0644]
distmaker/dists/drupal6_php5.sh
distmaker/dists/drupal_php5.sh
distmaker/dists/drupal_sk_php5.sh
distmaker/dists/joomla_php5.sh
distmaker/dists/wordpress_php5.sh

diff --git a/distmaker/dists/common.sh b/distmaker/dists/common.sh
new file mode 100644 (file)
index 0000000..1dcbddf
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+## Copy files from one dir into another dir
+## usage: dm_install_dir <from-dir> <to-dir>
+function dm_install_dir() {
+  local from="$1"
+  local to="$2"
+
+  if [ ! -d "$to" ]; then
+    mkdir -p "$to"
+  fi
+  rsync -va "$from/./"  "$to/./"
+}
+
+## Copy listed files
+## usage: dm_install_files <from-dir> <to-dir> <file1> <file2>...
+function dm_install_files() {
+  local from="$1"
+  shift
+  local to="$1"
+  shift
+
+  for file in "$@" ; do
+    [ -f "$from/$file" ] && cp -f "$from/$file" "$to/$file"
+  done
+}
+
+## usage: dm_remove_files <directory> <file1> <file2>...
+function dm_remove_files() {
+  local tgt="$1"
+  shift
+
+  for file in "$@" ; do
+    [ -f "$tgt/$file" ] && rm -f "$tgt/$file"
+  done
+}
+
+## Copy all core files
+## usage: dm_install_core <core_repo_path> <to_path>
+function dm_install_core() {
+  local repo="$1"
+  local to="$2"
+
+  for dir in css i js PEAR templates bin CRM api extern Reports install settings Civi ; do
+    [ -d "$repo/$dir" ] && dm_install_dir "$repo/$dir" "$to/$dir"
+  done
+
+  dm_install_files "$repo" "$to" {agpl-3.0,agpl-3.0.exception,gpl,README,CONTRIBUTORS}.txt
+
+  mkdir -p "$to/sql"
+  pushd "$repo" >> /dev/null
+    dm_install_files "$repo" "$to" sql/civicrm*.mysql sql/case_sample*.mysql sql/counties.US.sql.gz
+    ## TODO: for master, remove counties.US.SQL.gz
+  popd >> /dev/null
+
+  if [ -d $to/bin ] ; then
+    rm -f $to/bin/setup.sh
+    rm -f $to/bin/setup.php4.sh
+    rm -f $to/bin/setup.bat
+  fi
+
+  set +e
+  rm -rf $to/sql/civicrm_*.??_??.mysql
+  set -e
+}
index ca8c0a21ba032599a207ce691276fa3444580856..392d6252b7c932259f37412c9adaab0d8e834dd4 100755 (executable)
@@ -15,6 +15,8 @@ else
        . $CFFILE
 fi
 
+. "$P/common.sh"
+
 RSYNCOPTIONS="-avC $DM_EXCLUDES_RSYNC --include=core"
 RSYNCCOMMAND="$DM_RSYNC $RSYNCOPTIONS"
 SRC=$DM_SOURCEDIR
@@ -23,6 +25,7 @@ TRG=$DM_TMPDIR/civicrm
 
 # checkout the right code revisions
 pushd "$DM_SOURCEDIR/drupal"
+git checkout .
 git checkout "$DM_REF_DRUPAL6"
 popd
 
@@ -32,38 +35,13 @@ if [ -d $TRG ] ; then
 fi
 
 # copy all the stuff
-for CODE in css i js packages PEAR templates bin CRM api drupal extern Reports install settings; do
+dm_install_core "$SRC" "$TRG"
+for CODE in packages drupal; do
   echo $CODE
   [ -d $SRC/$CODE ] && $RSYNCCOMMAND $SRC/$CODE $TRG
 done
 
-# delete any setup.sh or setup.php4.sh if present
-if [ -d $TRG/bin ] ; then
-  rm -f $TRG/bin/setup.sh
-  rm -f $TRG/bin/setup.php4.sh
-  rm -f $TRG/bin/setup.bat
-fi
-
-
-# copy selected sqls
-if [ ! -d $TRG/sql ] ; then
-       mkdir $TRG/sql
-fi
-
-for F in $SRC/sql/civicrm*.mysql $SRC/sql/counties.US.sql.gz $SRC/sql/case_sample*.mysql; do
-       cp $F $TRG/sql
-done
-
-set +e
-rm -rf $TRG/sql/civicrm_*.??_??.mysql
-set -e
-
 # copy docs
-cp $SRC/agpl-3.0.txt $TRG
-cp $SRC/gpl.txt $TRG
-cp $SRC/README.txt $TRG
-cp $SRC/CONTRIBUTORS.txt $TRG
-cp $SRC/agpl-3.0.exception.txt $TRG
 cp $SRC/drupal/civicrm.config.php.drupal $TRG/civicrm.config.php
 
 # final touch
index 1881d44606a9eeb05ff2935604c7d611221c002b..8d29ebdf1f91df4f4ed0dcfbae24644b1a7ce959 100755 (executable)
@@ -15,6 +15,8 @@ else
        . $CFFILE
 fi
 
+. "$P/common.sh"
+
 RSYNCOPTIONS="-avC $DM_EXCLUDES_RSYNC --include=core"
 RSYNCCOMMAND="$DM_RSYNC $RSYNCOPTIONS"
 SRC=$DM_SOURCEDIR
@@ -22,6 +24,7 @@ TRG=$DM_TMPDIR/civicrm
 
 # checkout the right code revisions
 pushd "$DM_SOURCEDIR/drupal"
+git checkout .
 git checkout "$DM_REF_DRUPAL"
 popd
 
@@ -31,38 +34,12 @@ if [ -d $TRG ] ; then
 fi
 
 # copy all the stuff
-for CODE in css i js packages PEAR templates bin CRM api drupal extern Reports install settings; do
+dm_install_core "$SRC" "$TRG"
+for CODE in packages drupal; do
   echo $CODE
   [ -d $SRC/$CODE ] && $RSYNCCOMMAND $SRC/$CODE $TRG
 done
 
-# delete any setup.sh or setup.php4.sh if present
-if [ -d $TRG/bin ] ; then
-  rm -f $TRG/bin/setup.sh
-  rm -f $TRG/bin/setup.php4.sh
-  rm -f $TRG/bin/setup.bat
-fi
-
-
-# copy selected sqls
-if [ ! -d $TRG/sql ] ; then
-       mkdir $TRG/sql
-fi
-
-for F in $SRC/sql/civicrm*.mysql $SRC/sql/counties.US.sql.gz $SRC/sql/case_sample*.mysql; do
-       cp $F $TRG/sql
-done
-
-set +e
-rm -rf $TRG/sql/civicrm_*.??_??.mysql
-set -e
-
-# copy docs
-cp $SRC/agpl-3.0.txt $TRG
-cp $SRC/gpl.txt $TRG
-cp $SRC/README.txt $TRG
-cp $SRC/CONTRIBUTORS.txt $TRG
-cp $SRC/agpl-3.0.exception.txt $TRG
 cp $SRC/drupal/civicrm.config.php.drupal $TRG/civicrm.config.php
 
 # set full version in .info files
index f6da93bd4c4aace8b4065d879df77d506ac4a389..e1190998cc5b8efe97439536a61d82d7aedbbe97 100755 (executable)
@@ -15,6 +15,8 @@ else
        . $CFFILE
 fi
 
+. "$P/common.sh"
+
 RSYNCOPTIONS="-avC $DM_EXCLUDES_RSYNC --include=core"
 RSYNCCOMMAND="$DM_RSYNC $RSYNCOPTIONS"
 SRC=$DM_SOURCEDIR
@@ -31,18 +33,12 @@ if [ -d $TRG ] ; then
 fi
 
 # copy all the stuff
-for CODE in css i js packages PEAR templates bin CRM api drupal extern Reports install settings; do
+dm_install_core "$SRC" "$TRG"
+for CODE in packages drupal; do
   echo $CODE
   [ -d $SRC/$CODE ] && $RSYNCCOMMAND $SRC/$CODE $TRG
 done
 
-# delete any setup.sh or setup.php4.sh if present
-if [ -d $TRG/bin ] ; then
-  rm -f $TRG/bin/setup.sh
-  rm -f $TRG/bin/setup.php4.sh
-  rm -f $TRG/bin/setup.bat
-fi
-
 # delete packages that distributions on Drupal.org repalce if present
 # also delete stuff that we dont really use and should not be included
 rm -rf $TRG/packages/dompdf
@@ -53,25 +49,7 @@ rm -rf $TRG/packages/tinymce
 rm -rf $TRG/joomla
 rm -rf $TRG/WordPress
 
-# copy selected sqls
-if [ ! -d $TRG/sql ] ; then
-       mkdir $TRG/sql
-fi
-
-for F in $SRC/sql/civicrm*.mysql $SRC/sql/counties.US.sql.gz $SRC/sql/case_sample*.mysql; do
-       cp $F $TRG/sql
-done
-
-set +e
-rm -rf $TRG/sql/civicrm_*.??_??.mysql
-set -e
-
 # copy docs
-cp $SRC/agpl-3.0.txt $TRG
-cp $SRC/gpl.txt $TRG
-cp $SRC/README.txt $TRG
-cp $SRC/CONTRIBUTORS.txt $TRG
-cp $SRC/agpl-3.0.exception.txt $TRG
 cp $SRC/drupal/civicrm.config.php.drupal $TRG/civicrm.config.php
 
 # final touch
index 1387c7dd5659b0203a70e604ca42352c4d9876be..e7bd357148390e9e9e0ecd39096b8166a0f37de4 100755 (executable)
@@ -15,6 +15,8 @@ else
        . $CFFILE
 fi
 
+. "$P/common.sh"
+
 RSYNCOPTIONS="-avC $DM_EXCLUDES_RSYNC --include=core"
 RSYNCCOMMAND="$DM_RSYNC $RSYNCOPTIONS"
 SRC=$DM_SOURCEDIR
@@ -31,36 +33,13 @@ if [ -d $TRG ] ; then
 fi
 
 # copy all the rest of the stuff
-for CODE in css i install js packages PEAR templates bin joomla CRM api extern Reports settings; do
+dm_install_core "$SRC" "$TRG"
+for CODE in packages joomla ; do
   echo $CODE
   [ -d $SRC/$CODE ] && $RSYNCCOMMAND $SRC/$CODE $TRG
 done
 
-# delete any setup.sh or setup.php4.sh if present
-if [ -d $TRG/bin ] ; then
-  rm -f $TRG/bin/setup.sh
-  rm -f $TRG/bin/setup.php4.sh
-  rm -f $TRG/bin/setup.bat
-fi
-
-# copy selected sqls
-if [ ! -d $TRG/sql ] ; then
-       mkdir $TRG/sql
-fi
-for F in $SRC/sql/civicrm*.mysql $SRC/sql/counties.US.sql.gz $SRC/sql/case_sample*.mysql; do
-       cp $F $TRG/sql
-done
-
-set +e
-rm -rf $TRG/sql/civicrm_*.??_??.mysql
-set -e
-
 # copy docs
-cp $SRC/agpl-3.0.txt $TRG
-cp $SRC/gpl.txt $TRG
-cp $SRC/README.txt $TRG
-cp $SRC/CONTRIBUTORS.txt $TRG
-cp $SRC/agpl-3.0.exception.txt $TRG
 cp $SRC/civicrm.config.php $TRG
 
 # final touch
index 32c6c05f9d5907d3c2acfac8d21f455ae87863b1..88d6d20d025d8ed794d3e99df57c47b955fc28fd 100644 (file)
@@ -15,6 +15,8 @@ else
        . $CFFILE
 fi
 
+. "$P/common.sh"
+
 RSYNCOPTIONS="-avC $DM_EXCLUDES_RSYNC --include=core"
 RSYNCCOMMAND="$DM_RSYNC $RSYNCOPTIONS"
 SRC=$DM_SOURCEDIR
@@ -43,40 +45,18 @@ if [ ! -d $TRG/civicrm/civicrm ] ; then
 fi
 
 # copy all the stuff
-for CODE in css i js packages PEAR templates bin CRM api extern Reports install settings; do
+dm_install_core "$SRC" "$TRG/civicrm/civicrm"
+for CODE in packages ; do
   echo $CODE
   [ -d $SRC/$CODE ] && $RSYNCCOMMAND $SRC/$CODE $TRG/civicrm/civicrm
 done
 
-# delete any setup.sh or setup.php4.sh if present
-if [ -d $TRG/civicrm/civicrm/bin ] ; then
-  rm -f $TRG/civicrm/civicrm/bin/setup.sh
-  rm -f $TRG/civicrm/civicrm/bin/setup.php4.sh
-  rm -f $TRG/civicrm/civicrm/bin/setup.bat
-fi
-
-# copy selected sqls
-if [ ! -d $TRG/civicrm/civicrm/sql ] ; then
-       mkdir $TRG/civicrm/civicrm/sql
-fi
-
-for F in $SRC/sql/civicrm*.mysql $SRC/sql/counties.US.sql.gz $SRC/sql/case_sample*.mysql; do
-       cp $F $TRG/civicrm/civicrm/sql
-done
-
-set +e
-rm -rf $TRG/civicrm/civicrm/sql/civicrm_*.??_??.mysql
-set -e
-
 for F in $SRC/WordPress/*; do
        cp $F $TRG/civicrm
 done
 rm -f $TRG/civicrm/civicrm.config.php.wordpress
 
 # copy docs
-cp $SRC/agpl-3.0.txt $TRG/civicrm/civicrm
-cp $SRC/gpl.txt $TRG/civicrm/civicrm
-cp $SRC/README.txt $TRG/civicrm/civicrm
 cp $SRC/WordPress/civicrm.config.php.wordpress $TRG/civicrm/civicrm/civicrm.config.php
 
 # final touch