# 5 - EPM Packaging Examples

This chapter shows how the EPM and CUPS software is packaged using EPM list files. The EPM list file example highlights the basic features of EPM, while the CUPS list file example shows the more advanced features of EPM.

## Packaging the EPM Software

The EPM software comes with its own autoconf-generated epm.list file that is used to package and test EPM. The EPM package consists of the main package plus a "documentation" subpackage for the documentation files and a "man" subpackage for the man pages.

We start by defining variables for each of the autoconf directory variables:

    $prefix=/usr
    $exec_prefix=/usr
    $bindir=${exec_prefix}/bin
    $datadir=/usr/share
    $docdir=${datadir}/doc/epm
    $libdir=/usr/lib
    $mandir=/usr/share/man
    $srcdir=.

Then we provide the general product information that is required for all packages; notice the use of `${srcdir}` to reference the LICENSE and README files:

    %product ESP Package Manager
    %copyright 1999-2020 by Michael R Sweet, All Rights Reserved.
    %copyright 2020 by Jim Jagielski, All Rights Reserved.
    %vendor Michael R Sweet
    %vendor Jim Jagielski
    %license ${srcdir}/LICENSE
    %readme ${srcdir}/README.md
    %description Universal software packaging tool for UNIX.
    %version 4.6 460

After the product information, we include all of the non-GUI files that are part of EPM:

    # Executables
    %system all
    f 0555 root sys ${bindir}/epm epm
    f 0555 root sys ${bindir}/epminstall epminstall
    f 0555 root sys ${bindir}/mkepmlist mkepmlist

    # Documentation
    %subpackage documentation
    %description Documentation for EPM
    f 0444 root sys ${docdir}/README $srcdir/README.md
    f 0444 root sys ${docdir}/LICENSE $srcdir/LICENSE
    f 0444 root sys ${docdir}/epm-book.epub $srcdir/doc/epm-book.epub
    f 0444 root sys ${docdir}/epm-book.html $srcdir/doc/epm-book.html
    f 0444 root sys ${docdir}/epm-book.pdf $srcdir/doc/epm-book.pdf

    # Man pages
    %subpackage man
    %description Man pages for EPM
    f 0444 root sys ${mandir}/man1/epm.1 $srcdir/doc/epm.man
    f 0444 root sys ${mandir}/man1/epminstall.1 $srcdir/doc/epminstall.1
    f 0444 root sys ${mandir}/man1/mkepmlist.1 $srcdir/doc/mkepmlist.1
    f 0444 root sys ${mandir}/man5/epm.list.5 $srcdir/doc/epm.list.5

Finally, we conditionally include the GUI files depending on the state of a variable called `GUIS`:

    # GUI files...
    $GUIS=setup uninst

    %if GUIS
    %subpackage
    f 0555 root sys ${libdir}/epm/setup setup
    f 0555 root sys ${libdir}/epm/uninst uninst

    %system macos
    f 0444 root sys ${datadir}/epm/default.icns default.icns
    %system all

    %subpackage man
    f 0444 root sys ${mandir}/man1/setup.1 $srcdir/doc/setup.1
    f 0444 root sys ${mandir}/man5/setup.types.5 $srcdir/doc/setup.types.5

    %endif