From 5cbd97694108593a91cb6983a5afb2fc174540b4 Mon Sep 17 00:00:00 2001 From: Mathieu Lu Date: Sun, 20 Aug 2023 15:04:34 -0400 Subject: [PATCH] Distmaker: add CiviCRM Standalone support --- distmaker/distmaker.sh | 17 +++++++++- distmaker/dists/standalone.sh | 32 +++++++++++++++++++ .../CheckDbWellFormed.civi-setup.php | 7 +++- setup/res/index.php.txt | 6 ++-- 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 distmaker/dists/standalone.sh diff --git a/distmaker/distmaker.sh b/distmaker/distmaker.sh index 2230d89c1c..3c4a2504a3 100755 --- a/distmaker/distmaker.sh +++ b/distmaker/distmaker.sh @@ -42,6 +42,7 @@ J5PACK=0 WP5PACK=0 PATCHPACK=0 SK5PACK=0 +STANDALONEPACK=0 L10NPACK=0 REPOREPORT=0 @@ -62,6 +63,7 @@ display_usage() echo " WordPress|wp5 - generate Wordpress PHP5 module" echo " patchset - generate a tarball with patch files" echo " sk - generate Drupal StarterKit module" + echo " standalone - generate CiviCRM Standalone" echo echo "You also need to have distmaker.conf file in place." echo "See distmaker.conf.dist for example contents." @@ -123,7 +125,7 @@ check_conf() echo "Current directory is : $THIS_DIR"; exit 1 else - 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_DRUPAL8 DM_REF_JOOMLA DM_REF_WORDPRESS DM_REF_PACKAGES + 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_DRUPAL8 DM_REF_JOOMLA DM_REF_WORDPRESS DM_REF_STANDALONE DM_REF_PACKAGES if [ ! -d "$DM_SOURCEDIR" ]; then 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; fi @@ -187,6 +189,12 @@ case $1 in WP5PACK=1 ;; + # STANDALONE + standalone|Standalone) + echo; echo "Generating CiviCRM Standalone"; echo; + STANDALONEPACK=1 + ;; + ## PATCHSET export patchset) echo; echo "Generating patchset"; echo; @@ -208,6 +216,7 @@ case $1 in WP5PACK=1 PATCHPACK=1 SKPACK=1 + STANDALONEPACK=1 L10NPACK=1 REPOREPORT=1 ;; @@ -293,6 +302,11 @@ if [ "$WP5PACK" = 1 ]; then bash $P/dists/wordpress_php5.sh fi +if [ "$STANDALONEPACK" = 1 ]; then + echo; echo "Packaging for CiviCRM Standalone"; echo; + bash $P/dists/standalone.sh +fi + if [ "$PATCHPACK" = 1 ]; then echo; echo "Packaging for patchset tarball"; echo; bash $P/dists/patchset.sh @@ -308,6 +322,7 @@ if [ "$REPOREPORT" = 1 ]; then SKPACK="$SKPACK" \ J5PACK="$J5PACK" \ WP5PACK="$WP5PACK" \ + STANDALONEPACK="$STANDALONEPACK" \ bash $P/dists/repo-report.sh fi diff --git a/distmaker/dists/standalone.sh b/distmaker/dists/standalone.sh new file mode 100644 index 0000000000..49d435ea0a --- /dev/null +++ b/distmaker/dists/standalone.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -ex + +P=`dirname $0` +CFFILE=$P/../distmaker.conf +if [ ! -f $CFFILE ] ; then + echo "NO DISTMAKER.CONF FILE!" + exit 1 +else + . $CFFILE +fi +. "$P/common.sh" + +SRC=$DM_SOURCEDIR +TRG=$DM_TMPDIR/civicrm + +# copy all the stuff +dm_reset_dirs "$TRG" "$TRG/civicrm/web/core" +dm_install_core "$SRC" "$TRG/civicrm/web/core" +dm_install_coreext "$SRC" "$TRG/civicrm/web/core" $(dm_core_exts) +dm_install_packages "$SRC/packages" "$TRG/civicrm/web/core/packages" +dm_install_vendor "$SRC/vendor" "$TRG/civicrm/web/core/vendor" +dm_install_bower "$SRC/bower_components" "$TRG/civicrm/web/core/bower_components" +dm_install_cvext com.iatspayments.civicrm "$TRG/civicrm/web/core/ext/iatspayments" +$SRC/tools/standalone/bin/scaffold $TRG/civicrm + +# gen tarball +cd $TRG/civicrm +tar czf $DM_TARGETDIR/civicrm-$DM_VERSION-standalone.tar.gz . + +# clean up +rm -rf $TRG diff --git a/setup/plugins/checkRequirements/CheckDbWellFormed.civi-setup.php b/setup/plugins/checkRequirements/CheckDbWellFormed.civi-setup.php index 4f09d7c832..968a80bd89 100644 --- a/setup/plugins/checkRequirements/CheckDbWellFormed.civi-setup.php +++ b/setup/plugins/checkRequirements/CheckDbWellFormed.civi-setup.php @@ -13,7 +13,12 @@ if (!defined('CIVI_SETUP')) { ->addListener('civi.setup.checkRequirements', function (\Civi\Setup\Event\CheckRequirementsEvent $e) { \Civi\Setup::log()->info(sprintf('[%s] Handle %s', basename(__FILE__), 'checkRequirements')); - $dbFields = array('db', 'cmsDb'); + $dbFields = ['db']; + + if ($e->getModel()->cms !== 'Standalone') { + $dbFields[] = 'cmsDb'; + } + foreach ($dbFields as $dbField) { $errors = 0; $db = $e->getModel()->{$dbField}; diff --git a/setup/res/index.php.txt b/setup/res/index.php.txt index 4007d898a3..1af5a24da1 100644 --- a/setup/res/index.php.txt +++ b/setup/res/index.php.txt @@ -118,8 +118,6 @@ if (file_exists(findStandaloneSettings())) { invoke(); } else { - $coreUrl = '/assets/civicrm/core'; - \Civi\Setup::assertProtocolCompatibility(1.0); \Civi\Setup::init([ @@ -127,8 +125,10 @@ else { 'cms' => 'Standalone', 'srcPath' => $civiCorePath, ]); - $ctrl = \Civi\Setup::instance()->createController()->getCtrl(); + $coreUrl = \Civi\Setup::instance()->getModel()->mandatorySettings['userFrameworkResourceURL']; + + $ctrl = \Civi\Setup::instance()->createController()->getCtrl(); $ctrl->setUrls([ // The URL of this setup controller. May be used for POST-backs 'ctrl' => '/civicrm', /* @todo this had url('civicrm') ? */ -- 2.25.1