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 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 forge_define_config_item ('default_server', 'scmarch', forge_get_config ('web_host')) ;
24 forge_define_config_item ('repos_path', 'scmarch', forge_get_config('chroot').'/scmrepos/arch') ;
26 class ArchPlugin extends SCMPlugin {
27 function ArchPlugin () {
30 $this->name = 'scmarch';
32 $this->hooks[] = 'scm_generate_snapshots' ;
37 function getDefaultServer() {
38 return forge_get_config('default_server', 'scmarch') ;
41 function getBlurb () {
42 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>') ;
45 function createOrUpdateRepo ($params) {
46 $project = $this->checkParams ($params) ;
51 if (! $project->usesPlugin ($this->name)) {
55 $repo = forge_get_config('repos_path', 'scmarch') . '/' . $project->getUnixName() ;
56 $unix_group = 'scm_' . $project->getUnixName() ;
58 $repo_exists = false ;
60 system ("mkdir -p $repo") ;
61 system ("find $repo -type d | xargs chmod g+s") ;
64 system ("chgrp -R $unix_group $repo") ;
65 if ($project->enableAnonSCM()) {
66 system ("chmod -R g+wX,o+rX-w $repo") ;
68 system ("chmod -R g+wX,o-rwx $repo") ;
72 function generateSnapshots ($params) {
76 $project = $this->checkParams ($params) ;
81 $group_name = $project->getUnixName() ;
83 $snapshot = forge_get_config('scm_snapshots_path').'/'.$group_name.'-scm-latest.tar'.util_get_compressed_file_extension();
84 $tarball = forge_get_config('scm_tarballs_path').'/'.$group_name.'-scmroot.tar'.util_get_compressed_file_extension();
86 if (! $project->usesPlugin ($this->name)) {
90 if (! $project->enableAnonSCM()) {
91 if (file_exists ($snapshot)) unlink ($snapshot) ;
92 if (file_exists ($tarball)) unlink ($tarball) ;
96 $toprepo = forge_get_config('repos_path', 'scmarch') ;
97 $repo = $toprepo . '/' . $project->getUnixName() ;
99 if (!is_dir ($repo) || !is_file ("$repo/format")) {
100 if (file_exists ($snapshot)) unlink ($snapshot) ;
101 if (file_exists ($tarball)) unlink ($tarball) ;
105 $tmp = trim (`mktemp -d`) ;
109 system ("tar cCf $toprepo - ".$project->getUnixName() ."|".forge_get_config('compression_method')."> $tmp/tarball") ;
110 chmod ("$tmp/tarball", 0644) ;
111 copy ("$tmp/tarball", $tarball) ;
112 unlink ("$tmp/tarball") ;
113 system ("rm -rf $tmp") ;
119 // c-file-style: "bsd"