makepack rule writing

Contents

3 examples

A good way to learn is by studying examples.

fftw, a simple example

We start with an example which is almost as simple as a rule file can get, the rule file for fftw. The file is named fftw and contains the following:
DESCRIPTION = Fastest Fourier Transform in the West.
SRC_PKG = fftw-3.1.2.tar.gz

URL_DIR += http://www.fftw.org/
URL_DIR += ftp://ftp.fftw.org/pub/fftw
Makepack rule files are really only a part of a Makefile. Their task is to set a few variables. As shown above only 3 variables need to be set for a well behaved software without any dependencies.

The 3 mandatory variables for all rule files are:
VariableDescription
DESCRIPTION This should be a short description of the software. It will be shown when doing "make list" and it will also be added to the log file in /var/log/packages.
SRC_PKG This is the name of the source package.
URL_DIRThis is where on the internet the source package can be found. The URL_DIR can contain more than one URL, Makepack will automatically find out which server is the nearest one and download the source package from the nearest server.

URL_DIR can be replaced by SF_DIR or CPAN_DIR instead of listing all SourceForge mirrors or CPAN mirrors. SF_DIR should be set to the SourceForge project name and CPAN_DIR should be set to the category directory below the directory modules/by-module on CPAN mirrors.

gpgme, a typical example

We continue with a more typical example, the rule file for gpgme, as you might have already guessed by now the name of the rule file is also gpgme.
DESCRIPTION = GPGME  (GnuPG Made Easy), a library for cryptography.

SRC_PKG = gpgme-1.0.3.tar.gz
MD5SUM = 4d33cbdf844fcee1c724e4cf2a32dd11
DEPS += libgpg-error
URL_DIR += ftp://ftp.gnupg.org/gcrypt/gpgme/
This file sets two more variables, MD5SUM and DEPS. MD5SUM is an optional variable, if set, after the source package has been downloaded its md5sum will be checked. If this check fails, Makepack will try to download the source package from another URL or consider the download as failed. DEPS can contain one or more dependencies. Before trying to configure and compile the software, Makepack will install the dependencies. This means that for all dependencies there also has to be a rule file. In the example above there is only one dependency, but DEPS, like URL_DIR can contain more than one string.

openoffice.org, a big example

You are probably reading this text because you are planning to write a rule file yourself. The examples above might be enough information for you to write working rule files for the software you intend to install. If you are lucky you can stop reading here. However, if you are trying to install software which requires some kind of non standard procedure to get installed you will need to read on. We will end this paragraph with a complex example, a rule file called openoffice.org:
DESCRIPTION = OpenOffice.org office suite
ORG_PKG = OOo_2.0.2_src.tar.gz
SRC_PKG = openoffice.org-2.0.2.tar.gz

UNPACK_METHOD = cd $(@D) && tar -xzvf $< && mv OOB680_m5 $(@F) && \
     cp $(SOURCE_DIR)/mozilla-source-1.7.5.tar.gz $(@F)/moz/download && \
     unzip -j -d $(@F)/external/gpc $(SOURCE_DIR)/gpc232.zip

# Hack to avoid gnome dependency if gnome is not installed
CONFIG_FLAGS = $(shell pkg-config --modversion gnome-vfs-2.01 >& /dev/null || \
                       echo "--disable-gnome-vfs")
CONFIG_FLAGS += --enable-build-mozilla
CONFIG_FLAGS += --with-ant-home=$(PREFIX)/ant
# All languages takes far to much disk space (> 15 GB)
# CONFIG_FLAGS += --with-lang=ALL
# Unfortunately it is only possible to have one language installed at one time
# therefore it is not even any idea to compile more than one language.
# CONFIG_FLAGS += --with-lang="de fr es"
CONFIG_FLAGS += --with-dict=ALL
CONFIG_FLAGS += --prefix=$(PREFIX)
CONFIGURE_METHOD = cd config_office ; ./configure $(CONFIG_FLAGS)

# Have to patch code to make it compile with java 1.5, thats what sed is for,
# this patching will probably not be needed from version 2.0.3
XMD = xmerge/source/xmerge/java/org/openoffice/xmerge
BUILD_METHOD   = ./bootstrap && \
   mv $(XMD)/ConvertData.java $(XMD)/ConvertData.java.org && \
   sed -e 's/enum/enumerate/' \
      $(XMD)/ConvertData.java.org > $(XMD)/ConvertData.java && \
   mv $(XMD)/converter/xml/xslt/DocumentDeserializerImpl.java \
      $(XMD)/converter/xml/xslt/DocumentDeserializerImpl.java.org && \
   sed -e 's/enum/enumerate/' \
      $(XMD)/converter/xml/xslt/DocumentDeserializerImpl.java.org > \
      $(XMD)/converter/xml/xslt/DocumentDeserializerImpl.java && \
   mv $(XMD)/converter/xml/xslt/PluginFactoryImpl.java \
      $(XMD)/converter/xml/xslt/PluginFactoryImpl.java.org && \
   sed -e 's/enum/enumerate/' \
      $(XMD)/converter/xml/xslt/PluginFactoryImpl.java.org > \
      $(XMD)/converter/xml/xslt/PluginFactoryImpl.java && \
   echo "source LinuxIntelEnv.Set.sh ; export CLASSPATH=$(PREFIX)/ant/lib/xalan.jar:$(PREFIX)/ant/lib/serializer.jar:\$CLASSPATH ; dmake && cd instsetoo_native/util && dmake ooolanguagepack" | bash

INSTALL_METHOD = rpm --nodeps -U \
           instsetoo_native/unxlngi4.pro/OpenOffice/rpm/install/*/*/*.rpm && \
                 mkdir -p $(PREFIX)/bin && \
                 ln -s /opt/openoffice.org2.0/program/soffice $(PREFIX)/bin

# We need the mozilla sources
DEPS_DOWNLOAD_ONLY += mozilla-source
# We need sources for gpc
DEPS_DOWNLOAD_ONLY += gpc

DEPS += apache-ant
DEPS += xalan

# Perl modules
DEPS += Archive-Zip Crypt-SSLeay SOAP-Lite XML-Parser

# We need Java, depending on version of Slackware this could be called
# jdk or j2sdk. As there is no rule to install jdk we only have a dummy.
JDK_TEST = $(shell which javac)
ifeq ($(JDK_TEST),)
DEPS_DOWNLOAD_ONLY += jdk
endif

# OpenOffice.org needs PAM, but we don't want to install PAM. It is possible
# to trick OpenOffice.org with the headers from PAM only.
ifeq ($(wildcard /usr/include/security/pam_appl.h),)
DEPS += PAM_headers
endif

export C_INCLUDE_PATH = /usr/local/pam-headers

# If optimization would have been possible it should have been done
# like this:
# export ARCH_FLAGS=$(CFLAGS)

URL_DIR += http://openoffice.mirrors.ilisys.com.au/stable/2.0.2/
URL_DIR += ftp://mirror.pacific.net.au/OpenOffice/stable/2.0.2/
URL_DIR += http://mirror.pacific.net.au/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.planetmirror.com/pub/openoffice/stable/2.0.2/
URL_DIR += http://planetmirror.com/pub/openoffice/stable/2.0.2/
URL_DIR += http://gd.tuwien.ac.at/office/openoffice/stable/2.0.2/
URL_DIR += ftp://gd.tuwien.ac.at/office/openoffice/stable/2.0.2/
URL_DIR += http://ftp.belnet.be/pub/mirror/ftp.openoffice.org/stable/2.0.2/
URL_DIR += ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/openoffice.org/stable/2.0.2/
URL_DIR += ftp://ftp.scarlet.be/pub/openoffice/stable/2.0.2/
URL_DIR += http://ftp.scarlet.be/pub/openoffice/stable/2.0.2/
URL_DIR += http://linorg.usp.br/OpenOffice.org/stable/2.0.2/
URL_DIR += ftp://ftp.pucpr.br/openoffice/stable/2.0.2/
URL_DIR += http://gulus.USherbrooke.ca/pub/appl/openoffice/stable/2.0.2/
URL_DIR += http://ftp.sh.cvut.cz/MIRRORS/OpenOffice/stable/2.0.2/
URL_DIR += ftp://ftp.sh.cvut.cz/MIRRORS/OpenOffice/stable/2.0.2/
URL_DIR += http://mirrors.sunsite.dk/openoffice/stable/2.0.2/
URL_DIR += ftp://sunsite.dk/mirrors/openoffice/stable/2.0.2/
URL_DIR += ftp://openoffice.cict.fr/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.tu-chemnitz.de/pub/openoffice/stable/2.0.2/
URL_DIR += ftp://sunsite.informatik.rwth-aachen.de/pub/mirror/OpenOffice/stable/2.0.2/
URL_DIR += ftp://ftp.leo.org/pub/comp/general/office/openoffice/stable/2.0.2/
URL_DIR += http://ftp.leo.org/pub/comp/general/office/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.join.uni-muenster.de/pub/software/OpenOffice/stable/2.0.2/
URL_DIR += ftp://openoffice.tu-bs.de/OpenOffice.org/stable/2.0.2/
URL_DIR += http://ftp.stardiv.de/pub/OpenOffice.org/stable/2.0.2/
URL_DIR += ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/ftp.openoffice.org/stable/2.0.2/
URL_DIR += http://mirror.xaranet.de/openoffice/stable/2.0.2/
URL_DIR += http://www.ellak.gr/pub/openoffice/stable/2.0.2/
URL_DIR += http://ftp.ntua.gr/pub/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.ntua.gr/pub/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.kddlabs.co.jp/office/openoffice/stable/2.0.2/
URL_DIR += http://www.ring.gr.jp/archives/misc/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.ring.gr.jp/pub/misc/openoffice/stable/2.0.2/
URL_DIR += http://mymirror.asiaosc.org/openoffice/stable/2.0.2/
URL_DIR += http://ftp.nluug.nl/pub/office/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.snt.utwente.nl/pub/software/openoffice/stable/2.0.2/
URL_DIR += http://vlaai.snt.utwente.nl/pub/software/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.man.poznan.pl/pub/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.openoffice.pl/OpenOffice.ORG/stable/2.0.2/
URL_DIR += http://mirrors.oninet.pt/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.iasi.roedu.net/pub/mirrors/openoffice.org/stable/2.0.2/
URL_DIR += http://ftp.iasi.roedu.net/mirrors/openoffice.org/stable/2.0.2/
URL_DIR += http://mirror.etf.bg.ac.yu/openoffice/stable/2.0.2/
URL_DIR += ftp://mirror.averse.net/pub/openoffice/stable/2.0.2/
URL_DIR += http://mirror.averse.net/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.bevc.net/mirrors/openoffice/stable/2.0.2/
URL_DIR += http://mirrors.bevc.net/openoffice/stable/2.0.2/
URL_DIR += http://www.wsection.com/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.kr.freebsd.org/pub/openoffice/stable/2.0.2/
URL_DIR += http://ftp.rediris.es/ftp/mirror/openoffice.org/stable/2.0.2/
URL_DIR += ftp://ftp.rediris.es/mirror/openoffice.org/stable/2.0.2/
URL_DIR += http://ftp.sunet.se/pub/Office/OpenOffice.org/stable/2.0.2/
URL_DIR += ftp://sunsite.cnlab-switch.ch/mirror/OpenOffice/stable/2.0.2/
URL_DIR += http://mirror.switch.ch/ftp/mirror/openoffice/stable/2.0.2/
URL_DIR += ftp://mirror.switch.ch/mirror/openoffice/stable/2.0.2/
URL_DIR += http://www.mirror.ac.uk/mirror/sunsite.dk/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.mirror.ac.uk/mirror/sunsite.dk/openoffice/stable/2.0.2/
URL_DIR += http://www.mirror.ac.uk/mirror/sunsite.dk/openoffice/stable/2.0.2/
URL_DIR += http://www.binarycode.org/openoffice/stable/2.0.2/
URL_DIR += http://mirrors.ibiblio.org/pub/mirrors/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.ibiblio.org/pub/mirrors/openoffice/stable/2.0.2/
URL_DIR += ftp://ftp.ussg.iu.edu/pub/openoffice/stable/2.0.2/
URL_DIR += ftp://openoffice.mirrors.pair.com/stable/2.0.2/
URL_DIR += http://openoffice.mirrors.pair.com/stable/2.0.2/
URL_DIR += ftp://openofficeorg.secsup.org/pub/software/openoffice/stable/2.0.2/
URL_DIR += http://openofficeorg.secsup.org/stable/2.0.2/
URL_DIR += ftp://ftp.nctu.edu.tw/UNIX/OpenOffice/stable/2.0.2/
To understand how to write a more complex rule file we must first understand how Makepack work when it installs software.

How things work

Slackware package management

A slackware package is a gzipped tar archive with a file name on the form name-version-architecture-revision.tgz. As "-" is used as a separator in the file name the version, architecture or revision must not contain any "-". The name and only the name of the application may contain "-".

The gzipped tar archive contains a directory structure that is unpacked in the root directory by slackware package management tools like pkginstall. The archive may also contain a script, install/doinst.sh, that is run at the installation.

For each package that has been installed Slackware keeps a file in /var/log/packages. That file is named as the package, but without the .tgz extension. The log file is a text file containing information about which files belong to the package, the size of the package and a comment about the package. Makepack checks for the existence of such files to determine if a software has already been installed. If the same or another version of a software is already installed on the system Makepack will not overwrite that installation. To upgrade to another version of a software with makepack you will therefore first have to remove the old software with the Slackware tool removepkg.

Checkinstall

The conventional way of installing software from source is to download, configure, build and install the software with whatever mechanisms are supported by the software. The most common way of performing the installation step is to type "make install" which will copy some files to to different directories on your system. The drawback of installing software from source in this way is that the slackware package management tools will not know anything about the installed software.

Checkinstall is a software which traces the installation process. After running an installation through checkinstall 3 things has happened:

The default name of the package created by checkinstall is determined by the directory in which checkinstall is run. The name of this directory should be like the beginning of the package file name, so it will be on the form name-version.

GNU make

Makepack is completely written as a set of Makefiles. This means that Makepack is run by calling make with different options. If you want to assign variables in your rule files in an advanced way it might be a good idea to read the GNU make manual.

The steps of Makepack

To understand the steps of Makepack you should first be familiar with the usage and the configuration of Makepack

Downloading a source package

The target for this step is to create the file $(SOURCE_DIR)/$(SRC_PKG).

A well behaved source package should have a file name on the form name-version.extension. The downloaded source package shall be placed in the $(SOURCE_DIR) directory. For makepack to work it is assumed that the source package is on the form name-version.extension. This is because makepack uses the source package name together with the $(ARCH) variable and a variable called $(PKG_RELEASE) to name the Slackware package and the file in /var/log/packages. You have already seen that the package name is set in SRC_PKG and that it can be downloaded when makepack is pointed to a server with URL_DIR, but what if the source package on the server has a file name that isn't well behaved? The solution for makepack is to rename the file to a well behaved name after the file has been downloaded. Instead of downloading SRC_PKG from URL_DIR a file ORG_PKG is downloaded and renamed to SRC_PKG. An example is shown in the rule for pdnsd:
DESCRIPTION = a proxy DNS server with permanent caching
SRC_PKG = pdnsd-1.2.4.tar.gz
ORG_PKG = pdnsd-1.2.4-par.tar.gz

URL_DIR += http://www.phys.uu.nl/~rombouts/pdnsd/releases/

URL_DIR can be used to list a lot of servers hosting the source package as shown in the openoffice.org example. The advantages of listing many servers in URL_DIR are that different users will download from different servers as makepack allways makes sure that a source package is downloaded from the nearest server. Many servers are also good for redundancy if any servers would be down when someone wants to download the source package. SourceForge hosts many software projects and instead of listing a lot of URL_DIR pointing to SourceForge mirrors it is possible to use the SF_DIR variable. The same applies also to CPAN_DIR for Perl packages hosted on CPAN mirrors. The SF_DIR should be set to the name of the SourceForge project as in the example of lame:
DESCRIPTION = LAME is an LGPL MP3 encoder.
SRC_PKG = lame-3.96.1.tar.gz

SF_DIR = lame

The CPAN_DIR should be set to the category directory below the directory modules/by-module on CPAN mirrors, below is the example rule Archive-Zip:
DESCRIPTION = Archive::Zip Perl module
SRC_PKG = Archive-Zip-1.16.tar.gz
CPAN_DIR = Archive

DEPS = Compress-Zlib

Sometimes it is necessary to download more than one source package to compile a single piece of software. If any extra source packages are needed that shouldn't be installed by themselves they shouldn't be listed as DEPS but as DEPS_DOWNLOAD_ONLY. Also for each such package a rule file is needed. If the software can't be compiled and installed by itself the rule file should not be in $(RULE_DIR) but in $(RULE_DL_ONLY_DIR). All downloaded files are placed in $(SOURCE_DIR) regardless of if the rule file is in $(RULE_DIR) or $(RULE_DL_ONLY_DIR). An example of a software that needs more than one file to be downloaded is xrmap:
DESCRIPTION = Vector world map program with CIA World data bank II
SRC_PKG = xrmap-2.33.1.tar.bz2

# We don't want paths like /usr/local/X11R6/bin...
CONFIGURE_METHOD = mv Imakefile Imakefile.org && \
                   sed -e 's/DESTDIR=\/usr/DESTDIR=$(subst /,\/,$(PREFIX))/' \
                     Imakefile.org > Imakefile.tmp1 && \
                   sed -e 's/=\/X11R6/=/' \
                     Imakefile.tmp1 > Imakefile.tmp2 && \
                   sed -e 's/X11\///' \
                     Imakefile.tmp2 > Imakefile.tmp3 && \
                   sed -e 's/$$(SHAREDIR)\/editkit//' \
                     Imakefile.tmp3 > Imakefile.tmp4 && \
                   sed -e 's/$$(SHAREDIR)\"\/editkit/"/' \
                     Imakefile.tmp4 > Imakefile && \
                   cd editkit && \
                   mv Imakefile Imakefile.org && \
                   sed -e 's/DESTDIR=\/usr/DESTDIR=$(subst /,\/,$(PREFIX))/' \
                     Imakefile.org > Imakefile.tmp1 && \
                   sed -e 's/=\/X11R6/=/' \
                     Imakefile.tmp1 > Imakefile.tmp2 && \
                   sed -e 's/X11\///' \
                     Imakefile.tmp2 > Imakefile && \
                   cd ../earthview && \
                   mv Makefile Makefile.org && \
                   sed -e 's/X11R6\/bin/bin/' Makefile.org > Makefile && \
                   cd .. && \
                   xmkmf

INSTALL_METHOD = make install && \
cd ../.. && \
tar -C $(PREFIX)/share/rmap -xjvf $(SOURCE_DIR)/anthems-1.2.tar.bz2 && \
tar -C $(PREFIX)/share/rmap -xjvf $(SOURCE_DIR)/earthdata_high_res.tar.bz2 && \
tar -C $(PREFIX)/share/rmap -xjvf $(SOURCE_DIR)/eawpats12.tar.bz2 && \
tar -C $(PREFIX)/share/rmap -xjvf $(SOURCE_DIR)/flags-2.9-eps.tar.bz2 && \
tar -C $(PREFIX)/share/rmap -xjvf $(SOURCE_DIR)/factbook_html_2006.tar.bz2 && \
tar -C $(PREFIX)/share/rmap -xjvf $(SOURCE_DIR)/factbook_text_2006.tar.bz2 && \
tar -C $(PREFIX)/share/rmap -xjvf $(SOURCE_DIR)/hymns-1.3.tar.bz2 && \
tar -C $(PREFIX)/share/rmap -xjvf $(SOURCE_DIR)/pdfmaps-1.3.tar.bz2 && \
bzcat $(SOURCE_DIR)/CIA_WDB2.jpd.bz2 > $(PREFIX)/share/rmap/CIA_WDB2.jpd && \
bzcat $(SOURCE_DIR)/population.dat.bz2 > \
      $(PREFIX)/share/rmap/earthdata/population/population.dat

DEPS += TiMidity++ dillo

DEPS_DOWNLOAD_ONLY += CIA_WDB2 anthems hymns earthdata population eawpats
DEPS_DOWNLOAD_ONLY += flags factbook_html factbook_text pdfmaps

URL_DIR += ftp://ftp.ac-grenoble.fr/ge/geosciences/xrmap/
# URL_DIR += http://frmas.free.fr/files/

We have now seen that it is possible to download source packages from ftp and web servers. But what if there is no such premade source package? It is possible to customize the download by specifying DOWNLOAD_METHOD. The following example shows how cvs was used to get ffmpeg when ffmpeg was hosted on the mplayer cvs server.
DESCRIPTION = programs and libs to record, convert and stream audio and video.

FILE_TAG = 0.4.9.pre1
CVS_TAG = release_0_4_9_pre1

SRC_PKG = ffmpeg-$(FILE_TAG).tar.gz

DEPS += lzo

DOWNLOAD_METHOD = cd $(SOURCE_DIR) && \
                  cvs -z9 -d:pserver:anonymous@mplayerhq.hu:/cvsroot/ffmpeg \
                  checkout -r $(CVS_TAG) ffmpeg && \
                  mv ffmpeg ffmpeg-$(FILE_TAG) && \
                  tar -czvf $(SRC_PKG) ffmpeg-$(FILE_TAG) && \
                  $(RM) -r ffmpeg-$(FILE_TAG)

CONFIGURE_METHOD = ./configure --prefix=$(PREFIX) --enable-gpl \
                   --enable-a52 --enable-pp --enable-shared-pp \
                   --enable-pthreads

BUILD_METHOD = make && cd libavcodec/libpostproc && make

INSTALL_METHOD = make install && make installlib && \
                 cd libavcodec/libpostproc && make install

The final and optional step after a source package has been downloaded is to check if the downloaded file is correct by calculating a checksum. This will be done if the MD5SUM variable is set. This variable should be set if the software maintainer has provided a checksum. If the checksum calculation fails makepack will try to download the source package from another server. An example of a rule file with an MD5SUM is flac:
DESCRIPTION = library for Free Lossless Audio Codec
SRC_PKG = flac-1.1.2.tar.gz

MD5SUM = 2bfc127cdda02834d0491ab531a20960

URL_DIR += http://downloads.xiph.org/releases/flac/

Unpacking a source package

The target for this step is to create the directory $(BUILD_DIR)/name-version where name-version is the same as $(SRC_PKG) but without the extension that describes how the source package was archived and compressed.

Makepack knows how to unpack most archive files like .tgz, .tar.gz, .tar.bz2, .tar and .zip and well behaved software usually are delivered in an archive which when unpacked is placed in a directory structure below a top level directory named on the form name-version. However, if the top level directory is named in another way makepack needs to know about this and that is what the ORG_DIR variable is for. An example of a rule file using the ORG_DIR variable is mpeg2dec:
DESCRIPTION = MPEG-2 video stream decoder
SRC_PKG = mpeg2dec-0.4.0b.tar.gz

ORG_DIR = mpeg2dec-0.4.0

URL_DIR = http://libmpeg2.sourceforge.net/files
As the source package for mpeg2dec is called mpeg2dec-0.4.0b.tar.gz makepack expects the top level directory to be named mpeg2dec-0.4.0b. However, the file mpeg2dec-0.4.0b.tar.gz contains the top level directory mpeg2dec-0.4.0, so ORG_DIR is used to tell makepack to rename mpeg2dec-0.4.0 to mpeg2dec-0.4.0b after the archive has been unpacked.

It is also possible to specify a custom way of unpacking the source package by setting the variable UNPACK_METHOD. This has already been shown in the big example for openoffice.org which needs more than one source package. Older versions of makepack didn't have support for the ORG_DIR variable, so then it was also necessary to specify an UNPACK_METHOD for those cases. An example using UNPACK_METHOD where ORG_DIR would be a better solution is bio2jack:
DESCRIPTION = A lib for simple porting of OSS/ALSA audio applications to Jack.

# Version 0.8 seems to have broken comability with MPlayer 1.0pre7try2
# SRC_PKG = bio2jack-0.8.tar.gz

SRC_PKG = bio2jack-0.7.tar.gz
DEPS += jack-audio-connection-kit
DEPS += libsamplerate

UNPACK_METHOD = cd $(@D) && tar -xzvf ../$< && mv bio2jack $(@F)

SF_DIR = bio2jack

Configuring before build

This step doesn't have any visible target for makepack as different software do different things during this step. Some software doesn't need to be configured at all before it is built.

Makepack knows about the standard ways to configure before build. These standard ways are:

Makepack will apply one of the configure methods above if it finds a file named configure, Makefile.PL or setup.py.

Sometimes it is necessary to give some extra flags to configure. This is done by adding those flags to the variable CONFIGURE_FLAGS which by default is set to --prefix=$(PREFIX). An example of a rule using this is sylpheed:
DESCRIPTION = A lightweight but featureful, and easy-to-use e-mail client
SRC_PKG = sylpheed-2.2.6.tar.bz2
CONFIGURE_FLAGS += --enable-ldap

DEPS += gpgme gtkspell compface

URL_DIR += http://sylpheed.good-day.net/sylpheed/v2.2/



# sylpheed-claws does not seem to mirror version 2.2.6
# SF_DIR = sylpheed-claws

Most configure scripts uses the environment variable CFLAGS which has been set by makepack to give optimization flags for the compiler depending on ARCH. If for some reason those optimization flags can't be used for a software the CFLAGS environment variable has to be unset. An example of such a rule is numpy:
DESCRIPTION = Python package for scientific computing
SRC_PKG = numpy-0.9.2.tar.gz

# This package is unable to handle some optimizations...
unexport CFLAGS

DEPS += atlas

SF_DIR = numpy

It is possible to customize the configuration step by specifying a CONFIGURE_METHOD, this is used by the rule for SOAP-Lite:
DESCRIPTION = Perl module to access the SOAP based CWS webservice
SRC_PKG = SOAP-Lite-0.67.tar.gz
CPAN_DIR = SOAP

DEPS += Crypt-SSLeay

# We don't want to answer any questions
CONFIGURE_METHOD = yes | perl Makefile.PL

After configuration most software writes a summary of the result. During development of a rule file it can be useful to temporary set BUILD_METHOD to false to avoid that the compilation produces output that causes this summary of the configuration to scroll away.

Building software

Like the configure step, this step doesn't have any visible target for makepack as different software do different things during the build step.

Makepack knows about two standard ways to build software. These standard ways are:

Makepack will run make if it finds a file called Makefile or makefile. "python setup.py build" will be done if makepack finds a file named setup.py.

It is possible to customize the build step by specifying a BUILD_METHOD, this is shown with the rule file for smpeg as an example:
DESCRIPTION = SDL MPEG Player Library
SRC_PKG = smpeg-0.4.4.tar.gz

URL_DIR += ftp://sunsite.dk/pub/os/linux/loki/open-source/smpeg/

# smpeg fails to build unless g++ is pointed out.
BUILD_METHOD = make CC=g++

Installing software

The target for this step is a file /var/log/packages/name-version-architecture-revision. The name-version part of the filename is taken from the directory that has been created below $(BUILD_DIR) in the unpack step. The architecture part is taken from $(ARCH) which can be set in Settings.mk or taken from an environment variable. The revision part of the filename is taken from $(PKG_RELEASE) which is set in Settings.mk.

During installation, makepack creates a Slackware package in $(PACKAGE_DIR). If such a package already exists the software doesn't have to be compiled again, but can be installed with "sudo installpkg $(PACKAGE_DIR)/name-version-architecture-revision.tgz".

The installation step is run within sudo checkinstall to also create the Slackware package. Makepack knows about two standard ways to install software. These standard ways are:

Makepack will run "make install" if it finds a file called Makefile or makefile. "python setup.py build" will be done if makepack finds a file named setup.py.

Checkinstall will trace all files that have been added or changed during installation and add those files to the Slackware package created. Sometimes you don't want all the changed files to be added to the package, this can be accomplished with the variable REMOVE_FROM_PACKAGE. Sometimes you might want to run a command after package installation, this can be accomplished with the variable DOINST_SH_COMMAND. One such example is when installing kernel modules. This modifies the files /lib/modules/*/modules.* but you don't want to add those files to the slackware package as it would break things when installed on another box with other modules installed. Instead, when installing modules you want to run depmod. The example with kqemu shows how this is done:
DESCRIPTION = Kernel module which accelerates qemu
SRC_PKG = kqemu-1.3.0pre7.tar.gz

BUILD_METHOD = make || \
( echo *** Error! *** && \
  echo The build of kqemu requires that you have a compiled Linux && \
  echo source tree at /usr/src/linux && \
  echo Copy the right config file like this: && \
  echo cp /boot/config /usr/src/linux/.config && \
  echo and run "make bzImage" as root in /usr/src/linux && \
  false )

DOINST_SH_COMMAND = chroot . /sbin/depmod -a
REMOVE_FROM_PACKAGE = lib/modules/*/modules.*

URL_DIR += http://www.qemu.org/

As Makepack uses checkinstall to create Slackware packages it is also possible to give arguments to checkinstall. This is done by adding arguments to the variable CHECKINSTALL_FLAGS. One such example would be:

CHECKINSTALL_FLAGS += --strip=no
This feature has not been used in any rule file yet at the time of this writing.

As you might have guessed by now, it is possible to customize the install step by specifying an INSTALL_METHOD. This is shown with the rule file for nas:
DESCRIPTION = The Network Audio System, the audio equivalent of an X server.
 
ORG_PKG = nas-1.7.src.tar.gz
SRC_PKG = nas-1.7.tar.gz

CONFIGURE_METHOD = xmkmf
BUILD_METHOD = make World
INSTALL_METHOD = make install && make install.man

URL_DIR += http://nas.codebrilliance.com/nas

Variable reference

Variables that can be set by rule files

VariableDescription
DESCRIPTION This should be a short description of the software. It will be shown when doing "make list" and it will also be added to the log file in /var/log/packages.
DEPS Other software packages that need to be installed before this software will be possible to unpack, configure, build and install. Rules for these dependencies will be searched for in RULE_DIR.
DEPS_DOWNLOAD_ONLY Other software packages that need to be downloaded, but not necessary installed, before this software will be possible to unpack, configure, build and install. Rules for these dependencies will be searched for in RULE_DIR and RULE_DL_ONLY_DIR.
SRC_PKG This is the name of the source package.
ORG_PKG This is a bad name of a source package before it has been downloaded and renamed.
URL_DIRThis is where on the internet the source package can be found. The URL_DIR can contain more than one URL, Makepack will automatically find out which server is the nearest one and downloade the source package from the nearest server.
SF_DIR SF_DIR can be used instead of or together with URL_DIR. SF_DIR should be set to the SourceForge project name to download from SourceForge mirrors.
CPAN_DIR CPAN_DIR can be used instead of or together with URL_DIR. CPAN_DIR should be set to the category directory below the directory modules/by-module on CPAN mirrors.
DOWNLOAD_METHOD Allows specifying of a custom way to download the source package.
UNPACK_METHOD Allows specifying of a custom way to unpack the source package.
CONFIGURE_METHOD Allows specifying of a custom way to configure the software.
BUILD_METHOD Allows specifying of a custom way to build the software.
INSTALL_METHOD Allows specifying of a custom way to install the software.
MD5SUM Can optionally be used to check the downloaded file.
ORG_DIR Needs to be set if the source package isn't unpacked in a top level directory with the right name.
CONFIGURE_FLAGS Arguments for the configure command.
REMOVE_FROM_PACKAGE Can be used to Specify files which shouldn't be included in the created Slackware package.
DOINST_SH_COMMAND Can be used to specify a command which should be run when the created Slackware package is installed. However, this command will not be run during the creation of the package if it isn't done by the standard or specified INSTALL_METHOD.

Variables that are set before a rule file is run

VariableDescription
RULE_DIR Directory containing rule files for software that can be installed.
RULE_DL_ONLY_DIR Directory containing rule files for source packages that shouldn't be installed by themselves but only are needed together with another rule file.
SOURCE_DIR Directory where downloaded source packages are placed.
BUILD_DIR Temporary directory where applications are unpacked, configured and built.
PACKAGE_DIR Directory where created Slackware packages are placed.
CFLAGS Optimization flags for C compiler. Some software will require this variable to be unexported.