aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--www-apps/cgit/Manifest3
-rw-r--r--www-apps/cgit/cgit-1.2.3-r4.ebuild (renamed from www-apps/cgit/cgit-1.2.3-r3.ebuild)8
-rw-r--r--www-apps/cgit/files/cgit-1.2.3-git-http-backend.patch221
3 files changed, 230 insertions, 2 deletions
diff --git a/www-apps/cgit/Manifest b/www-apps/cgit/Manifest
index 13041dd..d602954 100644
--- a/www-apps/cgit/Manifest
+++ b/www-apps/cgit/Manifest
@@ -1,4 +1,5 @@
+AUX cgit-1.2.3-git-http-backend.patch 6644 BLAKE2B d82af5f99768494d33b938a3f77d74d3cbf794fc25b1b8c87c9df408e163f8df2707e4eee26523ed3177f8e0e2998f689922750ce2a051654db8ade220b85df4 SHA512 13f0218dca8d9c83f17b20f0844397006667e8339bce07ab7c8f65ad738d6ddda3240d3fd1f3d11bf29e137b4c278c0f750c0a7a1d44c967cf96807631d8bd54
DIST cgit-1.2.3.tar.xz 90632 BLAKE2B 594a9b2ae0b449e0ef090f428f955cc02833f5f5b1e4d6dc8c737daa565d01ba6840933c0bdc53d4eb683b2f44e2fae885ddd020cfb2de38141a870a6eae2380 SHA512 58f9bb644b07be49dc51f3ef30a3d0e53699cede3c06b1d6920f3874fe846c83dd2589632aa84357b70ea2d60272448409aa1b892f405d14dd6745f5559b4504
DIST git-2.25.1.tar.xz 5875548 BLAKE2B 582da3d4ac996d7b9ce6cf505661496ab1a2cd061f058745350498121956b33d79739b567fb5fea0b4e298303261256034aa0b8da0b842feab04ae67a7d5b142 SHA512 15241143acfd8542d85d2709ac3c80dbd6e8d5234438f70c4f33cc71a2bdec3e32938df7f6351e2746d570b021d3bd0b70474ea4beec0c51d1fc45f9c287b344
-EBUILD cgit-1.2.3-r3.ebuild 2293 BLAKE2B 970081aaaaac0b95aba7315e16903aa90db4692fb96cf8773dff51046fdf704bf3b860a7d7bd9120101d0d3941c003f755bdb042c4dd301f80f74348f5d45e38 SHA512 843483acb27f3f166f88d0e612ff2a8ccffd3f69dd878e957d9b0915c1202da75ff9ab82343e0238d9e80b72366fc605eda74b2630e8275b691bdc7c5e1328c1
+EBUILD cgit-1.2.3-r4.ebuild 2393 BLAKE2B 5b3f54b347ea51c6ee9682a7099058d12a6757762b24f4e463b5b3ddd7f1a359fed51a018044d84020235e2c5601a68215657677f5066136ee3a2c0fbd4100c0 SHA512 4d67e9db74b9d792ae9821eb2de81f2d5b5c9d6a93017899ffe0adda5da7ead4c383d2319ed657eb96f7368ced06eea75dba11196be1111cf4223147985f95d1
MISC metadata.xml 1029 BLAKE2B e46976de1886fef155a1488142b4b3733c1e682a8851b4b36449e95759a050722d3147221f3cc587a984e28c2b167dacf3e29a4cc208f30bd52e0216806d2327 SHA512 bcd83dfd7789597db8ef429aebe5c34138aba888706bce5972208e6cb8e991a820691cef5268fcebf9e30ec5bf9d4ccc65d36790372282f96c09243137856fdd
diff --git a/www-apps/cgit/cgit-1.2.3-r3.ebuild b/www-apps/cgit/cgit-1.2.3-r4.ebuild
index 2b57dcb..58030e6 100644
--- a/www-apps/cgit/cgit-1.2.3-r3.ebuild
+++ b/www-apps/cgit/cgit-1.2.3-r4.ebuild
@@ -15,7 +15,7 @@ SRC_URI="https://www.kernel.org/pub/software/scm/git/git-${GIT_V}.tar.xz
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 x86"
-IUSE="doc highlight lua luajit lzip markdown static zip zstd"
+IUSE="doc highlight lua luajit lzip markdown static +vanilla zip zstd"
LUA_DEPEND="
lua? (
@@ -51,6 +51,12 @@ REQUIRED_USE="
"
src_prepare() {
+ if ! use vanilla; then
+ PATCHES+=(
+ "${FILESDIR}/${P}-git-http-backend.patch"
+ )
+ fi
+
default
rmdir git || die
diff --git a/www-apps/cgit/files/cgit-1.2.3-git-http-backend.patch b/www-apps/cgit/files/cgit-1.2.3-git-http-backend.patch
new file mode 100644
index 0000000..4331629
--- /dev/null
+++ b/www-apps/cgit/files/cgit-1.2.3-git-http-backend.patch
@@ -0,0 +1,221 @@
+From d90a0186d519bae5dddb25830eb07b6d8d2287ec Mon Sep 17 00:00:00 2001
+From: Wynn Wolf Arbor <wolf@oriole.systems>
+Date: Sat, 30 May 2020 21:51:39 +0200
+Subject: [PATCH] Support Git over HTTP by proxying git-http-backend(1)
+
+cgit lacks an easy way to support the "smart" HTTP protocol out of the
+box. A patch [1] has been proposed in the past, but was never merged.
+A few years later there was a short discussion at [2] which did not go
+anywhere.
+
+The majority of users who want to support the "smart" HTTP protocol
+right now seem to conditionally point their web server to
+git-http-backend(1) directly. This relies on proper path-matching and
+regular expression support in the web server as seen in the EXMAPLES
+section of git-http-backend(1).
+
+As proposed in [3], it is possible to have cgit interface with the
+necessary functionality in Git directly, but that would require more
+work. It does not seem that this is something forthcoming in cgit.
+
+Instead, for now, use a modified version of the patch suggested in [1],
+which simply executes git-http-backend(1) when needed. This removes the
+need for any additional plumbing in the web server.
+
+Notable changes to the original patch:
+
+ * Remove automatic handling of GIT_PROJECT_ROOT in favour of having the
+ user set the variable correctly themselves. This reduces complexity.
+
+ * Use the correct function to generate error pages. The original patch
+ used html_status(), which does not exist anymore.
+
+ * In cmd.c, adjust the struct entries to fit. Sadly we cannot use the
+ def_cmd() macro directly, as the endpoints "git-upload-pack" and
+ "git-receive-pack" contain dashes.
+
+[1] https://lists.zx2c4.com/pipermail/cgit/2014-December/002312.html
+[2] https://lists.zx2c4.com/pipermail/cgit/2016-February/002907.html
+[3] https://lists.zx2c4.com/pipermail/cgit/2016-February/002926.html
+---
+ cgit.c | 3 +++
+ cgit.h | 1 +
+ cgitrc.5.txt | 8 ++++++++
+ cmd.c | 13 +++++++++++++
+ ui-clone.c | 42 ++++++++++++++++++++++++++++++++++++++++++
+ ui-clone.h | 2 ++
+ 6 files changed, 69 insertions(+)
+
+diff --git a/cgit.c b/cgit.c
+index c4320f0..fc85c18 100644
+--- a/cgit.c
++++ b/cgit.c
+@@ -151,6 +151,8 @@ static void config_cb(const char *name, const char *value)
+ ctx.cfg.head_include = xstrdup(value);
+ else if (!strcmp(name, "header"))
+ ctx.cfg.header = xstrdup(value);
++ else if (!strcmp(name, "http-backend-path"))
++ ctx.cfg.http_backend_path = xstrdup(value);
+ else if (!strcmp(name, "logo"))
+ ctx.cfg.logo = xstrdup(value);
+ else if (!strcmp(name, "logo-link"))
+@@ -379,6 +381,7 @@ static void prepare_context(void)
+ ctx.cfg.css = "/cgit.css";
+ ctx.cfg.logo = "/cgit.png";
+ ctx.cfg.favicon = "/favicon.ico";
++ ctx.cfg.http_backend_path = NULL;
+ ctx.cfg.local_time = 0;
+ ctx.cfg.enable_http_clone = 1;
+ ctx.cfg.enable_index_owner = 1;
+diff --git a/cgit.h b/cgit.h
+index 7ec46b4..cd29892 100644
+--- a/cgit.h
++++ b/cgit.h
+@@ -200,6 +200,7 @@ struct cgit_config {
+ char *footer;
+ char *head_include;
+ char *header;
++ char *http_backend_path;
+ char *logo;
+ char *logo_link;
+ char *mimetype_file;
+diff --git a/cgitrc.5.txt b/cgitrc.5.txt
+index 33a6a8c..820cfa6 100644
+--- a/cgitrc.5.txt
++++ b/cgitrc.5.txt
+@@ -234,6 +234,11 @@ header::
+ The content of the file specified with this option will be included
+ verbatim at the top of all pages. Default value: none.
+
++http-backend-path::
++ Path to the git-http-backend binary. Setting this allows the git clone to
++ fetch/push via Git over HTTP. You'll also need to set enable-http-clone
++ for this to work. See git-http-backend(1). Default value: none.
++
+ include::
+ Name of a configfile to include before the rest of the current config-
+ file is parsed. Default value: none. See also: "MACRO EXPANSION".
+@@ -824,6 +829,9 @@ enable-index-owner=1
+ # Allow http transport git clone
+ enable-http-clone=1
+
++# Use git-http-backend to serve Git over HTTP
++http-backend-path=/usr/lib/git-core/git-http-backend
++
+
+ # Show extra links for each repository on the index page
+ enable-index-links=1
+diff --git a/cmd.c b/cmd.c
+index bf6d8f5..7f1ca98 100644
+--- a/cmd.c
++++ b/cmd.c
+@@ -164,6 +164,17 @@ static void tree_fn(void)
+ cgit_print_tree(ctx.qry.sha1, ctx.qry.path);
+ }
+
++static void git_upload_pack_fn(void)
++{
++ cgit_clone_git_upload_pack();
++}
++
++static void git_receive_pack_fn(void)
++{
++ cgit_clone_git_receive_pack();
++}
++
++
+ #define def_cmd(name, want_repo, want_vpath, is_clone) \
+ {#name, name##_fn, want_repo, want_vpath, is_clone}
+
+@@ -191,6 +202,8 @@ struct cgit_cmd *cgit_get_cmd(void)
+ def_cmd(summary, 1, 0, 0),
+ def_cmd(tag, 1, 0, 0),
+ def_cmd(tree, 1, 1, 0),
++ {"git-upload-pack", git_upload_pack_fn, 1, 0, 1},
++ {"git-receive-pack", git_receive_pack_fn, 1, 0, 1},
+ };
+ int i;
+
+diff --git a/ui-clone.c b/ui-clone.c
+index 5dccb63..5dea33c 100644
+--- a/ui-clone.c
++++ b/ui-clone.c
+@@ -77,8 +77,24 @@ static void send_file(const char *path)
+ html_include(path);
+ }
+
++static void dispatch_to_git_http_backend(void)
++{
++ if (access(ctx.cfg.http_backend_path, X_OK) == -1) {
++ fprintf(stderr, "[cgit] http-backend-path (%s) is not executable: %s\n",
++ ctx.cfg.http_backend_path, strerror(errno));
++ cgit_print_error_page(500, "Internal Server Error", "Internal Server Error");
++ return;
++ }
++
++ execl(ctx.cfg.http_backend_path, "git-http-backend", NULL);
++}
++
+ void cgit_clone_info(void)
+ {
++ if (ctx.cfg.http_backend_path) {
++ return dispatch_to_git_http_backend();
++ }
++
+ if (!ctx.qry.path || strcmp(ctx.qry.path, "refs")) {
+ cgit_print_error_page(400, "Bad request", "Bad request");
+ return;
+@@ -94,6 +110,10 @@ void cgit_clone_objects(void)
+ {
+ char *p;
+
++ if (ctx.cfg.http_backend_path) {
++ return dispatch_to_git_http_backend();
++ }
++
+ if (!ctx.qry.path)
+ goto err;
+
+@@ -122,5 +142,27 @@ err:
+
+ void cgit_clone_head(void)
+ {
++ if (ctx.cfg.http_backend_path) {
++ return dispatch_to_git_http_backend();
++ }
++
+ send_file(git_path("%s", "HEAD"));
+ }
++
++void cgit_clone_git_upload_pack(void)
++{
++ if (ctx.cfg.http_backend_path) {
++ return dispatch_to_git_http_backend();
++ }
++
++ cgit_print_error_page(404, "Not found", "Not found");
++}
++
++void cgit_clone_git_receive_pack(void)
++{
++ if (ctx.cfg.http_backend_path) {
++ return dispatch_to_git_http_backend();
++ }
++
++ cgit_print_error_page(404, "Not found", "Not found");
++}
+diff --git a/ui-clone.h b/ui-clone.h
+index 3e460a3..b27087e 100644
+--- a/ui-clone.h
++++ b/ui-clone.h
+@@ -4,5 +4,7 @@
+ void cgit_clone_info(void);
+ void cgit_clone_objects(void);
+ void cgit_clone_head(void);
++void cgit_clone_git_upload_pack(void);
++void cgit_clone_git_receive_pack(void);
+
+ #endif /* UI_CLONE_H */
+--
+2.27.0
+