mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Use custom templates for Git repositories
Do not waste disk space by copying dozens of unneeded sample hooks. Use a custom template directory that only includes the git-update hook. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
cb661cd971
commit
4dbd562b8e
5 changed files with 42 additions and 10 deletions
12
INSTALL
12
INSTALL
|
@ -19,7 +19,11 @@ Setup on Arch Linux
|
||||||
|
|
||||||
$ mysql -uaur -p AUR </srv/http/aur/schema/aur-schema.sql
|
$ mysql -uaur -p AUR </srv/http/aur/schema/aur-schema.sql
|
||||||
|
|
||||||
5) Clone the OpenSSH project, apply the AUR sshd patch and run `make`:
|
5) Generate templates for new Git repositories:
|
||||||
|
|
||||||
|
$ /srv/http/aur/scripts/git-integration/gen-templates.py
|
||||||
|
|
||||||
|
6) Clone the OpenSSH project, apply the AUR sshd patch and run `make`:
|
||||||
|
|
||||||
$ cd /srv/http/aur/
|
$ cd /srv/http/aur/
|
||||||
$ git clone git://anongit.mindrot.org/openssh.git
|
$ git clone git://anongit.mindrot.org/openssh.git
|
||||||
|
@ -30,7 +34,7 @@ Setup on Arch Linux
|
||||||
$ ./configure
|
$ ./configure
|
||||||
$ make
|
$ make
|
||||||
|
|
||||||
6) Create and edit the sshd configuration:
|
7) Create and edit the sshd configuration:
|
||||||
|
|
||||||
$ cd /srv/http/aur/
|
$ cd /srv/http/aur/
|
||||||
$ umask 077
|
$ umask 077
|
||||||
|
@ -38,12 +42,12 @@ Setup on Arch Linux
|
||||||
$ ssh-keygen -f .ssh/ssh_host_rsa_key -N '' -t rsa
|
$ ssh-keygen -f .ssh/ssh_host_rsa_key -N '' -t rsa
|
||||||
$ cp scripts/git-integration/sshd_config .ssh/
|
$ cp scripts/git-integration/sshd_config .ssh/
|
||||||
|
|
||||||
7) Create a new user and change ownership of the .ssh directory:
|
8) Create a new user and change ownership of the .ssh directory:
|
||||||
|
|
||||||
# useradd -U -d /srv/http/aur -c 'AUR user' aur
|
# useradd -U -d /srv/http/aur -c 'AUR user' aur
|
||||||
# chown aur:aur /srv/http/aur/.ssh/
|
# chown aur:aur /srv/http/aur/.ssh/
|
||||||
|
|
||||||
8) Add, enable and start systemd unit files for the new sshd:
|
9) Add, enable and start systemd unit files for the new sshd:
|
||||||
|
|
||||||
# cp /srv/http/aur/conf/aur-sshd.socket /etc/systemd/system/
|
# cp /srv/http/aur/conf/aur-sshd.socket /etc/systemd/system/
|
||||||
# cp /srv/http/aur/conf/aur-sshd@.service /etc/systemd/system/
|
# cp /srv/http/aur/conf/aur-sshd@.service /etc/systemd/system/
|
||||||
|
|
|
@ -35,6 +35,7 @@ ssh-options = no-port-forwarding,no-X11-forwarding,no-pty
|
||||||
[serve]
|
[serve]
|
||||||
repo-base = /srv/http/aur/repos/
|
repo-base = /srv/http/aur/repos/
|
||||||
repo-regex = [a-z0-9][a-z0-9.+_-]*$
|
repo-regex = [a-z0-9][a-z0-9.+_-]*$
|
||||||
|
template-path = /srv/http/aur/scripts/git-integration/templates/
|
||||||
git-update-hook = /srv/http/aur/scripts/git-integration/git-update.py
|
git-update-hook = /srv/http/aur/scripts/git-integration/git-update.py
|
||||||
git-shell-cmd = /usr/bin/git-shell
|
git-shell-cmd = /usr/bin/git-shell
|
||||||
ssh-cmdline = ssh -p 2222 aur@aur.archlinux.org
|
ssh-cmdline = ssh -p 2222 aur@aur.archlinux.org
|
||||||
|
|
29
scripts/git-integration/gen-templates.py
Executable file
29
scripts/git-integration/gen-templates.py
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import configparser
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
|
||||||
|
config = configparser.RawConfigParser()
|
||||||
|
config.read(os.path.dirname(os.path.realpath(__file__)) + "/../../conf/config")
|
||||||
|
|
||||||
|
template_path = config.get('serve', 'template-path')
|
||||||
|
git_update_hook = config.get('serve', 'git-update-hook')
|
||||||
|
|
||||||
|
def die(msg):
|
||||||
|
sys.stderr.write("%s\n" % (msg))
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if os.path.exists(template_path):
|
||||||
|
shutil.rmtree(template_path)
|
||||||
|
|
||||||
|
os.mkdir(template_path)
|
||||||
|
os.chdir(template_path)
|
||||||
|
os.mkdir("branches")
|
||||||
|
os.mkdir("hooks")
|
||||||
|
os.mkdir("info")
|
||||||
|
os.symlink(git_update_hook, template_path + 'hooks/update')
|
||||||
|
|
||||||
|
with open("description", 'w') as f:
|
||||||
|
f.write("Unnamed repository; push to update the description.\n")
|
|
@ -19,9 +19,9 @@ aur_db_socket = config.get('database', 'socket')
|
||||||
|
|
||||||
repo_base_path = config.get('serve', 'repo-base')
|
repo_base_path = config.get('serve', 'repo-base')
|
||||||
repo_regex = config.get('serve', 'repo-regex')
|
repo_regex = config.get('serve', 'repo-regex')
|
||||||
git_update_hook = config.get('serve', 'git-update-hook')
|
|
||||||
git_shell_cmd = config.get('serve', 'git-shell-cmd')
|
git_shell_cmd = config.get('serve', 'git-shell-cmd')
|
||||||
ssh_cmdline = config.get('serve', 'ssh-cmdline')
|
ssh_cmdline = config.get('serve', 'ssh-cmdline')
|
||||||
|
template_path = config.get('serve', 'template-path')
|
||||||
|
|
||||||
def repo_path_validate(path):
|
def repo_path_validate(path):
|
||||||
if not path.startswith(repo_base_path):
|
if not path.startswith(repo_base_path):
|
||||||
|
@ -87,8 +87,7 @@ def setup_repo(repo, user):
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
repo_path = repo_base_path + '/' + repo + '.git/'
|
repo_path = repo_base_path + '/' + repo + '.git/'
|
||||||
pygit2.init_repository(repo_path, True)
|
pygit2.init_repository(repo_path, True, 48, template_path=template_path)
|
||||||
os.symlink(git_update_hook, repo_path + 'hooks/update')
|
|
||||||
|
|
||||||
def check_permissions(pkgbase, user):
|
def check_permissions(pkgbase, user):
|
||||||
db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
|
db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
|
||||||
|
|
|
@ -19,7 +19,7 @@ aur_db_socket = config.get('database', 'socket')
|
||||||
|
|
||||||
repo_base_path = config.get('serve', 'repo-base')
|
repo_base_path = config.get('serve', 'repo-base')
|
||||||
repo_regex = config.get('serve', 'repo-regex')
|
repo_regex = config.get('serve', 'repo-regex')
|
||||||
git_update_hook = config.get('serve', 'git-update-hook')
|
template_path = config.get('serve', 'template-path')
|
||||||
|
|
||||||
def die(msg):
|
def die(msg):
|
||||||
sys.stderr.write("%s\n" % (msg))
|
sys.stderr.write("%s\n" % (msg))
|
||||||
|
@ -45,7 +45,6 @@ for repo in repos:
|
||||||
print("[%s/%d] %s" % (str(i).rjust(len(str(n))), n, repo))
|
print("[%s/%d] %s" % (str(i).rjust(len(str(n))), n, repo))
|
||||||
|
|
||||||
repo_path = repo_base_path + '/' + repo + '.git/'
|
repo_path = repo_base_path + '/' + repo + '.git/'
|
||||||
pygit2.init_repository(repo_path, True)
|
pygit2.init_repository(repo_path, True, 48, template_path=template_path)
|
||||||
os.symlink(git_update_hook, repo_path + 'hooks/update')
|
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue