2 /** FusionForge Arch 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 ArchPlugin extends SCMPlugin {
25 function ArchPlugin () {
28 $this->name = 'scmarch';
30 $this->hooks[] = 'scm_generate_snapshots' ;
32 require_once $gfconfig.'plugins/scmarch/config.php' ;
34 $this->default_arch_server = $default_arch_server ;
35 if (isset ($arch_root)) {
36 $this->arch_root = $arch_root;
38 $this->arch_root = forge_get_config('chroot').'/scmrepos/arch' ;
44 function getDefaultServer() {
45 return $this->default_arch_server ;
48 function getBlurb () {
49 return _('<p>Documentation for GNU Arch (sometimes referred to as "tla") is available <a href="http://www.gnu.org/software/gnu-arch/">here</a>.</p>') ;
52 function createOrUpdateRepo ($params) {
53 $project = $this->checkParams ($params) ;
58 if (! $project->usesPlugin ($this->name)) {
62 $repo = $this->arch_root . '/' . $project->getUnixName() ;
63 $unix_group = 'scm_' . $project->getUnixName() ;
65 $repo_exists = false ;
67 system ("mkdir -p $repo") ;
68 system ("find $repo -type d | xargs chmod g+s") ;
71 system ("chgrp -R $unix_group $repo") ;
72 if ($project->enableAnonSCM()) {
73 system ("chmod -R g+wX,o+rX-w $repo") ;
75 system ("chmod -R g+wX,o-rwx $repo") ;
79 function generateSnapshots ($params) {
83 $project = $this->checkParams ($params) ;
88 $group_name = $project->getUnixName() ;
90 $snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar.gz';
91 $tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar.gz';
93 if (! $project->usesPlugin ($this->name)) {
97 if (! $project->enableAnonSCM()) {
103 $toprepo = $this->arch_root ;
104 $repo = $toprepo . '/' . $project->getUnixName() ;
106 if (!is_dir ($repo) || !is_file ("$repo/format")) {
112 $tmp = trim (`mktemp -d`) ;
116 system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ;
117 chmod ("$tmp/tarball.tar.gz", 0644) ;
118 copy ("$tmp/tarball.tar.gz", $tarball) ;
119 unlink ("$tmp/tarball.tar.gz") ;
120 system ("rm -rf $tmp") ;
126 // c-file-style: "bsd"