2 /** FusionForge CPOLD plugin
4 * Copyright 2009, Roland Mas
6 * This file is part of FusionForge.
8 * FusionForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2 of the License,
11 * or (at your option) any later version.
13 * FusionForge is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with FusionForge; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 class CpoldPlugin extends SCMPlugin {
25 function CpoldPlugin () {
28 $this->name = 'scmcpold';
29 $this->text = 'CPOLD';
30 $this->hooks[] = 'scm_generate_snapshots' ;
31 $this->hooks[] = 'scm_cpold_do_nothing' ;
33 require_once $gfconfig.'plugins/scmcpold/config.php' ;
35 $this->default_cpold_server = $default_cpold_server ;
36 $this->enabled_by_default = $enabled_by_default ;
37 $this->cpold_root = $cpold_root;
42 function CallHook ($hookname, $params) {
46 case 'scm_cpold_do_nothing':
50 parent::CallHook ($hookname, $params) ;
54 function getDefaultServer() {
55 return $this->default_cpold_server ;
58 function getBlurb () {
59 return _('<p>This CPOLD plugin is only intended as a proof of concept.</p>') ;
62 function getInstructionsForAnon ($project) {
63 $b = _('<p><b>Anonymous CPOLD Access</b></p><p>This project\'s CPOLD repository cannot be anonymously checked out yet.</p>');
67 function getInstructionsForRW ($project) {
68 $b = _('<p><b>Developer CPOLD Access via SSH</b></p><p>Only project developers can access the CPOLD tree via this method. SSH must be installed on your client machine. Substitute <i>developername</i> with the proper values. Enter your site password when prompted.</p>');
69 $b .= '<p><tt>scp -r <i>'._('developername').'</i>@' . $project->getSCMBox() . ':'. $this->cpold_root .'/'. $project->getUnixName().'/ .</tt></p>' ;
73 function getSnapshotPara ($project) {
77 function getBrowserLinkBlock ($project) {
81 function getStatsBlock ($project) {
85 function createOrUpdateRepo ($params) {
86 $project = $this->checkParams ($params) ;
91 if (! $project->usesPlugin ($this->name)) {
95 $repo = $this->cpold_root . '/' . $project->getUnixName() ;
96 $unix_group = 'scm_' . $project->getUnixName() ;
98 system ("mkdir -p $repo") ;
99 system ("chgrp -R $unix_group $repo") ;
100 if ($project->enableAnonSCM()) {
101 system ("chmod -R g+wXs,o+rX-w $repo") ;
103 system ("chmod -R g+wXs,o-rwx $repo") ;
107 function generateSnapshots ($params) {
108 global $sys_scm_tarballs_path ;
110 $project = $this->checkParams ($params) ;
115 $group_name = $project->getUnixName() ;
117 $tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
119 if (! $project->usesPlugin ($this->name)
120 || ! $project->enableAnonSCM()) {
125 $toprepo = $this->cpold_root ;
126 $repo = $toprepo . '/' . $project->getUnixName() ;
128 if (!is_dir ($repo)) {
133 $tmp = trim (`mktemp -d`) ;
137 system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
138 chmod ("$tmp/tarball.tar.gz", 0644) ;
139 copy ("$tmp/tarball.tar.gz", $tarball) ;
140 unlink ("$tmp/tarball.tar.gz") ;
141 system ("rm -rf $tmp") ;
147 // c-file-style: "bsd"