[16:23]  * persia  will be giving a special packaging lesson on how to package scripts, webapps, and firmware installers in #ubuntu-classroom starting at 15:30 UTC today.
[16:30] <persia> Welcome to the special session on packaging scripts, webapps, firmware installers, and other things without code.
[16:31] <persia> First off, let's take a quick attendance.  Please indicate your presence.
[16:31]  * sebner hugs persia =)
[16:31]  * Iulian waves
[16:31] <mok0> here
[16:31] <albert23> +1
[16:31] <schmiedc> here
[16:32]  * ssweeny coughs
[16:32] <persia> Great.  We've passed the quorum of 5 active students :)
[16:33] <sebner> persia: what if there would be less?
[16:33] <lukehasnoname> >_>
[16:33] <persia> So, this is about packaging those special types of package that don't have any source.
[16:33] <persia> sebner: I'd reschedule.
[16:33] <sebner> persia: kk
[16:33] <persia> The important thing to consider is how the typical meanings of "source package" and "binary package" apply in these cases.
[16:34] <amikrop> Hello. I will be away, but logging.
[16:34] <persia> There typically isn't anything to compile, and you just want to put the files on the target system.
[16:34] <persia> So, at a high level, a "source" package is the set of files that is used to edit and maintain a package.
[16:34] <persia> A "binary" package is the set of files that get installed on a user system.
[16:35] <persia> Even where most of the files are the same, it is useful to maintain this distinction, because there may be some files (README, COPYING, etc.) that don't need to be installed on a user system.
[16:35] <persia> Also, there may be special configuration changes that need to be applied to a user system, but which are not required for development.
[16:36] <persia> By keeping separate source and binary packages, it becomes very easy to separate these files into the appropriate places, and improves the experience for both users and developers.
[16:36] <persia> This is true even though the binary package may not have any actual binaries.
[16:38] <persia> As an example, we're going to package the very simple script from http://paste.ubuntu.com/16605/
[16:38] <persia> Now, the first thing to notice is that upstream didn't license this script properly, so we need to ask upstream for a license.
[16:39] <mok0> so, see you next week?
[16:40] <sebner> lol
[16:40] <persia> (three months pass)
[16:40] <persia> So upstream finally provides http://paste.ubuntu.com/16607/
[16:40] <persia> This, we can package.
[16:40] <persia> as upstream just sent us the script in a pastebin, we'll need to create an orig.tar.gz ourselves.
[16:41] <persia> So we create a directory hello-host-0.1
[16:41] <persia> And we copy the script into the directory, and call it hello-host.
[16:41] <persia> We then tar and compress the directory, and get hello-host-0.1.tar.gz
[16:42] <persia> This needs to be renamed to hello-host_0.1.orig.tar.gz.
[16:42] <persia> After we have the orig.tar.gz, we can start the packaging.
[16:42] <persia> First, we'll create a debian/ directory.
[16:42] <persia> Our first target will be copyright.
[16:43] <persia> This needs to include information about the package license.
[16:43] <persia> As this package doesn't have a homepage, we can get away with something simple.
[16:46] <persia> http://paste.ubuntu.com/16608/
[16:46] <persia> (Note that those preferring machine-readable debian/copyright are welcome to do it that way)
[16:46] <persia> (in fact, if someone wants to draft that, and post for the rest of the class, it would be appreciated)
[16:47] <persia> Next, we'll need a debian/control.  This is again fairly simple.  Just use the minimum information.
[16:47] <persia> I recommend using CDBS for this type of package, only because it means less typing, although those familiar with debhelper 7 may find that as easy a choice.
[16:48] <mok0> aie
[16:49] <persia> http://paste.ubuntu.com/16609/ is a quick debian/control for our package.
[16:49] <persia> Note that because it's just scripts, and we're not using any special handlers, we have to set all the Dependencies manually.
[16:49] <persia> In this case, it's a bash script, so we depend on bash.
[16:50] <sebner> persia: is that necessary?
[16:51] <mok0> bash is in the minimal installation
[16:51] <persia> sebner: I'm actually not sure.  I know bash is no longer the default /bin/sh, but I don't know if it is still Priority: Essential.
[16:51] <mok0> ok
[16:51] <persia> For something like a PHP script, it is much more important.
[16:51] <sebner> ok
[16:52] <mok0> we can convert it php later :-)
[16:52] <mok0> to php
[16:52] <persia> mok0: Right :)
[16:52] <persia> So, for this example, I'm using CDBS, so debian/rules looks like http://paste.ubuntu.com/16610/
[16:53] <persia> I use this mostly because I don't want to think about it, and will use the implied debhelper calls for most things.
[16:53] <persia> Now comes the important part: this needs to be installed somewhere.
[16:53] <persia> This is handled by the implied call to dh_install.
[16:54] <persia> We create a debian/install file that specifies where the files go.  Our example is http://paste.ubuntu.com/16611/
[16:54] <persia> Now this directory doesn't exist yet, so we need a debian/dirs to create it (http://paste.ubuntu.com/16612/)
[16:55] <persia> OOps.  I made a mistake with debian/install.  It should really have been http://paste.ubuntu.com/16613/
[16:55] <persia> It is important not to have the leading / to make sure that it installs in the package, instead of the developer's system.
[16:56] <persia> Now we have a package that installs the scripts into the right places, and has all the necessary bits to make a good package.
[16:57] <persia> There are still a couple pieces missing: we probably want to create a manual page, as otherwise lintian will complain, and we'll never get it past REVU.
[16:58] <persia> If we're packaging a firmware installer, or something that needs to initialise a database, we might want to do something with debconf or maintainer scripts.
[16:58] <persia> And so on.
[16:58] <persia> Now, any questions?
[16:59] <sebner> not yet =)
[17:01] <sebner> *silence*
[17:01] <persia> OK.  If there are no questions, I presume that you all are prepared to package random bash scripts, quick python bits, and so on.
[17:02] <sebner> persia: that was it?
[17:02] <persia> If you get as far as trying to package an entire Ruby-on-Rails application, don't forget to install the necessary integration hooks for the webservers, and handle the DB startup and cleanup in the maintainer scripts.
[17:02] <persia> sebner: Yep.  Packaging scripts is pretty easy.  Once the files are installed in the right place, the user is typically happy.
[17:03] <sebner> great
[17:03]  * sebner hugs persia :)
[17:03] <schmiedc> so but how do i know what i have to write in the certain scripts
[17:03] <persia> The really tricky bit is understanding the difference between a "source" package and a "binary" package when the "binary" package looks like it contains source.
[17:03] <persia> schmiedc: Which scripts?
[17:04] <schmiedc> for example the debian/control
[17:04] <persia> schmiedc: OK.  We created debian/copyright, debian/control, debian/rules, debian/changelog, and debian/install.
[17:05] <persia> debian/rules can almost always be just the two lines for script packages.
[17:05] <persia> debian/install is set up based on where the files need to end up.  This is usually available in the upstream documentation.
[17:05] <persia> Oh, and I forgot about debian/dirs.
[17:06] <persia> debian/dirs needs to include all the directories used in debian/install.
[17:06] <persia> debian/changelog is best created with dch --create
[17:07] <persia> debian/copyright is often just a quick summary of: who packaged it and when, the authors, the copyright holders, the upstream license, and the packaging license.
[17:07] <persia> debian/control is a bit trickier.  Let's look at http://paste.ubuntu.com/16609/ carefully.
[17:07] <persia> There are two stanzas, the source stanza and the binary stanza
[17:08] <persia> The source stanza describes the source package, and the binary stanza the binary package.
[17:08] <persia> For the source stanza, you need to set the Source: header to be the name of the package.
[17:08] <persia> The Section header should match one of the package sections
[17:08]  * persia digs for the URL
[17:09] <persia> http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
[17:09] <persia> Priority is almost always "optional" for new packages, although it can be "extra" if it breaks something (try not to do this)
[17:09] <persia> The Maintainer is the person responsible for the package.
[17:10] <persia> Build-Depends should be "cdbs": you shouldn't need anything else for a simple scripts package.
[17:10] <albert23> should debhelper be added?
[17:10] <persia> Standards-Version: should match whatever the current standards are when you package it.
[17:11] <persia> albert23: It's not required, as cdbs depends on debhelper.
[17:11] <albert23> lintian complained
[17:11] <persia> If you use a feature from a newer debhelper than the version depended upon by CDBS, you can add a versioned depends.
[17:12] <persia> albert23: You remind me, it's a good idea to add a debian/compat file containing any of "5", "6", or "7".
[17:12] <albert23> that was the other lintian complaint indeed
[17:12] <persia> In which case, you want to add "debhelper (>= 5)" (or 6 or 7) to your Build-Depends.
[17:12] <persia> albert23: Thanks for checking :)
[17:13] <persia> Now, for the binary stanza, we again have the package name
[17:13] <persia> scripts are always Architecture: all
[17:14] <persia> As mentioned previously, you need to manually set the Depends: depending on what the scripts require.  I tend to always include ${misc:Depends} just in case some of the CDBS magic requires something.
[17:14] <persia> And the Description is as normal.
[17:14] <persia> more information about writing control files is available from http://www.debian.org/doc/debian-policy/ch-controlfields.html
[17:14] <schmiedc> ok thxc
[17:14] <persia> schmiedc: Does that answer it?
[17:15] <schmiedc> but architecture would be i368 and so on or?
[17:15] <schmiedc> yes
[17:15] <schmiedc> the thing is that i concider about getting involved
[17:15] <schmiedc> and haven't done any work yet
[17:15] <persia> schmiedc: No point.  As these are just scripts, it ought be architecture: all.  That way they can work for anyone, regardless of their architecture (as long as they meet the Depends)
[17:16] <persia> Any other questions?
[17:16] <schmiedc> yes but for other packages
[17:16] <sebner> schmiedc: #ubuntu-motu ;)
[17:16] <persia> schmiedc: Oh, sure, for non-script packages, you might need to set architectures.  "any" is a good choice.
[17:16] <schmiedc> am there ..
[17:17] <schmiedc> ok
[17:18] <persia> Any other questions?  Iulian?
[17:18] <schmiedc> not yet ..
[17:18] <persia> ssweeny:?
[17:18] <mok0> I think, for consistency, it is better to name install and dirs -> <package>.install and <package>.dirs
[17:18] <schmiedc> when should the next lesson take place?
[17:19] <persia> mok0: It works either way, but sure.
[17:19] <schmiedc> or to mention in the beginning to replace debian/ with the packages name
[17:19] <persia> schmiedc: I tend to do ad-hoc lessons.  You might check the MOTU School schedule on the wiki.
[17:19] <schmiedc> ok
[17:20] <persia> schmiedc: No, you use debian/$(pacakgename).install and debian/$(packagename).dirs, etc.
[17:20] <schmiedc> ok
[17:20] <mok0> schmiedc: debian/ is sacred
[17:22] <schmiedc> where is a good place to look for simple upstreams to play with?
[17:23] <persia> schmiedc: http://bashscripts.org/ has heaps of samples, although many are not suitable for packaging
[17:23] <schmiedc> ok
[17:24] <persia> http://www.scripts.com/ has some python and perl (but be careful, some of these may be more than scripts)
[17:25] <schmiedc> ok thx
[17:25] <schmiedc> should be enought for today
[17:25] <persia> On the other hand, aside from experimentation (for which variations on hello-host work just fine), you'd do best to wait until you found something so useful you didn't know how you worked without it before packaging it for general release.
[17:25] <schmiedc> have to do something for school
[17:25]  * persia rings the 300 second bell
[17:26] <persia> Any last questions?
[17:27] <schmiedc> so you mean i should beginn straight with packaging for releases?
[17:27] <mok0> schmiedc: you can create a PPA on launchpad
[17:27] <persia> schmiedc: If you have something worthwhile to package, why not?
[17:27] <schmiedc> PPAA?
[17:28] <schmiedc> PPA*
[17:29] <persia> Thanks to everyone for attending, even with the short notice.  Good luck with your script packaging, and don't hesitate to ask in #ubuntu-motu if you have any further questions.
[17:29] <schmiedc> whats PPA?
[17:29] <albert23> thanks persia
[17:29] <schmiedc> thanks
[17:29] <mok0> schmiedc: personal package archive
[17:30] <schmiedc> where do i create one?
[17:30] <mok0> schmiedc: on Launchpad.net
[17:30] <schmiedc> have an account ..
[17:30] <schmiedc> oh here
[17:30] <schmiedc> found it :)
[17:30] <mok0> schmiedc: :-)
[17:30] <mok0> schmiedc: you upload a "source package"
[17:31] <mok0> schmiedc: it compiles and publishes it for you
[17:31] <schmiedc> nice
[17:31] <mok0> schmiedc: yes, really cool
[17:31] <persia> (or if it's a script, it organises it for user-release and publishes it for you)
[17:31] <mok0> schmiedc: so you can distribute apt-get'able software
[17:32] <sebner> persia: overtime ^^
[17:33] <persia> sebner: Yeah, well.  Give me an apple!
[17:33] <schmiedc> gg
[17:34] <mok0> sebner: give persia a Mac
[17:34] <sebner> rofl rofl rofl
[17:39] <Iulian> Ahh
[21:36] <Anon234> d