Distmaker: add CiviCRM Standalone support
authorMathieu Lu <mathieu@symbiotic.coop>
Sun, 20 Aug 2023 19:04:34 +0000 (15:04 -0400)
committerTim Otten <totten@civicrm.org>
Fri, 25 Aug 2023 04:08:46 +0000 (21:08 -0700)
distmaker/distmaker.sh
distmaker/dists/standalone.sh [new file with mode: 0644]
setup/plugins/checkRequirements/CheckDbWellFormed.civi-setup.php
setup/res/index.php.txt

index 2230d89c1c4d2ceb8e87ff8e4f744e5e42306ece..3c4a2504a36d6c4b7b6aec1bca258f71fa2e2e58 100755 (executable)
@@ -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 (file)
index 0000000..49d435e
--- /dev/null
@@ -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
index 4f09d7c8328a5b2755b042340ac1628b0c1d9d0e..968a80bd89d3a1e5b93a79849825523bbdd33e73 100644 (file)
@@ -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};
index 4007d898a363419c4c88e4f953fd68708f6d7e0f..1af5a24da1b36e002b847655ee1b4e20d4d3b9b6 100644 (file)
@@ -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') ? */