Added by Eric Lake, last edited by Eric Lake on Sep 27, 2008  (view change)

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

The intent of this page is to show how to create a package. The assumption is that your build environment have been created using the examples on HOWTO setup a Foresight 2.x build environment.

In this example we will work with a user named John Doe who has set up his build environment to use /home/jdoe/conary/jdoe so he can build for his personal repository. John wants to build a package for the boo programming language. The first thing we need to do is change to that directory

cd ~/conary/jdoe

What did I do with that recipe?

Now that we are in the directory we need to start the new package. Foresight has conary recipe templates that help make things a lot easier to get started. For typical source packages that just need ./configure; make; make install you can use the "foresight" template and then customize from there.

cvc newpkg boo --template foresight

So what did this do for us? It created a boo directory in our ~/conary/jdoe with a CONARY file and a recipe to get us started. If we change to that directory then we should see:

[jdoe@localhost jdoe]$ cd boo
[jjdoe@localhost boo]$ ls
boo.recipe  CONARY

If we take a look at the boo.recipe file we will see this

#
# Copyright (c) 2008 Foresight Linux
# This file is distributed under the terms of the MIT License.
# A copy is available at http://www.rpath.com/permanent/mit-license.html
#

class Boo(AutoPackageRecipe):
    name = 'boo'
    version = ''
 
    buildRequires = []
 
    def unpack(r):
        r.addArchive('mirror://sourceforge/boo/')

This has done a lot of work for us. It has created a shell for us to fill and added the copyright header. The items that we need to fill in for this package are version and r.addArchive. The boo language is found at http://dist.codehaus.org/boo/distributions/ and the current version as of the writing of this guide is 0.8.2.2960. Conary is smart enough (most of the time) to add the boo-0.8.2.2960.tar.gz to the end of the url and it reads this from the name and verison variables. So once we make the edits to the file in our favorite editor it will look like this.

#
# Copyright (c) 2008 Foresight Linux
# This file is distributed under the terms of the MIT License.
# A copy is available at http://www.rpath.com/permanent/mit-license.html
#

class Boo(AutoPackageRecipe):
    name = 'boo'
    version = '0.8.2.2960'
 
    buildRequires = []
 
    def unpack(r):
        r.addArchive('http://dist.codehaus.org/boo/distributions/')
What about the buildRequires thing?

For now we will leave the buildRequires part blank because the next step will tell us what to put in there.

Let's get to cooking

Now that we have our recipe in place and looking good lets "cook" it.

cvc cook boo.recipe

This will start the download process for the archive and then unpack it. Once that is done since we are using class Boo(AutoPackageRecipe): the cook process will run "./configure; make; make install" on the source. Assuming that you have all of the dependencies for the application you are packaging installed it should go smoothly. Once the cook is complete it should say something like this:

...
warning: Suggested buildRequires additions: ['mono:cil', 'mono:devel', 'mono:runtime', 'pkgconfig:devel', 'shared-mime-info:config']
+ looking up pathids from repository history
+ pathId lookup complete
Created component: boo:cil /jdoe@fl:2-devel//local@local:COOK/0.8.2.2960-1-0.1 is: x86_64
Created component: boo:data /jdoe@fl:2-devel//local@local:COOK/0.8.2.2960-1-0.1 is: x86_64
Created component: boo:debuginfo /jdoe@fl:2-devel//local@local:COOK/0.8.2.2960-1-0.1 is: x86_64
Created component: boo:devellib /jdoe@fl:2-devel//local@local:COOK/0.8.2.2960-1-0.1 is: x86_64
Created component: boo:lib /jdoe@fl:2-devel//local@local:COOK/0.8.2.2960-1-0.1 is: x86_64
Created component: boo:runtime /jdoe@fl:2-devel//local@local:COOK/0.8.2.2960-1-0.1 is: x86_64




Created component: boo:supdoc /jdoe@fl:2-devel//local@local:COOK/0.8.2.2960-1-0.1 is: x86_64
Changeset written to: boo-0.8.2.2960.ccs

It looks like everything worked fine and it created the installable boo-0.8.2.2960.ccs changeset. But what is that warning there in the output? That is conary telling us that we need to add some stuff to our recipe so that when we use rmake to build the binaries it will have everything it needs for the chroot. So lets add this to the recipe and see what it looks like now.

#
# Copyright (c) 2008 Foresight Linux
# This file is distributed under the terms of the MIT License.
# A copy is available at http://www.rpath.com/permanent/mit-license.html
#

class Boo(AutoPackageRecipe):
    name = 'boo'
    version = '0.8.2.2960'
 
    buildRequires = ['mono:cil', 'mono:devel', 'mono:runtime', 
        'pkgconfig:devel', 'shared-mime-info:config']
 
    def unpack(r):
        r.addArchive('http://dist.codehaus.org/boo/distributions/')

If we run it through another cook we should see that line gone now. Now we are ready to test our package.

sudo conary update boo-0.8.2.2960.ccs

Test the app to make sure that it works as expected and nothing is missing. If that is the case we can move on to the rmake process.

Done with the cooking now on to the baking

By using rmake to build a package we have a level of confidence that it will work on everyone's systems. This is because it is built in a chroot environment with the minimal packages needed (hence the buildRequires part of the recipe). John has a 64bit computer and so he will be building boo for both 64bit and 32bit in one command. If you only have 32bit then we will have to change the command slightly.

Again, we are assuming that you followed the guide on setting up the build environment and that you used the context of jdoe for the ~/conary/jdoe directory.

This command tells rmake to build the package for 32bit (x86) and 64bit (x86_64) systems.

rmake build --context jdoe boo.recipe{x86} boo.recipe{x86_64}

Once the build completes you should see something like this

[16:08:57] [26] - boo:source - State: Built
[16:08:58] [26] - State: Built
[16:08:58] [26] - build job finished successfully

This output shows us the time we ran the build, the rmake job number, and the outcome. Another command you can use to verify the build is "rmake q <job_number>". So in this case we would run:

[jdoe@localhost boo]$ rmake q 26
26    Built                     2 minutes ago
      (2 troves) boo, boo

We have 2 troves because we did the build with both architectures. If you only have a 32bit system then use the following command to run the build.

rmake build --context jdoe boo.recipe{x86}

Commit that build dude

Since everything went as planned and the package is good we can now commit it to the jdoe repository. To do that we run a command like 'rmake ci <job_number> -m "a commit message"'. So when we do it for real it should all look like this:

[jdoe@localhost boo]$ rmake ci 26 -m "initial commit of the boo package"
                                                                    
Committed job 26:
    boo:source=/jdoe.rpath.org@fl:2-devel//localhost@local:2-devel/0.8.2.2960-0.3[is: x86(~cmov,~i486,~i586,~i686,~mmx,~nx,~sse,~sse2)]{x86} ->
       boo=/jdoe.rpath.org@fl:2-devel/0.8.2.2960-1-1[is: x86]

    boo:source=/jdoe.rpath.org@fl:2-devel//localhost@local:2-devel/0.8.2.2960-0.3[is: x86_64(~3dnow,~3dnowext,~nx)]{x86_64} ->
       boo=/jdoe.rpath.org@fl:2-devel/0.8.2.2960-1-1[is: x86_64]
       boo:source=/jdoe.rpath.org@fl:2-devel/0.8.2.2960-1[]


+ Replacing CONARY file /home/jdoe/conary/jdoe/boo after initial commit

Where to look for more information

So now you have built your first package and want to know where to get some more information to help you build even more. Here are just a few places where you can get help.