[Fusionforge-commits] r7966 - trunk/gforge/plugins/scmcvs/common

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Aug 27 15:36:41 CEST 2009


Author: lolando
Date: 2009-08-27 15:36:41 +0200 (Thu, 27 Aug 2009)
New Revision: 7966

Modified:
   trunk/gforge/plugins/scmcvs/common/CVSPlugin.class.php
Log:
Added skeleton for generating snapshots and tarballs from a hook

Modified: trunk/gforge/plugins/scmcvs/common/CVSPlugin.class.php
===================================================================
--- trunk/gforge/plugins/scmcvs/common/CVSPlugin.class.php	2009-08-27 13:36:31 UTC (rev 7965)
+++ trunk/gforge/plugins/scmcvs/common/CVSPlugin.class.php	2009-08-27 13:36:41 UTC (rev 7966)
@@ -33,6 +33,7 @@
 		$this->hooks[] = 'scm_admin_page';
 		$this->hooks[] = 'scm_stats';
 		$this->hooks[] = 'scm_createrepo' ;
+		$this->hooks[] = 'scm_snapshots_and_tarballs' ;
 		$this->hooks[] = 'scm_plugin';
 
 		require_once $GLOBALS['gfconfig'].'plugins/scmcvs/config.php' ;
@@ -74,6 +75,9 @@
 		case 'scm_createrepo':
 			$this->createOrUpdateRepo ($params) ;
 			break;
+		case 'scm_snapshots_and_tarballs':
+			$this->generateSnapshots ($params) ;
+			break;
 		case 'scm_plugin':
 			$scm_plugins=& $params['scm_plugins'];
 			$scm_plugins[]=$this->name;
@@ -323,6 +327,63 @@
 			system ("chmod -R g+wXs,o-rwx $repo") ;
 		}
 	}
+
+	function generateSnapshots ($params) {
+		$group_id = $params['group_id'] ;
+
+		$project =& group_get_object($group_id);
+		if (!$project || !is_object($project)) {
+			return false;
+		} elseif ($project->isError()) {
+			return false;
+		}
+
+		$group_name = $project->getUnixName();
+
+		$snapshot = $sys_scm_snapshots_path.'/'.$group_name.'-scm-latest.tar.gz';
+		$tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
+
+		if (! $project->usesPlugin ($this->name)
+		    || ! $project->enableAnonSCM()) {
+			unlink ($snapshot) ;
+			unlink ($tarball) ;
+			return false;
+		}
+
+		$repo = $this->cvs_root . '/' . $project->getUnixName() ;
+
+		$repo_exists = false ;
+		if (is_dir ($repo) && is_dir ("$repo/CVSROOT")) {
+			$repo_exists = true ;
+		}
+		
+		if (!$repo_exists) {
+			unlink ($snapshot) ;
+			unlink ($tarball) ;
+			return false ;
+		}
+
+		/*
+		 $compression = --gzip
+		 
+		 Déléguer la suite à un script shell
+
+		 system ("scmcvs-snapshots.sh $repo $group_name $snapshot")
+		 
+		 tmp=$(mktemp -d)
+		 cd $tmp
+		 $today=$(date +%Y-%m-%d)
+		 mkdir -p $group_name-$today
+		 cd $group_name-$today
+		 cvs -d $repo checkout .
+		 cd ..
+		 tar cf snapshot.tar.compressed $compression $group_name-$today
+		 chmod
+		 mv snapshot.tar.compressed $snapshot
+		 cd /
+		 rm -rf $tmp
+		*/
+	}
   }
 
 // Local Variables:




More information about the Fusionforge-commits mailing list