[Fusionforge-commits] r11967 - in trunk/src: common/include plugins/scmarch/common plugins/scmbzr/common plugins/scmcvs/common plugins/scmdarcs/common plugins/scmgit/common plugins/scmhg/common plugins/scmsvn/common

Roland Mas lolando at libremir.placard.fr.eu.org
Tue Jan 11 14:54:10 CET 2011


Author: lolando
Date: 2011-01-11 14:54:07 +0100 (Tue, 11 Jan 2011)
New Revision: 11967

Modified:
   trunk/src/common/include/config-vars.php
   trunk/src/common/include/utils.php
   trunk/src/plugins/scmarch/common/ArchPlugin.class.php
   trunk/src/plugins/scmbzr/common/BzrPlugin.class.php
   trunk/src/plugins/scmcvs/common/CVSPlugin.class.php
   trunk/src/plugins/scmdarcs/common/DarcsPlugin.class.php
   trunk/src/plugins/scmgit/common/GitPlugin.class.php
   trunk/src/plugins/scmhg/common/HgPlugin.class.php
   trunk/src/plugins/scmsvn/common/SVNPlugin.class.php
Log:
Allow different compression methods for SCM snapshots/tarballs (from Evolvis 4.8)

Modified: trunk/src/common/include/config-vars.php
===================================================================
--- trunk/src/common/include/config-vars.php	2011-01-10 21:11:20 UTC (rev 11966)
+++ trunk/src/common/include/config-vars.php	2011-01-11 13:54:07 UTC (rev 11967)
@@ -138,6 +138,8 @@
 forge_define_config_item ('show_source', 'core', $GLOBALS['sys_show_source']) ;
 forge_define_config_item ('default_trove_cat', 'core', $GLOBALS['default_trove_cat']) ;
 
+forge_define_config_item ('compression_method', 'core', 'gzip') ;
+
 // Arch plugin
 if (file_exists ($gfconfig.'plugins/scmarch/config.php')) {
 	require_once $gfconfig.'plugins/scmarch/config.php' ;

Modified: trunk/src/common/include/utils.php
===================================================================
--- trunk/src/common/include/utils.php	2011-01-10 21:11:20 UTC (rev 11966)
+++ trunk/src/common/include/utils.php	2011-01-11 13:54:07 UTC (rev 11967)
@@ -1359,6 +1359,23 @@
 	return $postfile;
 }
 
+function util_get_compressed_file_extension() {
+	$m = forge_get_config('compression_method');
+	if (preg_match ('/^gzip /', $m)) {
+		return '.gz';
+	} elseif (preg_match ('/^bzip2 /', $m)) {
+		return '.bzip2';
+	} elseif (preg_match ('/^lzma /', $m)) {
+		return '.lzma';
+	} elseif (preg_match ('/^xz /', $m)) {
+		return '.xz';
+	} elseif (preg_match ('/^cat /', $m)) {
+		return '';
+	} else {
+		return '.compressed';
+	}
+}
+
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"

Modified: trunk/src/plugins/scmarch/common/ArchPlugin.class.php
===================================================================
--- trunk/src/plugins/scmarch/common/ArchPlugin.class.php	2011-01-10 21:11:20 UTC (rev 11966)
+++ trunk/src/plugins/scmarch/common/ArchPlugin.class.php	2011-01-11 13:54:07 UTC (rev 11967)
@@ -81,8 +81,8 @@
 		
 		$group_name = $project->getUnixName() ;
 
-		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar.gz';
-		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
+		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar'.util_get_compressed_file_extension();
+		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
 
 		if (! $project->usesPlugin ($this->name)) {
 			return false;
@@ -107,10 +107,10 @@
 		if ($tmp == '') {
 			return false ;
 		}
-		system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
-		chmod ("$tmp/tarball.tar.gz", 0644) ;
-		copy ("$tmp/tarball.tar.gz", $tarball) ;
-		unlink ("$tmp/tarball.tar.gz") ;
+		system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
+		chmod ("$tmp/tarball", 0644) ;
+		copy ("$tmp/tarball", $tarball) ;
+		unlink ("$tmp/tarball") ;
 		system ("rm -rf $tmp") ;
 	}
   }

Modified: trunk/src/plugins/scmbzr/common/BzrPlugin.class.php
===================================================================
--- trunk/src/plugins/scmbzr/common/BzrPlugin.class.php	2011-01-10 21:11:20 UTC (rev 11966)
+++ trunk/src/plugins/scmbzr/common/BzrPlugin.class.php	2011-01-11 13:54:07 UTC (rev 11967)
@@ -424,8 +424,8 @@
 		
 		$group_name = $project->getUnixName() ;
 
-		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar.gz';
-		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
+		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar'.util_get_compressed_file_extension();
+		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
 
 		if (! $project->usesPlugin ($this->name)) {
 			return false;
@@ -453,19 +453,26 @@
 		$today = date ('Y-m-d') ;
 		$branch = $this->findMainBranch ($project) ;
 		if ($branch != '') {
-			system ("bzr export --root=$group_name-scm-$today $tmp/snapshot.tar.gz $repo/$bname") ;
-			chmod ("$tmp/snapshot.tar.gz", 0644) ;
-			copy ("$tmp/snapshot.tar.gz", $snapshot) ;
-			unlink ("$tmp/snapshot.tar.gz") ;
+			system ("cd $tmp ; svn checkout file://$repo/trunk $dir > /dev/null 2>&1") ;
+			system ("tar cCf $tmp - $dir |".forge_get_config('compression_method')."> snapshot") ;
+			chmod ("$tmp/snapshot", 0644) ;
+			copy ("$tmp/snapshot", $snapshot) ;
+			unlink ("$tmp/snapshot") ;
 			system ("rm -rf $tmp/$dir") ;
+
+			system ("bzr export --root=$group_name-scm-$today --format=tar - $repo/$bname |".forge_get_config('compression_method')."> $tmp/snapshot") ;
+			chmod ("$tmp/snapshot", 0644) ;
+			copy ("$tmp/snapshot", $snapshot) ;
+			unlink ("$tmp/snapshot") ;
+			system ("rm -rf $tmp/$dir") ;
 		} else {
 			unlink ($snapshot) ;
 		}
 
-		system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
-		chmod ("$tmp/tarball.tar.gz", 0644) ;
-		copy ("$tmp/tarball.tar.gz", $tarball) ;
-		unlink ("$tmp/tarball.tar.gz") ;
+		system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
+		chmod ("$tmp/tarball", 0644) ;
+		copy ("$tmp/tarball", $tarball) ;
+		unlink ("$tmp/tarball") ;
 		system ("rm -rf $tmp") ;
 	}
   }

Modified: trunk/src/plugins/scmcvs/common/CVSPlugin.class.php
===================================================================
--- trunk/src/plugins/scmcvs/common/CVSPlugin.class.php	2011-01-10 21:11:20 UTC (rev 11966)
+++ trunk/src/plugins/scmcvs/common/CVSPlugin.class.php	2011-01-11 13:54:07 UTC (rev 11967)
@@ -113,7 +113,7 @@
 	function getSnapshotPara ($project) {
 
 		$b = "" ;
-		$filename = $project->getUnixName().'-scm-latest.tar.gz';
+		$filename = $project->getUnixName().'-scm-latest.tar'.util_get_compressed_file_extension();
 		if (file_exists(forge_get_config('scm_snapshots_path').'/'.$filename)) {
 			$b .= '<p>[' ;
 			$b .= util_make_link ("/snapshots.php?group_id=".$project->getID(),
@@ -388,8 +388,8 @@
 		
 		$group_name = $project->getUnixName() ;
 
-		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar.gz';
-		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
+		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar'.util_get_compressed_file_extension();
+		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
 
 		if (! $project->usesPlugin ($this->name)) {
 			return false;
@@ -423,16 +423,16 @@
 		$dir = $project->getUnixName ()."-$today" ;
 		system ("mkdir -p $tmp/$dir") ;
 		system ("cd $tmp/$dir ; cvs -d $repo checkout . > /dev/null 2>&1") ;
-		system ("tar czCf $tmp $tmp/snapshot.tar.gz $dir") ;
-		chmod ("$tmp/snapshot.tar.gz", 0644) ;
-		copy ("$tmp/snapshot.tar.gz", $snapshot) ;
-		unlink ("$tmp/snapshot.tar.gz") ;
+		system ("tar cCf $tmp - $dir |".forge_get_config('compression_method')."> snapshot") ;
+		chmod ("$tmp/snapshot", 0644) ;
+		copy ("$tmp/snapshot", $snapshot) ;
+		unlink ("$tmp/snapshot") ;
 		system ("rm -rf $tmp/$dir") ;
 
-		system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
-		chmod ("$tmp/tarball.tar.gz", 0644) ;
-		copy ("$tmp/tarball.tar.gz", $tarball) ;
-		unlink ("$tmp/tarball.tar.gz") ;
+		system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
+		chmod ("$tmp/tarball", 0644) ;
+		copy ("$tmp/tarball", $tarball) ;
+		unlink ("$tmp/tarball") ;
 		system ("rm -rf $tmp") ;
 	}
   }

Modified: trunk/src/plugins/scmdarcs/common/DarcsPlugin.class.php
===================================================================
--- trunk/src/plugins/scmdarcs/common/DarcsPlugin.class.php	2011-01-10 21:11:20 UTC (rev 11966)
+++ trunk/src/plugins/scmdarcs/common/DarcsPlugin.class.php	2011-01-11 13:54:07 UTC (rev 11967)
@@ -148,7 +148,7 @@
 	function getSnapshotPara ($project) {
 
 		$b = "" ;
-		$filename = $project->getUnixName().'-scm-latest.tar.gz';
+		$filename = $project->getUnixName().'-scm-latest.tar'.util_get_compressed_file_extension();
 		if (file_exists(forge_get_config('scm_snapshots_path').'/'.$filename)) {
 			$b .= '<p>[' ;
 			$b .= util_make_link ("/snapshots.php?group_id=".$project->getID(),
@@ -375,7 +375,7 @@
 		
 		$group_name = $project->getUnixName() ;
 
-		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
+		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
 
 		if (! $project->usesPlugin ($this->name)) {
 			return false;
@@ -403,16 +403,16 @@
 		$dir = $project->getUnixName ()."-$today" ;
 		system ("mkdir -p $tmp/$dir") ;
 		system ("cd $tmp ; darcs $repo $dir > /dev/null 2>&1") ;
-		system ("tar czCf $tmp $tmp/snapshot.tar.gz $dir") ;
-		chmod ("$tmp/snapshot.tar.gz", 0644) ;
-		copy ("$tmp/snapshot.tar.gz", $snapshot) ;
-		unlink ("$tmp/snapshot.tar.gz") ;
+		system ("tar cCf $tmp - $dir |".forge_get_config('compression_method')."> snapshot") ;
+		chmod ("$tmp/snapshot", 0644) ;
+		copy ("$tmp/snapshot", $snapshot) ;
+		unlink ("$tmp/snapshot") ;
 		system ("rm -rf $tmp/$dir") ;
 
-		system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
-		chmod ("$tmp/tarball.tar.gz", 0644) ;
-		copy ("$tmp/tarball.tar.gz", $tarball) ;
-		unlink ("$tmp/tarball.tar.gz") ;
+		system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
+		chmod ("$tmp/tarball", 0644) ;
+		copy ("$tmp/tarball", $tarball) ;
+		unlink ("$tmp/tarball") ;
 		system ("rm -rf $tmp") ;
 	}
 

Modified: trunk/src/plugins/scmgit/common/GitPlugin.class.php
===================================================================
--- trunk/src/plugins/scmgit/common/GitPlugin.class.php	2011-01-10 21:11:20 UTC (rev 11966)
+++ trunk/src/plugins/scmgit/common/GitPlugin.class.php	2011-01-11 13:54:07 UTC (rev 11967)
@@ -176,7 +176,7 @@
 	function getSnapshotPara ($project) {
 
 		$b = "" ;
-		$filename = $project->getUnixName().'-scm-latest.tar.gz';
+		$filename = $project->getUnixName().'-scm-latest.tar'.util_get_compressed_file_extension();
 		if (file_exists(forge_get_config('scm_snapshots_path').'/'.$filename)) {
 			$b .= '<p>[' ;
 			$b .= util_make_link ("/snapshots.php?group_id=".$project->getID(),
@@ -533,8 +533,8 @@
 
 		$group_name = $project->getUnixName() ;
 
-		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar.gz';
-		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
+		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar'.util_get_compressed_file_extension();
+		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
 
 		if (! $project->usesPlugin ($this->name)) {
 			return false;
@@ -569,15 +569,15 @@
 			return false ;
 		}
 		$today = date ('Y-m-d') ;
-		system ("GIT_DIR=\"$repo\" git archive --format=tar --prefix=$group_name-scm-$today/ HEAD | gzip > $tmp/snapshot.tar.gz");
-		chmod ("$tmp/snapshot.tar.gz", 0644) ;
-		copy ("$tmp/snapshot.tar.gz", $snapshot) ;
-		unlink ("$tmp/snapshot.tar.gz") ;
+		system ("GIT_DIR=\"$repo\" git archive --format=tar --prefix=$group_name-scm-$today/ HEAD |".forge_get_config('compression_method')." > $tmp/snapshot");
+		chmod ("$tmp/snapshot", 0644) ;
+		copy ("$tmp/snapshot", $snapshot) ;
+		unlink ("$tmp/snapshot") ;
 
-		system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
-		chmod ("$tmp/tarball.tar.gz", 0644) ;
-		copy ("$tmp/tarball.tar.gz", $tarball) ;
-		unlink ("$tmp/tarball.tar.gz") ;
+		system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
+		chmod ("$tmp/tarball", 0644) ;
+		copy ("$tmp/tarball", $tarball) ;
+		unlink ("$tmp/tarball") ;
 		system ("rm -rf $tmp") ;
 	}
 }

Modified: trunk/src/plugins/scmhg/common/HgPlugin.class.php
===================================================================
--- trunk/src/plugins/scmhg/common/HgPlugin.class.php	2011-01-10 21:11:20 UTC (rev 11966)
+++ trunk/src/plugins/scmhg/common/HgPlugin.class.php	2011-01-11 13:54:07 UTC (rev 11967)
@@ -128,7 +128,7 @@
 
 		$group_name = $project->getUnixName() ;
 
-		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
+		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
 
 		if (! $project->usesPlugin ($this->name)) {
 			return false;
@@ -151,10 +151,10 @@
 		if ($tmp == '') {
 			return false ;
 		}
-		system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
-		chmod ("$tmp/tarball.tar.gz", 0644) ;
-		copy ("$tmp/tarball.tar.gz", $tarball) ;
-		unlink ("$tmp/tarball.tar.gz") ;
+		system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
+		chmod ("$tmp/tarball", 0644) ;
+		copy ("$tmp/tarball", $tarball) ;
+		unlink ("$tmp/tarball") ;
 		system ("rm -rf $tmp") ;
 	}
   }

Modified: trunk/src/plugins/scmsvn/common/SVNPlugin.class.php
===================================================================
--- trunk/src/plugins/scmsvn/common/SVNPlugin.class.php	2011-01-10 21:11:20 UTC (rev 11966)
+++ trunk/src/plugins/scmsvn/common/SVNPlugin.class.php	2011-01-11 13:54:07 UTC (rev 11967)
@@ -470,8 +470,8 @@
 		
 		$group_name = $project->getUnixName() ;
 
-		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar.gz';
-		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
+		$snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar'.util_get_compressed_file_extension();
+		$tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
 
 		if (! $project->usesPlugin ($this->name)) {
 			return false;
@@ -511,10 +511,10 @@
 		system ("svn ls file://$repo/trunk > /dev/null", $code) ;
 		if ($code == 0) {
 			system ("cd $tmp ; svn checkout file://$repo/trunk $dir > /dev/null 2>&1") ;
-			system ("tar czCf $tmp $tmp/snapshot.tar.gz $dir") ;
-			chmod ("$tmp/snapshot.tar.gz", 0644) ;
-			copy ("$tmp/snapshot.tar.gz", $snapshot) ;
-			unlink ("$tmp/snapshot.tar.gz") ;
+			system ("tar cCf $tmp - $dir |".forge_get_config('compression_method')."> snapshot") ;
+			chmod ("$tmp/snapshot", 0644) ;
+			copy ("$tmp/snapshot", $snapshot) ;
+			unlink ("$tmp/snapshot") ;
 			system ("rm -rf $tmp/$dir") ;
 		} else {
 			if (is_file($snapshot)) {
@@ -522,10 +522,10 @@
 			}
 		}
 
-		system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
-		chmod ("$tmp/tarball.tar.gz", 0644) ;
-		copy ("$tmp/tarball.tar.gz", $tarball) ;
-		unlink ("$tmp/tarball.tar.gz") ;
+		system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
+		chmod ("$tmp/tarball", 0644) ;
+		copy ("$tmp/tarball", $tarball) ;
+		unlink ("$tmp/tarball") ;
 		system ("rm -rf $tmp") ;
 	}
   }




More information about the Fusionforge-commits mailing list