Subversion Server on Gentoo

Reference: Subversion - Gentoo

  1. Install svn as a server, using FSFS (ordinary flat files), and turning off berkeley DB:
    #  USE="-berkdb svnserve vim-syntax java" emerge -pv subversion
    Calculating dependencies... done!
    [ebuild   R   ] dev-util/subversion-1.4.6  USE="apache2 bash-completion nls perl python ruby svnserve vim-syntax java -berkdb -debug -doc -emacs -extras -nowebdav" 0 kB

    #  USE="-berkdb svnserve vim-syntax java" emerge -v subversion

  2. Add the above USE flag to /etc/portage/package.use. Add the following line:
    dev-util/subversion -berkdb svnserve vim-syntax java
  3. At the end of the above command, we see a server note:
     * Man pages are not installed for most modules now.
     * Please use perldoc instead.
     * Subversion Server Notes
     * -----------------------
     *
     * If you intend to run a server, a repository needs to be created using
     * svnadmin (see man svnadmin) or the following command to create it in
     * /var/svn:
     *
     *     emerge --config =dev-util/subversion-1.4.6
     *
     * Subversion has multiple server types, take your pick:
     *
     *  - svnserve daemon:
     *    1. edit /etc/conf.d/svnserve
     *    2. start daemon: /etc/init.d/svnserve start
     *    3. make persistent: rc-update add svnserve default
     *
     *  - svnserve via xinetd:
     *    1. edit /etc/xinetd.d/svnserve (remove disable line)
     *    2. restart xinetd.d: /etc/init.d/xinetd restart
     *
     *  - svn over ssh:
     *    1. Fix the repository permissions:
     *         groupadd svnusers
     *         chown -R root:svnusers /var/svn/repos/
     *         chmod -R g-w /var/svn/repos
     *         chmod -R g+rw /var/svn/repos/db
     *         chmod -R g+rw /var/svn/repos/locks
     *    2. create an svnserve wrapper in /usr/local/bin to set the umask you
     *       want, for example:
     *          #!/bin/bash
     *          . /etc/conf.d/svnserve
     *          umask 002
     *          exec /usr/bin/svnserve ${SVNSERVE_OPTS} "$@"
     *
     *  - http-based server:
     *    1. edit /etc/conf.d/apache2 to include both "-D DAV" and "-D SVN"
     *    2. create an htpasswd file:
     *       htpasswd2 -m -c /var/svn/conf/svnusers USERNAME
     *
     * If you intend to use svn-hot-backup, you can specify the number of
     * backups to keep per repository by specifying an environment variable.
     * If you want to keep e.g. 2 backups, do the following:
     * echo '# hot-backup: Keep that many repository backups around' > /etc/env.d/80subversion
     * echo 'SVN_HOTBACKUP_NUM_BACKUPS=2' >> /etc/env.d/80subversion
     *
  4. Following the notes above, create the repository:
    # emerge --config =dev-util/subversion-1.4.6
  5. Following the notes above, start svnserve daemon:
    # /etc/init.d/svnserve start
    # rc-update add svnserve default
  6. Following the notes above, configure svn over ssh.
  7. Enable urandom for dev-libs/apr to avoid problems with svnserve, as suggested in Subversion - Gentoo
    #emerge -pv dev-libs/apr
    [ebuild   R   ] dev-libs/apr-1.2.11  USE="-debug -doc -ipv6 -urandom" 0 kB

    # USE=urandom emerge -v dev-libs/apr

  8. Enable ssl for net-misc/neon to have SSL support enabled in svn:
    # emerge -pv net-misc/neon

    These are the packages that would be merged, in order:

    Calculating dependencies... done!
    [ebuild   R   ] net-misc/neon-0.26.4  USE="nls ssl zlib -expat -kerberos -socks5" 0 kB

  9. Update java-config-wrapper if needed
      # emerge -pv java-config-wrapper
  10. Install new java-config
    # emerge -1 "=java-config-1*" "=java-config-2*"  
  11. Check your environment
    # java-check-environment  
  12. To use the default repository in /var/svn, simply configure the ebuild and then add each svn user to the apache group so that they have the permissions required to access the repository.
    # ebuild /var/db/pkg/dev-util/subversion-1.*/subversion-1.*.ebuild config
    # gpasswd -a $USER svnusers # login again or use 'newgrp' for changes to take affect
    # chmod -R g+w /var/svn/repos/  
  13. Follow the section Importing your code to import code into the repository.
  14. From another machine, svn checkout the code.