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->cpold_root = $cpold_root;
41 function CallHook ($hookname, $params) {
45 case 'scm_cpold_do_nothing':
49 parent::CallHook ($hookname, $params) ;
53 function getDefaultServer() {
54 return $this->default_cpold_server ;
57 function getBlurb () {
58 return _('<p>This CPOLD plugin is only intended as a proof of concept.</p>') ;
61 function getInstructionsForAnon ($project) {
62 $b = _('<p><b>Anonymous CPOLD Access</b></p><p>This project\'s CPOLD repository cannot be anonymously checked out yet.</p>');
66 function getInstructionsForRW ($project) {
67 $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>');
68 $b .= '<p><tt>scp -r <i>'._('developername').'</i>@' . $project->getSCMBox() . ':'. $this->cpold_root .'/'. $project->getUnixName().'/ .</tt></p>' ;
72 function getSnapshotPara ($project) {
76 function getBrowserLinkBlock ($project) {
80 function getStatsBlock ($project) {
84 function createOrUpdateRepo ($params) {
85 $project = $this->checkParams ($params) ;
90 if (! $project->usesPlugin ($this->name)) {
94 $repo = $this->cpold_root . '/' . $project->getUnixName() ;
95 $unix_group = 'scm_' . $project->getUnixName() ;
97 system ("mkdir -p $repo") ;
98 system ("chgrp -R $unix_group $repo") ;
99 if ($project->enableAnonSCM()) {
100 system ("chmod -R g+wXs,o+rX-w $repo") ;
102 system ("chmod -R g+wXs,o-rwx $repo") ;
106 function generateSnapshots ($params) {
107 global $sys_scm_tarballs_path ;
109 $project = $this->checkParams ($params) ;
114 $group_name = $project->getUnixName() ;
116 $tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
118 if (! $project->usesPlugin ($this->name)) {
122 if (! $project->enableAnonSCM()) {
127 $toprepo = $this->cpold_root ;
128 $repo = $toprepo . '/' . $project->getUnixName() ;
130 if (!is_dir ($repo)) {
135 $tmp = trim (`mktemp -d`) ;
139 system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
140 chmod ("$tmp/tarball.tar.gz", 0644) ;
141 copy ("$tmp/tarball.tar.gz", $tarball) ;
142 unlink ("$tmp/tarball.tar.gz") ;
143 system ("rm -rf $tmp") ;
149 // c-file-style: "bsd"