2023-08-15 16:09:13 +02:00
|
|
|
<?php
|
2023-08-27 08:36:25 +02:00
|
|
|
// This file is part of the Studyplan plugin for Moodle
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
/**
|
2023-08-27 08:53:37 +02:00
|
|
|
* Build script to properly create a distribution zip
|
2023-08-27 08:36:25 +02:00
|
|
|
* @package block_mytreestudyplan
|
|
|
|
* @copyright 2023 P.M. Kuipers
|
|
|
|
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
define('CLI_SCRIPT', true);
|
|
|
|
require_once("../../config.php");
|
2023-08-15 16:09:13 +02:00
|
|
|
$plugin = new stdClass;
|
2023-08-27 08:36:25 +02:00
|
|
|
require_once('version.php');
|
2023-08-15 16:09:13 +02:00
|
|
|
|
2023-08-27 08:36:25 +02:00
|
|
|
$a = explode("_", $plugin->component, 2);
|
2023-08-15 16:09:13 +02:00
|
|
|
$plugin->type = $a[0];
|
|
|
|
$plugin->name = $a[1];
|
|
|
|
|
2023-08-27 08:36:25 +02:00
|
|
|
$excludepaths = [
|
|
|
|
"build", // Dir for build zip files.
|
2023-08-15 16:09:13 +02:00
|
|
|
"build/*",
|
|
|
|
"build.*",
|
2023-08-27 08:36:25 +02:00
|
|
|
"vuemode.sh",
|
2023-08-15 16:09:13 +02:00
|
|
|
"amd/src",
|
|
|
|
"amd/src/*",
|
|
|
|
".git",
|
|
|
|
".git/*",
|
|
|
|
".gitignore",
|
|
|
|
"*.zip",
|
|
|
|
];
|
|
|
|
|
2023-08-27 08:36:25 +02:00
|
|
|
// Determine some paths.
|
2023-08-15 16:09:13 +02:00
|
|
|
$wd = realpath(dirname(__FILE__));
|
|
|
|
$parent = dirname($wd);
|
|
|
|
$plugindirname = basename($wd);
|
|
|
|
$builddir = $wd."/"."build";
|
|
|
|
$zipname = $builddir."/"."{$plugin->name}-{$plugin->version}.zip";
|
|
|
|
|
2023-08-27 08:36:25 +02:00
|
|
|
// Create the exclude line.
|
2023-08-15 16:09:13 +02:00
|
|
|
$exclude = "-x ";
|
2023-08-27 08:36:25 +02:00
|
|
|
foreach ($excludepaths as $x) {
|
2023-08-15 16:09:13 +02:00
|
|
|
$exclude .= "'{$plugindirname}/{$x}' ";
|
|
|
|
}
|
|
|
|
|
2023-08-27 08:36:25 +02:00
|
|
|
if (!is_dir($builddir)) {
|
2023-08-15 16:09:13 +02:00
|
|
|
mkdir($builddir);
|
2023-08-27 08:36:25 +02:00
|
|
|
if (!is_dir($builddir)) {
|
2023-08-15 16:09:13 +02:00
|
|
|
print("Cannot access dir '{$builddir}' to store zip files\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-27 08:36:25 +02:00
|
|
|
if (file_exists($zipfile)) {
|
2023-08-15 16:09:13 +02:00
|
|
|
print("Zip file '{$zipfile}' already exists. Exiting...\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$cwd = getcwd();
|
|
|
|
chdir($parent);
|
|
|
|
|
|
|
|
$cmd = "zip -r '{$zipname}' '{$plugindirname}' {$exclude}";
|
|
|
|
system($cmd);
|
|
|
|
|
|
|
|
chdir($cwd);
|