Our build server builds ubuntu packages (*.deb) via dpkg-buildpackage. The server checks out the source code via git and runs the build via make <target>. The source directory contains the debian/ subdirectory where the dpkg configuration files are.

I would like to add the internal build counter number to the current package version and further set the package file name but dpkg-buildpackage does not let me control how the resulting package_version_arch.deb looks like. How can I achieve this?

2 Answers 2


Have a look at git-buildpackage:

Customizing snapshot numbers

If the auto incrementing of the snapshot number doesn't suite you needs you can give any python expression that evaluates to a positive integer to calculate the new snapshot number:

gbp dch -S -a --snapshot-number=1  
gbp dch -S -a --snapshot-number='snapshot + 2'
gbp dch -S -a --snapshot-number='os.popen("git-log --pretty=oneline | wc -l").readlines()[0]'
gbp dch -S -a --snapshot-number=`git-log --pretty=oneline debian/0.3.3 | wc -l`

You can also add the snapshot-number calculation to gbp.conf:

snapshot-number = os.popen("git-log --pretty=oneline | wc -l").readlines()[0]
  • dch alone does neither accept -S nor --snapshot-number.
    – Stefan
    Jul 14, 2014 at 11:05
  • @Stefan why should it, when that is an option provided by git-buildpackage? Think of dch in this case as a command to gbp, like commit, and not as executable passed on to dch as an argument. See the man page: manpages.ubuntu.com/manpages/trusty/man1/gbp-dch.1.html
    – muru
    Jul 14, 2014 at 20:15
  • 1
    I understand. Still I do not want to use git-buildpackage but dpkg-buildpackage alone as git-buildpackage again has certain requirements for project/directory layout.
    – Stefan
    Jul 15, 2014 at 9:23
  • @Stefan, does setting a version manually using the --newversion option of dch work?
    – muru
    Jul 15, 2014 at 9:26

You can change the version number in the control file, sampkg/DEBIAN/control

The control file is the core of the Debian package; it contains all relevant metadata. Things such as package name, version, supported architectures, and dependencies are all included in this file.

Package: sampkg
Architecture: all
Essential: no
Section: web
Priority: optional
Depends: python (>=2.3)
Maintainer: Swaminathan Mathivanan
Description: Sample package.

And the final pkg name will be sampkg_1.0.0_all.deb

  • I know, but I need to do it in an automated way. For instance, the Version in the control file could be 1.2.3ubuntu3~ppa3 and I want to add my build number as well => 1.2.3ubuntu3~ppa3-<buildnumber>
    – Stefan
    Jul 14, 2014 at 11:06
  • For that you need to keep one more tmp control file for adding the <buildNumber> to the deb package. once the build number is ready and you can sed/replace the build number to tmp control file and save it to the original control file. like Version: 1.0.0.$$BUILD$$
    – msnfreaky
    Jul 14, 2014 at 11:17
  • How can I specify a custom control file to dpkg-buildpackage?
    – Stefan
    Jul 14, 2014 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.