debian packaging tutorial.en

Upload: gintales

Post on 05-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Debian Packaging Tutorial.en

    1/76

    Debian Packaging Tutorial

    Lucas [email protected]

    version 0.5 2012-01-14

    Debian Packaging Tutorial 1 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    2/76

    About this tutorial

    Goal: tell you what you really need to know about Debian packaging Modify existing packages

    Create your own packages

    Interact with the Debian community

    Become a Debian power-user

    Covers the most important points, but is not complete

    You will need to read more documentation

    Most of the content also applies to Debian derivatives distributions That includes Ubuntu

    Debian Packaging Tutorial 2 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    3/76

    Outline1 Introduction

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessionsDebian Packaging Tutorial 3 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    4/76

    Outline1 Introduction

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11

    Answers to practical sessionsDebian Packaging Tutorial 4 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    5/76

  • 7/31/2019 Debian Packaging Tutorial.en

    6/76

    Debian packages

    .deb files (binary packages)

    A very powerful and convenient way to distribute software to users

    One of the two most common packages format (with RPM)

    Universal:

    30,000 binary packages in Debian most of the available free software is packaged in Debian!

    For 12 ports (architectures), including 2 non-Linux (Hurd; KFreeBSD)

    Also used by 120 Debian derivatives distributions

    Debian Packaging Tutorial 6 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    7/76

    The Deb package format

    .deb file: an ar archive

    $ a r tv w ge t_ 1 . 12 - 2 .1 _ i 38 6 . d ebrw -r - -r - - 0/0 4 Sep 5 15:43 2010 debian - binary

    rw -r --r -- 0/0 2403 S ep 5 1 5:43 2 010 c ontrol . tar .gz

    rw - r -- r- - 0 /0 7 51 61 3 S ep 5 1 5: 43 2 01 0 d at a . tar . gz

    debian-binary: version of the deb file format, "2.0\n"

    control.tar.gz: metadata about the packagecontrol, md5sums, (pre|post)(rm|inst), triggers, shlibs, . . . data.tar.gz: data files of the package

    You could create your .deb files manuallyhttp://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/

    But most people dont do it that way

    This tutorial: create Debian packages, the Debian way

    Debian Packaging Tutorial 7 / 76

    http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/
  • 7/31/2019 Debian Packaging Tutorial.en

    8/76

    Tools you will need

    A Debian (or Ubuntu) system (with root access)

    Some packages:

    build-essential: has dependencies on the packages that will beassumed to be available on the developers machine (no need tospecify them in the Build-Depends: control field of your package)

    includes a dependency on dpkg-dev, which contains basicDebian-specific tools to create packages

    devscripts: contains many useful scripts for Debian maintainers

    Many other tools will also be mentioned later, such as debhelper, cdbs, quilt,pbuilder, sbuild, lintian, svn-buildpackage, git-buildpackage, . . .Install them when you need them.

    Debian Packaging Tutorial 8 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    9/76

    General packaging workflow

    Web upstream sourceDebian mirror

    source package where most of themanual work is done

    one or several binary packages .deb

    dh_makeapt-get source dget

    debuild (build and test with lintian)or dpkg-buildpackage

    install (debi)upload (dput)

    Debian Packaging Tutorial 9 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    10/76

    Example: rebuilding dash

    1 Install packages needed to build dash, and devscriptssudo apt-get build-dep dash

    (requires deb-src lines in /etc/apt/sources.list)sudo apt-get install --no-install-recommends devscripts

    2 Create a working directory, and get in it:mkdir /tmp/debian-tutorial ; cd /tmp/debian-tutorial

    3 Grab the dash source package

    apt-get source dash(This needs you to have deb-src lines in your /etc/apt/sources.list)

    4 Build the packagecd dash-*

    debuild -us -uc

    5 Check that it worked

    There are some new .deb files in the parent directory

    6 Look at the debian/ directory

    Thats where the packaging work is done

    Debian Packaging Tutorial 10 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    11/76

    Outline1 Introduction

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 11 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    12/76

    Source package

    One source package can generate several binary packagese.g the libtar source generates the libtar0 and libtar-dev binary packages

    Two kinds of packages: (if unsure, use non-native) Native packages: normally for Debian specific software (dpkg, apt) Non-native packages: software developed outside Debian

    Main file: .dsc (meta-data)

    Other files depending on the version of the source format 1.0 native: package_version.tar.gz

    1.0 non-native:

    pkg_ver.orig.tar.gz : upstream source pkg_debver.diff.gz : patch to add Debian-specific changes

    3.0 (quilt):

    pkg_ver.orig.tar.gz : upstream source pkg_debver.debian.tar.gz : tarball with the Debian changes

    (See dpkg-source(1) for exact details)

    Debian Packaging Tutorial 12 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    13/76

    Source package example (wget_1.12-2.1.dsc)

    F or ma t : 3 .0 ( q ui lt )

    S o ur c e : w ge t

    B i na r y : w ge tA r c hi t e ct u r e : a ny

    V e rs i on : 1 .1 2 - 2 .1

    M a in t ai n e r : N oe l K ot he < n o e l @d e b ia n . o rg >

    H o m e pa g e : h t t p : / / w ww . g n u . o r g / s o f t w a r e / w g e t /

    S t an d ar d s - V e r s i o n : 3 . 8. 4

    B ui ld - D e p en d s : d e bh e lp e r ( > > 5 .0 .0 ) , g et te xt , t ex in fo ,l ib ss l - d e v ( > = 0 .9 .8 ) , d pa tc h , i n fo 2 ma n

    Checksums - Sha1:

    5 0 d 4 e d2 4 4 1e 6 7 [ . . ]1 e e 0e 9 42 4 8 2 4 64 7 47 w g et _ 1 . 1 2. o ri g . t ar . g z

    d 4 c 1c 8 b be 4 3 1d [ .. ] d d 7 c e f3 6 11 4 8 30 8 w g et _ 1 . 1 2 - 2 .1 . d e b ia n . t a r . gz

    Checksums -Sha256 :

    7 57 8 e d 0 9 74 e 12 [ .. ] d c b a 6 5b 5 72 2 4 64 7 47 w g et _ 1 . 1 2. o ri g . t ar . g z1 e 9 b 0 c 4c 0 0 ea e [ . .] 8 9 c 4 0 2a d 78 4 8 30 8 w g et _ 1 . 1 2 - 2 .1 . d e b ia n . t a r . gz

    Files:

    1 4 14 6 1 b 9 c 04 e 4 [ . . ]9 d 1 f2 a bf 8 3 2 4 64 7 47 w g et _ 1 . 1 2. o ri g . t ar . g z

    e 9 3 12 3 c 93 4 e 3c [ .. ] 2 f 3 8 0 27 8 c2 4 8 30 8 w g et _ 1 . 1 2 - 2 .1 . d e b ia n . t a r . gz

    Debian Packaging Tutorial 13 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    14/76

    Retrieving an existing source package

    From the Debian archive:

    apt-get source package apt-get source package=version apt-get source package/release

    (You need deb-src lines in sources.list)

    From the Internet:

    dget url-to.dsc dget http://snapshot.debian.org/archive/debian-archive/

    20090802T004153Z/debian/dists/bo/main/source/web/

    wget_1.4.4-6.dsc

    (snapshot.d.o provides all packages from Debian since 2005)

    From the (declared) version control system:

    debcheckout package

    Once downloaded, extract with dpkg-source -x file.dsc

    Debian Packaging Tutorial 14 / 76

    C i b i k

    http://snapshot.debian.org/http://snapshot.debian.org/http://snapshot.debian.org/
  • 7/31/2019 Debian Packaging Tutorial.en

    15/76

    Creating a basic source package

    Download the upstream source(upstream source = the one from the softwares original developers)

    Rename to _.orig.tar.gz

    (example: simgrid_3.6.orig.tar.gz)

    Untar it cd upstream_source && dh_make (from the dh-make package)

    There are some alternatives to dh_make for specific sets of packages:dh-make-perl, dh-make-php, . . .

    debian/ directory created, with a lot of files in it

    Debian Packaging Tutorial 15 / 76

    Fil i d bi /

  • 7/31/2019 Debian Packaging Tutorial.en

    16/76

    Files in debian/All the packaging work should be made by modifying files in debian/

    Main files:

    control meta-data about the package (dependencies, etc) rules specifies how to build the package copyright copyright information for the package changelog history of the Debian package

    Other files:

    compat watch dh_install* targets

    *.dirs, *.docs, *.manpages, . . . maintainer scripts

    *.postinst, *.prerm, . . . source/format patches/ if you need to modify the upstream sources

    Several files use a format based on RFC 822 (mail headers)

    Debian Packaging Tutorial 16 / 76

    d bi / h l

  • 7/31/2019 Debian Packaging Tutorial.en

    17/76

    debian/changelog Lists the Debian packaging changes

    Gives the current version of the package

    1.2.1.1-5Debian

    revision

    Upstream

    version

    Edited manually or with dch

    Special format to automatically close Debian or Ubuntu bugsDebian: Closes: #595268; Ubuntu: LP: #616929

    Installed as /usr/share/doc/package /changelog.Debian.gz

    mpich2 (1.2.1.1 -5) unstable ; urgency = low

    * U se / u sr / b in / p y th on i ns te ad o f / u sr / b in / p y th on 2 . 5. A ll owto d ro p d ep en de nc y on p yt ho n2 . 5. C lo se s : # 59 52 68

    * M ak e / u sr / b in / m p dr oo t s et ui d . T hi s i s t he d ef au lt a ft er

    t he i n st a ll at i on o f m pi ch 2 f ro m s ou rc e , t oo . L P : # 61 69 29

    + A dd c o rr e sp o nd in g l in ti an o ve rr id e .

    - - L uc as N us sb au m < l uc as @d eb ia n . org > Wed , 15 S ep 2 01 0 1 8: 13 :4 4 + 02 0

    Debian Packaging Tutorial 17 / 76

    d bi / t l

  • 7/31/2019 Debian Packaging Tutorial.en

    18/76

    debian/control Package metadata

    For the source package itself For each binary package built from this source

    Package name, section, priority, maintainer, uploaders,build-dependencies, dependencies, description, homepage, . . .

    Documentation: Debian Policy chapter 5http://www.debian.org/doc/debian-policy/ch-controlfields.html

    S o ur c e : w ge tS e ct i on : w eb

    P r io r it y : i m po r ta n t

    M a in t a in e r : N oe l K o th e < n o e l @d e b ia n . o rg >

    B ui ld - D e p en d s : d e bh e lp e r ( > > 5 .0 .0 ) , g et te xt , t ex in fo ,

    l ib ss l - d e v ( > = 0 .9 .8 ) , d pa tc h , i n fo 2 ma n

    S t an d a rd s - V e r s i o n : 3 . 8 .4

    H o m e pa g e : h t t p : / / w w w . g n u . o r g / s o f t w a r e / w g e t /

    P a ck a ge : w ge t

    A r c hi t e ct u r e : a ny

    D e pe n ds : $ { s h li b s : D e p en d s } , $ { m i sc : D e p e nd s }

    D es c ri p ti on : r et r ie ve s f il es f ro m t he w eb

    W ge t is a n et wo rk u ti li ty to r et ri ev e f il es f ro m t he We bDebian Packaging Tutorial 18 / 76

    http://www.debian.org/doc/debian-policy/ch-controlfields.htmlhttp://www.debian.org/doc/debian-policy/ch-controlfields.html
  • 7/31/2019 Debian Packaging Tutorial.en

    19/76

    debian/rules

  • 7/31/2019 Debian Packaging Tutorial.en

    20/76

    debian/rules

    Makefile

    Interface used to build Debian packages

    Documented in Debian Policy, chapter 4.8http://www.debian.org/doc/debian-policy/ch-source.html#s-debianrules

    Five required targets:

    build: should perform all the configuration and compilation

    binary, binary-arch, binary-indep: build the binary packages

    dpkg-buildpackage will call binary to build all the packages, or

    binary-arch to build only the Architecture: any packages

    clean: clean up the source directory

    Debian Packaging Tutorial 20 / 76

    Packaging helpers debhelper

  • 7/31/2019 Debian Packaging Tutorial.en

    21/76

    Packaging helpers debhelper You could write shell code in debian/rules directly

    See the adduser package for example

    Better practice (used by most packages): use a Packaging helper Most popular one: debhelper (used by 98% of packages)

    Goals:

    Factor the common tasks in standard tools used by all packages

    Fix some packaging bugs once for all packagesdh_installdirs, dh_installchangelogs, dh_installdocs, dh_installexamples, dh_install,

    dh_installdebconf, dh_installinit, dh_link, dh_strip, dh_compress, dh_fixperms, dh_perl,

    dh_makeshlibs, dh_installdeb, dh_shlibdeps, dh_gencontrol, dh_md5sums, dh_builddeb, . . .

    Called fromdebian/rules Configurable using command parameters or files in debian/

    package.docs, package.examples, package.install, package.manpages, ...

    Third-party helpers for sets of packages: python-support, dh_ocaml, . . .

    Gotcha: debian/compat: Debhelper compatibility version (use "7")

    Debian Packaging Tutorial 21 / 76

    debian/rules using debhelper (1/2)

  • 7/31/2019 Debian Packaging Tutorial.en

    22/76

    debian/rules using debhelper (1/2)

    # !/ u s r / b in / m a k e - f

    # U nc om me nt t hi s to t ur n on v er bo se m od e .

    # e x p or t D H _V E R BO S E = 1

    build:

    $ ( M A K E )

    # d o cb oo k - to - m an d e bi a n / p a c k ag e n am e . s g m l > p a c ka g e na m e . 1

    clean:

    dh_testdirdh_testroot

    r m - f b ui ld - s t a mp c on f ig u re - s t a mp

    $ ( M A KE ) c l ea n

    dh_clean

    i n st a ll : b u il d

    dh_testdirdh_testroot

    d h _c l ea n - k

    dh_installdirs

    # A dd h er e c om ma nd s to i ns ta ll t he p ac ka ge i nt o d eb ia n / pa ck ag

    $ ( M A KE ) D E ST D IR = $ ( C U R D IR ) / d e b i an / p a c ka g e na m e i n st a ll

    Debian Packaging Tutorial 22 / 76

    debian/rules using debhelper (2/2)

  • 7/31/2019 Debian Packaging Tutorial.en

    23/76

    debian/rules using debhelper (2/2)

    # B u il d a r ch i te c tu r e - i n d e p en d e nt f i le s h er e .

    b in ar y - i n d ep : b ui l d i n st a ll

    # B u il d a r ch i te c tu r e - d e p e nd e nt f i le s h er e .b in ar y - a r ch : b ui l d i n st a ll

    dh_testdir

    dh_testroot

    d h _ i n s t a l l c h a n g e l o g s

    dh_installdocs

    d h _ i n s t a l l e x a m p l e s

    dh_install

    dh_installman

    dh_link

    dh_strip

    dh_compress

    dh_fixperms

    dh_installdebdh_shlibdeps

    dh_gencontrol

    dh_md5sums

    dh_builddeb

    b i na r y : b in ar y - i n d ep b in ar y - a r ch

    . P H ON Y : b ui ld c le an b in ar y - i n de p b in ar y - a rc h b in ar y i ns ta ll c on f ig ur eDebian Packaging Tutorial 23 / 76

    CDBS

  • 7/31/2019 Debian Packaging Tutorial.en

    24/76

    CDBS With debhelper, still a lot of redundancy between packages

    Second-level helpers that factor common functionality

    E.g building with ./configure && make && make install or CMake CDBS:

    Introduced in 2005, based on advanced GNU make magic Documentation: /usr/share/doc/cdbs/ Support for Perl, Python, Ruby, GNOME, KDE, Java, Haskell, . . . But some people hate it:

    Sometimes difficult to customize package builds:"twisty maze of makefiles and environment variables"

    Slower than plain debhelper (many useless calls to dh_*)

    # !/ u s r / b in / m a k e - fi n c l ud e / u s r / s h a r e / c d b s / 1 / r u l e s / d e b h e l p e r . m k

    i n c l ud e / u s r / s h a r e / c d b s / 1 / c l a s s / a u t o t o o l s . m k

    # add an a cti on af ter the b uil d

    b u i l d / m y p a c k a g e : :

    / b i n / b as h d e bi a n / s c ri p ts / f o o . s h

    Debian Packaging Tutorial 24 / 76

    Dh (aka Debhelper 7 or dh7)

  • 7/31/2019 Debian Packaging Tutorial.en

    25/76

    Dh (aka Debhelper 7, or dh7)

    Introduced in 2008 as a CDBS killer

    dh command that calls dh_* Simple debian/rules, listing only overrides

    Easier to customize than CDBS

    Doc: manpages (debhelper(7), dh(1)) + slides from DebConf9 talk

    http://kitenet.net/~joey/talks/debhelper/debhelper-slides.pdf

    # !/ u s r / b in / m a k e - f

    %:

    dh $@

    o v e r r i d e _ d h _ a u t o _ c o n f i g u r e :

    d h _ a u t o _ c o n fi g u r e - - - - w it h - k i t ch e n - s i n k

    o v e r r i d e _ d h _ a u t o _ b u i l d :

    make world

    Debian Packaging Tutorial 25 / 76

    Classic debhelper vs CDBS vs dh

    http://kitenet.net/~joey/talks/debhelper/debhelper-slides.pdfhttp://kitenet.net/~joey/talks/debhelper/debhelper-slides.pdf
  • 7/31/2019 Debian Packaging Tutorial.en

    26/76

    Classic debhelper vs CDBS vs dh Mind shares:

    Classic debhelper: 36% CDBS: 21% dh: 41%

    Which one should I learn? Probably a bit of all of them You need to know debhelper to use dh and CDBS You might have to modify CDBS packages

    Which one should I use for a new package?

    dh (only solution with an increasing mind share)

    11/2009 05/2010 12/2010 06/2011 01/20120

    20

    40

    60

    Time

    Market

    share(%)

    debhelper

    dh

    CDBS

    Debian Packaging Tutorial 26 / 76

    Outline

  • 7/31/2019 Debian Packaging Tutorial.en

    27/76

    Outline1 Introduction

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 27 / 76

    Building packages

  • 7/31/2019 Debian Packaging Tutorial.en

    28/76

    Building packages

    apt-get build-dep mypackage

    Installs the build-dependencies(for a package in the archive)

    debuild: build, test with lintian, sign with GPG

    Also possible to call dpkg-buildpackage directly

    Usually with dpkg-buildpackage -us -uc

    It is better to build packages in a clean & minimal environment pbuilder helper to build packages in a chroot

    Good documentation: https://wiki.ubuntu.com/PbuilderHowto(optimization: cowbuilder ccache distcc)

    schroot and sbuild: used on the Debian build daemons

    (not as simple as pbuilder, but allows LVM snapshotssee: https://help.ubuntu.com/community/SbuildLVMHowto )

    Generates .deb files and a .changes file

    .changes: describes what was built; used to upload the package

    Debian Packaging Tutorial 28 / 76

    Installing and testing packages

    https://wiki.ubuntu.com/PbuilderHowtohttps://help.ubuntu.com/community/SbuildLVMHowtohttps://help.ubuntu.com/community/SbuildLVMHowtohttps://wiki.ubuntu.com/PbuilderHowto
  • 7/31/2019 Debian Packaging Tutorial.en

    29/76

    Installing and testing packages

    Install the package locally: debi (will use .changes to know what to install)

    List the content of the package: debc ../mypackage.changes

    Compare the package with a previous version:debdiff ../mypackage_1_*.changes ../mypackage_2_*.changes

    or to compare the sources:

    debdiff ../mypackage_1_*.dsc ../mypackage_2_*.dsc Check the package with lintian (static analyzer):

    lintian ../mypackage.changes

    lintian -i: gives more information about the errors

    Upload the package to Debian (dput) (needs configuration)

    Manage a private Debian archive with repreproDocumentation: http://mirrorer.alioth.debian.org/

    Debian Packaging Tutorial 29 / 76

    Outline

    http://mirrorer.alioth.debian.org/http://mirrorer.alioth.debian.org/
  • 7/31/2019 Debian Packaging Tutorial.en

    30/76

    Outline1 Introduction

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 30 / 76

    Practical session 1: modifying the grep package

  • 7/31/2019 Debian Packaging Tutorial.en

    31/76

    y g g p p g

    1 Go to http://ftp.debian.org/debian/pool/main/g/grep/ anddownload version 2.6.3-3 of the package (if you use Ubuntu 11.10 or later,

    or Debian testing or unstable, use version 2.9-1 or 2.9-2 instead)2 Look at the files in debian/.

    How many binary packages are generated by this source package? Which packaging helper does this package use?

    3 Build the package

    4 We are now going to modify the package. Add a changelog entry andincrease the version number.

    5 Now disable perl-regexp support (it is a ./configure option)

    6 Rebuild the package

    7 Compare the original and the new package with debdiff

    8 Install the newly built package

    9 Cry if you messed up ;)

    Debian Packaging Tutorial 31 / 76

    Outline

    http://ftp.debian.org/debian/pool/main/g/grep/http://ftp.debian.org/debian/pool/main/g/grep/
  • 7/31/2019 Debian Packaging Tutorial.en

    32/76

    1 Introduction

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 32 / 76

    debian/copyright

  • 7/31/2019 Debian Packaging Tutorial.en

    33/76

    py g

    Copyright and license information for the source and the packaging

    Traditionally written as a text file

    New machine-readable format: http://dep.debian.net/deps/dep5/

    F o r m at : < V E R S I O N E D _ FO R M A T _ UR L >

    U p st r ea m - N a m e : X S o l i t ai r e

    S o u r ce : f t p : / / f t p . e x a m p l e . c o m / p u b / g a m e s

    F il es : *

    C op yr ig ht : C op yr i gh t 1 99 8 J oh n D oe < j d oe @ ex a mp l e . com >L i ce n se : G PL - 2+

    T hi s p ro gr am is f re e s of tw ar e ; y ou ca n r ed is tr ib ut e it

    [...]

    .

    On D eb ia n s ys te ms , th e f ul l t ex t of th e G NU G en er al P ub li c

    L ic en se v er si on 2 c an be f ou nd in the f il e

    / u s r / s h a r e / c o m m o n - l i c e n s e s / G P L - 2 .

    F i le s : d e bi a n / *

    C o py r ig h t : C o py r i gh t 1 99 8 J an e S m it h < j s m i th @ e xa m p le . n et >

    L i c e n s e :

    [ L I C EN S E T EX T ]

    Debian Packaging Tutorial 33 / 76

    Modifying the upstream source

    http://dep.debian.net/deps/dep5/http://dep.debian.net/deps/dep5/
  • 7/31/2019 Debian Packaging Tutorial.en

    34/76

    y g p

    Often needed:

    Fix bugs or add customizations that are specific to Debian Backport fixes from a newer upstream release

    Several methods to do it:

    Modifying the files directly

    Simple But no way to track and document the changes

    Using patch systems

    Eases contributing your changes to upstream

    Helps sharing the fixes with derivatives Gives more exposure to the changes

    http://patch-tracker.debian.org/

    Debian Packaging Tutorial 34 / 76

    http://patch-tracker.debian.org/http://patch-tracker.debian.org/
  • 7/31/2019 Debian Packaging Tutorial.en

    35/76

    Documentation of patches

  • 7/31/2019 Debian Packaging Tutorial.en

    36/76

    Standard headers at the beginning of the patch

    Documented in DEP-3 - Patch Tagging Guidelineshttp://dep.debian.net/deps/dep3/

    D e s cr i p ti o n : F ix w i dg e t f r o bn i c at i o n s p ee d sF r ob n ic a ti n g w id ge ts t oo q ui ck ly t en de d t o c au se e xp l os io n s .

    F o r w a rd e d : h t tp : / / l i s t s . e x a m p l e . c o m / 2 0 1 0 / 0 3 / 1 2 3 4 . h t m l

    A u th o r : J oh n D oe < j oh nd oe - g u e s t@ u s er s . a l i o th . d e bi a n . or g >

    A p pl i ed - U p s t r e a m : 1 .2 , h t tp : / / b z r . f o o . c o m / f r o b n i c a t o r / r e v i s i o n / 1 2 3

    L as t - U p da t e : 2 01 0 - 0 3 - 29

    - - - a / s rc / w i d g et s . c+ ++ b / s rc / w i d g et s . c

    @@ -101 , 9 + 10 1 ,6 @@ s tr uc t {

    Debian Packaging Tutorial 36 / 76

    Doing things during installation and removal

    http://dep.debian.net/deps/dep3/http://dep.debian.net/deps/dep3/
  • 7/31/2019 Debian Packaging Tutorial.en

    37/76

    Decompressing the package is sometimes not enough

    Create/remove system users, start/stop services, manage alternatives

    Done in maintainer scriptspreinst, postinst, prerm, postrm

    Snippets for common actions can be generated by debhelper

    Documentation:

    Debian Policy Manual, chapter 6http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html

    Debian Developers Reference, chapter 6.4http://www.debian.org/doc/developers-reference/best-pkging-practices.html

    http://people.debian.org/~srivasta/MaintainerScripts.html

    Prompting the user

    Must be done with debconf

    Documentation: debconf-devel(7) (debconf-doc package)

    Debian Packaging Tutorial 37 / 76

    Monitoring upstream versions

    http://www.debian.org/doc/debian-policy/ch-maintainerscripts.htmlhttp://www.debian.org/doc/developers-reference/best-pkging-practices.htmlhttp://people.debian.org/~srivasta/MaintainerScripts.htmlhttp://people.debian.org/~srivasta/MaintainerScripts.htmlhttp://www.debian.org/doc/developers-reference/best-pkging-practices.htmlhttp://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
  • 7/31/2019 Debian Packaging Tutorial.en

    38/76

    Specify where to look in debian/watch (see uscan(1))

    version=3

    h t tp : / / t m r c . m i t . e d u / m i r r o r / t w i s t e d / T w i s te d / ( \ d \ . \ d ) / \

    Twisted -([\d \.]*)\. tar\. bz2

    Debian infrastructure that makes use of debian/watch:

    Debian External Health Statushttp://dehs.alioth.debian.org/

    Maintainer warned by emails sent to the Package Tracking Systemhttp://packages.qa.debian.org/

    uscan: run a manual check

    uupdate: try to update your package to the latest upstream version

    Debian Packaging Tutorial 38 / 76

    Packaging with a VCS (SVN, Git, etc.)

    http://dehs.alioth.debian.org/http://packages.qa.debian.org/http://packages.qa.debian.org/http://dehs.alioth.debian.org/
  • 7/31/2019 Debian Packaging Tutorial.en

    39/76

    Several tools to help manage branches and tags for your packaging work:svn-buildpackage, git-buildpackage

    Example: git-buildpackage upstream branch to track upstream with upstream/version tags master branch tracks the Debian package debian/version tags for each upload pristine-tar branch to be able to rebuild the upstream tarball

    Vcs-* fields in debian/control to locate the repository http://wiki.debian.org/Alioth/Git http://wiki.debian.org/Alioth/Svn

    V cs - B r o w s e r : h t tp : / / g i t . d e b i a n . o r g / ? p = d e v s c r i p t s / d e v s c r ip t s . g i t

    V cs - G i t : g i t : / / g i t . d e b i a n . o r g / d e v s c r i p t s / d e v s c r ip t s . g i t

    V cs - B r o w s e r : h t tp : / / s v n . d e b i a n . o r g / v i e w s v n / p kg - p e r l / t r u n k / l i b ww w - p e r l

    V cs - S v n : s v n : / / s v n . d e b i a n . o r g / p kg - p e r l / t r u n k / l i b ww w - p e r l

    VCS-agnostic interface: debcheckout, debcommit, debrelease

    debcheckout grep checks out the source package from Git

    Debian Packaging Tutorial 39 / 76

    Backporting packages

    http://wiki.debian.org/Alioth/Githttp://wiki.debian.org/Alioth/Svnhttp://wiki.debian.org/Alioth/Svnhttp://wiki.debian.org/Alioth/Git
  • 7/31/2019 Debian Packaging Tutorial.en

    40/76

    Goal: use a newer version of a package on an older systeme.g use mutt from Debian unstable on Debian stable

    General idea:

    Take the source package from Debian unstable

    Modify it so that it builds and works fine on Debian stable Sometimes trivial (no changes needed) Sometimes difficult Sometimes impossible (many unavailable dependencies)

    Some backports are provided and supported by the Debian projecthttp://backports.debian.org/

    Debian Packaging Tutorial 40 / 76

    Outline

    http://backports.debian.org/http://backports.debian.org/
  • 7/31/2019 Debian Packaging Tutorial.en

    41/76

    1 Introduction

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 41 / 76

    Several ways to contribute to Debian

  • 7/31/2019 Debian Packaging Tutorial.en

    42/76

    Worst way to contribute:

    1 Package your own application

    2 Get it into Debian3 Disappear

    Better ways to contribute:

    Get involved in packaging teams

    Many teams that focus on set of packages, and need help List available at http://wiki.debian.org/Teams An excellent way to learn from more experienced contributors

    Adopt existing unmaintained packages (orphaned packages)

    Bring new software to Debian

    Only if its interesting/useful enough, please Are there alternatives already packaged in Debian?

    Debian Packaging Tutorial 42 / 76

    Adopting orphaned packages

    http://wiki.debian.org/Teamshttp://wiki.debian.org/Teams
  • 7/31/2019 Debian Packaging Tutorial.en

    43/76

    Many unmaintained packages in Debian

    Full list + process: http://www.debian.org/devel/wnpp/

    Installed on your machine: wnpp-alert Different states:

    Orphaned: the package is unmaintained

    Feel free to adopt it

    RFA: Request For Adopter

    Maintainer looking for adopter, but continues work in the meantimeFeel free to adopt it. A mail to the current maintainer is polite

    ITA: Intent To Adopt

    Someone intends to adopt the package

    You could propose your help!

    RFH: Request For HelpThe maintainer is looking for help

    Some unmaintained packages not detected not orphaned yet

    When in doubt, ask [email protected] #debian-qa on irc.debian.org

    Debian Packaging Tutorial 43 / 76

    http://www.debian.org/devel/wnpp/http://www.debian.org/devel/wnpp/
  • 7/31/2019 Debian Packaging Tutorial.en

    44/76

    Where to find help?

  • 7/31/2019 Debian Packaging Tutorial.en

    45/76

    Help you will need:

    Advice and answers to your questions, code reviews

    Sponsorship for your uploads, once your package is ready

    You can get help from:

    Other members of a packaging team

    They know the specifics of your package You can become a member of the team

    The Debian Mentors group (if your package doesnt fit in a team)

    http://wiki.debian.org/DebianMentorsFaq Mailing list: [email protected]

    (also a good way to learn by accident) IRC: #debian-mentors on irc.debian.org http://mentors.debian.net/

    Debian Packaging Tutorial 45 / 76

    Official documentation

    http://wiki.debian.org/DebianMentorsFaqhttp://localhost/var/www/apps/conversion/current/tmp/scratch26816/[email protected]://mentors.debian.net/http://mentors.debian.net/http://localhost/var/www/apps/conversion/current/tmp/scratch26816/[email protected]://wiki.debian.org/DebianMentorsFaq
  • 7/31/2019 Debian Packaging Tutorial.en

    46/76

    Debian Developers Cornerhttp://www.debian.org/devel/

    Links to many resources about Debian development

    Debian New Maintainers Guidehttp://www.debian.org/doc/maint-guide/

    An introduction to Debian packaging, but could use an update

    Debian Developers Reference

    http://www.debian.org/doc/developers-reference/Mostly about Debian procedures, but also some best packaging practices (part 6)

    Debian Policyhttp://www.debian.org/doc/debian-policy/

    All the requirements that every package must satisfy Specific policies for Perl, Java, Python, . . .

    Ubuntu Packaging Guidehttps://wiki.ubuntu.com/PackagingGuide

    Debian Packaging Tutorial 46 / 76

    Debian dashboards for maintainers

    http://www.debian.org/devel/http://www.debian.org/doc/maint-guide/http://www.debian.org/doc/developers-reference/http://www.debian.org/doc/debian-policy/https://wiki.ubuntu.com/PackagingGuidehttps://wiki.ubuntu.com/PackagingGuidehttp://www.debian.org/doc/debian-policy/http://www.debian.org/doc/developers-reference/http://www.debian.org/doc/maint-guide/http://www.debian.org/devel/
  • 7/31/2019 Debian Packaging Tutorial.en

    47/76

    Source package centric: Package Tracking System (PTS)http://packages.qa.debian.org/dpkg

    Maintainer/team centric: Developers Packages Overview (DDPO)http://qa.debian.org/developer.php?login=

    [email protected]

    Debian Packaging Tutorial 47 / 76

    More interested in Ubuntu?

    http://packages.qa.debian.org/dpkghttp://qa.debian.org/developer.php?login=pkg-ruby-extras-maintainers@lists.alioth.debian.orghttp://qa.debian.org/developer.php?login=pkg-ruby-extras-maintainers@lists.alioth.debian.orghttp://qa.debian.org/developer.php?login=pkg-ruby-extras-maintainers@lists.alioth.debian.orghttp://qa.debian.org/developer.php?login=pkg-ruby-extras-maintainers@lists.alioth.debian.orghttp://packages.qa.debian.org/dpkg
  • 7/31/2019 Debian Packaging Tutorial.en

    48/76

    Ubuntu mainly manages the divergence with Debian

    No real focus on specific packagesInstead, collaboration with Debian teams

    Usually recommend uploading new packages to Debian firsthttps://wiki.ubuntu.com/UbuntuDevelopment/NewPackages

    Possibly a better plan: Get involved in a Debian team and act as a bridge with Ubuntu

    Help reduce divergence, triage bugs in Launchpad

    Many Debian tools can help:

    Ubuntu column on the Developers packages overview Ubuntu box on the Package Tracking System Receive launchpad bugmail via the PTS

    Debian Packaging Tutorial 48 / 76

    Outline1 Introduction

    https://wiki.ubuntu.com/UbuntuDevelopment/NewPackageshttps://wiki.ubuntu.com/UbuntuDevelopment/NewPackages
  • 7/31/2019 Debian Packaging Tutorial.en

    49/76

    1 Introduction

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 49 / 76

    Conclusion

  • 7/31/2019 Debian Packaging Tutorial.en

    50/76

    You now have a full overview of Debian packaging

    But you will need to read more documentation

    Best practices have evolved over the years

    If not sure, use the dh packaging helper, and the 3.0 (quilt) format

    Things that were not covered in this tutorial:

    UCF manage user changes to configuration files when upgrading dpkg triggers group similar maintainer scripts actions together

    Debian development organization:

    Bug Tracking System (BTS) Suites: stable, testing, unstable, experimental, security,

    *-updates, backports, . . . Debian Blends subsets of Debian targeting specific groups

    Feedback: [email protected]

    Debian Packaging Tutorial 50 / 76

    Legal stuff

  • 7/31/2019 Debian Packaging Tutorial.en

    51/76

    Copyright c2011 Lucas Nussbaum [email protected]

    This document is free software: you can redistribute it and/or modify it under either

    (at your option):

    The terms of the GNU General Public License as published by the Free Software

    Foundation, either version 3 of the License, or (at your option) any later version.http://www.gnu.org/licenses/gpl.html

    The terms of the Creative Commons Attribution-ShareAlike 3.0 Unported License.

    http://creativecommons.org/licenses/by-sa/3.0/

    Debian Packaging Tutorial 51 / 76

    Latest version & source code

    http://www.gnu.org/licenses/gpl.htmlhttp://creativecommons.org/licenses/by-sa/3.0/http://creativecommons.org/licenses/by-sa/3.0/http://www.gnu.org/licenses/gpl.html
  • 7/31/2019 Debian Packaging Tutorial.en

    52/76

    Latest version:http://git.debian.org/?p=collab-maint/packaging-tutorial.git;a=blob_plain;f=

    packaging-tutorial.pdf;hb=refs/heads/pdf

    Contribute: git clone

    git://git.debian.org/collab-maint/packaging-tutorial.git

    apt-get source packaging-tutorial

    http://git.debian.org/?p=collab-maint/packaging-tutorial.git

    Feedback: [email protected]

    Debian Packaging Tutorial 52 / 76

    Outline1 Introduction

    http://git.debian.org/?p=collab-maint/packaging-tutorial.git;a=blob_plain;f=packaging-tutorial.pdf;hb=refs/heads/pdfhttp://git.debian.org/?p=collab-maint/packaging-tutorial.git;a=blob_plain;f=packaging-tutorial.pdf;hb=refs/heads/pdfhttp://git.debian.org/?p=collab-maint/packaging-tutorial.gitmailto:[email protected]:[email protected]://git.debian.org/?p=collab-maint/packaging-tutorial.githttp://git.debian.org/?p=collab-maint/packaging-tutorial.git;a=blob_plain;f=packaging-tutorial.pdf;hb=refs/heads/pdfhttp://git.debian.org/?p=collab-maint/packaging-tutorial.git;a=blob_plain;f=packaging-tutorial.pdf;hb=refs/heads/pdf
  • 7/31/2019 Debian Packaging Tutorial.en

    53/76

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 53 / 76

    Practical session 2: packaging GNUjump

    1 Download GNUjump 1 0 6 from

  • 7/31/2019 Debian Packaging Tutorial.en

    54/76

    1 Download GNUjump 1.0.6 fromhttp://ftp.gnu.org/gnu/gnujump/1.0.6/gnujump-1.0.6.tar.gz

    2 Create a Debian package for it Install build-dependencies so that you can build the package Get a basic working package Finish filling debian/control and other files

    3 Enjoy

    Debian Packaging Tutorial 54 / 76

    Outline1 Introduction

    http://ftp.gnu.org/gnu/gnujump/1.0.6/gnujump-1.0.6.tar.gzhttp://ftp.gnu.org/gnu/gnujump/1.0.6/gnujump-1.0.6.tar.gz
  • 7/31/2019 Debian Packaging Tutorial.en

    55/76

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 55 / 76

    Practical session 3: packaging a Java library

  • 7/31/2019 Debian Packaging Tutorial.en

    56/76

    1 Take a quick look at some documentation about Java packaging:

    http://wiki.debian.org/Java

    http://wiki.debian.org/Java/Packaging

    http://www.debian.org/doc/packaging-manuals/java-policy/

    http://pkg-java.alioth.debian.org/docs/tutorial.html

    Paper and slides from a Debconf10 talk about javahelper:http://pkg-java.alioth.debian.org/docs/debconf10-javahelper-paper.pdf

    http://pkg-java.alioth.debian.org/docs/debconf10-javahelper-slides.pdf

    2 Download IRClib from http://moepii.sourceforge.net/

    3 Package it

    Debian Packaging Tutorial 56 / 76

    Outline1 Introduction

    http://wiki.debian.org/Javahttp://wiki.debian.org/Java/Packaginghttp://www.debian.org/doc/packaging-manuals/java-policy/http://pkg-java.alioth.debian.org/docs/tutorial.htmlhttp://pkg-java.alioth.debian.org/docs/debconf10-javahelper-paper.pdfhttp://pkg-java.alioth.debian.org/docs/debconf10-javahelper-slides.pdfhttp://moepii.sourceforge.net/http://moepii.sourceforge.net/http://pkg-java.alioth.debian.org/docs/debconf10-javahelper-slides.pdfhttp://pkg-java.alioth.debian.org/docs/debconf10-javahelper-paper.pdfhttp://pkg-java.alioth.debian.org/docs/tutorial.htmlhttp://www.debian.org/doc/packaging-manuals/java-policy/http://wiki.debian.org/Java/Packaginghttp://wiki.debian.org/Java
  • 7/31/2019 Debian Packaging Tutorial.en

    57/76

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 57 / 76

    Practical session 4: packaging a Ruby gem

  • 7/31/2019 Debian Packaging Tutorial.en

    58/76

    1 Take a quick look at some documentation about Ruby packaging: http://wiki.debian.org/Ruby

    http://wiki.debian.org/Teams/Ruby

    http://wiki.debian.org/Teams/Ruby/Packaging

    gem2deb(1), dh_ruby(1) (in the gem2deb package)

    2 Create a basic Debian source package from the net-ssh gem:gem2deb net-ssh

    3 Improve it so that it becomes a proper Debian package

    Debian Packaging Tutorial 58 / 76

    Outline1 Introduction

    http://wiki.debian.org/Rubyhttp://wiki.debian.org/Teams/Rubyhttp://wiki.debian.org/Teams/Ruby/Packaginghttp://wiki.debian.org/Teams/Ruby/Packaginghttp://wiki.debian.org/Teams/Rubyhttp://wiki.debian.org/Ruby
  • 7/31/2019 Debian Packaging Tutorial.en

    59/76

    2 Creating source packages

    3 Building and testing packages

    4 Practical session 1: modifying the grep package

    5 Advanced packaging topics

    6 Maintaining packages in Debian

    7 Conclusion

    8 Practical session 2: packaging GNUjump

    9 Practical session 3: packaging a Java library

    10 Practical session 4: packaging a Ruby gem

    11 Answers to practical sessions

    Debian Packaging Tutorial 59 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    60/76

    Answers to

    practical sessions

    Debian Packaging Tutorial 60 / 76

    Practical session 1: modifying the grep package

    1 Go to http://ftp debian org/debian/pool/main/g/grep/ and

    http://ftp.debian.org/debian/pool/main/g/grep/http://ftp.debian.org/debian/pool/main/g/grep/
  • 7/31/2019 Debian Packaging Tutorial.en

    61/76

    1 Go to http://ftp.debian.org/debian/pool/main/g/grep/ anddownload version 2.6.3-3 of the package (if you use Ubuntu 11.10 or later,or Debian testing or unstable, use version 2.9-1 or 2.9-2 instead)

    2 Look at the files in debian/.

    How many binary packages are generated by this source package? Which packaging helper does this package use?

    3 Build the package

    4 We are now going to modify the package. Add a changelog entry andincrease the version number.

    5 Now disable perl-regexp support (it is a ./configure option)

    6 Rebuild the package

    7 Compare the original and the new package with debdiff

    8 Install the newly built package

    9 Cry if you messed up ;)

    Debian Packaging Tutorial 61 / 76

    Fetching the source1 Go to http://ftp.debian.org/debian/pool/main/g/grep/ and

    d l d i 2 6 3 3 f th k

    http://ftp.debian.org/debian/pool/main/g/grep/http://ftp.debian.org/debian/pool/main/g/grep/http://ftp.debian.org/debian/pool/main/g/grep/http://ftp.debian.org/debian/pool/main/g/grep/
  • 7/31/2019 Debian Packaging Tutorial.en

    62/76

    download version 2.6.3-3 of the package

    Use dget to download the .dsc file:

    dget http://cdn.debian.net/debian/pool/main/g/grep/grep_2.6.3-3.dsc

    According to http://packages.qa.debian.org/grep, grep version2.6.3-3 is currently in stable (squeeze). If you have deb-src lines forsqueeze in your /etc/apt/sources.list, you can use:apt-get source grep=2.6.3-3

    or apt-get source grep/stableor, if you feel lucky: apt-get source grep

    The grep source package is composed of three files: grep_2.6.3-3.dsc grep_2.6.3-3.debian.tar.bz2 grep_2.6.3.orig.tar.bz2

    This is typical of the "3.0 (quilt)" format.

    If needed, uncompress the source withdpkg-source -x grep_2.6.3-3.dsc

    Debian Packaging Tutorial 62 / 76

    Looking around and building the package

  • 7/31/2019 Debian Packaging Tutorial.en

    63/76

    2 Look at the files in debian/.

    How many binary packages are generated by this source package? Which packaging helper does this package use?

    According to debian/control, this package only generates one binarypackage, named grep.

    According to debian/rules, this package is typical of classic debhelperpackaging, without using CDBS or dh. One can see the various calls todh_* commands in debian/rules.

    3 Build the package

    Use apt-get build-dep grep to fetch the build-dependencies

    Then debuild or dpkg-buildpackage -us -uc (Takes about 1 min)

    Debian Packaging Tutorial 63 / 76

    Editing the changelog

  • 7/31/2019 Debian Packaging Tutorial.en

    64/76

    4 We are now going to modify the package. Add a changelog entry and

    increase the version number.

    debian/changelog is a text file. You could edit it and add a new entrymanually.

    Or you can use dch -i, which will add an entry and open the editor

    The name and email can be defined using the DEBFULLNAME and DEBEMAIL

    environment variables

    After that, rebuild the package: a new version of the package is built

    Package versioning is detailed in section 5.6.12 of the Debian policy

    http://www.debian.org/doc/debian-policy/ch-controlfields.html

    Debian Packaging Tutorial 64 / 76

    Disabling Perl regexp support and rebuilding

    http://www.debian.org/doc/debian-policy/ch-controlfields.htmlhttp://www.debian.org/doc/debian-policy/ch-controlfields.html
  • 7/31/2019 Debian Packaging Tutorial.en

    65/76

    5 Now disable perl-regexp support (it is a ./configure option)

    6 Rebuild the package

    Check with ./configure --help: the option to disable Perl regexp is--disable-perl-regexp

    Edit debian/rules and find the ./configure line

    Add --disable-perl-regexp

    Rebuild with debuild or dpkg-buildpackage -us -uc

    Debian Packaging Tutorial 65 / 76

    Comparing and testing the packages

  • 7/31/2019 Debian Packaging Tutorial.en

    66/76

    7 Compare the original and the new package with debdiff

    8 Install the newly built package

    Compare the binary packages: debdiff ../*changes

    Compare the source packages: debdiff ../*dsc

    Install the newly built package: debi

    Or dpkg -i ../grep_

    grep -P foo no longer works!

    9 Cry if you messed up ;)

    Or not: reinstall the previous version of the package:

    apt-get install --reinstall grep=2.6.3-3 (= previous version)

    Debian Packaging Tutorial 66 / 76

    Practical session 2: packaging GNUjump

    1 Download GNUjump 1.0.6 from// / / / /

    http://ftp.gnu.org/gnu/gnujump/1.0.6/gnujump-1.0.6.tar.gzhttp://ftp.gnu.org/gnu/gnujump/1.0.6/gnujump-1.0.6.tar.gz
  • 7/31/2019 Debian Packaging Tutorial.en

    67/76

    http://ftp.gnu.org/gnu/gnujump/1.0.6/gnujump-1.0.6.tar.gz

    2 Create a Debian package for it Install build-dependencies so that you can build the package Get a basic working package Finish filling debian/control and other files

    3 Enjoy

    Debian Packaging Tutorial 67 / 76

    Step by step. . .

    wget http://ftp.gnu.org/gnu/gnujump/1.0.6/gnujump-1.0.6.tar.gz

    http://ftp.gnu.org/gnu/gnujump/1.0.6/gnujump-1.0.6.tar.gzhttp://ftp.gnu.org/gnu/gnujump/1.0.6/gnujump-1.0.6.tar.gz
  • 7/31/2019 Debian Packaging Tutorial.en

    68/76

    mv gnujump-1.0.6.tar.gz gnujump_1.0.6.orig.tar.gz

    tar xf gnujump_1.0.6.orig.tar.gz cd gnujump-1.0.6/

    dh_make Type of package: single binary (for now)

    g nu ju mp - 1 .0 . 6 $ l s d e bi a n /changelog gnujump . default . ex preinst . ex

    compat gnujump . doc - base . EX prerm . ex

    control init . d . ex README . Debian

    copyright manpage .1. ex README . source

    docs manpage . sgml . ex rules

    emacsen - install .ex manpage . xml .ex source

    emacsen - remove . ex menu . ex watch . ex

    e ma cs en - s t a rt u p . e x p o st i ns t . e x

    g nu ju mp . c ro n .d . ex p os tr m . ex

    Debian Packaging Tutorial 68 / 76

    Step by step. . . (2)

    Look at debian/changelog debian/rules debian/control

  • 7/31/2019 Debian Packaging Tutorial.en

    69/76

    Look at debian/changelog, debian/rules, debian/control(auto-filled by dh_make)

    In debian/control:Build-Depends: debhelper (>= 7.0.50 ), autotools-dev

    Lists the build-dependencies= packages needed to build the package

    Try to build the package as-is (thanks to dh magic)

    And add build-dependencies, until it builds Hint: use apt-cache search and apt-file to find the packages Example:

    c he ck in g f or sdl - c o nf ig . . . n o

    c he ck in g fo r S DL - v er si on >= 1 .2 .0 .. . no

    [...]

    c on fi gu r e : e rr or : * ** S DL v er si on 1 .2 .0 n ot f ou nd !

    Add libsdl1.2-dev to Build-Depends and install it.

    Better: use pbuilder to build in a clean environment

    Debian Packaging Tutorial 69 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    70/76

    Practical session 3: packaging a Java library

  • 7/31/2019 Debian Packaging Tutorial.en

    71/76

    1 Take a quick look at some documentation about Java packaging:

    http://wiki.debian.org/Java http://wiki.debian.org/Java/Packaging

    http://www.debian.org/doc/packaging-manuals/java-policy/

    http://pkg-java.alioth.debian.org/docs/tutorial.html

    Paper and slides from a Debconf10 talk about javahelper:http://pkg-java.alioth.debian.org/docs/debconf10-javahelper-paper.pdf

    http://pkg-java.alioth.debian.org/docs/debconf10-javahelper-slides.pdf

    2 Download IRClib from http://moepii.sourceforge.net/

    3 Package it

    Debian Packaging Tutorial 71 / 76

    Step by step. . .

    http://wiki.debian.org/Javahttp://wiki.debian.org/Java/Packaginghttp://www.debian.org/doc/packaging-manuals/java-policy/http://pkg-java.alioth.debian.org/docs/tutorial.htmlhttp://pkg-java.alioth.debian.org/docs/debconf10-javahelper-paper.pdfhttp://pkg-java.alioth.debian.org/docs/debconf10-javahelper-slides.pdfhttp://moepii.sourceforge.net/http://moepii.sourceforge.net/http://pkg-java.alioth.debian.org/docs/debconf10-javahelper-slides.pdfhttp://pkg-java.alioth.debian.org/docs/debconf10-javahelper-paper.pdfhttp://pkg-java.alioth.debian.org/docs/tutorial.htmlhttp://www.debian.org/doc/packaging-manuals/java-policy/http://wiki.debian.org/Java/Packaginghttp://wiki.debian.org/Java
  • 7/31/2019 Debian Packaging Tutorial.en

    72/76

    apt-get install javahelper

    Create a basic source package: jh_makepkg

    Library None Default Free compiler/runtime

    Look at and fix debian/*

    dpkg-buildpackage -us -uc or debuild

    lintian, debc, etc.

    Compare your result with the libirclib-java source package

    Debian Packaging Tutorial 72 / 76

    Practical session 4: packaging a Ruby gem

  • 7/31/2019 Debian Packaging Tutorial.en

    73/76

    1 Take a quick look at some documentation about Ruby packaging: http://wiki.debian.org/Ruby

    http://wiki.debian.org/Teams/Ruby

    http://wiki.debian.org/Teams/Ruby/Packaging

    gem2deb(1), dh_ruby(1) (in the gem2deb package)

    2 Create a basic Debian source package from the net-ssh gem:gem2deb net-ssh

    3 Improve it so that it becomes a proper Debian package

    Debian Packaging Tutorial 73 / 76

    Step by step. . .

    gem2deb net-ssh:

    http://wiki.debian.org/Rubyhttp://wiki.debian.org/Teams/Rubyhttp://wiki.debian.org/Teams/Ruby/Packaginghttp://wiki.debian.org/Teams/Ruby/Packaginghttp://wiki.debian.org/Teams/Rubyhttp://wiki.debian.org/Ruby
  • 7/31/2019 Debian Packaging Tutorial.en

    74/76

    gem2deb net ssh:

    Downloads the gem from rubygems.org

    Creates a suitable .orig.tar.gz archive, and untar it

    Initializes a Debian source package based on the gems metadata

    Named ruby-gemname

    Tries to build the Debian binary package (this might fail)

    dh_ruby (included in gem2deb) does the Ruby-specific tasks:

    Build C extensions for each Ruby version

    Copy files to their destination directory

    Update shebangs in executable scripts

    Run tests defined in debian/ruby-tests.rb ordebian/ruby-test-files.yaml, as well as various other checks

    Debian Packaging Tutorial 74 / 76

  • 7/31/2019 Debian Packaging Tutorial.en

    75/76

    Step by step. . . (3)

    Build the package. It fails to build. There are two problems:

  • 7/31/2019 Debian Packaging Tutorial.en

    76/76

    You need to disable the gem call in the test suite.In test/common.rb, remove the gem "test-unit" line:

    edit-patch disable-gem.patch Edit test/common.rb, remove the gem line. Exit the sub-shell Describe the changes in debian/changelog Document the patch in debian/patches/disable-gem.patch

    The package lacks a build-dependency on ruby-mocha, which is used bythe test suite (you might need to build your package in a cleanenvironment, using pbuilder, to reproduce that problem)

    Add ruby-mocha to the packages Build-Depends gem2deb copies the dependencies documented in the gem as

    comments in debian/control, but mocha is not listed as adevelopment dependency by the gem (thats a bug in the gem)

    Compare your package with the ruby-net-ssh package in the Debian archive

    Debian Packaging Tutorial 76 / 76