18 October 2010

Package Builds in Linux

This document details how to create a package on Linux.  Only the creation
of a simple package is detailed in this doc.  For more elaborate packages,
see the relevant man pages.

The following assumptions are being made regarding the package build
described herein:

        - the program, etc, has already been installed on the host
          the package is to be built upon
                - program version is 4.17 (for illustrative purposes)

        - for simplicity, the program, yourProg, and its relevant files
          are installed under /usr/local

        - you have root on the host (hostA) that the package is going
          to be created on

        - hostA's root shell prompt is:

                hostA [0]

After yourProg has been installed, an rpm spec file needs to be created.
The spec file basically drives the install of the entire package.
Change directory to /tmp and create a spec file (/tmp/yourProg-spec)
similar to that below:

        Name: yourProg
        Version: 4.17
        Release: 1
        License: GPL
        Group: Applications/System
        Vendor: Systems Engineering
        URL: http://some.site.tld/download/yourProg-4.17.tar.gz
        Source: http://origin.site.tld/files/yourProg/yourProg-4.17.tar.gz
        Summary: yourProg - some single line description of yourProg.
        some description of yourProg, allows multiple lines; built on
        Linux Distro 5 (linux 2.6.18) x86 from source


Once the spec file has been written, rpmbuild can be used to create the
actual package:

        hostA [0] pwd
        hostA [0] ls -l yourProg-spec
        -rw-r--r--   1 root     root         841 Jul 22 13:36 yourProg-spec
        hostA [0] /usr/bin/rpmbuild -bb yourProg-spec
        Processing files: yourProg-4.17-1
        Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
        Requires: libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1) libc.so.6(GLIBC_2.3) rtld(GNU_HASH)
        Checking for unpackaged file(s): /usr/lib/rpm/check-files %{buildroot}
        Wrote: /usr/src/redhat/RPMS/i386/yourProg-4.17-1.i386.rpm
        hostA [0] ls -l /tmp /usr/src/redhat/RPMS/i386
        -rw-r--r--   1 root     root         841 Jul 22 13:36 yourProg-spec

        -rw-r--r--   1 root     root       74403 Jul 22 13:39 yourProg-4.17-1.i386.rpm

Since a working package has now been created, you can install it via rpm:

        hostA [0] /bin/rpm -iv /usr/src/redhat/RPMS/i386/yourProg-4.17-1.i386.rpm

For further references, please see the following:

        rpmbuild(8)     rpm(8)

No comments: