Commit 57316ba5 authored by Alain Takoudjou's avatar Alain Takoudjou

Add Git Repository support to TRAC

parent 943fa6aa
......@@ -138,6 +138,24 @@ class Recipe(GenericBaseRecipe):
os.path.join(svn_repo_path, 'hooks/post-revprop-change'))
self.logger.info("Finished initializing %s reposiroty" % svn_repo)
repolist = json.loads(self.options.get('git-project-list', '{}'))
for repo, desc in repolist.iteritems():
absolute_path = os.path.join(self.options['git-dir'], '%s.git' % repo)
if not os.path.exists(absolute_path):
self.logger.info("Initializing %s GIT repository..." % repo)
subprocess.check_call([self.options['git-binary'], 'init',
'--bare', absolute_path])
subprocess.check_call([trac_admin, project_dir, 'repository',
'add', repo, absolute_path, 'git'])
subprocess.check_call([trac_admin, project_dir, 'repository',
'resync', repo])
# XXX: Hardcoded path
shutil.copy(self.options['trac-git-hook'].strip(),
os.path.join(absolute_path, 'hooks/post-commit'))
description_filename = os.path.join(absolute_path, 'description')
with open(description_filename, 'w') as description_file:
description_file.write(desc)
user_list = json.loads(self.options.get('user-list', '{}'))
fd = open(os.path.join(project_dir, 'svnpasswd'), 'w')
fd.write("[users]\n%s = %s" % (admin, passwd))
......
......@@ -12,7 +12,9 @@ parts =
trac-git-hook-script
trac-svn-hook-script
post-revprop-change-script
gitweb-conf
httpd
gitdaemon
promise
ca-shellinabox
......@@ -197,6 +199,10 @@ output = $${rootdirectory:etc}/apache.conf
document_root = $${rootdirectory:srv}/site/
wsgi_location = $${inittrac:wsgi-dir}
gitweb-static-dir = ${gitweb:location}/share/gitweb/static/
gitweb-script = $${gitweb-cgi:output}
git-http-backend = $${git-http-backend-cgi:output}
cgid-sock = $${basedirectory:run}/cgid.sock
pid_file = $${basedirectory:run}/apache.pid
lock_file = $${basedirectory:run}/apache.lock
ip = $${slap-network-information:global-ipv6}
......@@ -210,8 +216,8 @@ url = ${tracIni:location}/${tracIni:filename}
output = $${directory:tracconfig}/trac-config-model.ini
mode = 0600
project_dir = $${rootdirectory:srv}/site
#project_url = http://[$${slap-network-information:global-ipv6}]:8080
project_url = $${request-frontend:connection-site_url}
project_url = http://[$${slap-network-information:global-ipv6}]:8080
#project_url = $${request-frontend:connection-site_url}
trac_plugins = $${:project_dir}/plugins
git_bin = ${git:location}/bin/git
git_project_base = $${:project_dir}/git
......@@ -222,7 +228,6 @@ project_description = $${slap-parameter:project-desc}
project_footer = $${slap-parameter:project-footer}
project_name = $${slap-parameter:project-name}
#MySQL informations
mysql_username = $${mariadb-urlparse:username}
mysql_password = $${mariadb-urlparse:password}
......@@ -275,6 +280,31 @@ trac_admin = ${buildout:bin-directory}
svn_bin = ${subversion-1.9:location}/bin
svn_python = ${subversion-1.9:location}/lib/svn-python
[gitweb-conf]
recipe = slapos.recipe.template
url = ${template-gitweb-conf:location}/${template-gitweb-conf:filename}
output = $${rootdirectory:etc}/gitweb.conf
url-list = $${trac-config:project_url}/git git://[$${slap-network-information:global-ipv6}]
base-directory = $${trac-config:project_dir}/git
[gitweb-cgi]
recipe = slapos.recipe.template
url = ${template-gitweb-cgi:location}/${template-gitweb-cgi:filename}
output = $${rootdirectory:bin}/gitweb.cgi
mode = 700
perl = ${perl:location}/bin/perl
gitweb = ${gitweb:location}/share/gitweb/gitweb.cgi
[git-http-backend-cgi]
recipe = slapos.recipe.template
url = ${template-git-http-backend-cgi:location}/${template-git-http-backend-cgi:filename}
output = $${rootdirectory:bin}/git-http-backend.cgi
mode = 700
githttpbackend = ${git:location}/libexec/git-core/git-http-backend
base-directory = $${trac-config:project_dir}/git
[trac-admin]
recipe = slapos.cookbook:pwgen
file = $${buildout:directory}/.password
......@@ -304,8 +334,10 @@ mysql-password = $${mariadb-urlparse:password}
mysql-database = $${mariadb-urlparse:path}
mysql-host = $${stunnel:local-host}
mysql-port = $${stunnel:local-port}
#Svn Project list
#SVN - GIT Project list
svn-project-list = $${slap-parameter:svn-project-list}
git-project-list = $${slap-parameter:git-project-list}
git-binary = ${git:location}/bin/git
#configurations files
trac-ini = $${trac-config:output}
trac-wsgi = $${trac-wsgi:output}
......@@ -328,6 +360,14 @@ environment = PYTHONPATH=${subversion-1.9:location}/lib/svn-python:$${inittrac:p
wrapper-path = $${basedirectory:services}/httpd
wait-for-files = $${inittrac:file-status}
[gitdaemon]
recipe = slapos.cookbook:wrapper
ip = $${slap-network-information:global-ipv6}
port = 9418
command-line = ${git:location}/bin/git daemon --export-all --listen=$${:ip} --port=$${:port} --interpolated-path=$${inittrac:site-dir}/git/%D
wrapper-path = $${basedirectory:services}/git-daemon
wait-for-files = $${inittrac:file-status}
[logrotate-entry-apache]
<= logrotate
recipe = slapos.cookbook:logrotate.d
......@@ -368,7 +408,6 @@ key-file = $${directory:shellinabox}/private.key
[shell-wrapper]
recipe = slapos.cookbook:wrapper
command-line = ${buildout:bin-directory}/trac-admin $${inittrac:site-dir}
#${busybox:location}/bin/sh
environment = PYTHONPATH=${subversion-1.9:location}/lib/svn-python:$${inittrac:python_path}
ENV=$${inittrac:site-dir}
SNV_REPOS=$${inittrac:site-dir}/svn
......@@ -409,6 +448,8 @@ config-custom_domain = $${slap-parameter:domain}
recipe = slapos.cookbook:publish
backend_url = http://[$${httpd-conf:ip}]:$${httpd-conf:port}/
url = $${request-frontend:connection-site_url}
git = $${request-frontend:connection-site_url}/git
svn = $${request-frontend:connection-site_url}/svn
admin_user = $${trac-admin:user}
admin_password = $${trac-admin:password}
admin_shell = https://[$${shellinabox:ipv6}]:$${shellinabox:port}/
......@@ -444,7 +485,7 @@ project-name = project
project-desc = My example project
project-footer = Visit the Trac open source project at<br /><a href="http://trac.edgewall.org/">http://trac.edgewall.org/</a>
admin-email = you.admin@email.com
trac-user-list = {}
svn-project-list = {}
git-project-list = {}
trac-user-list = {"alain.takoudjou":"passwd"}
svn-project-list = {"bonjourgrid":"Sample SVN Project"}
git-project-list = {"boinc":"Sample Git repository"}
......@@ -19,6 +19,9 @@ parts =
trac-svn-hook
trac-git-hook
post-revprop-change
template-gitweb-cgi
template-gitweb-conf
template-git-http-backend-cgi
# trac-plugins-egg
# check-egg
slapos.cookbook-repository
......@@ -40,7 +43,7 @@ extends =
../../component/git/buildout.cfg
../../component/pwgen/buildout.cfg
../../component/shellinabox/buildout.cfg
../../component/busybox/buildout.cfg
../../component/perl/buildout.cfg
allow-hosts +=
*.edgewall.org
......@@ -62,6 +65,28 @@ eggs =
pytz
Trac
[instance]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg
mode = 0644
md5sum = bc6ed91a1862a10af661713aa0691848
[instance-trac]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-trac.cfg
output = ${buildout:directory}/template-trac.cfg
md5sum = 2ea122303cac6fa912ed65f7c77ebdab
mode = 0644
[instance-mariadb]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-mariadb.cfg
output = ${buildout:directory}/template-mariadb.cfg
md5sum = 4ea69039e41ff45bffe8f2620bdf187c
mode = 0644
[trac-plugins-egg]
recipe = plone.recipe.command
svn = ${subversion-1.9:location}/bin/svn
......@@ -69,83 +94,61 @@ location = ${buildout:parts-directory}/${:_buildout_section_name_}
multipleproject = ${:location}/SimpleMultiProject-0.0.3dev_r0-py2.7.egg
command = ${:svn} co http://trac-hacks.org/svn/simplemultiprojectplugin/trunk/ ${:multipleproject}
[tracIni]
[template-download]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/templates/${:filename}
mode = 0644
location = ${buildout:parts-directory}/${:_buildout_section_name_}
[tracIni]
<= template-download
filename = trac.ini.in
md5sum = 10286b368b9b6eacae2cdd6caf362759
location = ${buildout:parts-directory}/${:_buildout_section_name_}
[tracWsgi]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/templates/${:filename}
mode = 0644
<= template-download
filename = trac.wsgi.in
md5sum = 622ca33ed7299409afec43bb79e4c7e9
location = ${buildout:parts-directory}/${:_buildout_section_name_}
[trac-svn-hook]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/templates/${:filename}
mode = 0644
<= template-download
filename = trac-svn-hook.in
md5sum = 81a0e2627af1db4c1d601aabc0ebee0a
location = ${buildout:parts-directory}/${:_buildout_section_name_}
[trac-git-hook]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/templates/${:filename}
mode = 0644
<= template-download
filename = trac-git-hook.in
md5sum = 8704e9717bf1223157b3d25de5a8d9d6
location = ${buildout:parts-directory}/${:_buildout_section_name_}
[post-revprop-change]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/templates/${:filename}
mode = 0644
<= template-download
filename = post-revprop-change.in
md5sum = 917deaeda572ca3e98c2baaf15fcdacc
location = ${buildout:parts-directory}/${:_buildout_section_name_}
[instance]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
output = ${buildout:directory}/template.cfg
mode = 0644
md5sum = bc6ed91a1862a10af661713aa0691848
[instance-trac]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-trac.cfg
output = ${buildout:directory}/template-trac.cfg
md5sum = 7525cd9596527a22cf3447e38771a3c5
mode = 0644
[create-svn-repo]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/templates/${:filename}
mode = 0644
<= template-download
filename = create-svn-repo.sh.in
md5sum = 7ec8822bd5676c3506f079e33ed9f771
location = ${buildout:parts-directory}/${:_buildout_section_name_}
[instance-mariadb]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-mariadb.cfg
output = ${buildout:directory}/template-mariadb.cfg
md5sum = 4ea69039e41ff45bffe8f2620bdf187c
mode = 0644
[template-httpd-conf]
recipe = slapos.recipe.download
url = ${:_profile_base_location_}/templates/${:filename}
mode = 0644
<= template-download
filename = apache.in
md5sum = ca8099b21bc08bb66429440917f4f6b6
location = ${buildout:parts-directory}/${:_buildout_section_name_}
md5sum = be3418e3053ec7f74a3df21830a7edc0
[template-gitweb-cgi]
<= template-download
filename = gitweb.cgi.in
md5sum = 957a7741c7ab60c4bee6c640e0bdd2fb
[template-gitweb-conf]
<= template-download
filename = gitweb.conf.in
md5sum = ace5a69f59c0be7ea7454183a5550537
[template-git-http-backend-cgi]
<= template-download
filename = git-http-backend.cgi.in
md5sum = d6101df47ddd3b04e34e1f0284686b55
# Local development
[slapos.cookbook-repository]
......@@ -283,3 +286,89 @@ signature-certificate-list =
#Error: Couldn't install: lxml 3.1.2
lxml = 3.1.1
Genshi = 0.7
Jinja2 = 2.6
MySQL-python = 1.2.4
Pygments = 1.6
Trac = 1.0.1
Werkzeug = 0.8.3
apache-libcloud = 0.12.4
async = 0.6.1
buildout-versions = 1.7
collective.recipe.cmd = 0.6
docutils = 0.10
gitdb = 0.5.4
hexagonit.recipe.cmmi = 2.0
inotifyx = 0.2.0
meld3 = 0.6.10
netaddr = 0.7.10
plone.recipe.command = 1.1
pycrypto = 2.6
pytz = 2013b
slapos.recipe.download = 1.0.dev-r4053
slapos.recipe.template = 2.4.2
slapos.toolbox = 0.34.0
smmap = 0.8.2
z3c.recipe.scripts = 1.0.1
# Required by:
# slapos.core==0.35.1
# slapos.toolbox==0.34.0
Flask = 0.9
# Required by:
# slapos.toolbox==0.34.0
GitPython = 0.3.2.RC1
# Required by:
# slapos.toolbox==0.34.0
atomize = 0.1.1
# Required by:
# slapos.toolbox==0.34.0
feedparser = 5.1.3
# Required by:
# slapos.core==0.35.1
netifaces = 0.8
# Required by:
# slapos.toolbox==0.34.0
paramiko = 1.10.1
# Required by:
# slapos.toolbox==0.34.0
psutil = 0.7.0
# Required by:
# slapos.core==0.35.1
pyflakes = 0.7.1
# Required by:
# hexagonit.recipe.download==1.6nxd002
# slapos.cookbook==0.76.1.dev
# slapos.core==0.35.1
# supervisor==3.0b1
# zc.buildout==1.6.0-dev-SlapOS-010
# zope.interface==4.0.5
setuptools = 0.6c12dev-r88846
# Required by:
# slapos.toolbox==0.34.0
slapos.core = 0.35.1
# Required by:
# slapos.core==0.35.1
supervisor = 3.0b1
# Required by:
# slapos.core==0.35.1
unittest2 = 0.5.1
# Required by:
# slapos.toolbox==0.34.0
xml-marshaller = 0.9.7
# Required by:
# slapos.core==0.35.1
zope.interface = 4.0.5
......@@ -42,7 +42,7 @@ WSGIScriptAlias / ${:wsgi_location}/trac.wsgi
DAV svn
SVNParentPath ${:document_root}/svn/
AuthType Basic
AuthName "SVN Repository Admin"
AuthName "SVN Repository Access"
AuthUserFile ${:document_root}/.htpasswd
SVNAdvertiseV2Protocol Off
<LimitExcept GET PROPFIND OPTIONS REPORT>
......@@ -50,10 +50,62 @@ WSGIScriptAlias / ${:wsgi_location}/trac.wsgi
</LimitExcept>
</Location>
ScriptSock "${:cgid-sock}"
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER
Alias "/static/" "${:gitweb-static-dir}"
<Directory "${:gitweb-static-dir}">
Options FollowSymLinks
Require all granted
</Directory>
# This is Static Accelerated git pull
AliasMatch "^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$" "${:document_root}/git/$1"
AliasMatch "^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$" "${:document_root}/git/$1"
# When it can't be statically delivered, we rely on git-http-backend
ScriptAliasMatch \
"(?x)^/git/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
"/srv/slapgrid/slappart19/srv/runner/instance/slappart0/bin/git-http-backend.cgi/$1"
# Everything else is gitweb interface
ScriptAlias "/git" "${:gitweb-script}"
RewriteEngine On
RewriteCond %{QUERY_STRING} service=git-receive-pack
RewriteRule ^/git/.*/info/refs$ - [E=git_receive_pack:1]
<Location /git>
Order deny,allow
Deny from env=git_receive_pack
AuthType Basic
AuthName "Git Push Access"
AuthBasicProvider file
AuthUserFile ${:document_root}/.htpasswd
Require valid-user
Satisfy any
</Location>
<LocationMatch "^/git/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Push Access"
AuthBasicProvider file
AuthUserFile ${:document_root}/.htpasswd
Require valid-user
SetEnv REMOTE_USER $REDIRECT_REMOTE_USER
</LocationMatch>
# List of modules
LoadModule unixd_module modules/mod_unixd.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule setenvif_module modules/mod_setenvif.so
......@@ -61,6 +113,8 @@ LoadModule version_module modules/mod_version.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule mime_module modules/mod_mime.so
LoadModule cgid_module modules/mod_cgid.so
LoadModule env_module modules/mod_env.so
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule negotiation_module modules/mod_negotiation.so
......@@ -72,6 +126,8 @@ LoadModule wsgi_module modules/mod_wsgi.so
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
\ No newline at end of file
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
\ No newline at end of file
#!/bin/sh
## This is a very dirty hack
export PATH_INFO="$${REDIRECT_URL:-$PATH_INFO}"
GIT_PROJECT_ROOT='${:base-directory}' GIT_HTTP_EXPORT_ALL= exec '${:githttpbackend}' $@
#!/bin/sh
GITWEB_CONFIG='${gitweb-conf:output}' exec '${:perl}' '${:gitweb}' $@
\ No newline at end of file
$projectroot = '${:base-directory}';
$site_name = '${slap-parameter:project-name}';
our @git_base_url_list = qw(${:url-list});
# Beautiful URLs
$feature{'pathinfo'}{'default'} = [1];
$feature{'blame'}{'default'} = [1];
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment