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 if (isset ($cpold_root)) {
37 $this->cpold_root = $cpold_root;
39 $this->cpold_root = $GLOBALS['sys_chroot'].'/scmrepos/cpold' ;
45 function CallHook ($hookname, $params) {
49 case 'scm_cpold_do_nothing':
53 parent::CallHook ($hookname, $params) ;
57 function getDefaultServer() {
58 return $this->default_cpold_server ;
61 function getBlurb () {
62 return _('<p>This CPOLD plugin is only intended as a proof of concept.</p>') ;
65 function getInstructionsForAnon ($project) {
66 $b = sprintf (_('<p><b>Anonymous CPOLD Access</b></p><p>This project\'s CPOLD repository can be accessep anonymously at %s.</p>'),
67 util_make_link ('/anonscm/cpold/'.$project->getUnixName().'/',
68 util_make_url ('/anonscm/cpold/'.$project->getUnixName().'/'))) ;
72 function getInstructionsForRW ($project) {
73 $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>');
74 $b .= '<p><tt>scp -r <i>'._('developername').'</i>@' . $project->getSCMBox() . ':'. $this->cpold_root .'/'. $project->getUnixName().'/ .</tt></p>' ;
78 function getSnapshotPara ($project) {
82 function getBrowserLinkBlock ($project) {
86 function getStatsBlock ($project) {
90 function createOrUpdateRepo ($params) {
91 $project = $this->checkParams ($params) ;
96 if (! $project->usesPlugin ($this->name)) {
100 $repo = $this->cpold_root . '/' . $project->getUnixName() ;
101 $unix_group = 'scm_' . $project->getUnixName() ;
103 system ("mkdir -p $repo") ;
104 system ("chgrp -R $unix_group $repo") ;
105 if ($project->enableAnonSCM()) {
106 system ("chmod -R g+wXs,o+rX-w $repo") ;
108 system ("chmod -R g+wXs,o-rwx $repo") ;
112 function generateSnapshots ($params) {
113 global $sys_scm_tarballs_path ;
115 $project = $this->checkParams ($params) ;
120 $group_name = $project->getUnixName() ;
122 $tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
124 if (! $project->usesPlugin ($this->name)) {
128 if (! $project->enableAnonSCM()) {
133 $toprepo = $this->cpold_root ;
134 $repo = $toprepo . '/' . $project->getUnixName() ;
136 if (!is_dir ($repo)) {
141 $tmp = trim (`mktemp -d`) ;
145 system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
146 chmod ("$tmp/tarball.tar.gz", 0644) ;
147 copy ("$tmp/tarball.tar.gz", $tarball) ;
148 unlink ("$tmp/tarball.tar.gz") ;
149 system ("rm -rf $tmp") ;
155 // c-file-style: "bsd"