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 along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 class CpoldPlugin extends SCMPlugin {
24 function CpoldPlugin () {
27 $this->name = 'scmcpold';
28 $this->text = 'CPOLD';
29 $this->hooks[] = 'scm_generate_snapshots' ;
30 $this->hooks[] = 'scm_cpold_do_nothing' ;
32 require $gfconfig.'plugins/scmcpold/config.php' ;
34 $this->default_cpold_server = $default_cpold_server ;
35 if (isset ($cpold_root)) {
36 $this->cpold_root = $cpold_root;
38 $this->cpold_root = $GLOBALS['sys_chroot'].'/scmrepos/cpold' ;
44 function CallHook ($hookname, &$params) {
48 case 'scm_cpold_do_nothing':
52 parent::CallHook ($hookname, $params) ;
56 function getDefaultServer() {
57 return $this->default_cpold_server ;
60 function getBlurb () {
61 return _('<p>This CPOLD plugin is only intended as a proof of concept.</p>') ;
64 function getInstructionsForAnon ($project) {
65 $b = sprintf (_('<p><b>Anonymous CPOLD Access</b></p><p>This project\'s CPOLD repository can be accessep anonymously at %s.</p>'),
66 util_make_link ('/anonscm/cpold/'.$project->getUnixName().'/',
67 util_make_url ('/anonscm/cpold/'.$project->getUnixName().'/'))) ;
71 function getInstructionsForRW ($project) {
72 if (session_loggedin()) {
73 $u =& user_get_object(user_getid()) ;
74 $d = $u->getUnixName() ;
75 $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>');
76 $b .= '<p><tt>scp -r '.$d.'@' . $project->getSCMBox() . ':'. $this->cpold_root .'/'. $project->getUnixName().'/ .</tt></p>' ;
78 $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>');
79 $b .= '<p><tt>scp -r <i>'._('developername').'</i>@' . $project->getSCMBox() . ':'. $this->cpold_root .'/'. $project->getUnixName().'/ .</tt></p>' ;
84 function getSnapshotPara ($project) {
88 function getBrowserLinkBlock ($project) {
92 function getStatsBlock ($project) {
96 function createOrUpdateRepo ($params) {
97 $project = $this->checkParams ($params) ;
102 if (! $project->usesPlugin ($this->name)) {
106 $repo = $this->cpold_root . '/' . $project->getUnixName() ;
107 $unix_group = 'scm_' . $project->getUnixName() ;
109 system ("mkdir -p $repo") ;
110 system ("chgrp -R $unix_group $repo") ;
111 system ("find $repo -type d | xargs chmod g+s") ;
113 if ($project->enableAnonSCM()) {
114 system ("chmod -R g+wX,o+rX-w $repo") ;
116 system ("chmod -R g+wX,o-rwx $repo") ;
120 function generateSnapshots ($params) {
121 global $sys_scm_tarballs_path ;
123 $project = $this->checkParams ($params) ;
128 $group_name = $project->getUnixName() ;
130 $tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
132 if (! $project->usesPlugin ($this->name)) {
136 if (! $project->enableAnonSCM()) {
141 $toprepo = $this->cpold_root ;
142 $repo = $toprepo . '/' . $project->getUnixName() ;
144 if (!is_dir ($repo)) {
149 $tmp = trim (`mktemp -d`) ;
153 system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
154 chmod ("$tmp/tarball.tar.gz", 0644) ;
155 copy ("$tmp/tarball.tar.gz", $tarball) ;
156 unlink ("$tmp/tarball.tar.gz") ;
157 system ("rm -rf $tmp") ;
163 // c-file-style: "bsd"