Building a Debian package for ooRexx

This is intended to be a short manual for building a debian package of ooRexx. At the moment this consists of information that can not be found in the ooRexx source or any official ooRexx debian package - there is none…

Throughout the manual I assume that the C build environment is set up correctly to allow ooRexx to compile. If the normal compile works (the combination of bootstrapping, configuring and make) then only a few more tools are required to build the debian package.

As a first start I recomment reading Debian New Maintainers' Guide which explains a lot of details about the package building process.

Here are the build dependencies:

debhelper, autotools-dev, libc6, libgcc1, xalan, libtool (>= 1.5), g++ (>= 4)

Note that the version requirements may not be strict, I guess ooRexx also compiles with gcc 3.x. After the required packages have been installed (xalan is not necessarily required) some debian specific files need to be added to the source.

Inside the main source directory (in the SVN tree located under /main/trunk) create a directory debian.

Inside create

oorexx (4.0.0) stable; urgency=medium

    * Initial debianization.

 -- Your Name <name@domain.tld>  Fri, 03 Oct 2008 22:00:00 -0100
5
Source: oorexx
Section: interpreters
Priority: optional
Maintainer: Moritz Hoffmann <moritz@antiguru.de>
Build-Depends: debhelper, autotools-dev, libc6, libgcc1, xalan, libtool (>=1.5), g++ (>=4)
Standards-Version: 3.7.2

Package: oorexx
Conflicts: regina-rexx
Architecture: i386
Depends: ${shlibs:Depends}
Description:  Open Object Rexx (ooRexx)
 ooRexx is an Open Source project managed by Rexx Language Association (RexxLA)
 providing a free implementation of Object Rexx.
 ooRexx is distributed under Common Public License (CPL) v1.0.
 Object Rexx is an enhancement of classic Rexx; a powerful, full-featured
 programming language which has a human-oriented syntax. The Open Object Rexx
 interpreter allows you to write programs procedurally as well as in an
 object-oriented fashion. Its main benefits include:
    * Easy to use and easy to learn
    * Upwardly compatible with classic Rexx
    * The ability to issue commands to multiple environments
    * Offers powerful functions
    * Based on English-like commands
    * Enhanced with full object orientation
    * Designed for object-oriented programming, and also allows Rexx
      conventional programming
    * Provides a standard Rexx API to develop external function libraries
      written in C (provided by librexx4-dev)


Package: librexx4-dev
Section: libdevel
Provides: librexx-dev
Conflicts: librexx-dev
Architecture: i386
Depends: libc6-dev
Description: Open Object Rexx, development files
 ooRexx is an Open Source project managed by Rexx Language Association (RexxLA)
 providing a free implementation of Object Rexx.
 ooRexx is distributed under Common Public License (CPL) v1.0.
 This package contains shared libraries required by ooRexx.

Package: librexx4
Section: libs
Architecture: i386
Depends: ${shlibs:Depends}
Description: Open Object Rexx, run-time library librexx
 ooRexx is an Open Source project managed by Rexx Language Association (RexxLA)
 providing a free implementation of Object Rexx.
 ooRexx is distributed under Common Public License (CPL) v1.0.
 This package contains the development headers for building applications
 interfacing with ooRexx.

Package: oorexx-dbg
Section: devel
Architecture: i386
Depends: oorexx (= ${binary:Version})
Description: Open Object Rexx, run-time library debug symbols
 ooRexx is an Open Source project managed by Rexx Language Association (RexxLA)
 providing a free implementation of Object Rexx.
 ooRexx is distributed under Common Public License (CPL) v1.0.
 This package contains the debug symbols for librexx4.
CONTRIBUTORS
#!/usr/bin/make -f
#/*----------------------------------------------------------------------------*/
#/*                                                                            */
#/* Copyright (c) 2008 Rexx Language Association. All rights reserved.         */
#/*                                                                            */
#/* This program and the accompanying materials are made available under       */
#/* the terms of the Common Public License v1.0 which accompanies this         */
#/* distribution. A copy is also available at the following address:           */
#/* http://www.oorexx.org/license.html                                         */
#/*                                                                            */
#/* Redistribution and use in source and binary forms, with or                 */
#/* without modification, are permitted provided that the following            */
#/* conditions are met:                                                        */
#/*                                                                            */
#/* Redistributions of source code must retain the above copyright             */
#/* notice, this list of conditions and the following disclaimer.              */
#/* Redistributions in binary form must reproduce the above copyright          */
#/* notice, this list of conditions and the following disclaimer in            */
#/* the documentation and/or other materials provided with the distribution.   */
#/*                                                                            */
#/* Neither the name of Rexx Language Association nor the names                */
#/* of its contributors may be used to endorse or promote products             */
#/* derived from this software without specific prior written permission.      */
#/*                                                                            */
#/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS        */
#/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT          */
#/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS          */
#/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT   */
#/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,      */
#/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED   */
#/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,        */
#/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY     */
#/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING    */
#/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS         */
#/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.               */
#/*                                                                            */
#/*----------------------------------------------------------------------------*/

# Uncomment this to turn on verbose mode.
 export DH_VERBOSE=1

# This is the debhelper compatibility version to use.
CFLAGS = -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif

deboorexx = $(CURDIR)/debian/oorexx
#deboorexxdbg = $(deboorexx)-dbg
deboorexxlib = $(CURDIR)/debian/librexx4
deboorexxlibdev = $(deboorexxlib)-dev
build: build-stamp
build-stamp:
        dh_testdir
        libtoolize --copy --force --automake
        aclocal
        autoheader -Wall
        automake --add-missing --copy -Werror
        #--foreign
        autoconf -Wall
        ./configure --prefix=/usr --config-cache
# Add here commands to compile the package.
        $(MAKE) -s
        touch build-stamp

clean:
        dh_testdir
        dh_testroot
        rm -f build-stamp

        # Add here commands to clean up after the build process.
        [ ! -f Makefile ] || $(MAKE) clean

        dh_clean

install: build
        dh_testdir
        dh_testroot
        dh_clean -k
        dh_installdirs

# oorexx package
# install rexx, rexxc, rxqueue, rxsubcom, rxdelipc
        $(MAKE) install-binPROGRAMS DESTDIR=$(deboorexx)
# install rexx.img, rexx.cat, oorexx-config, rx*.cls, samples, readme
        $(MAKE) install-exec-local DESTDIR=$(deboorexx)
# This doesn't work: all files under /usr/bin are executable, no matter what we do here...
# rexx.img needs to be moved somewhere else, e.g /usr/lib/ooRexx
#       find $(deboorexx)/usr/bin -perm /111 -exec chrpath -d '{}' \;
# install man pages
        $(MAKE) install-man DESTDIR=$(deboorexx)
# install private libraries
        $(MAKE) install-pkglibLTLIBRARIES DESTDIR=$(deboorexx)
        rm -f $(deboorexx)/usr/lib/ooRexx/librexx.* $(deboorexx)/usr/lib/ooRexx/*.la
# move rexx.cat to correct location
        install -d $(deboorexx)/usr/share/locale/C/
        mv $(deboorexx)/usr/bin/rexx.cat $(deboorexx)/usr/share/locale/C/

# librexx package - this only includes librexx
        $(MAKE) install-pkglibLTLIBRARIES DESTDIR=$(deboorexxlib)
# remove all a and so files, they're not needed
        rm -f $(deboorexxlib)/usr/lib/ooRexx/*.a $(deboorexxlib)/usr/lib/ooRexx/*.so $(deboorexxlib)/usr/lib/*.la
# move librexx to shared directory
        mv $(deboorexxlib)/usr/lib/ooRexx/librexx.* $(deboorexxlib)/usr/lib
# remove private lib directory
        rm -r $(deboorexxlib)/usr/lib/ooRexx/

# librexx-dev package for librexx
# librexx-dev package for librexx
# install all libraries
        $(MAKE) install-pkglibLTLIBRARIES DESTDIR=$(deboorexxlibdev)
# install header file
        $(MAKE) install-includeHEADERS DESTDIR=$(deboorexxlibdev)
# move the wanted library to shared location
        mv $(deboorexxlibdev)/usr/lib/ooRexx/librexx.* $(deboorexxlibdev)/usr/lib
# delete all other libraries
        rm -rf $(deboorexxlibdev)/usr/lib/ooRexx/
# delete unused files - they are part of librexx
        rm -f $$(find $(deboorexxlibdev)/usr/lib/ -regex '.*\.\(la\|so\..*\)$$')

        
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
        dh_testdir
        dh_testroot
#      dh_installdebconf
        dh_installdocs
#       dh_installexamples
#       dh_installmenu
#      dh_installlogrotate
#      dh_installemacsen
#      dh_installpam
#      dh_installmime
#      dh_installinit
#       dh_installcron
        dh_installman
#       dh_installinfo
#      dh_undocumented
        dh_installchangelogs CHANGES
        dh_link
        dh_strip --dbg-package=oorexx-dbg
        dh_compress
        dh_fixperms
        dh_makeshlibs
        dh_installdeb
#      dh_perl
        dh_shlibdeps
        dh_gencontrol
        dh_md5sums
        dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

Now all files should be in place.

From the top source directory issue the command

dpkg-buildpackage -rfakeroot

or, if only the .deb packages are required:

fakeroot debian/rules binary

to directly build the debs.

If the build succeeds the deb files should appear in the directory above the source:

moritz@TP42:debian % ls -al ../..
-rw-r--r--  1 moritz moritz  528450 2008-10-03 22:14 librexx4_4.0.0_i386.deb
-rw-r--r--  1 moritz moritz  759566 2008-10-03 22:14 librexx4-dev_4.0.0_i386.deb
-rw-r--r--  1 moritz moritz  363346 2008-10-03 22:14 oorexx_4.0.0_i386.deb
-rw-r--r--  1 moritz moritz 2041952 2008-10-03 22:14 oorexx-dbg_4.0.0_i386.deb

Now oorexx and librexx4 can be installed via dpkg:

moritz@TP42:debian % sudo dpkg -i ../../librexx4_4.0.0_i386.deb 
[sudo] password for moritz: 
(Reading database ... 201514 files and directories currently installed.)
Preparing to replace librexx4 4.0.0 (using ../../librexx4_4.0.0_i386.deb) ...
Unpacking replacement librexx4 ...
Setting up librexx4 (4.0.0) ...
moritz@TP42:debian % sudo dpkg -i ../../oorexx_4.0.0_i386.deb  
(Reading database ... 201511 files and directories currently installed.)
Preparing to replace oorexx 4.0.0 (using ../../oorexx_4.0.0_i386.deb) ...
Unpacking replacement oorexx ...
Setting up oorexx (4.0.0) ...
Processing triggers for man-db ...

Now try to run it:

moritz@TP42:debian % rexx -e "parse version s;say s"
REXX-ooRexx_4.0.0(MT) 6.03 3 Oct 2008