SCMPlugin () ; $this->name = 'scmbzr'; $this->text = 'Bazaar'; $this->hooks[] = 'scm_generate_snapshots' ; require_once $gfconfig.'plugins/scmbzr/config.php' ; $this->default_bzr_server = $default_bzr_server ; if (isset ($bzr_root)) { $this->bzr_root = $bzr_root; } else { $this->bzr_root = $GLOBALS['sys_chroot'].'/scmrepos/bzr' ; } $this->main_branch_names = array () ; $this->main_branch_names[] = 'trunk' ; $this->main_branch_names[] = 'master' ; $this->main_branch_names[] = 'main' ; $this->main_branch_names[] = 'head' ; $this->main_branch_names[] = 'HEAD' ; $this->register () ; } function getDefaultServer() { return $this->default_bzr_server ; } function getBlurb () { return _('
Documentation for Bazaar (sometimes referred to as "bzr") is available here.
') ; } function getInstructionsForAnon ($project) { $b = _('Anonymous Bazaar Access
This project\'s Bazaar repository can be checked out through anonymous access with the following command.
'); $b .= '' ;
$b .= 'bzr checkout '.util_make_url ('/anonscm/bzr/'.$project->getUnixName().'/').'
';
$b .= '
Developer Bazaar Access via SSH
Only project developers can access the Bazaar branches via this method. SSH must be installed on your client machine. Substitute developername with the proper values. Enter your site password when prompted.
'); $b .= 'bzr checkout bzr+ssh://'._('developername').'@' . $project->getSCMBox() . $this->bzr_root .'/'. $project->getUnixName().'/'._('branchname').'
' ; return $b ; } function getSnapshotPara ($project) { return ; } function getBrowserLinkBlock ($project) { return ; } function getStatsBlock ($project) { return ; } function createOrUpdateRepo ($params) { $project = $this->checkParams ($params) ; if (!$project) { return false ; } if (! $project->usesPlugin ($this->name)) { return false; } $repo = $this->bzr_root . '/' . $project->getUnixName() ; $unix_group = 'scm_' . $project->getUnixName() ; $repo_exists = false ; if (is_dir ($repo)) { $pipe = popen ("bzr info $repo 2>/dev/null", "r") ; $line = fgets ($pipe) ; fclose ($pipe) ; if (preg_match ("/^Shared repository/", $line) != 0) { $repo_exists = true ; } } if (!$repo_exists) { system ("mkdir -p $repo") ; system ("bzr init-repo --no-trees $repo >/dev/null") ; } system ("chgrp -R $unix_group $repo") ; if ($project->enableAnonSCM()) { system ("chmod -R g+wXs,o+rX-w $repo") ; } else { system ("chmod -R g+wXs,o-rwx $repo") ; } } function generateSnapshots ($params) { global $sys_scm_snapshots_path ; global $sys_scm_tarballs_path ; $project = $this->checkParams ($params) ; if (!$project) { return false ; } $group_name = $project->getUnixName() ; $snapshot = $sys_scm_snapshots_path.'/'.$group_name.'-scm-latest.tar.gz'; $tarball = $sys_scm_tarballs_path.'/'.$group_name.'-scmroot.tar.gz'; if (! $project->usesPlugin ($this->name)) { return false; } if (! $project->enableAnonSCM()) { unlink ($snapshot) ; unlink ($tarball) ; return false; } $toprepo = $this->bzr_root ; $repo = $toprepo . '/' . $project->getUnixName() ; if (!is_dir ($repo) || !is_file ("$repo/format")) { unlink ($snapshot) ; unlink ($tarball) ; return false ; } $tmp = trim (`mktemp -d`) ; if ($tmp == '') { return false ; } $today = date ('Y-m-d') ; $code = 0 ; $branch = '' ; foreach ($this->main_branch_names as $bname) { system ("bzr ls file://$repo/$bname > /dev/null 2>&1", $code) ; if ($code == 0) { $branch = $bname ; break ; } } if ($branch != '') { system ("bzr export --root=$group_name-scm-$today $tmp/snapshot.tar.gz $repo/$bname") ; chmod ("$tmp/snapshot.tar.gz", 0644) ; copy ("$tmp/snapshot.tar.gz", $snapshot) ; unlink ("$tmp/snapshot.tar.gz") ; system ("rm -rf $tmp/$dir") ; } else { unlink ($snapshot) ; } system ("tar czCf $toprepo $tmp/tarball.tar.gz " . $project->getUnixName()) ; chmod ("$tmp/tarball.tar.gz", 0644) ; copy ("$tmp/tarball.tar.gz", $tarball) ; unlink ("$tmp/tarball.tar.gz") ; system ("rm -rf $tmp") ; } } // Local Variables: // mode: php // c-file-style: "bsd" // End: ?>