packaging2

Ubuntu Open Week - Packaging 101 - Jordan Mantha - Wed, Apr 25, 2007

see also Monday Session.

TZ UTC-4

(12:04:10 PM) LaserJock: OK, first of all, thanks for coming everybody!
(12:04:28 PM) LaserJock: This is what makes the Ubuntu community and Linux/Open source fun
(12:04:57 PM) LaserJock: My name is Jordan Mantha and I'm a volunteer developer
(12:05:06 PM) LaserJock: and a PhD student in Physical Chemistry
(12:05:24 PM) LaserJock: today we're going to try to do a whirlwind intro to packaging for Ubuntu
(12:05:41 PM) LaserJock: Monday's session had tons of great questions
(12:05:54 PM) LaserJock: but we didn't have a chance to do much actual packaging stuff
(12:06:07 PM) LaserJock: so today I'm going to try to do a little more
(12:06:32 PM) LaserJock: First thing I'm going to have us do is set up a working package development system:
(12:06:46 PM) LaserJock: sudo apt-get install devscripts debhelper dpatch cdbs dh-make patchutils fakeroot lintian pbuilder
(12:07:32 PM) LaserJock: These packages have all kinds of useful tools.
(12:07:39 PM) LaserJock: pbuilder is the only one that takes a bit to set up so I've tweaked a build script that comes with it to work with Ubuntu. first, grab it:
(12:07:50 PM) LaserJock: wget http://tiber.tauware.de/~laserjock/pbuilder-ubuntu
(12:08:04 PM) LaserJock: then you need to rename it to pbuilder-<release you want> (like feisty or edgy) and put it somewhere in your PATH. You can copy the script to pbuilder-<another Ubuntu release> and it'll be ready to go.
(12:08:41 PM) LaserJock: Now a pbuilder is a minimal Ubuntu install built in a chroot environment. What it allows us to do is build the binary packages (.deb) from the source package without having to install all the build dependencies on our machine.
(12:08:55 PM) LaserJock: It also help make sure the build dependencies declared in the source package are correct, as the pbuilder environment has only a minimal set of packages installed.
(12:09:09 PM) LaserJock: So, lets create a feisty pbuilder:
(12:09:23 PM) LaserJock: make sure to have a pbuilder-feisty script in you path and then run
(12:09:31 PM) LaserJock: pbuilder-feisty create
(12:11:06 PM) LaserJock: I can't really go into detail with all those tools, you can read more in the Ubuntu Packaging Guide
(12:11:15 PM) LaserJock: http://doc.ubuntu.com/ubuntu/packagingguide/C/index.html
(12:12:15 PM) LaserJock: if you're running dapper or edgy and it complains about making a feisty chroot go ahead an make a dapper or edgy one
(12:13:38 PM) LaserJock: WARNING: pbuilder takes a fair amount of bandwidth and time, if you're on dialup or impatient just skip this step :-)
(12:14:00 PM) LaserJock: you should be able to create a feisty pbuilder on dapper or edgy (that's the fun of pbuilder)
(12:14:44 PM) LaserJock: ok, while that's all going lets move on

<rafaelmf> QUESTION: fakeroot is the best way for packaging works(and do packages) without high level tool, such as pbuilder or dpkg-deb...?

  • I strongly recommend you use a pbuilder environment. you *can* use dpkg-buildpackage but it is messy for your system and can cause some problems in the source package sometimes

<ranf> LaserJock, QUESTION does it work for gutsy too?

  • I don't think so yet. we need a version of debootstrap that contains scripts for gutsy. usually that's done fairly soon after the repos open. in the mean time you can actually dist-upgrade a feisty pbuilder

<habeeb> QUESTION: Will there be a repeat or something of this session? Because I'm not on Ubuntu right now, and I would like to try it out, ask questions etc.

<Loic> QUESTION: how can we use a pbuilder environment to build *and* test packages for gusty while using feisty (i.e. without having to install gusty)? How do we switch between feisty to gusty and vice-versa using pbuild?

  • well, for pbuilder you just need to copy that script I gave you to pbuilder-gutsy. then you can run either pbuilder-feisty or pbuilder-gutsy. as far as testing goes, I recommend a chroot

<brainsik> QUESTION: how can we get missing debootstrap scripts -- it seems on edgy I can't make a feisty pbuilder: http://paste.ubuntu-nl.org/17630/

  • you need to install the debootstrap .deb from feisty

<tuxmaniac> LaserJock, QUESTION: It says permission denied when I try to run pbuilder-feisty create

(12:24:36 PM) LaserJock: ok, let's move on
(12:24:43 PM) LaserJock: we've got very little time
(12:24:59 PM) LaserJock: Debian binary packages (.deb) are built from source packages (makes sense). A source package is actually made up of 3 different files:
(12:25:08 PM) LaserJock: 1. .dsc (description) file that holds md5sums of the other files
(12:25:17 PM) LaserJock: 2. .orig.tar.gz which is the source tarball as you would download it from the program's homepage
(12:25:26 PM) LaserJock: 3. .diff.gz that holds any changes we make to the .orig.tar.gz (including the packaging info)
(12:25:43 PM) LaserJock: Now packaging can be broken down into two different tasks, making the initial package, and maintaining the package(s).
(12:25:59 PM) LaserJock: we're going to try to touch on both briefly
(12:26:11 PM) LaserJock: first off, how do we make a source package from scratch
(12:26:41 PM) LaserJock: well, there is a fairly nice tool called dh_make for that
(12:27:04 PM) LaserJock: it gives you a bunch of template files to use
(12:27:18 PM) LaserJock: so let's make a source package, shall we? :-)
(12:27:36 PM) LaserJock: we're going to package the GNU hello program today
(12:28:19 PM) LaserJock: first off, let's make some working space:
(12:28:23 PM) LaserJock: mkdir ~/hello
(12:28:23 PM) LaserJock: cd ~/hello/
(12:28:45 PM) LaserJock: then we need to grab the source
(12:28:57 PM) LaserJock: and unpack it:
(12:28:58 PM) LaserJock: wget ftp://ftp.gnu.org/gnu/hello/hello-2.2.tar.gz
(12:28:58 PM) LaserJock: tar -xzf hello-2.2.tar.gz
(12:29:39 PM) LaserJock: now this is a typical Linux application source
(12:30:02 PM) LaserJock: but let's ubuntuize it ;-)
(12:30:05 PM) LaserJock: cd hello-2.2
(12:30:05 PM) LaserJock: dh_make -c gpl -e mantha@ubuntu.com -f ../hello-2.2.tar.gz
(12:30:20 PM) LaserJock: let me explain that dh_make line a little
(12:30:40 PM) LaserJock: the -c gpl tells dh_make that hello is licensed under the GPL
(12:30:54 PM) LaserJock: you really need to make sure that that's right
(12:31:05 PM) LaserJock: check the COPYING file in the source and the source files themselves
(12:31:27 PM) LaserJock: the -e flag tells dh_make the email address I want to use
(12:31:42 PM) LaserJock: and -f tells it what tarball to use for the source
(12:32:08 PM) LaserJock: dh_make has a set of predefined licenses
(12:32:20 PM) LaserJock: you can check them out by looking at man dh_make
(12:32:38 PM) LaserJock: if the app isn't licensed under one of those then leave -c blank and you'll fill it in later
(12:32:51 PM) LaserJock: ok, this is a single binary
(12:33:04 PM) LaserJock: you can have more than one .deb come from a source package
(12:33:18 PM) LaserJock: but in this case it is a simple app and we don't need to split it up
(12:33:36 PM) LaserJock: now, if everyone has got dh_make done lets have a look at what it did
(12:33:40 PM) LaserJock: cd debian/
(12:33:42 PM) LaserJock: ls
(12:34:08 PM) LaserJock: you will see many files. some with a .ex . These are various example files that you can use if needed. We don't need any of them so we're going to get rid of them.
(12:34:16 PM) babangipan left the room.
(12:34:26 PM) LaserJock: cd debian/
(12:34:26 PM) LaserJock: rm *.ex *.EX
(12:34:38 PM) LaserJock: in this case we also don't need dirs, docs, info, and README.Debian
(12:34:49 PM) LaserJock: rm dirs docs info README.Debian
(12:35:25 PM) LaserJock: so right now you should have 5 files
(12:35:28 PM) LaserJock: changelog  compat  control  copyright  rules
(12:35:47 PM) LaserJock: changelog should be fairly easy to get
(12:36:25 PM) LaserJock: for me I changed the top line to:
(12:36:27 PM) LaserJock: hello (2.2-0ubuntu1) feisty; urgency=low
(12:36:59 PM) LaserJock: that reflects an Ubuntu versioning and that I"m making the package for feisty
(12:37:25 PM) LaserJock: any questions?

<zorglu_> QUESTION: all the dh_* tools are usable, even if my apps doesnt uses autoconfig and co ?

  • I don't know that all of them are usable, but yes, they should still apply

<tuxmaniac> LaserJock, QUESTION: Any pointers to the Ubuntu versioning standard would help

  • ok, here's the general versioning scheme: <upstream version>-<debian revision>ubuntu<ubuntu revision>. so in this case 2.2-0ubuntu1 means: 2.2 is the upstream version; 0 is the debian revision, indicating that this package is not in Debian (which isn't true, btw ;-); and 1 is the ubuntu revision

<harrisony> can i make the urgency ZOMG? (/me translates as 'are there specifically set urgency levels?')

  • the urgency levels are specified in the Debian Policy, but aren't used in Ubuntu, so just leave them at what they are

<Monika|K> QUESTION: The version was 2.2-1, so why change it to 2.2-0 (2.2-0ubuntu1) and not 2.2-1ubuntu1?

  • well, because I'm illustrating what you do if it's never been packaged before, so it wouldn't be in Debian. I couldn't find an easy one that wasn't already in Debian. Wink ;-)

(12:42:51 PM) LaserJock: ok, let's move on to the other files
(12:43:00 PM) LaserJock: control is an important file
(12:43:19 PM) LaserJock: it's like the "vital facts" of the package
(12:43:36 PM) LaserJock: it has the version, maintainer, build dependencies, etc.
(12:44:08 PM) LaserJock: I don't have time to go into all the detail
(12:44:21 PM) LaserJock: I'll give you some references at the end
(12:44:47 PM) LaserJock: the only thing I changed was the Description:
(12:45:05 PM) LaserJock: Description: hello word program
(12:45:05 PM) LaserJock:  This on of those classic hello world program that every programming student
(12:45:05 PM) LaserJock:  knows and loves.
(12:45:05 PM) LaserJock:  .
(12:45:05 PM) LaserJock:  Homepage: http://www.gnu.org/software/hello/
(12:46:00 PM) LaserJock: notice the dependency on debhelper
(12:46:26 PM) LaserJock: debhelper is an awesome tool (which provides many dh_ tools)
(12:47:03 PM) LaserJock: the compat file in debian/ gives the version of debhelper we're using
(12:47:14 PM) LaserJock: in this case it simply contains "5"
(12:47:31 PM) LaserJock: copyright
(12:47:46 PM) LaserJock: ok, copyright is where I see a lot of problems
(12:48:22 PM) LaserJock: Open source software can often get quite messy when it comes to licenses
(12:48:41 PM) LaserJock: in Ubuntu we try to be very very attentive to licenses
(12:48:55 PM) LaserJock: we have to be sure we are legally able to distribute the software
(12:49:39 PM) LaserJock: sometimes a program's website will say the program is GPL, for instance, but then there will be files they got from another source that aren't GPL
(12:49:57 PM) LaserJock: the goal of the copyright file is to account for the license and copyright of *every* file in the source
(12:50:55 PM) LaserJock: ok, on to rules
(12:51:02 PM) LaserJock: rules is where all the fun happens
(12:51:12 PM) LaserJock: it's the file that gives the build instructions
(12:51:27 PM) LaserJock: it's a Makefile, which you might be familary with
(12:52:23 PM) LaserJock: I really can't go into detail but you can get a lot of info from just reading the man page for each of the dh_ commands you see in there
(12:53:04 PM) LaserJock: ok, let's build a source package out of it
(12:53:17 PM) LaserJock: I use debuild
(12:53:30 PM) LaserJock: which is a wrapper around dpkg-buildpackage -r fakeroot
(12:53:38 PM) LaserJock: I run:
(12:53:42 PM) LaserJock: debuild -S
(12:53:59 PM) LaserJock: the -S says to create a source package rather than binary
(12:54:26 PM) LaserJock: it will try to sign the package, so if you don't have a gpg key or it can't find it
(12:54:35 PM) LaserJock: run debuild -S -uc -us to turn off signing
(12:55:18 PM) LaserJock: if everything works right you should get some new files in ../../
(12:56:14 PM) LaserJock: ok, did everybody make it?
(12:56:43 PM) elkbuntu: <Monika|K> dpkg-source -b hello-2.2 failed :(
(12:57:12 PM) elkbuntu: you lost a couple i think
(12:57:35 PM) elkbuntu: LaserJock, there's a question, do you want it?
(12:57:35 PM) LaserJock: well, I'll deal with ones that didn't work after, ok?
(12:57:41 PM) LaserJock: elkbuntu: yes please

<Loic> QUESTION: Just to be sure I understood well : after I've used the script pbuilder-feisty, if I want to build a package for gutsy I just run pbuilder-gutsy without having to delete files installed by pbuilder-feisty, then just by putting feisty OR gutsy in the first line of debian/changelog everything will be taken care of?

  • you want to copy the pbuilder-feisty script to pbuilder-gutsy. then run pbuilder-gutsy create that will give you a gutsy pbuilder. then you can build packages with that. you can have many different pbuilders. even Debian ones. that's one of the nice things. you can be running feisty but building gutsy .debs or edgy .debs

<brainsik> QUESTION: How do I know this is using the pbuilder environment? It looks the same as when I was building packages without pbuilder setup.

  • ok, let's move on real quick to answer that. once we have the source package. .diff.gz .dsc and .orig.tar.gz files. we can build .debs out of them with pbuilder. pbuilder-feisty build *.dsc and if everything works out the way it should you should end up with some hello files in ~/pbuilder/feisty_result/

(01:03:18 PM) LaserJock: ok, that's gonna end my session
(01:03:28 PM) LaserJock: let me leave you with a few things and answer any last questions
(01:03:49 PM) LaserJock: http://www.debian.org/devel/ has links to Debian Policy and other goodies
(01:04:09 PM) LaserJock: also http://www.debian.org/devel/wnpp/
(01:04:22 PM) LaserJock: which has lists of packages in Debian that are being worked on
(01:05:04 PM) LaserJock: https://wiki.ubuntu.com/MOTU/TODO has some good stuff to get going
(01:05:39 PM) LaserJock: check out https://wiki.ubuntu.com/MOTU/School
(01:05:50 PM) LaserJock: http://doc.ubuntu.com/ubuntu/packagingguide/C/index.html
(01:06:01 PM) LaserJock: and especially check out the MOTU
(01:06:19 PM) LaserJock:  #ubuntu-motu
(01:06:47 PM) LaserJock: OK, I've taken enough of ogra's time
(01:06:58 PM) LaserJock: I can answer some stuff in -chat
(01:07:11 PM) LaserJock: Thanks for coming everybody!

MeetingLogs/openweekfeisty/packaging2 (last edited 2008-08-06 16:25:21 by localhost)