The following page describes the deployment of gitolite and gitweb to provide a git code hosting solution for Linaro.

Requirements

  • At least 16 GB RAM
  • At least 4 cores CPU
  • A partition of at least 250 GB to store repositories

External Documentation

Installation & Setup

All the following commands should be run as root or with sudo.
The following instructions assume that the partition where repositories will be store is /srv/. The following directory will be needed and created during the installation/setup:

  • /srv/git.linaro.org

  • /srv/repositories

  • /srv/gitolite

Required Software

  • Install python-software-properties:

    apt-get install python-software-properties
  • Add the Git PPA, install git and gitweb:

    apt-add-repository ppa:git-core/ppa && apt-get update && apt-get install git-core git-doc gitweb -y
  • Install Apache:

    apt-get install apache2 apache2-common apache2-utils -y
  • Make sure the following Perl packages are installed:

    libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libclass-accessor-perl libclass-isa-perl libdpkg-perl liberror-perl libhttp-date-perl libio-string-perl liblocale-gettext-perl libparse-debianchangelog-perl libsub-name-perl libswitch-perl libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libtimedate-perl perl perl-base perl-modules

Setup

  • Make sure the following Apache modules are enabled:

    expires headers mime proxy proxy_http ssl rewrite setenvif
  • Create a user called git, with its home in /home/git, no password and login disabled:

    adduser --home /home/git --disabled-password --disabled-login git

Setup Gitolite

As the root user:

  • Create the directories /srv/repositories and /srv/gitolite, and make sure only the git user can write into them:

    mkdir /srv/repositories /srv/gitolite
    chown -R git:git /srv/repositories && chown -R git:git /srv/gitolite
    chmod 750 /srv/repositories  && chmod 750 /srv/gitolite

As the git user:

  • Make sure that the directory /home/git/bin exists:

    mkdir /home/git/bin

    And that is in the PATH for the git user. In case add it to the .bash_rc file and source it.

  • Clone the necessary repositories:

    git clone git://github.com/sitaramc/gitolite
    git clone http://staging.git.linaro.org/git-ro/infrastructure/gitweb-linaro-theme.git
    git clone http://staging.git.linaro.org/git-ro/infrastructure/crowd-groups.git
    git clone http://staging.git.linaro.org/git-ro/infrastructure/clean-trash-repo.git
    git clone http://staging.git.linaro.org/git-ro/infrastructure/ldap-user-keys.git
  • Launch gitolite install:

    ./gitolite/install -ln
  • Make sure you have a valid SSH public key at hand, since this key will be used to set up the first administrator for gitolite. The key shall be renamed as name.surname@key_0.pub.
    For more info on the setup steps, see gitolite setup instructions.

  • Now launch gitolite setup, with the user SSH key:

    gitolite setup -pk KEY@key_0.pub
  • Copy the content of /home/git/.gitolite/ in /srv/gitolite and remove /home/git/.gitolite/

  • Link /srv/gitolite/ as /home/git/.gitolite

  • Copy the content of /home/git/repositories/ in /srv/repositories, and remove /home/git/repositories

  • Link /srv/repositories as /home/git/repositories

  • Create the following symlinks:

    ln -s /home/git/clean-trash-repo/clean-trash-repo.py /home/git/bin
    ln -s /home/git/create-clone-bundle/create-bundle /home/git/bin
  • Setup the following cron jobs:

    # Sync the SSH keys from LDAP: daily at 0200UTC.
    0 2 * * * /home/git/ldap-user-keys/ldap-keys.py
    
    # Clean up trashed repositories: daily at 0500UTC.
    0 5 * * * /home/git/bin/clean-trash-repo.py
    
    # Create clone bundles: on saturday at 0300UTC.
    0 3 * * 6 /home/git/bin/create-bundle
  • Modify the file /home/git/.gitolite.rc accordingly to the installation.
    The complete .gitolite.rc file can be found here: gitolite.rc.gz

Setup Gitweb

As the root user:

  • Create the directory /srv/git.linaro.org:

    mkdir /srv/git.linaro.org
  • Link the gitweb.cgi in that directory:

    ls -s /usr/lib/cgi-bi/gitweb.cgi /srv/git.linaro.org
  • Copy the Linaro theme in /srv/git.linaro.org:

    cp /home/git/gitweb-linaro-theme/* /srv/git.linaro.org
  • Make sure the user www-data can read/write the directory:

    chown -R www-data:www-data /srv/git.linaro.org
  • Create the file /etc/gitweb.local.conf, and make sure that at least it has these settings:

    $projectroot = "/srv/repositories";
    $git_temp = "/srv/repositories/../tmp";
    $projects_list = "/home/git/projects.list";
    $stylesheet = "/gitweb.css";
    $logo = "/git-logo-20130814.png";
    $logo_url = "http://www.linaro.org";
    $logo_label = "Linaro";
    $favicon = "/git-favicon-20130814.png";
    $site_name = "Linaro Git Code Hosting";

    The actual gitweb config file can be found here: gitweb.local.conf.gz

Setup Apache

  • Make sure the Apache user is in the git group:

    usermod -a -G git www-data
  • An example of the Apache configuration file can be found here: git.linaro.org.gz

Update Gitolite

As the git user:

  • Update the repository:

    cd /home/git/gitolite && git pull
  • Re-run the setup command:

    gitolite setup -ln

Platform/Systems/GitwebGitoliteDeployment (last modified 2014-06-24 17:47:42)