## F.3. Getting The Source Via CVSup

An alternative to using anonymous CVS for retrieving the PostgreSQL source tree is CVSup. CVSup was developed by John Polstra (`<jdp@polstra.com>`) to distribute CVS repositories and other file trees for the FreeBSD project.

A major advantage to using CVSup is that it can reliably replicate the entire CVS repository on your local system, allowing fast local access to cvs operations such as `log` and `diff`. Other advantages include fast synchronization to the PostgreSQL server due to an efficient streaming transfer protocol which only sends the changes since the last update.

### F.3.1. Preparing A CVSup Client System

Two directory areas are required for CVSup to do its job: a local CVS repository (or simply a directory area if you are fetching a snapshot rather than a repository; see below) and a local CVSup bookkeeping area. These can coexist in the same directory tree.

Decide where you want to keep your local copy of the CVS repository. On one of our systems we recently set up a repository in `/home/cvs/`, but had formerly kept it under a PostgreSQL development tree in `/opt/postgres/cvs/`. If you intend to keep your repository in `/home/cvs/`, then put

    setenv CVSROOT /home/cvs

in your `.cshrc` file, or a similar line in your `.bashrc` or `.profile` file, depending on your shell.

The cvs repository area must be initialized. Once `CVSROOT` is set, then this can be done with a single command:

    cvs init

after which you should see at least a directory named `CVSROOT` when listing the `CVSROOT` directory:

    $ ls $CVSROOT
    CVSROOT/

### F.3.2. Running a CVSup Client

Verify that cvsup is in your path; on most systems you can do this by typing

    which cvsup

Then, simply run cvsup using:

    cvsup -L 2 postgres.cvsup

where `-L 2` enables some status messages so you can monitor the progress of the update, and `postgres.cvsup` is the path and name you have given to your CVSup configuration file.

Here is a CVSup configuration file modified for a specific installation, and which maintains a full local CVS repository:

    # This file represents the standard CVSup distribution file
    # for the PostgreSQL ORDBMS project
    # Modified by lockhart@fourpalms.org 1997-08-28
    # - Point to my local snapshot source tree
    # - Pull the full CVS repository, not just the latest snapshot
    #
    # Defaults that apply to all the collections
    *default host=cvsup.postgresql.org
    *default compress
    *default release=cvs
    *default delete use-rel-suffix
    # enable the following line to get the latest snapshot
    #*default tag=.
    # enable the following line to get whatever was specified above or by default
    # at the date specified below
    #*default date=97.08.29.00.00.00

    # base directory where CVSup will store its 'bookmarks' file(s)
    # will create subdirectory sup/
    #*default base=/opt/postgres # /usr/local/pgsql
    *default base=/home/cvs

    # prefix directory where CVSup will store the actual distribution(s)
    *default prefix=/home/cvs

    # complete distribution, including all below
    pgsql

    # individual distributions vs 'the whole thing'
    # pgsql-doc
    # pgsql-perl5
    # pgsql-src

If you specify `repository` instead of `pgsql` in the above setup, you will get a complete copy of the entire repository at cvsup.postgresql.org, including its `CVSROOT` directory. If you do that, you will probably want to exclude those files in that directory that you want to modify locally, using a refuse file. For example, for the above setup you might put this in `/home/cvs/sup/repository/refuse`:

    CVSROOT/config*
    CVSROOT/commitinfo*
    CVSROOT/loginfo*

See the CVSup manual pages for how to use refuse files.

The following is a suggested CVSup config file from the PostgreSQL ftp site which will fetch the current snapshot only:

    # This file represents the standard CVSup distribution file
    # for the PostgreSQL ORDBMS project
    #
    # Defaults that apply to all the collections
    *default host=cvsup.postgresql.org
    *default compress
    *default release=cvs
    *default delete use-rel-suffix
    *default tag=.

    # base directory where CVSup will store its 'bookmarks' file(s)
    *default base=/usr/local/pgsql

    # prefix directory where CVSup will store the actual distribution(s)
    *default prefix=/usr/local/pgsql

    # complete distribution, including all below
    pgsql

    # individual distributions vs 'the whole thing'
    # pgsql-doc
    # pgsql-perl5
    # pgsql-src

### F.3.3. Installing CVSup

CVSup is available as source, pre-built binaries, or Linux RPMs. It is far easier to use a binary than to build from source, primarily because the very capable, but voluminous, Modula-3 compiler is required for the build.

CVSup Installation from Binaries

You can use pre-built binaries if you have a platform for which binaries are posted on the PostgreSQL ftp site or if you are running FreeBSD, for which CVSup is available as a port.

### Note

CVSup was originally developed as a tool for distributing the FreeBSD source tree. It is available as a “port”, and for those running FreeBSD, if this is not sufficient to tell how to obtain and install it then please contribute a procedure here.

At the time of writing, binaries are available for Alpha/Tru64, ix86/xBSD, HPPA/HP-UX 10.20, MIPS/IRIX, ix86/linux-libc5, ix86/linux-glibc, Sparc/Solaris, and Sparc/SunOS.

1. Retrieve the binary tar file for cvsup (cvsupd is not required to be a client) appropriate for your platform.

   1. If you are running FreeBSD, install the CVSup port.

   2. If you have another platform, check for and download the appropriate binary from the PostgreSQL ftp site.

2. Check the tar file to verify the contents and directory structure, if any. For the linux tar file at least, the static binary and man page is included without any directory packaging.

   1. If the binary is in the top level of the tar file, then simply unpack the tar file into your target directory:

          cd /usr/local/bin
          tar zxvf /usr/local/src/cvsup-16.0-linux-i386.tar.gz
          mv cvsup.1 ../doc/man/man1/

   2. If there is a directory structure in the tar file, then unpack the tar file within /usr/local/src and move the binaries into the appropriate location as above.

3. Ensure that the new binaries are in your path.

       $ rehash
       $ which cvsup
       $ set path=(path to cvsup $path)
       $ which cvsup
       /usr/local/bin/cvsup

### F.3.4. Installation from Sources

Installing CVSup from sources is not entirely trivial, primarily because most systems will need to install a Modula-3 compiler first. This compiler is available as Linux RPM, FreeBSD package, or source code.

### Note

A clean-source installation of Modula-3 takes roughly 200MB of disk space, which shrinks to roughly 50MB of space when the sources are removed.

Linux installation

1. Install Modula-3.

   1. Pick up the Modula-3 distribution from Polytechnique Montréal who are actively maintaining the code base originally developed by the DEC Systems Research Center. The PM3 RPM distribution is roughly 30MB compressed. At the time of writing, the 1.1.10-1 release installed cleanly on RH-5.2, whereas the 1.1.11-1 release is apparently built for another release (RH-6.0?) and does not run on RH-5.2.

      ### Tip

      This particular rpm packaging has many RPM files, so you will likely want to place them into a separate directory.

   2. Install the Modula-3 rpms:

          # rpm -Uvh pm3*.rpm

2. Unpack the cvsup distribution:

       # cd /usr/local/src
       # tar zxf cvsup-16.0.tar.gz

3. Build the cvsup distribution, suppressing the GUI interface feature to avoid requiring X11 libraries:

       # make M3FLAGS="-DNOGUI"

   and if you want to build a static binary to move to systems that may not have Modula-3 installed, try:

       # make M3FLAGS="-DNOGUI -DSTATIC"

4. Install the built binary:

       # make M3FLAGS="-DNOGUI -DSTATIC" install