.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "dgit-user 7" .TH dgit-user 7 "Debian Project" "perl v5.28.1" "dgit" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" dgit\-user \- making and sharing changes to Debian packages, with git .SH "INTRODUCTION" .IX Header "INTRODUCTION" dgit lets you fetch the source code to every package on your system as if your distro used git to maintain all of it. .PP You can then edit it, build updated binary packages (.debs) and install and run them. You can also share your work with others. .PP This tutorial gives some recipes and hints for this. It assumes you have basic familiarity with git. It does not assume any initial familiarity with Debian's packaging processes. .PP If you are a package maintainer within Debian; a \s-1DM\s0 or \s-1DD\s0; and/or a sponsee: this tutorial is not for you. Try \fBdgit\-nmu\-simple\fR\|(7), dgit\-maint\-*(7), or \fBdgit\fR\|(1) and \fBdgit\fR\|(7). .SH "SUMMARY" .IX Header "SUMMARY" (These runes will be discussed later.) .Sp .Vb 8 \& % dgit clone glibc jessie,\-security \& % cd glibc \& % curl \*(Aqhttps://bugs.debian.org/cgi\-bin/bugreport.cgi?bug=28250;mbox=yes;msg=89\*(Aq | patch \-p1 \-u \& % git commit \-a \-m \*(AqFix libc lost output bug\*(Aq \& % gbp dch \-S \-\-since=dgit/dgit/sid \-\-ignore\-branch \-\-commit \& % mk\-build\-deps \-\-root\-cmd=sudo \-\-install \& % dpkg\-buildpackage \-uc \-b \& % sudo dpkg \-i ../libc6_*.deb .Ve .PP Occasionally: .Sp .Vb 2 \& % git clean \-xdf \& % git reset \-\-hard .Ve .PP Later: .Sp .Vb 5 \& % cd glibc \& % dgit pull jessie,\-security \& % gbp dch \-S \-\-since=dgit/dgit/sid \-\-ignore\-branch \-\-commit \& % dpkg\-buildpackage \-uc \-b \& % sudo dpkg \-i ../libc6_*.deb .Ve .SH "FINDING THE RIGHT SOURCE CODE \- DGIT CLONE" .IX Header "FINDING THE RIGHT SOURCE CODE - DGIT CLONE" .Vb 2 \& % dgit clone glibc jessie,\-security \& % cd glibc .Ve .PP dgit clone needs to be told the source package name (which might be different to the binary package name, which was the name you passed to \*(L"apt-get install\*(R") and the codename or alias of the Debian release (this is called the \*(L"suite\*(R"). .SS "Finding the source package name" .IX Subsection "Finding the source package name" For many packages, the source package name is obvious. Otherwise, if you know a file that's in the package, you can look it up with dpkg: .Sp .Vb 7 \& % dpkg \-S /lib/i386\-linux\-gnu/libc.so.6 \& libc6:i386: /lib/i386\-linux\-gnu/libc.so.6 \& % dpkg \-s libc6:i386 \& Package: libc6 \& Status: install ok installed \& ... \& Source: glibc .Ve .PP (In this example, libc6 is a \*(L"multi-arch: allowed\*(R" package, which means that it exists in several different builds for different architectures. That's where \f(CW\*(C`:i386\*(C'\fR comes from.) .ie n .SS "Finding the Debian release (the ""suite"")" .el .SS "Finding the Debian release (the ``suite'')" .IX Subsection "Finding the Debian release (the suite)" Internally, Debian (and derived) distros normally refer to their releases by codenames. Debian also has aliases which refer to the current stable release etc. So for example, at the time of writing Debian \f(CW\*(C`jessie\*(C'\fR (Debian 8) is Debian \f(CW\*(C`stable\*(C'\fR; and the current version of Ubuntu is \f(CW\*(C`yakkety\*(C'\fR (Yakkety Yak, 16.10). You can specify either the codename \f(CW\*(C`jessie\*(C'\fR or the alias \f(CW\*(C`stable\*(C'\fR. If you don't say, you get \f(CW\*(C`sid\*(C'\fR, which is Debian \f(CW\*(C`unstable\*(C'\fR \- the main work-in progress branch. .PP If you don't know what you're running, try this: .Sp .Vb 4 \& % grep \*(Aq^deb\*(Aq /etc/apt/sources.list \& deb http://the.earth.li/debian/ jessie main non\-free contrib \& ... \& % .Ve .PP For Debian, you should add \f(CW\*(C`,\-security\*(C'\fR to the end of the suite name, unless you're on unstable or testing. Hence, in our example \&\f(CW\*(C`jessie\*(C'\fR becomes \f(CW\*(C`jessie,\-security\*(C'\fR. (Yes, with a comma.) .SH "WHAT DGIT CLONE PRODUCES" .IX Header "WHAT DGIT CLONE PRODUCES" .SS "What branches are there" .IX Subsection "What branches are there" dgit clone will give you a new working tree, and arrange for you to be on a branch named like \&\f(CW\*(C`dgit/jessie,\-security\*(C'\fR (yes, with a comma in the branch name). .PP For each release (like \f(CW\*(C`jessie\*(C'\fR) there is a tracking branch for the contents of the archive, called \&\f(CW\*(C`remotes/dgit/dgit/jessie\*(C'\fR (and similarly for other suites). This can be updated with \&\f(CW\*(C`dgit fetch jessie\*(C'\fR. This, the \fIremote suite branch\fR, is synthesized by your local copy of dgit. It is fast forwarding. .PP Debian separates out the security updates, into \f(CW\*(C`*\-security\*(C'\fR. Telling dgit \f(CW\*(C`jessie,\-security\*(C'\fR means that it should include any updates available in \f(CW\*(C`jessie\-security\*(C'\fR. The comma notation is a request to dgit to track jessie, or jessie-security if there is an update for the package there. .PP (You can also dgit fetch in a tree that wasn't made by dgit clone. If there's no \f(CW\*(C`debian/changelog\*(C'\fR you'll have to supply a \f(CW\*(C`\-p\*(C'\fR\fIpackage\fR option to dgit fetch.) .SS "What kind of source tree do you get" .IX Subsection "What kind of source tree do you get" If the Debian package is based on some upstream release, the code layout should be like the upstream version. You should find \f(CW\*(C`git grep\*(C'\fR helpful to find where to edit. .PP The package's Debian metadata and the scripts for building binary packages are under \f(CW\*(C`debian/\*(C'\fR. \&\f(CW\*(C`debian/control\*(C'\fR, \f(CW\*(C`debian/changelog\*(C'\fR and \f(CW\*(C`debian/rules\*(C'\fR are the starting points. The Debian Policy Manual has most of the in-depth technical details. .PP For many Debian packages, there will also be some things in \f(CW\*(C`debian/patches/\*(C'\fR. It is best to ignore these. Insofar as they are relevant the changes there will have been applied to the actual files, probably by means of actual comments in the git history. The contents of debian/patches are ignored when building binaries from dgitish git branches. .PP (For Debian afficionados: the git trees that come out of dgit are \&\*(L"patches-applied packaging branches without a .pc directory\*(R".) .SS "What kind of history you get" .IX Subsection "What kind of history you get" If you're lucky, the history will be a version of, or based on, the Debian maintainer's own git history, or upstream's git history. .PP But for many packages the real git history does not exist, or has not been published in a dgitish form. So you may find that the history is a rather short history invented by dgit. .PP dgit histories often contain automatically-generated commits, including commits which make no changes but just serve to make a rebasing branch fast-forward. This is particularly true of combining branches like \&\f(CW\*(C`jessie,\-security\*(C'\fR. .PP If the package maintainer is using git then after dgit clone you may find that there is a useful \f(CW\*(C`vcs\-git\*(C'\fR remote referring to the Debian package maintainer's repository for the package. You can see what's there with \f(CW\*(C`git fetch vcs\-git\*(C'\fR. But use what you find there with care: Debian maintainers' git repositories often have contents which are very confusing and idiosyncratic. In particular, you may need to manually apply the patches that are in debian/patches before you do anything else! .SH "BUILDING" .IX Header "BUILDING" .SS "Always commit before building" .IX Subsection "Always commit before building" .Vb 2 \& % wget \*(Aqhttps://bugs.debian.org/cgi\-bin/bugreport.cgi?bug=28250;mbox=yes;msg=89\*(Aq | patch \-p1 \-u \& % git commit \-a \-m \*(AqFix libc lost output bug\*(Aq .Ve .PP Debian package builds are often quite messy: they may modify files which are also committed to git, or leave outputs and temporary files not covered by \f(CW\*(C`.gitignore\*(C'\fR. .PP If you always commit, you can use .Sp .Vb 2 \& % git clean \-xdf \& % git reset \-\-hard .Ve .PP to tidy up after a build. (If you forgot to commit, don't use those commands; instead, you may find that you can use \f(CW\*(C`git add \-p\*(C'\fR to help commit what you actually wanted to keep.) .PP These are destructive commands which delete all new files (so you \fBmust\fR remember to say \f(CW\*(C`git add\*(C'\fR) and throw away edits to every file (so you \fBmust\fR remember to commit). .SS "Update the changelog (at least once) before building" .IX Subsection "Update the changelog (at least once) before building" .Vb 1 \& % gbp dch \-S \-\-since=dgit/dgit/sid \-\-ignore\-branch \-\-commit .Ve .PP The binaries you build will have a version number which ultimately comes from the \f(CW\*(C`debian/changelog\*(C'\fR. You want to be able to tell your binaries apart from your distro's. .PP So you should update \f(CW\*(C`debian/changelog\*(C'\fR to add a new stanza at the top, for your build. .PP This rune provides an easy way to do this. It adds a new changelog entry with an uninformative message and a plausible version number (containing a bit of your git commit id). .PP If you want to be more sophisticated, the package \f(CW\*(C`dpkg\-dev\-el\*(C'\fR has a good Emacs mode for editing changelogs. Alternatively, you could edit the changelog with another text editor, or run \f(CW\*(C`dch\*(C'\fR or \f(CW\*(C`gbp dch\*(C'\fR with different options. Choosing a good version number is slightly tricky and a complete treatment is beyond the scope of this tutorial. .SS "Actually building" .IX Subsection "Actually building" .Vb 2 \& % mk\-build\-deps \-\-root\-cmd=sudo \-\-install \& % dpkg\-buildpackage \-uc \-b .Ve .PP dpkg-buildpackage is the primary tool for building a Debian source package. \&\f(CW\*(C`\-uc\*(C'\fR means not to pgp-sign the results. \&\f(CW\*(C`\-b\*(C'\fR means build all binary packages, but not to build a source package. .SS "Using sbuild" .IX Subsection "Using sbuild" You can build in an schroot chroot, with sbuild, instead of in your main environment. (sbuild is used by the Debian build daemons.) .Sp .Vb 3 \& % git clean \-xdf \& % sbuild \-c jessie \-A \-\-no\-clean\-source \e \& \-\-dpkg\-source\-opts=\*(Aq\-Zgzip \-z1 \-\-format=1.0 \-sn\*(Aq .Ve .PP Note that this will seem to leave a \*(L"source package\*(R" (.dsc and .tar.gz) in the parent directory, but that source package should not be used. It is likely to be broken. For more information see Debian bug #868527. .SH "INSTALLING" .IX Header "INSTALLING" .SS "Debian Jessie or older" .IX Subsection "Debian Jessie or older" .Vb 1 \& % sudo dpkg \-i ../libc6_*.deb .Ve .PP You can use \f(CW\*(C`dpkg \-i\*(C'\fR to install the \&.debs that came out of your package. .PP If the dependencies aren't installed, you will get an error, which can usually be fixed with \&\f(CW\*(C`apt\-get \-f install\*(C'\fR. .SS "Debian Stretch or newer" .IX Subsection "Debian Stretch or newer" .Vb 1 \& % sudo apt install ../libc6_*.deb .Ve .SH "Multiarch" .IX Header "Multiarch" If you're working on a library package and your system has multiple architectures enabled, you may see something like this: .Sp .Vb 2 \& dpkg: error processing package libpcre3\-dev:amd64 (\-\-configure): \& package libpcre3\-dev:amd64 2:8.39\-3~3.gbp8f25f5 cannot be configured because libpcre3\-dev:i386 is at a different version (2:8.39\-2) .Ve .PP The multiarch system used by Debian requires each package which is present for multiple architectures to be exactly the same across all the architectures for which it is installed. .PP The proper solution is to build the package for all the architectures you have enabled. You'll need a chroot for each of the secondary architectures. This is somewhat tiresome, even though Debian has excellent tools for managing chroots. \&\f(CW\*(C`sbuild\-debian\-developer\-setup\*(C'\fR from the package of the same name and \f(CW\*(C`sbuild\-createchroot\*(C'\fR from the \f(CW\*(C`sbuild\*(C'\fR package are good starting points. .PP Otherwise you could deinstall the packages of interest for those other architectures with something like \f(CW\*(C`dpkg \-\-remove libpcre3:i386\*(C'\fR. .PP If neither of those are an option, your desperate last resort is to try using the same version number as the official package for your own package. (The version is controlled by \f(CW\*(C`debian/changelog\*(C'\fR \- see above.) This is not ideal because it makes it hard to tell what is installed, and because it will mislead and confuse apt. .PP With the \*(L"same number\*(R" approach you may still get errors like .Sp .RS 4 trying to overwrite shared '/usr/include/pcreposix.h', which is different from other instances of package libpcre3\-dev .RE .PP but passing \f(CW\*(C`\-\-force\-overwrite\*(C'\fR to dpkg will help \&\- assuming you know what you're doing. .SH "SHARING YOUR WORK" .IX Header "SHARING YOUR WORK" The \f(CW\*(C`dgit/jessie,\-security\*(C'\fR branch (or whatever) is a normal git branch. You can use \f(CW\*(C`git push\*(C'\fR to publish it on any suitable git server. .PP Anyone who gets that git branch from you will be able to build binary packages (.deb) just as you did. .PP If you want to contribute your changes back to Debian, you should probably send them as attachments to an email to the Debian Bug System (either a followup to an existing bug, or a new bug). Patches in \f(CW\*(C`git\-format\-patch\*(C'\fR format are usually very welcome. .SS "Source packages" .IX Subsection "Source packages" The git branch is not sufficient to build a source package the way Debian does. Source packages are somewhat awkward to work with. Indeed many plausible git histories or git trees cannot be converted into a suitable source package. So I recommend you share your git branch instead. .PP If a git branch is not enough, and you need to provide a source package but don't care about its format/layout (for example because some software you have consumes source packages, not git histories) you can use this recipe to generate a \f(CW\*(C`3.0 (native)\*(C'\fR source package, which is just a tarball with accompanying .dsc metadata file: .Sp .Vb 3 \& % echo \*(Aq3.0 (native)\*(Aq >debian/source/format \& % git commit \-m \*(Aqswitch to native source format\*(Aq debian/source/format \& % dgit \-wgf build\-source .Ve .PP If you need to provide a good-looking source package, be prepared for a lot more work. You will need to read much more, perhaps starting with \&\fBdgit\-nmu\-simple\fR\|(7), \&\fBdgit\-sponsorship\fR\|(7) or dgit\-maint\-*(7) .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBdgit\fR\|(1), \fBdgit\fR\|(7)