# DEB binary package

This page describes canonical way of building of a binary package for DEB-based distributions (Ubuntu, Mint, Debian). The quick and easy preparation of portable packages for different architectures is the expected purpose.

A review of building of DEB packages is described in detail by New Maintainers' Guide. Munipack package has been prepared on base of AstropyPackagingTutorial. The tutorial contains instructions how a software can be cloned, modified, patched and re-build.

## Debian GIT Repository

Debian project maintains own repositories for packages. Every package, as well as Munipack, has three branches: upstream (meaning the source code of a project itself), master (Debian specific files under debian/ directory) and pristine-tar (with an original archive). The files specific to Debian should be independent on the original archive ones.

## Mercurial Repositories

The separation of Debian specific and original project files is reflected also in structure of my development Mercurial repositories:

- Munipack
- Munipack-debian

Munipack-debian repository contains a script and Debian control files needs for building of development branch packages.

## Prerequisites

Tools listed below are required for the building:

- Mercurial, the version control system
- Fortran 95 and C++ compilers
- wxWidgets development libraries
- debhelper tool (creating of deb packages)

All the tools are included in any standard distributions.

We will install Mercurial (execute the command under root account or use sudo) as the initial step:

      # apt install mercurial

## Getting Copy of Munipack-Debian

As a next step, we need a clone of munipack-debian repository (Munipack itself will be cloned later in a script). The task can be done under a regular user accout:

      $ hg clone https://integral.physics.muni.cz/hg/munipack-deb

A crucial matter for building is a script file `munipack-debian/munipack_hg.sh`. It will be made all for us.

Once before building, required software tools defined in `munipack-debian/debian/control` should to by presented:

      $ grep Build-Depends munipack-debian/debian/control
      Build-Depends: debhelper (>= 9), dh-autoreconf, gfortran, g++ (>=4.7), libcfitsio-dev, libwxgtk3.0-gtk3-dev, minpack-dev, oakleaf-dev

All the required, or any missing, utilities can be installed as:

    # apt install gfortran g++ libwxgtk3.0-gtk3-dev libcfitsio-dev debhelper dh-autoreconf minpack-dev oakleaf-dev

## Build of DEB Packages

The previous steps garanties to be all prerequisites available. Now, it's the moment of truth:

      $ bash -x munipack-deb/munipack_dev.sh

If the building process is successful, new packages does appear (see examples below) in the current working directory:

      $ ls
    munipack/                             munipack-doc_0.5.7+hg1500_all.deb
    munipack-0.5.7+hg1500/                munipack-gui_0.5.7+hg1500_amd64.deb
    munipack-0.5.7+hg1500.tar.gz          munipack_0.5.7+hg1500.dsc
    munipack-cli_0.5.7+hg1500_amd64.deb   munipack_0.5.7+hg1500.tar.xz
    munipack-core_0.5.7+hg1500_amd64.deb  munipack_0.5.7+hg1500_amd64.changes
    munipack-debian/                      munipack_0.5.7+hg1500_amd64.deb

## Installation of DEB Packages

The packages can be installed as:

      # dpkg -i munipack_*.deb munipack-gui_*.deb munipack-doc_*.deb \
                munipack-core_*.deb munipack-cli_*.deb

Or, they can be uninstalled analogically:

      dpkg -r munipack munipack-gui munipack-doc munipack-core munipack-cli

## See Also

Installation, DEB bundle builder.