2 /** FusionForge Darcs 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 DarcsPlugin extends SCMPlugin {
25 function DarcsPlugin () {
28 $this->name = 'scmdarcs';
29 $this->text = 'Darcs';
30 $this->hooks[] = 'scm_generate_snapshots' ;
31 $this->hooks[] = 'scm_darcs_do_nothing' ;
33 require_once $gfconfig.'plugins/scmdarcs/config.php' ;
35 $this->default_darcs_server = $default_darcs_server ;
36 $this->enabled_by_default = $enabled_by_default ;
37 $this->darcs_root = $darcs_root;
42 function getDefaultServer() {
43 return $this->default_darcs_server ;
46 function getBlurb () {
47 return _('<p>This Darcs plugin is not fully implemented yet.</p>') ;
50 function getInstructionsForAnon ($project) {
51 $b = _('<p><b>Anonymous Darcs Access</b></p><p>This project\'s Darcs repository cannot be anonymously checked out yet.</p>');
55 function getInstructionsForRW ($project) {
56 $b = _('<p><b>Developer Darcs Access via SSH</b></p><p>Only project developers can access the Darcs 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>');
57 $b .= '<p><tt>scp -r <i>'._('developername').'</i>@' . $project->getSCMBox() . ':'. $this->darcs_root .'/'. $project->getUnixName().'/ .</tt></p>' ;
61 function getSnapshotPara ($project) {
65 function getBrowserLinkBlock ($project) {
69 function getStatsBlock ($project) {
73 function createOrUpdateRepo ($params) {
74 $project = $this->checkParams ($params) ;
79 if (! $project->usesPlugin ($this->name)) {
83 $repo = $this->darcs_root . '/' . $project->getUnixName() ;
84 $unix_group = 'scm_' . $project->getUnixName() ;
86 system ("mkdir -p $repo") ;
87 system ("chgrp -R $unix_group $repo") ;
88 if ($project->enableAnonSCM()) {
89 system ("chmod -R g+wXs,o+rX-w $repo") ;
91 system ("chmod -R g+wXs,o-rwx $repo") ;
95 function generateSnapshots ($params) {
96 global $sys_scm_tarballs_path ;
98 $project = $this->checkParams ($params) ;
103 $group_name = $project->getUnixName() ;
105 $tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz';
107 if (! $project->usesPlugin ($this->name)) {
111 if (! $project->enableAnonSCM()) {
116 $toprepo = $this->darcs_root ;
117 $repo = $toprepo . '/' . $project->getUnixName() ;
119 if (!is_dir ($repo)) {
124 $tmp = trim (`mktemp -d`) ;
128 system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
129 chmod ("$tmp/tarball.tar.gz", 0644) ;
130 copy ("$tmp/tarball.tar.gz", $tarball) ;
131 unlink ("$tmp/tarball.tar.gz") ;
132 system ("rm -rf $tmp") ;
138 // c-file-style: "bsd"