Return to Video

1009_Packaging_for_beginners.ogv

  • 0:00 - 0:05
    The next talk is packaging for beginners
  • 0:05 - 0:07
    by Gergely Nagy
  • 0:11 - 0:13
    This talk will be,
  • 0:13 - 0:15
    about packaging in a
  • 0:15 - 0:17
    much, different style than
  • 0:17 - 0:19
    most would expect.
  • 0:19 - 0:21
    So, first of all
  • 0:21 - 0:23
    who amoung you have
  • 0:23 - 0:25
    read the new maintainers guide
  • 0:25 - 0:27
    or, the packaging guide or
  • 0:27 - 0:29
    any of that stuff?
  • 0:29 - 0:31
    How many of you
  • 0:31 - 0:33
    enjoyed it? [laughter]
  • 0:33 - 0:35
    [laughter]
  • 0:35 - 0:37
    Alright, well that's
  • 0:37 - 0:39
    because they are very dry
  • 0:39 - 0:41
    and to make
  • 0:41 - 0:43
    this talk, better and useful
  • 0:43 - 0:45
    I will ignore everything that is written in
  • 0:45 - 0:47
    them. [laughter] I would advise you
  • 0:47 - 0:49
    to do the same because they are very
  • 0:49 - 0:51
    useful once you know, what
  • 0:51 - 0:53
    you are doing but when you are
  • 0:53 - 0:55
    trying
  • 0:55 - 0:57
    your first steps, they are
  • 0:57 - 0:59
    an awful, boring
  • 0:59 - 1:01
    piece of something.
  • 1:01 - 1:03
    So, we will
  • 1:03 - 1:05
    do something very different today.
  • 1:05 - 1:07
    Another question, how
  • 1:07 - 1:09
    many of you have read the policy
  • 1:09 - 1:11
    from beginning to end?
  • 1:13 - 1:15
    ok, congratulations!
  • 1:15 - 1:17
    1 person, how many
  • 1:17 - 1:19
    of you tried to read
  • 1:19 - 1:21
    the policy ?
  • 1:21 - 1:23
    How many of you got bored
  • 1:23 - 1:25
    after the first 5 minutes?
  • 1:25 - 1:27
    Yes,
  • 1:27 - 1:29
    because the poilcy is not meant to be
  • 1:29 - 1:31
    read from begining to
  • 1:31 - 1:33
    end. You look at it
  • 1:33 - 1:35
    trying to find things when lintian,
  • 1:35 - 1:37
    yells at you.
  • 1:37 - 1:39
    So, that's what we will do
  • 1:39 - 1:41
    today.
  • 1:43 - 1:45
    I have one small announcement
  • 1:45 - 1:47
    to make,
  • 1:47 - 1:49
    I have bad news. I promised
  • 1:49 - 1:51
    ponies but it turns out
  • 1:51 - 1:53
    ponysay is not
  • 1:53 - 1:55
    free software. At, least
  • 1:55 - 1:57
    the data is not.
  • 1:57 - 1:59
    So, this talk we will
  • 1:59 - 2:01
    package something entirely different,
  • 2:01 - 2:03
    but since I promised ponies!
  • 2:03 - 2:05
    Here is one I drew,
  • 2:05 - 2:07
    today.
  • 2:07 - 2:09
    Doesn't look
  • 2:09 - 2:11
    like a pony! but.
  • 2:13 - 2:15
    Okay.
  • 2:15 - 2:17
    So, let's look at
  • 2:17 - 2:19
    what we will be packaging today.
  • 2:19 - 2:21
    It's a little program I
  • 2:21 - 2:23
    wrote.
  • 2:23 - 2:25
    Fit for,
  • 2:25 - 2:27
    Debian's 20th birthday!
  • 2:27 - 2:29
    The cake
  • 2:29 - 2:31
    is a lie,
  • 2:31 - 2:33
    appearently it isn't, but
  • 2:33 - 2:35
    it's an ASCII art so it doesn't
  • 2:35 - 2:37
    look like a cake.
  • 2:37 - 2:39
    But, if you squint a little you might notice,
  • 2:39 - 2:41
    that it is one.
  • 2:41 - 2:43
    And, the resolution
  • 2:43 - 2:45
    is terrible, so we have
  • 2:45 - 2:47
    the text all over the place. [laughter]
  • 2:47 - 2:49
    But that is ok, we don't mind.
  • 2:49 - 2:51
    It looks better when the resolution
  • 2:51 - 2:53
    is bigger, trust me on that. Anyway,
  • 2:53 - 2:55
    we will take this piece of software
  • 2:55 - 2:57
    it's, really easy and package
  • 2:57 - 2:59
    it.
  • 2:59 - 3:01
    It's your
  • 3:01 - 3:03
    standard how to
  • 3:03 - 3:05
    based thing written in C.
  • 3:05 - 3:07
    It has one
  • 3:07 - 3:09
    source file and that is about it.
  • 3:09 - 3:11
    How do you go about packaging
  • 3:11 - 3:13
    it ? Well, the easiest
  • 3:13 - 3:15
    way is to call
  • 3:15 - 3:17
    dpkd-buildpackage
  • 3:19 - 3:21
    command.
  • 3:21 - 3:23
    And see what it tells you,
  • 3:23 - 3:25
    well it's missing a changelog and a debian
  • 3:25 - 3:27
    directory, so let's make one.
  • 3:29 - 3:31
    There is a handy tool called
  • 3:31 - 3:33
    'dch', which is
  • 3:33 - 3:35
    short of deb change
  • 3:35 - 3:37
    it is mean't to,
  • 3:37 - 3:39
    help you write change logs.
  • 3:39 - 3:41
    And we will use it to
  • 3:41 - 3:43
    create one.
  • 3:45 - 3:47
    We fill it out
  • 3:47 - 3:49
    you've probably seen a few change logs.
  • 3:49 - 3:51
    It's not rocket science.
  • 3:53 - 3:55
    Oh,
  • 3:57 - 3:59
    ok,
  • 3:59 - 4:01
    sorry.
  • 4:03 - 4:05
    Fill it out.
  • 4:07 - 4:09
    We do not have an ITP,
  • 4:09 - 4:11
    bug to close, so that's about it.
  • 4:11 - 4:13
    Let's see what it says now.
  • 4:13 - 4:15
    Oh,
  • 4:15 - 4:17
    lots of text! What did it
  • 4:17 - 4:19
    type. Oh,
  • 4:19 - 4:21
    we need a control file! What is a control file?
  • 4:21 - 4:23
    Well, a control file
  • 4:23 - 4:25
    tells, dpkg
  • 4:25 - 4:27
    what
  • 4:27 - 4:29
    sources you have and what binaries
  • 4:29 - 4:31
    packages you want to build.
  • 4:31 - 4:33
    So, we will hack up a really
  • 4:33 - 4:35
    easy one.
  • 4:35 - 4:37
    First, of all
  • 4:37 - 4:39
    every control file
  • 4:39 - 4:41
    has to have 2
  • 4:41 - 4:43
    sections. The first section
  • 4:43 - 4:45
    describes the source
  • 4:45 - 4:47
    it looks a bit
  • 4:47 - 4:49
    like,
  • 4:51 - 4:53
    ok,
  • 4:53 - 4:55
    sorry I always forget my editor is
  • 4:55 - 4:57
    a bit dumb!
  • 4:57 - 4:59
    The first section
  • 4:59 - 5:01
    describes the source,
  • 5:01 - 5:03
    which
  • 5:03 - 5:05
    in this case
  • 5:05 - 5:07
    is this.
  • 5:07 - 5:09
    We also
  • 5:09 - 5:11
    have a couple of other fields we need
  • 5:11 - 5:13
    here like, maintainer
  • 5:17 - 5:19
    we need a Section
  • 5:21 - 5:23
    lets see
  • 5:23 - 5:25
    games, will be fine
  • 5:25 - 5:27
    and the
  • 5:27 - 5:29
    priotity which will be extra.
  • 5:29 - 5:31
    That should
  • 5:31 - 5:33
    be enough for starters,
  • 5:41 - 5:43
    and I need to learn to spell.
  • 5:43 - 5:45
    The next section,
  • 5:45 - 5:47
    is about the binary
  • 5:47 - 5:49
    we will build one
  • 5:49 - 5:51
    binary package
  • 5:51 - 5:53
    except it's called Package.
  • 5:55 - 5:57
    It has the same name.
  • 5:59 - 6:01
    We give it a description,
  • 6:07 - 6:09
    and,
  • 6:09 - 6:11
    the long description starts
  • 6:11 - 6:13
    right after in the next line.
  • 6:13 - 6:15
    You have to start it with a space,
  • 6:15 - 6:17
    because,
  • 6:17 - 6:19
    this whole control files looks like an email.
  • 6:21 - 6:23
    And starting
  • 6:23 - 6:25
    with a space tells the,
  • 6:25 - 6:27
    parser it
  • 6:27 - 6:29
    is a continuation,
  • 6:29 - 6:31
    of what was above.
  • 6:39 - 6:41
    Ok and that is about it.
  • 6:43 - 6:45
    So, we have a very
  • 6:45 - 6:47
    simple control file.
  • 6:47 - 6:49
    Let's see what the tool
  • 6:49 - 6:51
    tells us.
  • 6:51 - 6:53
    Oh,
  • 6:53 - 6:55
    right we need an Architecture field.
  • 7:01 - 7:03
    Every package in Debian must,
  • 7:03 - 7:05
    have an
  • 7:05 - 7:07
    Architecture associated
  • 7:07 - 7:09
    with it.
  • 7:11 - 7:13
    It can be
  • 7:13 - 7:15
    either
  • 7:15 - 7:17
    and Arch all
  • 7:17 - 7:19
    package, which means the same
  • 7:19 - 7:21
    binary will run on all
  • 7:21 - 7:23
    architectures.
  • 7:23 - 7:25
    In our case this is,
  • 7:25 - 7:27
    wrong, because this is a C
  • 7:27 - 7:29
    program which is compiled and
  • 7:29 - 7:31
    it depends on the architecture.
  • 7:31 - 7:33
    So, we write in here
  • 7:33 - 7:35
    you could list
  • 7:35 - 7:37
    the architectures here if your
  • 7:37 - 7:39
    package is something that
  • 7:39 - 7:41
    only works on a certain subset of
  • 7:41 - 7:43
    of architectures.
  • 7:45 - 7:47
    You can make it Linux,
  • 7:47 - 7:49
    specific by writing linux-any
  • 7:49 - 7:51
    or FreeBSD specific.
  • 7:53 - 7:55
    by writing,
  • 7:55 - 7:57
    kfreebsd-any.
  • 7:57 - 7:59
    This is a portable thing so we will write,
  • 7:59 - 8:01
    any.
  • 8:01 - 8:03
    Going further,
  • 8:03 - 8:05
    now it needs a rules
  • 8:05 - 8:07
    file. We are progressing,
  • 8:07 - 8:09
    a rules file is used
  • 8:09 - 8:11
    to do the hard
  • 8:11 - 8:13
    work.
  • 8:13 - 8:15
    It tells dpkg
  • 8:15 - 8:17
    rules
  • 8:17 - 8:19
    about how to build a
  • 8:19 - 8:21
    package. In the most simple case
  • 8:21 - 8:23
    like ours,
  • 8:27 - 8:29
    we will deal with
  • 8:29 - 8:31
    this only.
  • 8:31 - 8:33
    This is 'magic',
  • 8:33 - 8:35
    'black magic',
  • 8:35 - 8:37
    but the wonderful thing about
  • 8:37 - 8:39
    black magic is that you don't need to
  • 8:39 - 8:41
    understand it. If you need
  • 8:41 - 8:43
    to change the way,
  • 8:43 - 8:45
    the magic works.
  • 8:45 - 8:47
    You only have to understand little
  • 8:47 - 8:49
    pieces of it, and thankfully
  • 8:49 - 8:51
    deb helper, which
  • 8:51 - 8:53
    dh is a part of
  • 8:53 - 8:55
    has wonderful documentation.
  • 8:55 - 8:57
    Man pages and so on,
  • 8:57 - 8:59
    and so forth.
  • 8:59 - 9:01
    I would suggest,
  • 9:01 - 9:03
    that if you start packaging,
  • 9:03 - 9:05
    something. Start with this
  • 9:05 - 9:07
    and
  • 9:07 - 9:09
    if something goes wrong, go from there.
  • 9:09 - 9:11
    We will see how things,
  • 9:11 - 9:13
    will go wrong and
  • 9:13 - 9:15
    by the way Debian
  • 9:15 - 9:17
    rules is a make file thats
  • 9:17 - 9:19
    why we have this first
  • 9:19 - 9:21
    line here.
  • 9:21 - 9:23
    We also need to make
  • 9:23 - 9:25
    it executable, of course.
  • 9:27 - 9:29
    Now, lets see what happens
  • 9:31 - 9:33
    oh, yeah.
  • 9:35 - 9:37
    Since it's a make file,
  • 9:37 - 9:39
    I have to make it a makefile.
  • 9:41 - 9:43
    There we go.
  • 9:45 - 9:47
    Well,
  • 9:47 - 9:49
    it did things.
  • 9:51 - 9:53
    But, it also
  • 9:53 - 9:55
    gave us a lot of
  • 9:55 - 9:57
    errors and
  • 9:57 - 9:59
    other things.
  • 9:59 - 10:01
    So, we need to tell this
  • 10:01 - 10:03
    tool to ignore,
  • 10:03 - 10:05
    the git directory
  • 10:05 - 10:07
    and a couple of other
  • 10:07 - 10:09
    things. The best way to do that,
  • 10:13 - 10:15
    is to set the
  • 10:15 - 10:17
    source format to,
  • 10:17 - 10:19
    the one it suggests.
  • 10:19 - 10:21
    Right, here at the bottom.
  • 10:21 - 10:23
    We can do that by
  • 10:23 - 10:25
    creating a new directories,
  • 10:25 - 10:27
    called debian and then source.
  • 10:29 - 10:31
    And, creating
  • 10:31 - 10:33
    a new file in it
  • 10:33 - 10:35
    called format.
  • 10:37 - 10:39
    Which has the text,
  • 10:39 - 10:41
    '3.0
  • 10:41 - 10:43
    (quilt)' in it.
  • 10:43 - 10:45
    What this format does you
  • 10:45 - 10:47
    don't need to know, at least
  • 10:47 - 10:49
    not right now. It's
  • 10:49 - 10:51
    pretty complicated and
  • 10:51 - 10:53
    its a similiar
  • 10:53 - 10:55
    kind of 'magic' as debhelper.
  • 10:57 - 10:59
    It just has less documentation.
  • 11:01 - 11:03
    We also want to tell debhelper that,
  • 11:03 - 11:05
    we want to use
  • 11:05 - 11:07
    the latest and greatest version of
  • 11:07 - 11:09
    it. It was
  • 11:09 - 11:11
    complaining about that to at the beginning,
  • 11:11 - 11:13
    but I'm not going to scroll that high up.
  • 11:13 - 11:15
    Which we can do by,
  • 11:15 - 11:17
    echoing a '9' into a file called
  • 11:17 - 11:19
    debian/compat .
  • 11:19 - 11:21
    Now, lets see what happens.
  • 11:23 - 11:25
    Well, this is
  • 11:25 - 11:27
    much, much,
  • 11:27 - 11:29
    improved.
  • 11:31 - 11:33
    It compilied and now it is doing,
  • 11:33 - 11:35
    somethings and it
  • 11:35 - 11:37
    it is also asking for my password.
  • 11:39 - 11:41
    No, I'm not going to sign it right now.
  • 11:45 - 11:47
    So, it did stuff.
  • 11:47 - 11:49
    It also built,
  • 11:51 - 11:53
    a debian package for us,
  • 11:53 - 11:55
    which is great.
  • 11:55 - 11:57
    But I thing
  • 11:57 - 11:59
    is, a lot of
  • 11:59 - 12:01
    things missing from this.
  • 12:01 - 12:03
    For example,
  • 12:03 - 12:05
    we can run lintian,
  • 12:05 - 12:05
    on the changes file
    we can run lintian,
  • 12:05 - 12:07
    on the changes file
  • 12:07 - 12:09
    and it will tell us all kinds of things.
  • 12:11 - 12:13
    A lot of bad, bad
  • 12:13 - 12:15
    things about the package.
  • 12:19 - 12:21
    Ok,
  • 12:21 - 12:23
    let's see,
  • 12:23 - 12:25
    we are missing the maintainer name, which I'm not going
  • 12:25 - 12:27
    to fix right now.
  • 12:27 - 12:29
    I'm not going to fix the
  • 12:29 - 12:31
    changelog either, because I
  • 12:31 - 12:33
    know better.
  • 12:33 - 12:35
    It's missing a copyright file,
  • 12:35 - 12:37
    which I'm not going to add
  • 12:37 - 12:39
    either, because writing a
  • 12:39 - 12:41
    copyright file could take an
  • 12:41 - 12:43
    entire session of its own.
  • 12:45 - 12:47
    I can add the standards version
  • 12:47 - 12:49
    field.
  • 12:53 - 12:55
    Which is as easy,
  • 12:57 - 12:59
    as this, the standards
  • 12:59 - 13:01
    version field,
  • 13:03 - 13:05
    signals which version
  • 13:05 - 13:07
    of policy this package was
  • 13:07 - 13:09
    made to conform to.
  • 13:11 - 13:13
    What is worse, is that
  • 13:13 - 13:15
    we are missing dependencies.
  • 13:15 - 13:17
    If we look into the package
  • 13:19 - 13:21
    debian package.
  • 13:23 - 13:25
    We will see that there is no depends
  • 13:25 - 13:27
    line, if we try to install this
  • 13:27 - 13:29
    It may work
  • 13:29 - 13:31
    and on my computer it will because
  • 13:31 - 13:33
    I already have all the dependancies installed.
  • 13:35 - 13:37
    But since it's a compiled
  • 13:37 - 13:39
    thing, it will at least
  • 13:39 - 13:41
    need libc,
  • 13:41 - 13:43
    and probably a few other
  • 13:43 - 13:45
    things as well.
  • 13:45 - 13:47
    So, we do
  • 13:47 - 13:49
    another kind of magic.
  • 13:49 - 13:51
    And add
  • 13:51 - 13:53
    the depends line to
  • 13:53 - 13:55
    the binary section.
  • 13:55 - 13:57
    Now,
  • 13:59 - 14:01
    is this line of magic,
  • 14:01 - 14:03
    which looks like shell
  • 14:03 - 14:05
    variable except,
  • 14:05 - 14:07
    they are not.
  • 14:07 - 14:09
    The way it works,
  • 14:09 - 14:11
    is when debhelper
  • 14:11 - 14:13
    runs, it will
  • 14:15 - 14:17
    find all the
  • 14:17 - 14:19
    packages that your binary
  • 14:19 - 14:21
    is dependant on. At least if they are
  • 14:21 - 14:23
    in 'C' and
  • 14:23 - 14:25
    fill
  • 14:25 - 14:27
    this variable out,
  • 14:27 - 14:29
    with the results.
  • 14:29 - 14:31
    It something
  • 14:31 - 14:33
    like 'ldd'
  • 14:33 - 14:35
    improved.
  • 14:41 - 14:43
    Here we see,
  • 14:43 - 14:45
    the output of 'ldd'
  • 14:45 - 14:47
    as you can see, this
  • 14:47 - 14:49
    thing depends on quite a lot of
  • 14:49 - 14:51
    things.
  • 14:53 - 14:55
    Ranging from freetype
  • 14:55 - 14:57
    to libX11
  • 14:57 - 14:59
    to
  • 14:59 - 15:01
    otherthings.
  • 15:05 - 15:07
    Yes?
  • 15:13 - 15:15
    One moment.
  • 15:25 - 15:27
    [Question] Wouldn't you have to go through 'configure-ac',
  • 15:27 - 15:29
    to figure all this stuff?
  • 15:29 - 15:31
    [Gergely] We can,
  • 15:31 - 15:33
    and we will just not
  • 15:33 - 15:35
    right now.
  • 15:35 - 15:37
    We need
  • 15:37 - 15:39
    to figure out the
  • 15:39 - 15:41
    dependices of the binary,
  • 15:41 - 15:43
    if you go through,
  • 15:43 - 15:45
    'configureare-ac' you can figure
  • 15:45 - 15:47
    out the build dependices.
  • 15:47 - 15:49
    Which will be useful to,
  • 15:49 - 15:51
    and I'll get to that
  • 15:51 - 15:53
    in about 5 minutes.
  • 15:59 - 16:01
    To figure out the,
  • 16:01 - 16:03
    runtime dependicies you can,
  • 16:05 - 16:07
    use this 'sh.libs'
  • 16:07 - 16:09
    depends line.
  • 16:09 - 16:11
    It will be figured out
  • 16:11 - 16:13
    automatically most of the time.
  • 16:13 - 16:15
    To figure out,
  • 16:15 - 16:17
    the build dependicies
  • 16:17 - 16:19
    you have to do that manually.
  • 16:21 - 16:23
    And as I said we will get
  • 16:23 - 16:25
    to that in a moment.
  • 16:27 - 16:29
    I'm not going to build the package,
  • 16:29 - 16:31
    again because that takes a long time.
  • 16:31 - 16:33
    I will show you
  • 16:33 - 16:35
    another thing, a very
  • 16:35 - 16:37
    useful tool callled 'sbuild'.
  • 16:39 - 16:41
    Which works
  • 16:41 - 16:43
    by setting up a clean
  • 16:43 - 16:45
    environment to build your package in.
  • 16:55 - 16:57
    The last time I ran
  • 16:57 - 16:59
    'dpkg-buildpackage'
  • 16:59 - 17:01
    it also built a source package
  • 17:01 - 17:03
    I believe or if not?
  • 17:03 - 17:05
    Yes, it did.
  • 17:09 - 17:11
    'sbuild' works after
  • 17:11 - 17:13
    setting up which is easy and
  • 17:13 - 17:15
    and well documented in it's
  • 17:15 - 17:17
    man page and other
  • 17:17 - 17:19
    kinds of documentation.
  • 17:19 - 17:21
    It sets up a clean,
  • 17:21 - 17:23
    environment with only
  • 17:23 - 17:25
    'build-essential' installed.
  • 17:25 - 17:27
    You can give this tool,
  • 17:27 - 17:29
    debian source
  • 17:29 - 17:31
    control file. It will grab
  • 17:31 - 17:33
    all the build dependicies, install
  • 17:33 - 17:35
    it in the
  • 17:35 - 17:37
    'chroot'
  • 17:37 - 17:39
    amd try to build the package. It's very good
  • 17:39 - 17:41
    at figuring out your build dependicies
  • 17:41 - 17:43
    are and weather
  • 17:43 - 17:45
    your package will build on
  • 17:45 - 17:47
    the autobuilders or
  • 17:47 - 17:49
    if it will not.
  • 17:51 - 17:53
    This takes quite a long
  • 17:53 - 17:55
    time because it will have to
  • 17:55 - 17:57
    install the things.
  • 17:57 - 17:59
    Except it won't because
  • 17:59 - 18:01
    we don't have any build dependicies
  • 18:01 - 18:03
    right now.
  • 18:07 - 18:09
    Oh, we do
  • 18:09 - 18:11
    because
  • 18:11 - 18:13
    never mind.
  • 18:13 - 18:15
    I'll just stop this.
  • 18:19 - 18:21
    I forgot that
  • 18:21 - 18:23
    I built the source
  • 18:23 - 18:25
    earlier.
  • 18:31 - 18:33
    Maybe this time?
  • 18:41 - 18:43
    One momement,
  • 18:43 - 18:45
    I'll fix this in a moment.
  • 19:13 - 19:15
    Ok, lets see.
  • 19:15 - 19:17
    We should have
  • 19:17 - 19:19
    no build dependicies now.
  • 19:19 - 19:21
    Whats the problem
  • 19:21 - 19:23
    now?
  • 19:51 - 19:53
    Ok, while I
  • 19:53 - 19:55
    fix my environment,
  • 19:55 - 19:57
    lets skip
  • 19:57 - 19:59
    the next step.
  • 19:59 - 20:01
    If I had compiled this thing without
  • 20:01 - 20:03
    out build dependicies, it would fail
  • 20:03 - 20:05
    in a clean environment.
  • 20:07 - 20:09
    What we will do next is,
  • 20:09 - 20:11
    go through 'configure-ac' and figure out
  • 20:11 - 20:13
    what this thing needs.
  • 20:21 - 20:23
    Well, lets see.
  • 20:23 - 20:25
    It needs,
  • 20:25 - 20:27
    'pkg-config',
  • 20:27 - 20:29
    because that is what provides
  • 20:29 - 20:31
    this macro.
  • 20:31 - 20:33
    It will need,
  • 20:35 - 20:37
    I'm not sure how to pronounce this.
  • 20:37 - 20:39
    errr, lib-ca-ca somthing.....
  • 20:39 - 20:41
    It's like aalib
  • 20:41 - 20:43
    but with colours. It also
  • 20:43 - 20:45
    needs,
  • 20:45 - 20:47
    'imlib2'.
  • 20:47 - 20:49
    Lets add those
  • 20:49 - 20:51
    to the build dependency.
  • 20:55 - 20:57
    And, it also needs,
  • 20:57 - 20:59
    debhelper because we are using that.
  • 21:01 - 21:03
    Since, we are using compat level 9
  • 21:03 - 21:05
    we need 'debhelper'
  • 21:05 - 21:07
    version 9 or later.
  • 21:07 - 21:09
    We need,
  • 21:09 - 21:11
    this
  • 21:17 - 21:19
    and this should
  • 21:19 - 21:21
    do.
  • 21:23 - 21:25
    Rebuild the source package again and
  • 21:25 - 21:27
    I forgot to tell it, to not sign the package.
  • 21:29 - 21:31
    There we go.
  • 21:37 - 21:39
    Lets see how it worked.
  • 21:43 - 21:45
    Right,
  • 21:45 - 21:47
    now it figured out
  • 21:47 - 21:49
    that it needs
  • 21:49 - 21:51
    quite a few pacakges.
  • 21:57 - 21:59
    It can also download
  • 22:01 - 22:03
    the build dependicies from the internet.
  • 22:03 - 22:05
    I have them downloaded already,
  • 22:05 - 22:07
    which is why it didn't do that.
  • 22:07 - 22:09
    Then it,
  • 22:09 - 22:11
    installs all of them and
  • 22:11 - 22:13
    will try to compile the package
  • 22:13 - 22:15
    and make a binary out of it.
  • 22:15 - 22:17
    If it all succeeds, it will
  • 22:17 - 22:19
    copy the result
  • 22:19 - 22:21
    into the same directory,
  • 22:21 - 22:23
    which we ran the tool from.
  • 22:25 - 22:27
    If it doesn't work,
  • 22:27 - 22:29
    then it will
  • 22:29 - 22:31
    leave
  • 22:31 - 22:33
    the logfile of the whole
  • 22:33 - 22:35
    build in the same directory
  • 22:35 - 22:37
    which we ran it from.
  • 22:37 - 22:39
    Sadly, it takes a little while
  • 22:39 - 22:41
    on my laptop because
  • 22:41 - 22:43
    it is kind of old and
  • 22:43 - 22:45
    slow, but we are all ready at the
  • 22:45 - 22:47
    setting up stage.
  • 22:49 - 22:51
    Meanwhile,
  • 22:51 - 22:53
    do you have any
  • 22:53 - 22:55
    questions, so far?
  • 23:05 - 23:07
    [Question] The setup we see running
  • 23:07 - 23:09
    thats setting it up in a sandbox
  • 23:09 - 23:11
    or something. [Gergely] Yes.
  • 23:11 - 23:13
    'sbuild',
  • 23:13 - 23:15
    is a tool
  • 23:15 - 23:17
    with which you can setup a
  • 23:17 - 23:19
    'chroot'.
  • 23:21 - 23:23
    A clean one,
  • 23:23 - 23:25
    and it will
  • 23:25 - 23:27
    do all the magic in there.
  • 23:27 - 23:29
    It's also,
  • 23:29 - 23:31
    useful if you are running,
  • 23:31 - 23:33
    say, 'stable' or
  • 23:33 - 23:35
    'testing' but want to build for a
  • 23:35 - 23:37
    stable, because
  • 23:37 - 23:39
    everything that goes into debian
  • 23:39 - 23:41
    must be built on 'unstable'.
  • 23:45 - 23:47
    [Question] Do you have any recommendations
  • 23:47 - 23:49
    regarding the build environment? For, example using
  • 23:49 - 23:51
    'pbuilder' over 'cowbuilder',
  • 23:51 - 23:53
    or is it just a personal preference?
  • 23:53 - 23:55
    [Gergely] It's just personal
  • 23:55 - 23:57
    preference, I have used 'sbuild'
  • 23:57 - 23:59
    ever since it was
  • 23:59 - 24:01
    packaged. So, thats what
  • 24:03 - 24:05
    I'm familiar with,
  • 24:05 - 24:07
    but other
  • 24:07 - 24:09
    other people are using 'pbuilder' or
  • 24:09 - 24:11
    'cowbuilder' and
  • 24:11 - 24:13
    I think there are maybe one or two
  • 24:13 - 24:15
    more similiar tools.
  • 24:15 - 24:17
    They all work, they all
  • 24:17 - 24:19
    have different properties.
  • 24:19 - 24:21
    You can choose which ever
  • 24:21 - 24:23
    you like.
  • 24:25 - 24:27
    It builds and now it's
  • 24:27 - 24:29
    removing all the packages
  • 24:29 - 24:31
    it installed before.
  • 24:33 - 24:35
    We have a successful build but,
  • 24:35 - 24:37
    'lintian' failed.
  • 24:37 - 24:39
    Well, thats
  • 24:39 - 24:41
    kind of expected because there is a lot of
  • 24:41 - 24:43
    things missing from this package.
  • 24:47 - 24:49
    oh, I'm stupid
  • 24:49 - 24:51
    nevermind.
  • 24:51 - 24:53
    So,
  • 24:53 - 24:55
    we have a debian package.
  • 24:55 - 24:57
    Right here, which we built.
  • 25:01 - 25:03
    Lets try installing it.
  • 25:11 - 25:13
    Ooooh,
  • 25:13 - 25:15
    there are things in it.
  • 25:17 - 25:19
    and if I
  • 25:19 - 25:21
    run it.
  • 25:21 - 25:23
    It works! It
  • 25:23 - 25:25
    looks a bit silly [clapping] but it works
  • 25:25 - 25:27
    [clapping]
  • 25:29 - 25:31
    I just rememebered that I had this terminal
  • 25:31 - 25:33
    window open, because I wanted to run it
  • 25:33 - 25:35
    here, because it has
  • 25:35 - 25:37
    smaller fonts and it
  • 25:37 - 25:39
    looks much nicer this way.
  • 25:45 - 25:47
    That was what I had,
  • 25:47 - 25:49
    prepared.
  • 25:53 - 25:55
    Oh, wait.
  • 26:05 - 26:07
    So, if we run
  • 26:07 - 26:09
    'lintian' on this thing, it
  • 26:11 - 26:13
    tells us a few
  • 26:13 - 26:15
    errors
  • 26:15 - 26:17
    and warnings.
  • 26:17 - 26:19
    Like, this binary
  • 26:19 - 26:21
    doesn't have a man page,
  • 26:21 - 26:23
    it's in section games but
  • 26:23 - 26:25
    contains no games because games
  • 26:25 - 26:27
    need to go into
  • 26:27 - 26:29
    '/usr/games' not in
  • 26:29 - 26:31
    '/usr/bin'.
  • 26:31 - 26:33
    We can actually fix that easily.
  • 26:33 - 26:35
    That will show,
  • 26:35 - 26:37
    how to.
  • 26:41 - 26:43
    We have
  • 26:43 - 26:45
    a package which should
  • 26:45 - 26:47
    be installed
  • 26:47 - 26:49
    into
  • 26:49 - 26:51
    '/usr/games' instead of
  • 26:51 - 26:53
    '/usr/bin'.
  • 26:53 - 26:55
    Since we built only one
  • 26:55 - 26:57
    binary,
  • 26:57 - 26:59
    we can tell configure
  • 26:59 - 27:01
    that
  • 27:01 - 27:03
    binaries, should go into '/usr/games'
  • 27:03 - 27:05
    not '/usr/bin'.
  • 27:07 - 27:09
    With debhelper,
  • 27:09 - 27:11
    using this short form we
  • 27:11 - 27:13
    can do that by overriding,
  • 27:13 - 27:15
    the configure step.
  • 27:19 - 27:21
    That works
  • 27:21 - 27:23
    by adding a new target
  • 27:23 - 27:25
    to the
  • 27:25 - 27:27
    'debian/rules' makefile.
  • 27:27 - 27:29
    We simply call
  • 27:29 - 27:31
    the original
  • 27:31 - 27:33
    tool and
  • 27:33 - 27:35
    pass it
  • 27:35 - 27:37
    '--prefix=/usr/games' argument.
  • 27:41 - 27:43
    This will do all the magic
  • 27:43 - 27:45
    'dh_auto_configure'
  • 27:45 - 27:47
    does.
  • 27:47 - 27:49
    Which includes, adding
  • 27:51 - 27:53
    hardening flags,
  • 27:53 - 27:55
    adding
  • 27:55 - 27:57
    all kinds of other
  • 27:57 - 27:59
    options.
  • 27:59 - 28:01
    We will also tell it,
  • 28:01 - 28:03
    that we want to change
  • 28:03 - 28:05
    the prefix.
  • 28:09 - 28:11
    Another, thing
  • 28:11 - 28:13
    about the 'dch'
  • 28:13 - 28:15
    tool is,
  • 28:15 - 28:17
    it can not only create
  • 28:17 - 28:19
    changelog files it can
  • 28:19 - 28:21
    add new
  • 28:21 - 28:23
    entries into it.
  • 28:23 - 28:25
    By using the
  • 28:25 - 28:27
    '-i'
  • 28:27 - 28:29
    option.
  • 28:45 - 28:47
    Now we can build
  • 28:47 - 28:49
    the package again.
  • 28:57 - 28:59
    I stopped the build,
  • 29:07 - 29:09
    Anyway, if it wasn't
  • 29:09 - 29:11
    scrolling this fast, you could see the
  • 29:11 - 29:13
    argument we
  • 29:13 - 29:15
    added
  • 29:15 - 29:17
    was actually passed.
  • 29:21 - 29:23
    Anyway, if we
  • 29:23 - 29:25
    look at the,
  • 29:25 - 29:27
    Ok, not going to do that
  • 29:27 - 29:29
    in midnight commander.
  • 29:37 - 29:39
    There is another command called,
  • 29:39 - 29:41
    'dpkg-deb'
  • 29:41 - 29:43
    With which you can inspect,
  • 29:43 - 29:45
    extract and
  • 29:45 - 29:47
    reassemble
  • 29:47 - 29:49
    debian packages.
  • 29:49 - 29:51
    Right now we will use the
  • 29:51 - 29:53
    '-c' option
  • 29:53 - 29:55
    which means contents.
  • 29:57 - 29:59
    To list what
  • 29:59 - 30:01
    is inside it.
  • 30:03 - 30:05
    Well,
  • 30:05 - 30:07
    this worked a little
  • 30:07 - 30:09
    except we didn't want to
  • 30:09 - 30:11
    pass prefix because
  • 30:11 - 30:13
    everything under prefix
  • 30:13 - 30:15
    '/usr/games/' including
  • 30:15 - 30:17
    the documentation! We only want
  • 30:17 - 30:19
    to place the binaries
  • 30:19 - 30:21
    there.
  • 30:25 - 30:27
    So, it's not '--prefix=/usr/games'
  • 30:27 - 30:29
    but
  • 30:29 - 30:31
    '--bindir=/usr/games'.
  • 30:31 - 30:33
    I think,
  • 30:37 - 30:39
    yup.
  • 30:45 - 30:47
    Ok, here we go
  • 30:47 - 30:49
    again.
  • 30:51 - 30:53
    This time instead of
  • 30:53 - 30:55
    looking at the final
  • 30:55 - 30:57
    package, we will have a look at
  • 30:59 - 31:01
    the debian directory.
  • 31:01 - 31:03
    As you can see there are a couple of new
  • 31:03 - 31:05
    files there, like
  • 31:07 - 31:09
    'debian/files' or
  • 31:09 - 31:11
    the
  • 31:11 - 31:13
    'cake-is-a-lie.debhelper.log'
  • 31:13 - 31:15
    which is a log of
  • 31:15 - 31:17
    the 'debhelper' commands
  • 31:17 - 31:19
    which ran,
  • 31:19 - 31:21
    or the 'cake-is-a-lie.substvars' file.
  • 31:21 - 31:23
    There is also a directory
  • 31:25 - 31:27
    called 'cake-is-a-lie'.
  • 31:27 - 31:29
    In this
  • 31:29 - 31:31
    directory are
  • 31:33 - 31:35
    all the
  • 31:35 - 31:37
    things
  • 31:37 - 31:39
    installed which our package will
  • 31:39 - 31:41
    include.
  • 31:43 - 31:45
    If we go through that,
  • 31:45 - 31:47
    will we see that under '/usr/games'
  • 31:47 - 31:49
    is our program,
  • 31:49 - 31:51
    there is documentation,
  • 31:51 - 31:53
    and there are the pictures also,
  • 31:53 - 31:55
    and there is a DEBIAN
  • 31:55 - 31:57
    directory.
  • 31:57 - 31:59
    In all captial letters,
  • 31:59 - 32:01
    that directory is
  • 32:01 - 32:03
    special
  • 32:03 - 32:05
    it contains all the
  • 32:07 - 32:09
    metadata
  • 32:09 - 32:11
    which also goes into the
  • 32:11 - 32:13
    final debian
  • 32:13 - 32:15
    package. This is all
  • 32:15 - 32:17
    created by 'debhelper'.
  • 32:21 - 32:23
    If you want to quickly look at
  • 32:23 - 32:25
    what goes into your package
  • 32:25 - 32:27
    you can look
  • 32:27 - 32:29
    under the debian directory,
  • 32:29 - 32:31
    and find the
  • 32:31 - 32:33
    directory with the same name as
  • 32:33 - 32:35
    your binary package and see what is
  • 32:35 - 32:37
    there. What is in there will go
  • 32:37 - 32:39
    in your package.
  • 32:43 - 32:45
    If we run 'lintian'
  • 32:45 - 32:47
    on this again.
  • 32:59 - 33:01
    Well, it complains about a lot less
  • 33:01 - 33:03
    things.
  • 33:05 - 33:07
    Our program is finally at the correct
  • 33:07 - 33:09
    location.
  • 33:09 - 33:11
    So, what I would advise,
  • 33:11 - 33:13
    if you start
  • 33:13 - 33:15
    to package something from scratch
  • 33:15 - 33:17
    start with a very simple rules
  • 33:17 - 33:19
    file that pretty much
  • 33:19 - 33:21
    leaves everything to
  • 33:21 - 33:23
    'debhelper' and
  • 33:23 - 33:25
    after each interation
  • 33:25 - 33:27
    run 'lintian' and try to
  • 33:27 - 33:29
    correct the problems.
  • 33:29 - 33:31
    If you need
  • 33:31 - 33:33
    to change something,
  • 33:33 - 33:35
    which 'debhelper' can't figure out,
  • 33:35 - 33:37
    or something it
  • 33:37 - 33:39
    figures out but wrongly.
  • 33:39 - 33:41
    Just, add an override,
  • 33:41 - 33:43
    you don't have to know
  • 33:43 - 33:45
    all the magic that
  • 33:45 - 33:47
    is behind 'debhelper'
  • 33:47 - 33:49
    just a few tiny pieces.
  • 33:49 - 33:51
    Which you need,
  • 33:51 - 33:53
    for your package.
  • 33:57 - 33:59
    That's pretty much my recommendation.
  • 33:59 - 34:01
    I have found that,
  • 34:01 - 34:03
    it works fairly well.
  • 34:03 - 34:05
    Most of my packages are
  • 34:05 - 34:07
    built this way.
  • 34:11 - 34:13
    Any questions ?
  • 34:17 - 34:19
    Here in the front.
  • 34:25 - 34:27
    [Question] Where does
  • 34:27 - 34:29
    'make' come into play?
  • 34:33 - 34:35
    [Gergely] I am not quite sure why 'make' was chosen,
  • 34:35 - 34:37
    originally for Debian rules.
  • 34:39 - 34:41
    Some 10 years
  • 34:41 - 34:43
    ago you only needed a file,
  • 34:43 - 34:45
    it didn't have
  • 34:45 - 34:47
    to be a makefile although it was
  • 34:47 - 34:49
    recommended
  • 34:49 - 34:51
    but then the policy was changed
  • 34:53 - 34:55
    to require it being a
  • 34:55 - 34:57
    make file and I'm not quite sure why.
  • 34:57 - 34:59
    It's a
  • 34:59 - 35:01
    mostly likely
  • 35:01 - 35:03
    habit,
  • 35:03 - 35:05
    or historical reasons.
  • 35:11 - 35:13
    Does that answer your question?
  • 35:19 - 35:21
    [Questioner] Maybe my
  • 35:21 - 35:23
    question was wrong,
  • 35:23 - 35:25
    What is the difference between 'dpkg-buildpackage'
  • 35:25 - 35:27
    and make ?
  • 35:27 - 35:29
    [Gergely] Oh. Well the main
  • 35:29 - 35:31
    difference is
  • 35:31 - 35:33
    that 'dpkg-buildpackage'
  • 35:33 - 35:35
    does a few other things.
  • 35:35 - 35:37
    Like,
  • 35:37 - 35:39
    generating a changes file for you,
  • 35:39 - 35:41
    it can also build
  • 35:41 - 35:43
    source package
  • 35:43 - 35:45
    and
  • 35:45 - 35:47
    it can do a couple
  • 35:47 - 35:49
    of other things but the main
  • 35:49 - 35:51
    is generating
  • 35:51 - 35:53
    the changes file,
  • 35:53 - 35:55
    the changes file lists,
  • 35:55 - 35:57
    well we can just
  • 35:57 - 35:59
    have a look at it.
  • 36:01 - 36:03
    No.
  • 36:11 - 36:13
    The changes
  • 36:13 - 36:15
    file is what you,
  • 36:15 - 36:17
    actually upload
  • 36:17 - 36:19
    to the Debian servers,
  • 36:19 - 36:21
    along with the rest.
  • 36:21 - 36:23
    It lists all the
  • 36:23 - 36:25
    files that belong to this
  • 36:25 - 36:27
    version of the package
  • 36:27 - 36:29
    including the source,
  • 36:29 - 36:31
    if there is any.
  • 36:33 - 36:35
    This is something that 'make'
  • 36:35 - 36:37
    can't do, this is
  • 36:37 - 36:39
    all
  • 36:39 - 36:41
    done by,
  • 36:43 - 36:45
    'dpkg-buildpackage' or
  • 36:45 - 36:47
    actually a tool that it calls
  • 36:47 - 36:49
    for you.
  • 36:51 - 36:53
    We can
  • 36:53 - 36:55
    do something like Debian rules
  • 36:55 - 36:57
    binary,
  • 36:59 - 37:01
    if I where in the right directory,
  • 37:01 - 37:03
    that is.
  • 37:03 - 37:05
    Which we will do
  • 37:05 - 37:07
    nothing right now because it's already built,
  • 37:07 - 37:09
    but I can,
  • 37:09 - 37:11
    clean and I can run binary
  • 37:11 - 37:13
    and it will do all the things that
  • 37:13 - 37:15
    it did before.
  • 37:15 - 37:17
    'dkpg-buildpackage'
  • 37:17 - 37:19
    does call this command aswell,
  • 37:19 - 37:21
    the difference is that,
  • 37:21 - 37:23
    now I have a deb file,
  • 37:23 - 37:25
    and that is it.
  • 37:25 - 37:27
    I don't have a source
  • 37:27 - 37:29
    tarball, I don't have
  • 37:29 - 37:31
    the debian tarball,
  • 37:31 - 37:33
    I don't have the debian
  • 37:33 - 37:35
    source control file, I don't have the
  • 37:35 - 37:37
    changes file and I don't
  • 37:37 - 37:39
    have any of the signed either.
  • 37:39 - 37:41
    'dpkg-buildpackage'
  • 37:41 - 37:43
    does that
  • 37:43 - 37:45
    for you.
  • 37:47 - 37:49
    Any other questions ?
  • 37:49 - 37:51
    Another here.
  • 37:53 - 37:55
    [Question] I have never
  • 37:55 - 37:57
    packaged anything but I have
  • 37:57 - 37:59
    some code that has,
  • 37:59 - 38:01
    the Debian rules for ubuntu.
  • 38:01 - 38:03
    Is there any difference ?
  • 38:03 - 38:05
    [Gergely] Not much.
  • 38:05 - 38:07
    [Questioner] Could it be a start to learn to package ?
  • 38:07 - 38:09
    [Gergely] Yes. [Questioner] And if it's
  • 38:09 - 38:11
    a python package ?
  • 38:11 - 38:13
    [Gergely] Well, that's a little bit different.
  • 38:15 - 38:17
    You will most
  • 38:17 - 38:19
    likely
  • 38:19 - 38:21
    need to adjust the
  • 38:21 - 38:23
    dependicies by hand, I'm not
  • 38:23 - 38:25
    quite sure
  • 38:25 - 38:27
    but you can't figure out python
  • 38:27 - 38:29
    dependicies automatically.
  • 38:31 - 38:33
    But otherwise it's very similiar.
  • 38:33 - 38:35
    I believe.
  • 38:35 - 38:37
    But, if you have a debian
  • 38:37 - 38:39
    rules files from ubuntu
  • 38:39 - 38:41
    that is a good start.
  • 38:41 - 38:43
    [Questioner] Okay, thanks.
  • 38:53 - 38:55
    [Gergely] If there are no more questions then,
  • 38:57 - 38:59
    I think this is it.
  • 38:59 - 39:01
    I can be
  • 39:01 - 39:03
    algernon@debian.org
  • 39:03 - 39:05
    or on IRC,
  • 39:07 - 39:09
    if you have any packaging
  • 39:09 - 39:11
    questions feel free to
  • 39:11 - 39:13
    turn to me and
  • 39:13 - 39:15
    I will be happy to answer,
  • 39:15 - 39:17
    if I can.
  • 39:17 - 39:19
    If not I'll try to find
  • 39:19 - 39:21
    appropriate documention.
  • 39:23 - 39:29
    [Applause]
Title:
1009_Packaging_for_beginners.ogv
Video Language:
English
Team:
Debconf
Project:
2013_debconf13

English subtitles

Revisions