<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 11. A Ported Application</title><meta name="generator" content="DocBook XSL Stylesheets V1.71.1"><link rel="start" href="index.html" title="A-A-P Recipe Executive"><link rel="up" href="tutorial.html" title="Part I. Tutorial"><link rel="prev" href="tutor-pipe.html" title="Chapter 10. Commands in a Pipe"><link rel="next" href="user.html" title="Part II. User Manual"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table width="100%" id="navtable"><tbody><tr><td align="left" class="left" width="33%"><b><a href="http://www.a-a-p.org">A-A-P home page</a></b></td><td align="center" class="center" width="34%"><b><a href="index.html">A-A-P Recipe Executive</a></b></td><td align="right" class="right" width="33%"></td></tr><tr><td align="left" class="left"><a accesskey="p" href="tutor-pipe.html">Prev</a></td><td align="center" class="center">Tutorial</td><td align="right" class="right"><a accesskey="n" href="user.html">Next</a></td></tr></tbody></table><hr><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="tutor-port"></a>Chapter 11. A Ported Application</h2></div></div></div><p> When an application already exists but for your system it requires a few tweaks, a port recipe can do the work. This can also be used for applications that work fine but you want to apply a number of patches or to add a feature. The recipe can be distributed, so that others can install the application without knowing the details. This works very much like the FreeBSD ports system. </p><p> This chapter is specifically for doing the port. If you are only interested in another kind of building you might want to skip this chapter. </p><h2><a name="id2632873"></a>The Port Recipe</h2><p> Since A-A-P is prepared for doing all the work, usually you only need to specify the relevant information, such as where to find the files involved. Here is an example: </p><pre class="programlisting"> 1 # A-A-P port recipe for Vim 6.1 plus a few patches. 2 RECIPEVERSION = 1.0 3 4 PORTNAME = vim 5 LASTPATCH = 003 6 PORTVERSION = 6.1.$LASTPATCH 7 MAINTAINER = Bram@vim.org 8 9 CATEGORIES = editors 10 PORTCOMMENT = Vim - Vi IMproved, the text editor 11 PORTDESCR << EOF 12 This is the description for the Vim package. 13 A very nice editor, backwards compatible to Vi. 14 You can find all info on http://www.vim.org. 15 EOF 16 17 :recipe {fetch = http://www.a-a-p.org/ports/vim/main.aap} 18 19 WRKSRC = vim61 20 BUILDCMD = make 21 TESTCMD = make test 22 INSTALLCMD = make install DESTDIR=$PKGDIR 23 PREFIX = /usr/local 24 25 MASTER_SITES ?= ftp://ftp.vim.org/pub/vim 26 ftp://ftp.us.vim.org/pub/vim 27 PATCH_SITES = $*MASTER_SITES/patches 28 29 DISTFILES = unix/vim-6.1.tar.bz2 30 31 version1 = `range(1, int(LASTPATCH) + 1)` 32 PATCHFILES = 6.1.00$*version1 33 34 #>>> automatically inserted by "aap makesum" <<< 35 do-checksum: 36 :checksum $DISTDIR/vim-6.1.tar.bz2 {md5 = 7fd0f915adc7c0dab89772884268b030} 37 :checksum $PATCHDISTDIR/6.1.001 {md5 = 97bdbe371953b9d25f006f8b58b53532} 38 :checksum $PATCHDISTDIR/6.1.002 {md5 = f56455248658f019dcf3e2a56a470080} 39 :checksum $PATCHDISTDIR/6.1.003 {md5 = 0e000edba66562473a5f1e9b5b269bb8} 40 #>>> end <<< </pre><p> Well, that is the longest example we have had so far. Let's go through it from top to bottom. </p><pre class="programlisting"> 1 # A-A-P port recipe for Vim 6.1 plus a few patches. 2 RECIPEVERSION = 1.0 </pre><p> <code class="literal">RECIPEVERSION</code> tells <span class="application">Aap</span> what version of <span class="application">Aap</span> this recipe was written for. If in the future the recipe format changes, this line causes <span class="application">Aap</span> to interpret it as <span class="application">Aap</span> version 1.0 would do. </p><pre class="programlisting"> 4 PORTNAME = vim </pre><p> Setting <code class="literal">PORTNAME</code> to the name of the port is what actually triggers <span class="application">Aap</span> to read this recipe as a port recipe. It makes the other settings to be used to set up a whole range of targets and build commands. The result is that you can do <strong class="userinput"><code>aap install</code></strong> to install the application, for example. Note that <code class="literal">PORTNAME</code> does not include the version number. </p><pre class="programlisting"> 5 LASTPATCH = 003 6 PORTVERSION = 6.1.$LASTPATCH 7 MAINTAINER = Bram@vim.org 8 9 CATEGORIES = editors 10 PORTCOMMENT = Vim - Vi IMproved, the text editor 11 PORTDESCR << EOF 12 This is the description for the Vim package. 13 A very nice editor, backwards compatible to Vi. 14 You can find all info on http://www.vim.org. 15 EOF </pre><p> In lines 5 to 15 a number of informative items about the port are specified. These are used in various places. <code class="literal">LASTPATCH</code> is not a standard item, it is used here to only have to define the patchlevel in one place. </p><pre class="programlisting"> 17 :recipe {fetch = http://www.a-a-p.org/ports/vim/main.aap} </pre><p> The <code class="computeroutput">:recipe</code> command specifies where to obtain the recipe itself from. We have seen this before, nothing special here. </p><pre class="programlisting"> 19 WRKSRC = vim61 20 BUILDCMD = make 21 TESTCMD = make test </pre><p> The assignments in lines 19 to 21 specify how building is to be done. <code class="literal">WRKSRC</code> is the directory below which the source files are unpacked. The default is "$PORTNAME-$PORTVERSION". The archive used for Vim uses "vim61" instead, thus this needs to be specified. The "CMD" variables set the commands to be used to build the application. The default is to use <span class="application">Aap</span>. Since Vim uses "make" this needs to be specified. </p><pre class="programlisting"> 22 INSTALLCMD = make install DESTDIR=$PKGDIR 23 PREFIX = /usr/local </pre><p> Installing a port is done by creating a binary package and installing that package. This makes it possible to copy the package to another system and install it there without the need to compile from sources. Lines 22 and 23 specify how to do a "fake install" with Vim. This copies all the files that are to be installed to a specific directory, so that it is easy to include them in the package. <code class="literal">PREFIX</code> specifies below which directory Vim installs its files. </p><pre class="programlisting"> 25 MASTER_SITES ?= ftp://ftp.vim.org/pub/vim 26 ftp://ftp.us.vim.org/pub/vim 27 PATCH_SITES = $*MASTER_SITES/patches </pre><p> <code class="literal">MASTER_SITES</code> and <code class="literal">PATCH_SITES</code> specify the sites where the Vim files can be downloaded from. The first is for the archives, the second for the patches. Note the use of "$*" in line 27, this causes "/patches" to be appended to each item in <code class="literal">MASTER_SITES</code> instead of appending it once at the end of the whole list. </p><pre class="programlisting"> 29 DISTFILES = unix/vim-6.1.tar.bz2 </pre><p> <code class="literal">DISTFILES</code> is set to the name of the archive to download. This is appended to items in <code class="literal">MASTER_SITES</code> to form the URL. </p><pre class="programlisting"> 31 version1 = `range(1, int(LASTPATCH) + 1)` 32 PATCHFILES = 6.1.00$*version1 </pre><p> Lines 32 and 33 specify the list of patch file names. The Python function "range()" is used, this returns a list of numbers in the specified range (up to and excluding the upper number). Note the user of "int()" to turn the patch number in <code class="literal">LASTPATCH</code> into an int type, all <span class="application">Aap</span> variables are strings. </p><p> for three patch files this could also have been typed, but when the number of patches grows this mechanism is easier. The example only works up to patch number 009. To make it work for numbers from 100 up to 999: </p><pre class="programlisting"> version1 = `range(1, 10)` version2 = `range(10, 100)` version3 = `range(100, int(LASTPATCH) + 1)` PATCHFILES = 6.1.00$*version1 6.1.0$*version2 6.1.$*version3 </pre><p> </p><pre class="programlisting"> 34 #>>> automatically inserted by "aap makesum" <<< 35 do-checksum: 36 :checksum $DISTDIR/vim-6.1.tar.bz2 {md5 = 7fd0f915adc7c0dab89772884268b030} 37 :checksum $PATCHDISTDIR/6.1.001 {md5 = 97bdbe371953b9d25f006f8b58b53532} 38 :checksum $PATCHDISTDIR/6.1.002 {md5 = f56455248658f019dcf3e2a56a470080} 39 :checksum $PATCHDISTDIR/6.1.003 {md5 = 0e000edba66562473a5f1e9b5b269bb8} 40 #>>> end <<< </pre><p> Finally the "do-checksum" target is defined. This part was not typed, but added to the recipe with <strong class="userinput"><code>aap makesum</code></strong>. This is done by the port recipe maintainer, when he has verified that the files are correct. When a user later uses the recipe <span class="application">Aap</span> will check that the checksums match, so that problems with downloading or a cracked distribution file are found and reported. </p><h2><a name="id2634755"></a>Using CVS</h2><p> The port recipe specifies which source files and patches to download, thus it has to be adjusted for each version. This is good for a stable release, but when you are releasing a new version every day it is a lot of work. Another method is possible when the files are available from a CVS server. Adding these lines to the recipe will do it: </p><pre class="programlisting"> CVSROOT ?= :pserver:anonymous@vim.cvs.sf.net:/cvsroot/vim CVSMODULES = vim CVSTAG = vim-6-1-$LASTPATCH </pre><p> The first line specifies the cvsroot to use. This is specific for the cvs program. <code class="literal">CVSMODULES</code> is the name of the module to checkout. Mostly it is just one name, but you can specify several. Specifying <code class="literal">CVSTAG</code> is optional. If it is defined, like here, a specific version of the application is obtained. When it is omitted the latest version is obtained. </p><p> Much more about the port recipe can be found in <a href="user-porting.html" title="Chapter 22. Porting an Application">Chapter 22, <i>Porting an Application</i></a>. </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="tutor-pipe.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="tutorial.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="user.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 10. Commands in a Pipe </td><td width="20%" align="center"><a accesskey="h" href="index.html"> Contents</a></td><td width="40%" align="right" valign="top"> Part II. User Manual</td></tr></table></div></body></html>