Modern Web-UI for SVN repositories 0

AliExpress RU&CIS

cSvn — is a web interface for Subversion repositories. cSvn is based on CGI script written in С.

This article covers installing and configuring cSvn to work using Nginx + uWsgi. Setting up server components is quite simple and practically does not differ from setting up cGit.

cSvn supports Markdown files that are processed on the server side using the md4c library, which has proven itself in the KDE Plasma project. cSvn provides the ability to add site verification codes and scripts from systems such as Google Analytics and Yandex.Metrika for trafic analysis. Users who wonder to receive donations for his projects can create and import custom donation modal dialogs.

Instead of looking at screenshots, it is better to look at the working site to decide on installing cSvn on your own server.

It should be noted that you can browse not only your own repositories, but also configure viewing of third-party resources via HTTPS and SVN protocols.

Reqired packages

cSvn depends of following libraries: libpcre2, libmd4c, libmd4c-html, libmagic, and libxml2.

To use cSvn a web server must be installed and configured on the system. We recommend the Nginx with uWsgi application server. Of course Apache Subversion SCM system should be installed too.


The cSvn package consists of two parts. First of which is a regular Linux daemon that is responsible for parsing the configuration file, and the second is a CGI script that responds to HTTP requests. Both parts of the package are installed simultaneously but are maintained independently of each other.

Download Sources

To obtain sources we have to checkout its from SVN repository:

svn checkout svn checkout svn:// csvn-0.1.2

and run the bootstrap script:

cd csvn-0.1.2

Also cSvn source packages are available for download on the FTP-server.

Bootstrap Script

The bootstrap script especialy created for Autotools install automation. To install Autotools into source directory on build machine (i.e. when build == host) the bootstrap script can be run without arguments.


In this case Autotools will be installed from current root file system.

For the cross environment the --target-dest-dir option allows to install some stuff from development root file system:

TARGET_DEST_DIR=/home/developer/prog/trunk-672/dist/.s9xx-glibc/enybox-x2     ./bootstrap --target-dest-dir=${TARGET_DEST_DIR}

For example, in this case the aclocal.m4 script will be collected from the
${TARGET_DEST_DIR}/usr/share/aclocal directory.

Configuring Sources

./configure --prefix=/usr             --sysconfdir=/etc             --with-config=/etc/csvnrc             --with-controldir=/etc/rc.d             --with-logrotatedir=/etc/logrotate.d             --with-scriptdir=/var/www/htdocs/csvn             --with-homedir=/var/lib/csvn             --with-logdir=/var/log             --with-piddir=/var/run

Install on the Build Machine

make install

Cross Compilation Example



./bootstrap --target-dest-dir=${TARGET_DEST_DIR}

PKG_CONFIG=/usr/bin/pkg-config PKG_CONFIG_PATH=${TARGET_DEST_DIR}/usr/lib${LIBDIRSUFFIX}/pkgconfig:${TARGET_DEST_DIR}/usr/share/pkgconfig PKG_CONFIG_LIBDIR=${TARGET_DEST_DIR}/usr/lib${LIBDIRSUFFIX}/pkgconfig:${TARGET_DEST_DIR}/usr/share/pkgconfig STRIP="${TOOLCHAIN_PATH}/${TARGET}-strip" CC="${TOOLCHAIN_PATH}/${TARGET}-gcc --sysroot=${TARGET_DEST_DIR}" ./configure --prefix=/usr
  --build=x86_64-pc-linux-gnu   --host=${TARGET}   --sysconfdir=/etc   --with-config=/etc/csvnrc   --with-controldir=/etc/rc.d   --with-logrotatedir=/etc/logrotate.d   --with-scriptdir=/var/www/htdocs/csvn   --with-homedir=/var/lib/csvn   --with-logdir=/var/log   --with-piddir=/var/run


Also we can make use of additional variables such as CFLAGS, LDFLAGS:


Post Install

The system user, on whose behalf the Nginx server is launched, must have permissions to access the directory in which the cSvn CGI script was installed:

chown -R nginx:nginx /var/www/htdocs/csvn

If you configured access to your repositories on behalf system user named svn, then it would be good to grant permissions to svn user to acces to the directory /var/lib/csvn/ which is a home of csvnd(8) daemon:

chown -R svn:svn /var/lib/csvn

and also run the csvnd daemon on behalf of that svn user.

To run the csvnd daemon on systems with BSD-like initialization such as Slackware we have to add following lines to the /etc/rc.d/rc.M and /etc/rc.d/rc.6 scripts correspondengly:


# Start csvnd server:
if [ -x /etc/rc.d/rc.csvnd ]; then
  /etc/rc.d/rc.csvnd start


# Stop csvnd server:
if [ -x /etc/rc.d/rc.csvnd ]; then
  /etc/rc.d/rc.csvnd stop

For systems which uses systemd initialization you have to setup your own systemd unit like follow:


Description=The cSvn daemon

ExecStart=/usr/sbin/csvnd --daemonize --inotify --config=/etc/csvnrc
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID



Since we used the --with-scriptdir=/var/www/htdocs/csvn option on configuring stage, the cSvn CGI script installed in the /var/www/htdocs/csvn/ directory. In this case, the /etc/uwsgi/csvn.ini file should look like this:


master          = true
plugins         = cgi
socket          = /run/uwsgi/%n.sock
uid             = nginx
gid             = nginx
procname-master = uwsgi csvn
processes       = 1
threads         = 2
cgi             = /var/www/htdocs/csvn/csvn.cgi

Where /var/www/htdocs/csvn/csvn.cgi is the full name of installed cSvn CGI script.

To run the uWSGI daemon for cSvn backend we can make use following start/stop script:


# uWSGI daemon control script.


uwsgi_start() {
  # Sanity checks.
  if [ ! -r $CONFDIR/csvn.ini ]; then # no config files, exit:
    echo "There are config files in $CONFDIR directory. Abort."
    exit 1

  if [ -s $PID ]; then
    echo "uWSGI for cSvn appears to already be running?"
    exit 1

  echo "Starting uWSGI for cSvn server daemon..."
  if [ -x $BIN ]; then
    /bin/mkdir -p /run/uwsgi
    /bin/chown nginx:nginx /run/uwsgi
    /bin/chmod 0755 /run/uwsgi
    $BIN --thunder-lock --pidfile $PID --daemonize /var/log/csvn-uwsgi.log --ini $CONFDIR/$CONF.ini

uwsgi_stop() {
  echo "Shutdown uWSGI for cSvn gracefully..."
  /bin/kill -INT $(cat $PID)
  /bin/rm -f $PID

uwsgi_reload() {
  echo "Reloading uWSGI for cSvn configuration..."
  kill -HUP $(cat $PID)

uwsgi_restart() {
  sleep 3

case "$1" in
  echo "usage: `basename $0` {start|stop|reload|restart}"

To run this daemon on systems with BSD-like initialization such as Slackware we have to add following lines to the /etc/rc.d/rc.M and /etc/rc.d/rc.6 scripts correspondingly.


# Start uWSGI for cSvn server:
if [ -x /etc/rc.d/rc.csvn-uwsgi ]; then
  /etc/rc.d/rc.csvn-uwsgi start


# Stop uWSGI for cSvn server:
if [ -x /etc/rc.d/rc.csvn-uwsgi ]; then
  /etc/rc.d/rc.csvn-uwsgi stop


First of all we have to add virtual server to the main Nginx config file:


    include /etc/nginx/vhosts/;

The following configuration used uWsgi and will serve cSvn on a subdomain like


# cSvn server:

    server {
        listen 80;
        return 301$request_uri;

    server {
        listen 443 ssl;
        root /var/www/htdocs/csvn;

        charset UTF-8;

        # see:
        # ,
        # see also:
        # and do not include includeSubdomains; parameter into line:
        add_header Strict-Transport-Security "max-age=63072000; preload";

        error_log /var/log/nginx/;
        access_log /var/log/nginx/;

        keepalive_timeout        60;
        ssl_certificate          /etc/letsencrypt/live/;
        ssl_certificate_key      /etc/letsencrypt/live/;
        ssl_trusted_certificate  /etc/letsencrypt/live/;
        ssl_protocols            SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers              "RC4:HIGH:!aNULL:!MD5:!kEDH";

        gzip on;
        gzip_disable "msie6";
        gzip_comp_level 6;
        gzip_min_length 1100;
        gzip_buffers 16 8k;
        gzip_proxied any;
        gzip_types text/plain text/css text/js text/xml text/javascript
                   image/svg+xml image/gif image/jpeg image/png
                   application/json application/x-javascript application/xml application/xml+rss application/javascript
                   font/truetype font/opentype application/font-woff application/font-woff2
                   application/x-font-ttf application/x-font-opentype application/ application/font-sfnt;

        # Serve static content with nginx

        # Rewrite rules for versioning CSS + JS thtouh filemtime directive
        location ~* ^.+.(css|js)$ {
            rewrite ^(.+).(d+).(css|js)$ $1.$3 last;

            expires 31536000s;

            access_log off;
            log_not_found off;

            add_header Pragma public;
            add_header Cache-Control "max-age=31536000, public";

        # Caching of static files
        location ~* .(eot|gif|gz|gzip|ico|jpg|jpeg|otf|pdf|png|svg|svgz|swf|tar|t?gz|woff|zip)$ {
            expires 31536000s;

            access_log off;
            log_not_found off;

            add_header Pragma public;
            add_header Cache-Control "max-age=31536000, public";

        location ~ ^/favicon.ico$ {
            root /u3/nginx/vhosts/csvn;
            access_log off;
            log_not_found off;
            expires 30d;

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;

        location / {
            try_files $uri @csvn;

        location @csvn {
            gzip off;
            include uwsgi_params;
            uwsgi_modifier1 9;
            uwsgi_pass unix:/run/uwsgi/csvn.sock;

Configuring SVN Repositories

A detailed description of the configuration file format can be found in the csvnrc(5) manual page.

Here we will give a working example of a description of the cSvn repository which can be used as a template for your configurations.


svn-utc-offset = +0300;

checkout-prefix-readonly = 'svn://';
checkout-prefix          = 'svn+ssh://';

branches = 'branches';
trunk    = 'trunk';
tags     = 'tags';

snapshots = 'tar.xz';

css = '/.csvn/css/csvn.css';
logo = '/.csvn/pixmaps/csvn-banner-280x280.png';
logo-alt = "";
logo-link = "";
main-menu-logo = '/.csvn/pixmaps/logo/SVN-logo-white-744x744.svg';
favicon-path = '/.csvn/pixmaps/favicon';
syntax-highlight-css = '_csvn.css';
header = '/.csvn/html/header.html';
footer = '/.csvn/html/footer.html';
page-size = 200;

owner = "Andrey V.Kosteltsev";
author = "Andrey V.Kosteltsev";
title = " SVN Repositories";
description = "Subversion repositories hosted at (St.-Petersburg)";
keywords = "cSvn repositories";
copyright = "© Andrey V. Kosteltsev, 2019 – 2020.";
copyright-notice = "Where any material of this site is being reproduced, published or issued to others the reference to the source is obligatory.";

home-page = "";

section "Tools" {
  repo 'csvn' {
    owner = "Andrey V.Kosteltsev";
    title = "cSvn CGI Script";
    description = "cSvn CGI Script – is a web frontend for Subversion™ Repositories";
    home-page = "";

To access your own repositories, we recommend the svn+ssh protocol.

Final Settings

Files needed to work on web-client side are placed in the /var/www/htdocs/csvn/.csvn/ directory. By editing the HTML header file /.csvn/html/header.html and cSvn config file /etc/csvnrc user can change favicon.ico, change the theme of syntax highlighting, choose images for his repositories, define keywords for search engines such as Google, and also bunch of the other settings.

Additional information about support of analysis services and custom donation dialogues you can find on csvnrc(5) page.



Комментарии (0):