From 69ff4a4a07443dadae6d2f806738d25da9a02d1e Mon Sep 17 00:00:00 2001 From: "totten@civicrm.org" Date: Sat, 21 Jun 2014 03:13:24 -0700 Subject: [PATCH] distmaker - Extract function dm_install_core() 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 | 65 +++++++++++++++++++++++++++++++ distmaker/dists/drupal6_php5.sh | 32 +++------------ distmaker/dists/drupal_php5.sh | 33 +++------------- distmaker/dists/drupal_sk_php5.sh | 30 ++------------ distmaker/dists/joomla_php5.sh | 29 ++------------ distmaker/dists/wordpress_php5.sh | 28 ++----------- 6 files changed, 87 insertions(+), 130 deletions(-) create mode 100644 distmaker/dists/common.sh diff --git a/distmaker/dists/common.sh b/distmaker/dists/common.sh new file mode 100644 index 0000000000..1dcbddfaf9 --- /dev/null +++ b/distmaker/dists/common.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +## Copy files from one dir into another dir +## usage: dm_install_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 ... +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 ... +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 +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 +} diff --git a/distmaker/dists/drupal6_php5.sh b/distmaker/dists/drupal6_php5.sh index ca8c0a21ba..392d6252b7 100755 --- a/distmaker/dists/drupal6_php5.sh +++ b/distmaker/dists/drupal6_php5.sh @@ -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 diff --git a/distmaker/dists/drupal_php5.sh b/distmaker/dists/drupal_php5.sh index 1881d44606..8d29ebdf1f 100755 --- a/distmaker/dists/drupal_php5.sh +++ b/distmaker/dists/drupal_php5.sh @@ -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 diff --git a/distmaker/dists/drupal_sk_php5.sh b/distmaker/dists/drupal_sk_php5.sh index f6da93bd4c..e1190998cc 100755 --- a/distmaker/dists/drupal_sk_php5.sh +++ b/distmaker/dists/drupal_sk_php5.sh @@ -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 diff --git a/distmaker/dists/joomla_php5.sh b/distmaker/dists/joomla_php5.sh index 1387c7dd56..e7bd357148 100755 --- a/distmaker/dists/joomla_php5.sh +++ b/distmaker/dists/joomla_php5.sh @@ -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 diff --git a/distmaker/dists/wordpress_php5.sh b/distmaker/dists/wordpress_php5.sh index 32c6c05f9d..88d6d20d02 100644 --- a/distmaker/dists/wordpress_php5.sh +++ b/distmaker/dists/wordpress_php5.sh @@ -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 -- 2.25.1