= Co-maintaining a Debian package with git, git-buildpackage and pbuilder = Philipp Huebner [NOTE] This Howto is only useful to you if you're running a Debian/Ubuntu based system and know how packaging for these distributions works. == Preparations == Install the necessary software with * apt-get install cowbuilder debhelper devscripts dh-make fakeroot git-buildpackage pristine-tar [NOTE] ===================================================================== You can then find the upstream documentation in * file:///usr/share/doc/git-buildpackage/manual-html/gbp.html ===================================================================== Make sure to set your name and email address in your ~/.gitconfig file via: * git config --global user.name '' * git config --global user.email '' You can set these per-repository as well, once you have a repository, by running the command within that repository and omitting the --global flag. == Repository Layout == This is very important! See file:///usr/share/doc/git-buildpackage/manual-html/gbp.intro.html#GBP.REPOSITORY == Tags == Tags are very important for all this to work, so be careful to create them and to push them! == Configure git-buildpackage == cat << EOF > ~/.gbp.conf [DEFAULT] pristine-tar = True color = True EOF == Starting from scratch == * mkdir package-name * cd package-name * git init * gbp import-orig '' * dh-make ...work on Debian package... == Starting from an existing Debian package == * mkdir package-name * cd package-name * git init * gbp import-dsc '' [NOTE] ====== To do the above steps all at once, simply use * gbp import-dsc '<*.dsc>' A new git repository in a folder with the name of the package will be created automatically. ====== [NOTE] If you want to import further source package versions/revisions you can either run gbp import-dsc in the order of their revision numbers or use 'gbp import-dscs'. ...work on Debian package... == Starting from an existing repository == Clone the repository * git clone '' See which remote branches exist * git branch -r Check out all needed branches (usually "upstream" and "pristine-tar"), remote tracking will be set up automatically * git checkout '' [NOTE] ====== To do the above steps all at once, simply use * gbp clone '' ====== ...work on Debian package... == Working == After making your changes in debian/*, do * git add debian/'' * git commit Commit in small steps and write usefull commit messages. === Maganging the changelog === You can use gbp dch to generate debian/changelog automatically from your previous git commit messages. Creating a new version / revision: * gbp dch -a -N '' For a snapshot build: * gbp dch -a -S For a release build: * gbp dch -a -R Finally the new changelog must be comitted before doing the release build. [NOTE] For further information see file:///usr/share/doc/git-buildpackage/manual-html/man.gbp.dch.html == Working with patches == See * http://raphaelhertzog.com/2010/11/18/4-tips-to-maintain-a-3-0-quilt-debian-source-package-in-a-vcs/ * https://honk.sigxcpu.org/piki/development/debian_packages_in_git/ and decide for yourself. == Building the binary package(s) == Build: * gbp buildpackage ** use '--git-ignore-new' for testing with uncomitted changes (e.g. a snapshot) ** use '-uc -us' if you don't want to sign your build ** use '--git-tag' when building a release Clean up: * fakeroot debian/rules clean [NOTE] For further information see file:///usr/share/doc/git-buildpackage/manual-html/man.gbp.buildpackage.html == Creating a remote repository == If you cloned an existing repository you can skip this. === gitolite === * git push -u --all git@SERVER:FOLDER/NAME.git * git remote add origin git@SERVER:FOLDER/NAME.git * git push --tags === git+ssh === * gbp-create-remote-repo is your friend, see file:///usr/share/doc/git-buildpackage/manual-html/man.gbp.create.remote.repo.html == Pushing your changes == All you have to do is: * git push --all * git push --tags == Pulling your co-maintainer's changes == Let's hope your co-maintainer pushed all his commits and tags! Now, instead of pulling each branch one by one, pull all branches at once by simply calling * gbp-pull == Upgrading to a new upstream version == Using a 'debian/watch' file (recommended): * gbp import-orig --uscan Using a tarball file: * gbp import-orig '' -u '' ...work on Debian package... == Using pbuilder/cowbuilder == If you want to build a package for different architectures/distributions/releases or simply build it in a clean buildd-like chroot so you don't have to install all the build dependencies in your own system - pbuilder/cowbuilder is your friend! This is purely optional but recommended. Unless you're familiar with user-mode-linux you need root access for this. === Configure git-buildpackage === cat << EOF > ~/.gbp.conf [DEFAULT] builder = git-pbuilder cleaner = fakeroot debian/rules clean pristine-tar = True color = True EOF See also file:///usr/share/doc/git-buildpackage/manual-html/gbp.special.html#GBP.SPECIAL.PBUILDER === Set up chroot === Create a new chroot: * ' ' git-pbuilder create [NOTE] Ubuntu users will have to add '--components "main universe"' for the above to succeed, because the required package 'cowdancer' is not in main but in universe. Update an existing chroot: * ' ' git-pbuilder update Login to a chroot: * ' ' git-pbuilder login --save-after-login === Continue === Continue working like before. If you used the DIST or ARCH field when creating the chroot, you need to specify it from now on by calling 'gbp buildpackage' like either * DIST=sid ARCH=amd64 gbp buildpackage or * gbp buildpackage --git-pbuilder --git-dist=DIST --git-arch=ARCH == See also == * http://www.debian.org/doc/debian-policy/ * http://www.debian.org/doc/manuals/maint-guide/ * http://www.debian.org/doc/manuals/developers-reference/best-pkging-practices.html * https://wiki.debian.org/PackagingWithGit * https://wiki.debian.org/git-pbuilder * https://workaround.org/debian-git-comaintenance * http://www.eyrie.org/~eagle/notes/debian/git.html