[aur-dev] [PATCH] Reorganize Git interface scripts

Lukas Fleischer lfleischer at archlinux.org
Sat Oct 8 12:28:05 UTC 2016


Move the Git interface scripts from git-interface/ to aurweb/git/. Use
setuptools to automatically create wrappers which can be installed using
`python3 setup.py install`. Update the configuration files, the test
suite as well as the INSTALL and README files to reflect these changes.

Signed-off-by: Lukas Fleischer <lfleischer at archlinux.org>
---
 INSTALL                                            | 28 ++++++++++------------
 README                                             |  5 +---
 git-interface/git-auth.py => aurweb/git/auth.py    |  0
 git-interface/git-serve.py => aurweb/git/serve.py  |  0
 .../git-update.py => aurweb/git/update.py          |  0
 conf/config.proto                                  |  4 ++--
 git-interface/Makefile                             | 18 --------------
 git-interface/__init__.py                          |  0
 git-interface/config.mk                            |  1 -
 git-interface/git-auth.sh.in                       |  3 ---
 setup.py                                           |  7 ++++++
 test/setup.sh                                      |  8 +++----
 12 files changed, 26 insertions(+), 48 deletions(-)
 rename git-interface/git-auth.py => aurweb/git/auth.py (100%)
 rename git-interface/git-serve.py => aurweb/git/serve.py (100%)
 rename git-interface/git-update.py => aurweb/git/update.py (100%)
 delete mode 100644 git-interface/Makefile
 delete mode 100644 git-interface/__init__.py
 delete mode 100644 git-interface/config.mk
 delete mode 100644 git-interface/git-auth.sh.in

diff --git a/INSTALL b/INSTALL
index dab48cc..395915a 100644
--- a/INSTALL
+++ b/INSTALL
@@ -37,11 +37,16 @@ Setup on Arch Linux
 
     $ mysql -uaur -p AUR </srv/http/aurweb/schema/aur-schema.sql
 
-5) Create a new user:
+5) Install Python modules and dependencies:
+
+    # pacman -S python-mysql-connector python-pygit2 python-srcinfo
+    # python3 setup.py install
+
+6) Create a new user:
 
     # useradd -U -d /srv/http/aurweb -c 'AUR user' aur
 
-6) Initialize the Git repository:
+7) Initialize the Git repository:
 
     # mkdir /srv/http/aurweb/aur.git/
     # cd /srv/http/aurweb/aur.git/
@@ -49,29 +54,20 @@ Setup on Arch Linux
     # git config --local transfer.hideRefs '^refs/'
     # git config --local --add transfer.hideRefs '!refs/'
     # git config --local --add transfer.hideRefs '!HEAD'
-    # ln -s ../../git-interface/git-update.py hooks/update
+    # ln -s /usr/local/bin/aurweb-git-update hooks/update
     # chown -R aur .
 
-7) Install needed Python modules:
-
-    # pacman -S python-mysql-connector python-pygit2 python-srcinfo
-
-8) Install the git-auth wrapper script:
-
-    # cd /srv/http/aurweb/git-interface/
-    # make && make install
-
-9) Configure sshd(8) for the AUR. Add the following lines at the end of your
+8) Configure sshd(8) for the AUR. Add the following lines at the end of your
    sshd_config(5) and restart the sshd. Note that OpenSSH 6.9 or newer is
    needed!
 
     Match User aur
         PasswordAuthentication no
-        AuthorizedKeysCommand /usr/local/bin/aur-git-auth "%t" "%k"
+        AuthorizedKeysCommand /usr/local/bin/aurweb-git-auth "%t" "%k"
         AuthorizedKeysCommandUser aur
 
-10) If you want to enable smart HTTP support with nginx and fcgiwrap, you can
-    use the following directives:
+9) If you want to enable smart HTTP support with nginx and fcgiwrap, you can
+   use the following directives:
 
     location ~ "^/([a-z0-9][a-z0-9.+_-]*?)(\.git)?/(git-(receive|upload)-pack|HEAD|info/refs|objects/(info/(http-)?alternates|packs)|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx))$" {
         fastcgi_pass   unix:/run/fcgiwrap.sock;
diff --git a/README b/README
index c110ef8..e633ec3 100644
--- a/README
+++ b/README
@@ -18,7 +18,7 @@ Directory Layout
 ----------------
 
 aurweb::
-	Shared aurweb Python modules.
+	aurweb Python modules.
 
 conf::
 	Configuration and configuration templates.
@@ -26,9 +26,6 @@ conf::
 doc::
 	Project documentation.
 
-git-interface::
-	Scripts that make up the Git and SSH interface.
-
 po::
 	Translation files for strings in the aurweb interface.
 
diff --git a/git-interface/git-auth.py b/aurweb/git/auth.py
similarity index 100%
rename from git-interface/git-auth.py
rename to aurweb/git/auth.py
diff --git a/git-interface/git-serve.py b/aurweb/git/serve.py
similarity index 100%
rename from git-interface/git-serve.py
rename to aurweb/git/serve.py
diff --git a/git-interface/git-update.py b/aurweb/git/update.py
similarity index 100%
rename from git-interface/git-update.py
rename to aurweb/git/update.py
diff --git a/conf/config.proto b/conf/config.proto
index 21441a9..96fad80 100644
--- a/conf/config.proto
+++ b/conf/config.proto
@@ -46,14 +46,14 @@ RSA = SHA256:Ju+yWiMb/2O+gKQ9RJCDqvRg7l+Q95KFAeqM5sr6l2s
 [auth]
 valid-keytypes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519
 username-regex = [a-zA-Z0-9]+[.\-_]?[a-zA-Z0-9]+$
-git-serve-cmd = /srv/http/aurweb/git-interface/git-serve.py
+git-serve-cmd = /usr/local/bin/aurweb-git-serve
 ssh-options = restrict
 
 [serve]
 repo-path = /srv/http/aurweb/aur.git/
 repo-regex = [a-z0-9][a-z0-9.+_-]*$
 git-shell-cmd = /usr/bin/git-shell
-git-update-cmd = /srv/http/aurweb/git-interface/git-update.py
+git-update-cmd = /usr/local/bin/aurweb-git-update
 ssh-cmdline = ssh aur at aur.archlinux.org
 
 [update]
diff --git a/git-interface/Makefile b/git-interface/Makefile
deleted file mode 100644
index 8865790..0000000
--- a/git-interface/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-GIT_INTERFACE_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
-
-include config.mk
-
-git-auth.sh:
-	sed 's#%GIT_INTERFACE_DIR%#$(GIT_INTERFACE_DIR)#' <git-auth.sh.in >git-auth.sh
-	chmod +x git-auth.sh
-
-install: git-auth.sh
-	install -Dm0755 git-auth.sh "$(DESTDIR)$(PREFIX)/bin/aur-git-auth"
-
-uninstall:
-	rm -f "$(DESTDIR)$(PREFIX)/bin/aur-git-auth"
-
-clean:
-	rm -f git-auth.sh
-
-.PHONY: install uninstall clean
diff --git a/git-interface/__init__.py b/git-interface/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/git-interface/config.mk b/git-interface/config.mk
deleted file mode 100644
index 4d794a1..0000000
--- a/git-interface/config.mk
+++ /dev/null
@@ -1 +0,0 @@
-PREFIX = /usr/local
diff --git a/git-interface/git-auth.sh.in b/git-interface/git-auth.sh.in
deleted file mode 100644
index 223816a..0000000
--- a/git-interface/git-auth.sh.in
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-%GIT_INTERFACE_DIR%/git-auth.py "$1" "$2"
diff --git a/setup.py b/setup.py
index 48eb176..b64e71c 100644
--- a/setup.py
+++ b/setup.py
@@ -17,4 +17,11 @@ setup(
     name="aurweb",
     version=version,
     packages=find_packages(),
+    entry_points={
+        'console_scripts': [
+            'aurweb-git-auth = aurweb.git.auth:main',
+            'aurweb-git-serve = aurweb.git.serve:main',
+            'aurweb-git-update = aurweb.git.update:main',
+        ],
+    },
 )
diff --git a/test/setup.sh b/test/setup.sh
index dc9cff2..d02d298 100644
--- a/test/setup.sh
+++ b/test/setup.sh
@@ -8,9 +8,9 @@ PYTHONPATH="$TOPLEVEL"
 export PYTHONPATH
 
 # Configure paths to the Git interface scripts.
-GIT_AUTH="$TOPLEVEL/git-interface/git-auth.py"
-GIT_SERVE="$TOPLEVEL/git-interface/git-serve.py"
-GIT_UPDATE="$TOPLEVEL/git-interface/git-update.py"
+GIT_AUTH="$TOPLEVEL/aurweb/git/auth.py"
+GIT_SERVE="$TOPLEVEL/aurweb/git/serve.py"
+GIT_UPDATE="$TOPLEVEL/aurweb/git/update.py"
 MKPKGLISTS="$TOPLEVEL/scripts/mkpkglists.py"
 TUVOTEREMINDER="$TOPLEVEL/scripts/tuvotereminder.py"
 PKGMAINT="$TOPLEVEL/scripts/pkgmaint.py"
@@ -38,7 +38,7 @@ reply-to = noreply at aur.archlinux.org
 [auth]
 valid-keytypes = ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521 ssh-ed25519
 username-regex = [a-zA-Z0-9]+[.\-_]?[a-zA-Z0-9]+$
-git-serve-cmd = /srv/http/aurweb/git-interface/git-serve.py
+git-serve-cmd = $GIT_SERVE
 ssh-options = restrict
 
 [serve]
-- 
2.10.0


More information about the aur-dev mailing list