Skip to content

Commit

Permalink
Merge branch 'feature/build-upgrade-package'
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed May 14, 2020
2 parents c176004 + 4a7a648 commit 20e610c
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 64 deletions.
30 changes: 28 additions & 2 deletions build.properties
@@ -1,13 +1,39 @@
# Property files contain key=value pairs

# Geeklog version number
#################################################################################
#
# You should set:
# 1. version
# 2. previousVersion
# 3. previousVersionSHA
#
# before building
#
##################################################################################
#
## 1. Geeklog version number ##
version=2.2.2

# Git hash tag for the previous version of Geeklog. e.g., "936264c" for Geeklog 2.1.3
## 2. Geeklog previous version number
previousVersion=2.2.1sr1

# 3. Git hash tag for the previous version of Geeklog. e.g., "936264c" for Geeklog 2.1.3
previousVersionSHA=79296e7

# previousVersionSHA - Geeklog 2.2.1sr1 (79296e7)
# previousVersionSHA - Geeklog 2.2.1 (860e7e6)
# previousVersionSHA - Geeklog 2.2.0 (c7c2760)

# Git hash tag for the current version of Geeklog. May be left empty.
currentVersionSHA=

## Directory / File permissions ##

# dir with write permission
perm_dir_w=0777

# file with execute permission
perm_file_x=0755

# file with write permission
perm_file_w=0666
90 changes: 58 additions & 32 deletions build.xml
Expand Up @@ -7,7 +7,8 @@

<!-- Define custom tasks -->
<includepath classpath="${srcDir}/system/build/tasks"/>
<taskdef name="mydiff" classname="MyDiffTask"/>
<taskdef name="myDiff" classname="MyDiffTask"/>
<taskdef name="MyRemoveUnchangedFiles" classname="MyRemoveUnchangedFilesTask"/>

<!-- ============================== -->
<!-- Target: help -->
Expand All @@ -22,9 +23,12 @@
<echo msg="To show help [this screen], enter:"/>
<echo msg="./system/build/vendor/phing/phing/bin/phing.bat[ENTER]"/>
<echo msg=""/>
<echo msg="To create a tarball, enter:"/>
<echo msg="To create an INSTALL distribution tarball, enter:"/>
<echo msg="./system/build/vendor/phing/phing/bin/phing.bat dist[ENTER]"/>
<echo msg=""/>
<echo msg="To create an UPGRADE distribution tarball, enter:"/>
<echo msg="./system/build/vendor/phing/phing/bin/phing.bat dist-upgrade[ENTER]"/>
<echo msg=""/>
<echo msg="To synchronize language files, enter:"/>
<echo msg="./system/build/vendor/phing/phing/bin/phing.bat lang[ENTER]"/>
</target>
Expand Down Expand Up @@ -65,8 +69,8 @@
<!-- Target: build -->
<!-- ============================== -->
<target name="build" depends="prepare">
<!-- Create the "changed-files" file -->
<mydiff previousVersionSHA="${previousVersionSHA}" currentVersionSHA="${currentVersionSHA}"/>
<!-- Create the "changed-files" and "removed-files" files -->
<myDiff previousVersionSHA="${previousVersionSHA}" currentVersionSHA="${currentVersionSHA}"/>

<!-- Copy files -->
<echo msg="Copying files..."/>
Expand Down Expand Up @@ -110,60 +114,60 @@

<!-- Change permissions -->
<echo msg="Changing directory and file permissions..."/>
<chmod file="${dstDir}/db-config.php" mode="0666"/>
<chmod file="${dstDir}/emailgeeklogstories" mode="0755"/>
<chmod file="${dstDir}/backups" mode="0777"/>
<chmod file="${dstDir}/data" mode="0777"/>
<chmod file="${dstDir}/data/layout_cache" mode="0777"/>
<chmod file="${dstDir}/data/layout_css" mode="0777"/>
<chmod file="${dstDir}/logs" mode="0777"/>
<chmod mode="0666">
<chmod file="${dstDir}/db-config.php" mode="${perm_file_w}"/>
<chmod file="${dstDir}/emailgeeklogstories" mode="${perm_file_x}"/>
<chmod file="${dstDir}/backups" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/data" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/data/layout_cache" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/data/layout_css" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/logs" mode="${perm_dir_w}"/>
<chmod mode="${perm_file_w}">
<fileset dir="${dstDir}/logs">
<include name="*.log"/>
</fileset>
</chmod>
<chmod file="${dstDir}/public_html/backend" mode="0777"/>
<chmod mode="0666">
<chmod file="${dstDir}/public_html/backend" mode="${perm_dir_w}"/>
<chmod mode="${perm_file_w}">
<fileset dir="${dstDir}/public_html/backend">
<include name="*.rss"/>
</fileset>
</chmod>
<chmod file="${dstDir}/public_html/images/articles" mode="0777"/>
<chmod mode="0666">
<chmod file="${dstDir}/public_html/images/articles" mode="${perm_dir_w}"/>
<chmod mode="${perm_file_w}">
<fileset dir="${dstDir}/public_html/images/articles">
<include name="*,*.*"/>
</fileset>
</chmod>
<chmod file="${dstDir}/public_html/images/library" mode="0777"/>
<chmod file="${dstDir}/public_html/images/library/File" mode="0777"/>
<chmod file="${dstDir}/public_html/images/library/Flash" mode="0777"/>
<chmod file="${dstDir}/public_html/images/library/Image" mode="0777"/>
<chmod file="${dstDir}/public_html/images/library/Image/_thumbs" mode="0777"/>
<chmod file="${dstDir}/public_html/images/library/Media" mode="0777"/>
<chmod file="${dstDir}/public_html/images/topics" mode="0777"/>
<chmod mode="0666">
<chmod file="${dstDir}/public_html/images/library" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/public_html/images/library/File" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/public_html/images/library/Flash" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/public_html/images/library/Image" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/public_html/images/library/Image/_thumbs" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/public_html/images/library/Media" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/public_html/images/topics" mode="${perm_dir_w}"/>
<chmod mode="${perm_file_w}">
<fileset dir="${dstDir}/public_html/images/topics">
<include name="*,*.*"/>
</fileset>
</chmod>
<chmod file="${dstDir}/public_html/images/userphotos" mode="0777"/>
<chmod mode="0666">
<chmod file="${dstDir}/public_html/images/userphotos" mode="${perm_dir_w}"/>
<chmod mode="${perm_file_w}">
<fileset dir="${dstDir}/public_html/images/userphotos">
<include name="*,*.*"/>
</fileset>
</chmod>
<chmod file="${dstDir}/public_html/images/_thumbs" mode="0777"/>
<chmod file="${dstDir}/public_html/images/_thumbs/articles" mode="0777"/>
<chmod file="${dstDir}/public_html/images/_thumbs/userphotos" mode="0777"/>
<chmod file="${dstDir}/public_html/filemanager/config/filemanager.config.json" mode="0666"/>
<chmod file="${dstDir}/public_html/siteconfig.php" mode="0666"/>
<chmod file="${dstDir}/public_html/images/_thumbs" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/public_html/images/_thumbs/articles" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/public_html/images/_thumbs/userphotos" mode="${perm_dir_w}"/>
<chmod file="${dstDir}/public_html/filemanager/config/filemanager.config.json" mode="${perm_file_w}"/>
<chmod file="${dstDir}/public_html/siteconfig.php" mode="${perm_file_w}"/>
</target>

<!-- ============================== -->
<!-- Target: dist -->
<!-- ============================== -->
<target name="dist" depends="build">
<echo msg="Creating an archive..."/>
<echo msg="Creating an INSTALL package..."/>
<delete file="${project.basedir}/geeklog-${version}.tar.gz" quiet="true"/>
<tar destfile="${project.basedir}/geeklog-${version}.tar.gz" compression="gzip">
<fileset dir="${dstDir}">
Expand All @@ -176,4 +180,26 @@

<echo msg="Files copied and compressed in the current directory OK!"/>
</target>

<!-- ============================== -->
<!-- Target: dist-upgrade -->
<!-- ============================== -->
<target name="dist-upgrade" depends="build">
<echo msg="Creating an UPGRADE package..."/>

<!-- Remove unchanged file and create the "removed-files" file -->
<MyRemoveUnchangedFiles previousVersionSHA="${previousVersionSHA}" currentVersionSHA="${currentVersionSHA}" dstDir="${dstDir}"/>

<delete file="${project.basedir}/geeklog-${previousVersion}-to-${version}.tar.gz" quiet="true"/>
<tar destfile="${project.basedir}/geeklog-${previousVersion}-to-${version}.tar.gz" compression="gzip">
<fileset dir="${dstDir}">
<include name="*"/>
</fileset>
</tar>

<echo msg="Removing work files..."/>
<delete dir="${dstDir}"/>

<echo msg="Files copied and compressed in the current directory OK!"/>
</target>
</project>
1 change: 1 addition & 0 deletions system/build/lm/lm.php
Expand Up @@ -81,6 +81,7 @@
define('RECAPTCHA_NO_SUPPORT', 0);
define('RECAPTCHA_SUPPORT_V2', 1);
define('RECAPTCHA_SUPPORT_V2_INVISIBLE', 2);
define('RECAPTCHA_SUPPORT_V3', 4);

// list of all variables accessed in the language file
$_DB_mysqldump_path = '{$_DB_mysqldump_path}';
Expand Down
49 changes: 19 additions & 30 deletions system/build/tasks/MyDiffTask.php
@@ -1,6 +1,6 @@
<?php

require_once __DIR__ . '/../vendor/phing/phing/classes/phing/Task.php';
require_once dirname(__DIR__) . '/vendor/phing/phing/classes/phing/Task.php';

class MyDiffTask extends Task
{
Expand All @@ -17,38 +17,29 @@ class MyDiffTask extends Task
/**
* @var array
*/
private $startsWith = [
'.git',
'.idea',
'build',
'phpunit.xml',
'public_html/layout/glnet_curve',
'system/build',
'tests',
];
private $startsWith = [];

/**
* @var array
* @var array of pathes that should be excluded from the resulting archive
*/
private $includes = [
'/node_modules/',
'/css_src/dest/',
'buildpackage.php',
'.php.dist',
];
private $excludes = [];

/**
* Initialize the task
*/
public function init()
{
require_once __DIR__ . '/MyTaskCommon.php';
$this->startsWith = MyTaskCommon::$startsWith;
$this->excludes = MyTaskCommon::$excludes;

return true;
}

/**
* Setter for the attribute "previousVersionSHA"
*
* @param string $version
* @param string $version
*/
public function setPreviousVersionSHA($version)
{
Expand All @@ -58,7 +49,7 @@ public function setPreviousVersionSHA($version)
/**
* Setter for the attribute "currentVersionSHA"
*
* @param string $version
* @param string $version
*/
public function setCurrentVersionSHA($version)
{
Expand All @@ -68,7 +59,7 @@ public function setCurrentVersionSHA($version)
/**
* Return if a given path should be included in diff result
*
* @param string $path
* @param string $path
* @return bool true if the $path should be included in diff result
*/
private function shouldInclude($path)
Expand All @@ -79,7 +70,7 @@ private function shouldInclude($path)
}
}

foreach ($this->includes as $needle2) {
foreach ($this->excludes as $needle2) {
if (strpos($path, $needle2) > 0) {
return false;
}
Expand All @@ -95,20 +86,18 @@ public function main()
{
$currentDir = getcwd();
chdir(__DIR__ . '/../../../');
exec('git config diff.renameLimit 999999');

exec('git config diff.renameLimit 999999');

// Create 'changed-files'
exec(sprintf('git diff --name-only %s %s', $this->previousVersionSHA, $this->currentVersionSHA), $lines);
// Create the 'changed-files' file
exec(sprintf('git diff --name-only --diff-filter=ACMR %s %s', $this->previousVersionSHA, $this->currentVersionSHA), $lines);
$changedFiles = array_filter($lines, [$this, 'shouldInclude']);
@file_put_contents('./public_html/docs/changed-files', implode("\n", $changedFiles) . "\n");

// Create 'removed-files'
// Create the 'removed-files' file
unset($lines);
exec(sprintf('git diff --name-only --diff-filter=ACMRTUX %s %s', $this->previousVersionSHA, $this->currentVersionSHA), $lines);
$otherFiles = array_filter($lines, [$this, 'shouldInclude']);
$otherFiles = array_diff($changedFiles, $otherFiles);
@file_put_contents('./public_html/docs/removed-files', implode("\n", $otherFiles) . "\n");
exec(sprintf('git diff --name-only --diff-filter=R %s %s', $this->previousVersionSHA, $this->currentVersionSHA), $lines);
$removedFiles = array_filter($lines, [$this, 'shouldInclude']);
@file_put_contents('./public_html/docs/removed-files', implode("\n", $removedFiles) . "\n");

exec('git config --unset diff.renameLimit');

Expand Down

0 comments on commit 20e610c

Please sign in to comment.