This file explains how to generate packages (deb, rpm) for different Linux
distributions.

* Debian (and Ubuntu) packages
** Install the necessary requirements
   The following packages need to be installed (in addition to the
   ones you need to compile the source anyway):
   - dh-make
   - fakeroot
   - lintian
   - devscripts (not necessary, but has some nice utilities like dch)
** Checking whether the source code builds correctly
   If you downloaded the source code from SVN, run this first:
    autoreconf -i
   Then check to see if everything compiles and all files are included
   in the automake files (if you have multi-core CPU with e.g. 4
   cores, you can add the -j4 option to the make commands):
    ./configure
    make distcheck
   If there are no errors, a tar.gz file of the source should have been
   created. We will use this file in the next step where the actual
   package is built. But first we need to check whether the source
   builds correctly for various settings of the ./configure
   options. Run the following:
    DISTCHECK_CONFIGURE_FLAGS="--without-eigen" make distcheck
    DISTCHECK_CONFIGURE_FLAGS="--disable-palinear" make distcheck
    DISTCHECK_CONFIGURE_FLAGS="--disable-palogist" make distcheck
    DISTCHECK_CONFIGURE_FLAGS="--disable-pacoxph" make distcheck
    DISTCHECK_CONFIGURE_FLAGS="--enable-extract-snp" make distcheck
** Building the package for the first time
   Now that we verified that the source code builds without problems,
   let's create the package.
    mkdir /tmp/PA-deb
    cp probabel-0.4.0.tar.gz /tmp/PA-deb
    cd /tmp/PA-deb
    tar -xzf probabel-0.4.0.tar.gz
    cd probabel-0.4.0
    dh_make --single --email youremail@example.com \
     --file ../probabel-0.4.0.tar.gz --copyright gpl2
   Hit the enter key to confirm the settings. Several files need to be
   edited.
   - debian/control
   - debian/changelog (this file can be edited with 'dch' for convenience)
   - debian/copyright
   - debian/README.Debian
   dh_make also creates several example scripts in the debian/
   directory. We don't need them, so they can be deleted:
    rm debian/*.ex debian/*.EX debian/README.source
   Now the package can be built (NOTE that dpkg-buildpackage replaces
   our default CXXFLAGS with "-g -O2"):
    dpkg-buildpackage -rfakeroot -us -uc
   This creates an unsigned ~.deb~ file in the parent directory. As a
   final touch you can check you package for errors with
    lintian ../probabel_0.3.0-1_amd64.deb
   Several warnings will show up (e.g. binaries without man-pages),
   but we ignore these for now. If you are interested in a more
   detailed explanation of the warnings, add the -i option to the
   lintian command.
   These last two commands can be run in one go using debuild (which
   is part of the devscripts package):
    debuild -i -us -uc -b
   To run a parallel build using 4 processors change the previous
   command to
    debuild -eDEB_BUILD_OPTIONS="parallel=4" -i -us -uc -b
** Uploading to an Ubuntu PPA (Personal Package Archive)
   First, make sure you've set the correct version of the
   distribution you are packaging for in the debian/changelog file
   (use the dch command). E.g. for Ubuntu 12.04 (Precise) this should
   be
     probabel (0.4.0-0ubuntu1~precise1) precise; urgency=low
   Building a package for upload to a PPA is almost the same as shown above:
    debuild -i -S -kYOURKEYID
   where YOURKEYID is the ID of the gpg key you use for signing your
   package (this key should be known by launchpad).
   To upload the package created above to the GenABEL PPA simply type:
    dput ppa:l.c.karssen/genabel-ppa ../probabel_0.4.0-0ubuntu1~precise1_source.changes
