Unix Stuff

Subversion

This subversion is built to match up to the already-installed Apache2, Perl, and Python in /opt.

A small perl block makes scripts load the /opt/subversion/perl SVN API. I wrote a small module that wraps up the pieces of the SVN API that are useful to me that falls back to system()'ing the command-line svn. I hope to get it on CPAN someday, but it's not that hard to write. The loader block looks something like this:


BEGIN {
    my $svn_backend_api = 'lib';

    # we only have Unix & Windows, so this is OK
    if ( $^O ne 'MSWin32' ) {
        $ENV{LD_LIBRARY_PATH} = '/opt/subversion/lib:/opt/apache2/lib';
        lib->import( '/opt/subversion/perl' );
    }

    eval {
        require SVN::Client;
    };

    if ( $@ ) {
        $svn_backend_api = 'cli';
    }
    else {
        SVN::Client->import;
    }
    
    # off the top of my head, untested (will update this later -Al)
    foreach my $func (qw(ls cat checkout commit copy move delete)) {
        my $method = join( '_', $svn_backend_api, $func;
        *{$func} = &{$method};
    }


}

# later on, use $svn_backend_api to tell which functions to call like this:
sub lib_ls {
    ...
}

sub cli_ls {
    ...
}

A multiple class heirarchy with subclassing may be a better design.

SVN's "fsfs" backend creates a very large number of files in a single directory. When creating the ext3 filesystem to host SVN, be sure to specify the "-O dir_index" option to mkfs, or use tune2fs. For example,
mke2fs -m 0 -O dir_index /dev/vgroot/lv_svn_repo.


# install an upgraded swig in /opt/subversion/swig (may not be necessary)
PATH=/usr/java/j2sdk1.4.2_04/bin:$PATH \
    ./configure --prefix=/opt/subversion/swig

# shouldn't be necessary with official SVN source tarballs
#cd neon
#./configure --with-ssl --with-pic --with-libxml2 --prefix=/opt/subversion
#make &&  make install
#cd ..

# on HP-UX ... (haven't tested the perl bindings yet)
PATH=/usr/ccs/bin:/opt/hpws/apache/bin:/opt/ansic/bin:/opt/perl-5.8/bin:/opt/subversion/bin:/opt/subversion/swig/bin:$PATH \
CC=/opt/ansic/bin/cc \
CFLAGS="-O0 -g +Z +DD32" \
./configure --prefix=/opt/subversion \
            --with-ssl
gmake

# on Linux ...
PATH=/opt/apache2/bin:/opt/perl-5.8/bin:/opt/subversion/bin:/opt/subversion/swig/bin:$PATH \
./configure --prefix=/opt/subversion \
            --with-ssl \
            --with-editory=/usr/bin/vim \
            --with-apxs=/opt/apache2/bin/apxs \
            --with-swig=/opt/subversion/swig/bin/swig \
            --with-zlib \
            --with-apr=/opt/apache2/bin/apr-config \
            --with-apr-util=/opt/apache2/bin/apu-config \
            --with-jdk=/usr/java/j2sdk1.4.2_04 \
            --enable-javahl

make
make install

mkdir -p /opt/subversion/apache
install -m 0755 ./subversion/mod_dav_svn/.libs/mod_dav_svn.so /opt/subversion/apache
install -m 0755 ./subversion/mod_authz_svn/.libs/mod_authz_svn.so /opt/subversion/apache

# build/install the perl bindings
make swig-pl
cd ./subversion/bindings/swig/perl/native
/opt/perl-5.8/bin/perl Makefile.PL \
    PREFIX=/opt/subversion/perl \
    INSTALLMAN1DIR=/opt/subversion/man/man1 \
    INSTALLMAN3DIR=/opt/subversion/man/man3 \
    INSTALLARCHLIB=/opt/subversion/perl \
    INSTALLPRIVLIB=/opt/subversion/perl \
    INSTALLSITELIB=/opt/subversion/perl \
    INSTALLSITEARCH=/opt/subversion/perl
make
make install
for i in Makefile.client Makefile.delta Makefile.fs Makefile.ra  Makefile.repos  Makefile.wc
do
    make -f $i
    make -f $i install
done

# build/install the java bindings
make javahl
make install-javahl

## create the empty repository
/opt/subversion/bin/svnadmin create --fstype fsfs /opt/subversion_repository

################################################################################
################################################################################
################################################################################
################################################################################

# configure apache
# add the modules ...
LoadModule dav_module         modules/mod_dav.so
LoadModule dav_svn_module     modules/mod_dav_svn.so
# add the SVN repository -- add apache auth to taste after it's working

    DAV svn
    SVNPath /opt/subversion/repository


# WebDAV!

    DAV svn
    SVNParentPath /opt/subversion/repository
    SVNIndexXSLT "/svnindex.xsl"



################################################################################
################################################################################
################################################################################
################################################################################

# SVN::Web -- make sure to get the absolute latest available.   Currently, we're
# using it hot out of the public SVN repository to get mod_perl2 support.

/opt/perl-5.8/bin/perl -MCPAN -e "install Number::Format"
/opt/perl-5.8/bin/perl -MCPAN -e "install SVN::Web"
mkdir -p /opt/subversion/svnweb
cd /opt/subversion/svnweb
/opt/perl-5.8/bin/svnweb-install

# configure it in Apache2
# for now, I've set it up to use PAM (which may work fine with krb5)
Alias /svnweb /opt/subversion/svnweb

      AllowOverride None
      Options None
      SetHandler perl-script
      PerlHandler SVN::Web
      AuthType Basic
      AuthName "Web Access to SVN"
      AuthPAM_Enabled On