Browse Source

cgit: changed to build as fastcgi if fcgi is present

cross
Alejandro Mery 16 years ago
parent
commit
5db28ef397
  1. 9
      develop/cgit/cgit.conf
  2. 159
      develop/cgit/fastcgi.diff

9
develop/cgit/cgit.conf

@ -2,7 +2,7 @@
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../cgit/cgit.conf
# Copyright (C) 2008 The OpenSDE Project
# Copyright (C) 2008 - 2009 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
@ -14,7 +14,7 @@
makeinstopt=
hook_add premake 5 'cgit_extract_git'
hook_add prepatch 5 'cgit_extract_git'
hook_add postmake 5 'cgit_install'
#FIXME: try to use the installed git if possible
@ -39,3 +39,8 @@ cgit_install()
cp -a cgit $root$sbindir
cp -a cgitrc.5.txt README cgit.{css,png,cgi} $root$docdir
}
if pkginstalled fcgi; then
echo_status "Enabling fastcgi mode"
var_append patchfiles ' ' "$confdir/fastcgi.diff"
fi

159
develop/cgit/fastcgi.diff

@ -0,0 +1,159 @@
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../cgit/fastcgi.diff
# Copyright (C) 2009 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---
stolen from http://www.docunext.com/wiki/Cgit
--- ./git/wrapper.c.orig 2009-03-05 22:58:00.000000000 +0200
+++ ./git/wrapper.c 2009-03-05 22:59:49.000000000 +0200
@@ -133,6 +133,11 @@
}
}
+ssize_t ywrite(int fd, const void *buf, size_t len)
+{
+ return printf("%.*s",len,buf);
+}
+
ssize_t read_in_full(int fd, void *buf, size_t count)
{
char *p = buf;
--- ./git/git-compat-util.h.orig 2009-03-05 22:57:28.000000000 +0200
+++ ./git/git-compat-util.h 2009-03-05 22:57:51.000000000 +0200
@@ -48,7 +48,7 @@
#define _BSD_SOURCE 1
#include <unistd.h>
-#include <stdio.h>
+#include <fcgi_stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stddef.h>
--- ./Makefile.orig 2009-03-05 22:36:24.000000000 +0200
+++ ./Makefile 2009-03-05 22:36:39.000000000 +0200
@@ -68,7 +68,7 @@
$(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
-EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto
+EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lcrypto -lfcgi
OBJECTS =
OBJECTS += cache.o
OBJECTS += cgit.o
--- ./cache.c.orig 2009-03-05 22:36:46.000000000 +0200
+++ ./cache.c 2009-03-05 22:42:26.000000000 +0200
@@ -19,7 +19,7 @@
#define CACHE_BUFSIZE (1024 * 4)
struct cache_slot {
- const char *key;
+ char *key;
int keylen;
int ttl;
cache_fill_fn fn;
@@ -90,7 +90,7 @@
do {
i = j = xread(slot->cache_fd, slot->buf, sizeof(slot->buf));
if (i > 0)
- j = xwrite(STDOUT_FILENO, slot->buf, i);
+ j = ywrite(STDOUT_FILENO, slot->buf, i);
} while (i > 0 && j == i);
if (i < 0 || j != i)
@@ -308,7 +308,7 @@
}
/* Print cached content to stdout, generate the content if necessary. */
-int cache_process(int size, const char *path, const char *key, int ttl,
+int cache_process(int size, char *path, const char *key, int ttl,
cache_fill_fn fn, void *cbdata)
{
unsigned long hash;
--- ./cache.h.orig 2009-03-05 22:44:25.000000000 +0200
+++ ./cache.h 2009-03-05 22:45:26.000000000 +0200
@@ -22,7 +22,7 @@
* Return value
* 0 indicates success, everyting else is an error
*/
-extern int cache_process(int size, const char *path, const char *key, int ttl,
+extern int cache_process(int size, char *path, const char *key, int ttl,
cache_fill_fn fn, void *cbdata);
--- ./cgit.c.orig 2009-03-05 22:49:34.000000000 +0200
+++ ./cgit.c 2009-03-05 22:53:58.000000000 +0200
@@ -6,6 +6,7 @@
* (see COPYING for full license text)
*/
+#include <fcgi_stdio.h>
#include "cgit.h"
#include "cache.h"
#include "cmd.h"
@@ -426,13 +427,15 @@
return ctx.cfg.cache_repo_ttl;
}
-int main(int argc, const char **argv)
+int main(int argc, char **argv)
{
- const char *cgit_config_env = getenv("CGIT_CONFIG");
- const char *path;
+ char *path;
char *qry;
- int err, ttl;
+ while (FCGI_Accept() >= 0) {
+ const char *cgit_config_env = getenv("CGIT_CONFIG");
+ int err, ttl;
+
prepare_context(&ctx);
cgit_repolist.length = 0;
cgit_repolist.count = 0;
@@ -460,7 +463,6 @@
* long as PATH_INFO is included in the cache lookup key).
*/
path = getenv("PATH_INFO");
- if (!ctx.qry.url && path) {
if (path[0] == '/')
path++;
ctx.qry.url = xstrdup(path);
@@ -471,7 +473,6 @@
} else
ctx.qry.raw = ctx.qry.url;
cgit_parse_url(ctx.qry.url);
- }
ttl = calc_ttl();
ctx.page.expires += ttl*60;
@@ -482,5 +483,6 @@
if (err)
cgit_print_error(fmt("Error processing page: %s (%d)",
strerror(err), err));
- return err;
+ }
+ return 0;
}
--- ./html.c.orig 2009-03-05 22:54:24.000000000 +0200
+++ ./html.c 2009-03-05 22:54:37.000000000 +0200
@@ -7,7 +7,7 @@
*/
#include <unistd.h>
-#include <stdio.h>
+#include <fcgi_stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
Loading…
Cancel
Save