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 if (session_loggedin()) {
74 $u =& user_get_object(user_getid()) ;
75 $d = $u->getUnixName() ;
76 $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. Enter your site password when prompted.</p>');
77 $b .= '<p><tt>scp -r '.$d.'@' . $project->getSCMBox() . ':'. $this->cpold_root .'/'. $project->getUnixName().'/ .</tt></p>' ;
79 $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 value. Enter your site password when prompted.</p>');
80 $b .= '<p><tt>scp -r <i>'._('developername').'</i>@' . $project->getSCMBox() . ':'. $this->cpold_root .'/'. $project->getUnixName().'/ .</tt></p>' ;
85 function getSnapshotPara ($project) {
89 function getBrowserLinkBlock ($project) {
93 function getStatsBlock ($project) {
97 function createOrUpdateRepo ($params) {
98 $project = $this->checkParams ($params) ;
103 if (! $project->usesPlugin ($this->name)) {
107 $repo = $this->cpold_root . '/' . $project->getUnixName() ;
108 $unix_group = 'scm_' . $project->getUnixName() ;
110 system ("mkdir -p $repo") ;
111 system ("chgrp -R $unix_group $repo") ;
112 system ("find $repo -type d | xargs chmod g+s") ;
114 if ($project->enableAnonSCM()) {
115 system ("chmod -R g+wX,o+rX-w $repo") ;
117 system ("chmod -R g+wX,o-rwx $repo") ;
121 function generateSnapshots ($params) {
122 global $sys_scm_tarballs_path ;
124 $project = $this->checkParams ($params) ;
129 $group_name = $project->getUnixName() ;
131 $tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
133 if (! $project->usesPlugin ($this->name)) {
137 if (! $project->enableAnonSCM()) {
142 $toprepo = $this->cpold_root ;
143 $repo = $toprepo . '/' . $project->getUnixName() ;
145 if (!is_dir ($repo)) {
150 $tmp = trim (`mktemp -d`) ;
154 system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
155 chmod ("$tmp/tarball.tar.gz", 0644) ;
156 copy ("$tmp/tarball.tar.gz", $tarball) ;
157 unlink ("$tmp/tarball.tar.gz") ;
158 system ("rm -rf $tmp") ;
164 // c-file-style: "bsd"