diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index dab812e24ea55868802c434f82d119f02abf5be8..2e81ddc61a05f98de6ba055a8341cd3817a388bd 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -7,6 +7,9 @@ require_once __DIR__.'/../inc_functions.php'; require_once 'base.class.php'; require_once 'htmlguielements.class.php'; require_once 'messenger.class.php'; + +// plugins +require_once 'build_base.class.php'; require_once 'rollout_base.class.php'; /* ###################################################################### @@ -1897,11 +1900,42 @@ class project extends base { } $this->_TempFill($sReturn, $aActionList); - - // create tgz archive - $sReturn.=sprintf(t("creating-file"), $sPackageFileArchiv) . "<br>"; - $sReturn.=$this->_execAndSend("cd $sTempBuildDir && tar -czf $sPackageFileArchiv ."); - $this->_TempFill($sReturn, $aActionList); + // ----- loop over enabled build plugins + // WIP + // set name of the activated plugin for this project + $aPlugins=(isset($this->_aPrjConfig['build']['enabled_build_plugins']) && $this->_aPrjConfig['build']['enabled_build_plugins']) + ? $this->_aPrjConfig['build']['enabled_build_plugins'] + : ['tgz'] + ; + foreach($aPlugins as $sPluginName){ + $oPlugin = false; + $sReturn.='<h4>'.$sPluginName.'</h4>'; + try{ + include_once $this->_getPluginFilename('build', $sPluginName); + $sPluginClassname='build_'.$sPluginName; + $oPlugin = new $sPluginClassname(array( + 'lang'=>$this->_aConfig['lang'], + 'workdir'=>$sTempBuildDir, + 'outfile'=>$sPackageFileArchiv, + )); + } catch (Exception $ex) { + return $this->_oHtml->getBox("error", + "FAILED to initialize build plugin " .$sPluginName .'<br>' + . $sReturn + ); + } + + $sReturn.=sprintf(t("creating-file"), $oPlugin->getOutfile()) . "<br>"; + foreach($oPlugin->checkRequirements() as $sCommand){ + $sReturn.=$this->_execAndSend($sCommand); + $this->_TempFill($sReturn, $aActionList); + } + + foreach($oPlugin->getBuildCommands() as $sCommand){ + $sReturn.=$this->_execAndSend($sCommand); + $this->_TempFill($sReturn, $aActionList); + } + } // write info file (.json) $sReturn.=sprintf(t("creating-file"), $sInfoFileArchiv) . "<br>"; diff --git a/public_html/deployment/plugins/build/tgz/build_tgz.php b/public_html/deployment/plugins/build/tgz/build_tgz.php new file mode 100644 index 0000000000000000000000000000000000000000..6242ea762124b61570103cd8345a13a94a92ec36 --- /dev/null +++ b/public_html/deployment/plugins/build/tgz/build_tgz.php @@ -0,0 +1,33 @@ +<?php + +/** + * + * Build plugin - TGZ + * + * @author <axel.hahn@iml.unibe.ch> + */ +class build_tgz extends build_base { + + /** + * check requirements if the plugin could work + */ + public function checkRequirements() { + return [ + 'which tar' + ]; + } + + /** + * get an array with shell commands to execute + * @param string $sBuildDir full path of the build directory + * @param string $sOutFilename filename for output + * @return array + */ + public function getBuildCommands(){ + return [ + 'cd "'. $this->getBuildDir(). '" && tar -czf "'. $this->getOutfile().'" .' + ]; + } + + +} diff --git a/public_html/deployment/plugins/build/tgz/info.json b/public_html/deployment/plugins/build/tgz/info.json new file mode 100644 index 0000000000000000000000000000000000000000..dfff108b663107a81a2d0dfb206b444fbcb365af --- /dev/null +++ b/public_html/deployment/plugins/build/tgz/info.json @@ -0,0 +1,11 @@ +{ + "name": "TGZ Archive", + "description": "Create an TGZ archive", + "author": "Axel Hahn; University of Bern; Institute for Medical education", + + "version": "1.0", + "url": "[included]", + "license": "GNU GPL 3.0", + + "extension": "tgz" +} diff --git a/public_html/deployment/plugins/build/tgz/lang_de.json b/public_html/deployment/plugins/build/tgz/lang_de.json new file mode 100644 index 0000000000000000000000000000000000000000..33c3636fb2b9d9e6682b45cb15cb529accdd16b5 --- /dev/null +++ b/public_html/deployment/plugins/build/tgz/lang_de.json @@ -0,0 +1,4 @@ +{ + "plugin_name": "TGZ", + "description": "TGZ Archiv erstellen" +} \ No newline at end of file diff --git a/public_html/deployment/plugins/build/tgz/lang_en.json b/public_html/deployment/plugins/build/tgz/lang_en.json new file mode 100644 index 0000000000000000000000000000000000000000..efd39e8797f57b66880961193a6afc36881ac7c5 --- /dev/null +++ b/public_html/deployment/plugins/build/tgz/lang_en.json @@ -0,0 +1,4 @@ +{ + "plugin_name": "TGZ", + "description": "Create an TGZ archive" +} \ No newline at end of file