[00:32]  * nhandler is almost done preparing his packaging training session
[01:00] <nhandler> Hello everyone. My name is Nathan Handler. Today, we will be learning about creating packages using CDBS.
[01:00]  * asomething waves
[01:00] <nhandler> Could I get a quick show of hands to get a feel for who is here for the packaging training session?
[01:01]  * asomething looks around
[01:01] <nhandler> Before I begin, I would like to mention that this session is only going to cover the basics of using CDBS. It will not cover the advanced or special usage.
[01:02] <nhandler> Now, what exactly is CDBS?
[01:02] <nhandler> To quote https://wiki.ubuntu.com/PackagingGuide/Howtos/CDBS...
[01:02] <nhandler> "CDBS is a set of Makefile includes that uses debhelper to make building and maintaining Debian packages even easier. It uses advanced features of Makefiles to abstract the build process, so rules files end up primarily as a series of include statements."
[01:03] <nhandler> Now, when might you want to use CDBS?
[01:04] <nhandler> I often see people in #ubuntu-motu trying to learn how to package a small bash script that they put together.
[01:05] <nhandler> They look at the default debian/rules file created by dh_make, and they get a little nervous.
[01:05] <nhandler> Using CDBS, you can create a working package that has a debian/rules file only a couple of lines long.
[01:06] <nhandler> In order to demonstrate this, why we take a look at how easy it is to package a simple bash script using CDBS.
[01:07] <nhandler> Start by creating a directory to hold all of the files we will be dealing with. You can do this with: mkdir ~/cdbs-packaging
[01:07] <nhandler> Now, enter that new directory: cd ~/cdbs-packaging
[01:08] <nhandler> I have created a small script that we will attempt to package. You can download it to your current directory using: bzr branch lp:~nhandler/+junk/starwars.upstream
[01:08] <nhandler> You should now have a starwars.upstream folder
[01:09] <nhandler> If you enter this folder (cd starwars.upstream), you will see three files. There is 'starwars', the bash script. There is also a .desktop file and a .xpm icon.
[01:10] <nhandler> If you look at the bash script (cat ./starwars), you will see that it simply shows the all too familiar telnet star wars movie.
[01:10] <nhandler> Just to be clear, I did not create Star Wars or that telnet movie. I am simply using them for this educational demonstration.
[01:11] <nhandler> Now, it is time to start creating the package. You can download the necessary files using: bzr branch lp:~nhandler/+junk/starwars.debian debian
[01:11] <nhandler> For those of you who might have some experience packaging, you will notice that this newly created debian directory is missing a copyright file. It also has a few other issues that would prevent it from entering the repositories.
[01:12] <nhandler> This was done intentionally to try and keep the package as simple as possible.
[01:12] <nhandler> If you want to have your package enter the official repositories, you will want to read through the packaging guide (https://wiki.ubuntu.com/PackagingGuide/Complete) and Debian policy (http://www.debian.org/doc/debian-policy/)
[01:13] <nhandler> Now, going back to the package. Take a look at the rules file: cat debian/rules
[01:13] <nhandler> You might be surprised to notice that it only has two lines.
[01:14] <nhandler> The first line simply says that this is a Makefile. All debian/rules files need to have this line.
[01:14] <nhandler> The second line says that we want to use the debhelper.mk script provided by CDBS. This script will make the packaging of this script much easier.
[01:15] <nhandler> If you are interested in learning more about debhelper.mk, I would suggest that you open up /usr/share/cdbs/1/rules/debhelper.mk (you will need to have 'cdbs' installed).
[01:16] <nhandler> The file has lots of comments that explain exactly what it does.
[01:16] <nhandler> Now, you might be wondering how debhelper will know where to install all of our files. This is specified in debian/install.
[01:17] <nhandler> If you look at this file (cat debian/install), you will see that it lists the three files we want to install, and where we want them installed to.
[01:18] <mib_bjx1mnoq> hi
[01:18] <nhandler> Now, in order to use cdbs, you need to list it as a Build-Depends in debian/control. You can see that I have included this by doing: cat debian/control
[01:19] <nhandler> That is it. debian/changelog and debian/compat have nothing cdbs-specific in them. If you want to learn more about them, read some of the references I linked to earlier.
[01:20] <nhandler> We can now attempt to build the source package. However, you need to have some packages installed: sudo apt-get install devscripts cdbs
[01:21] <nhandler> Now, to build the source package, enter: debuild -S -us -uc
[01:21] <Ampelbein> question: are the .install files specific to cdbs? so, if i want to use them i have to build-depend on cdbs? or is it debhelper that provides this support?
[01:22] <nhandler> Ampelbein: debhelper is what uses the .install files. We need the cdbs build-depends because we are including debhelper.mk in debian/rules (which is provided by cdbs)
[01:22] <Ampelbein> ok, thanks.
[01:23] <nhandler> Running the command above will create an unsigned source package
[01:24] <nhandler> You will get some lintian warnings about the package containing .bzr directories. For our purposes, you can ignore that warning.
[01:24] <nhandler> Now, if you do a 'cd .. ; ls' you will see that you have four new files: starwars_0.1.dsc, starwars_0.1_source.build, starwars_0.1_source.changes, and starwars_0.1.tar.gz
[01:25] <nhandler> If you have pbuilder installed and configured properly, you can build the binary package using: pbuilder build starwars_0.1.dsc
[01:26] <nhandler> Otherwise, you can build the binary package in your PPA (https://help.launchpad.net/Packaging/PPA)
[01:26] <nhandler> I have already uploaded this package to my PPA: https://launchpad.net/~nhandler/+archive/ppa
[01:28] <nhandler> If you examine the the binary .deb file using 'dpkg --contents /path/to/deb', you will see that all of the files are getting installed to the correct locations.
[01:29] <nhandler> You can install the package using 'sudo dpkg -i /path/to/deb' to get the application to appear under Applications->Sound and Video->Star Wars. Clicking on it will run the bash script we looked at earlier.
[01:30] <nhandler> We have now successfully packaged a simple application using cdbs.
[01:30] <nhandler> Are there any questions about anything we have done?
[01:31] <nhandler> There is one more thing that I would like to mention
[01:33] <nhandler> When using dh_make to help create a package, you can actually have it make the necessary changes to use CDBS for you
[01:34] <nhandler> To do this, enter 'b' when it asks you about the "Type of package".
[01:35] <nhandler> This will create a debian/rules file similar to the one we saw earlier. It will also take care of adding a Build-Depends on 'cdbs' in debian/control
[01:36] <nhandler> Any last questions about CDBS?
[01:37] <nhandler> How about some feedback on these Packaging Training sessions in general. Any comments, suggestions, or feedback?
[01:40] <nhandler> Well, if nobody has any questions or comments, I think we can end a little early.
[01:40] <Pollywog> Will this be available later (logs)?
[01:40] <mib_bjx1mnoq> and when?
[01:40] <asomething> yes at https://wiki.ubuntu.com/Packaging/Training/Logs
[01:41] <Pollywog> ty
[01:41] <nhandler> Thanks for coming everyone
[01:41] <Pollywog> thanks for the session
[01:51] <asomething> logs are now up at https://wiki.ubuntu.com/Packaging/Training/Logs/2009-05-28
[01:53]  * nhandler hugs asomething