[Fusionforge-commits] FusionForge branch master updated. ba5d6f1bf4019aa76ba43cf3af7850dee5a64d6c

Franck Villaume nerville at fusionforge.org
Thu Nov 6 12:08:01 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  ba5d6f1bf4019aa76ba43cf3af7850dee5a64d6c (commit)
      from  64f122a704d40224320dc4059201835337067250 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ba5d6f1bf4019aa76ba43cf3af7850dee5a64d6c
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Thu Nov 6 12:07:27 2014 +0100

    implement [#737]: FRS zip per release, migration script

diff --git a/src/db/20141106-frs-zip-per-release.php b/src/db/20141106-frs-zip-per-release.php
new file mode 100644
index 0000000..3f6de8c
--- /dev/null
+++ b/src/db/20141106-frs-zip-per-release.php
@@ -0,0 +1,86 @@
+<?php
+/**
+ *
+ * Copyright 2014, Franck Villaume - TrivialDev
+ * http://fusionforge.org/
+ *
+ * This file is part of FusionForge.
+ *
+ * FusionForge 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FusionForge 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+require_once dirname(__FILE__).'/../common/include/env.inc.php';
+require_once $gfcommon.'include/pre.php';
+
+ini_set('memory_limit', -1);
+ini_set('max_execution_time', 0);
+
+$globalStatus = 0;
+
+if (class_exists('ZipArchive')) {
+	#select project using FRS
+	$packagesRes = db_query_params('select frs_package.package_id as pid, frs_package.name as pname, groups.group_id as gid, groups.unix_group_name as guxname
+					from frs_package, groups where frs_package.group_id = groups.group_id and groups.status = $1 and groups.use_frs = $2',
+					array('A', 1));
+
+	while ($packageArr = db_fetch_array($packagesRes)) {
+		$releasesRes = db_query_params('select distinct frs_release.release_id as rid, frs_release.name as rname from frs_release,frs_file where frs_release.package_id = $1 and frs_file.release_id = frs_release.release_id',
+						array($packageArr['pid']));
+		while ($releaseArr = db_fetch_array($releasesRes)) {
+			$filesRes = db_query_params('select filename from frs_file where release_id = $1', array($releaseArr['rid']));
+			if (db_numrows($filesRes)) {
+				$zip = new ZipArchive();
+				$zipPath = forge_get_config('upload_dir').'/'.$packageArr['guxname'].'/'.$packageArr['pname'].'/'.$packageArr['pname'].'-'.$releaseArr['rname'].'.zip';
+				if (!is_file($zipPath)) {
+					if ($zip->open($zipPath, ZIPARCHIVE::CREATE) !== true) {
+						echo _('Cannot open the file archive')._(': ').$zipPath."\n";
+						$globalStatus = 1;
+					} else {
+						$filesPath = forge_get_config('upload_dir').'/'.$packageArr['guxname'].'/'.$packageArr['pname'].'/'.$releaseArr['rname'];
+						while ($fileArr = db_fetch_array($filesRes)) {
+							$filePath = $filesPath.'/'.$fileArr['filename'];
+							if ($zip->addFile($filePath, $fileArr['filename']) !== true) {
+								echo _('Cannot add file to the file archive')._(': ').$fileArr['filename'].' -> '.$zipPath."\n";
+								$globalStatus = 1;
+							}
+						}
+						db_free_result($filesRes);
+						if ($zip->close() !== true) {
+							echo _('Cannot close the file archive')._(': ').$zipPath."\n";
+							$globalStatus = 1;
+						}
+					}
+					if (!is_file($zipPath)) {
+						echo _('Something went wrong during zip creation, check permission?').' '.$zipPath."\n";
+						$globalStatus = 1;
+					} else {
+						chown($zipPath, forge_get_config('apache_user'));
+						chgrp($zipPath, forge_get_config('apache_group'));
+					}
+				}
+			}
+		}
+		db_free_result($releasesRes);
+		@unlink(forge_get_config('upload_dir').'/'.$packageArr['guxname'].'/'.$packageArr['pname'].'/'.$packageArr['pname'].'-latest.zip');
+	}
+	db_free_result($packagesRes);
+}
+if ($globalStatus) {
+	echo "ERROR\n";
+	exit(1);
+}
+
+echo "SUCCESS\n";
+exit(0);

-----------------------------------------------------------------------

Summary of changes:
 src/db/20141106-frs-zip-per-release.php |   86 +++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
 create mode 100644 src/db/20141106-frs-zip-per-release.php


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list