How to set version numbers and package file names via dpkg-buildpackge for automated builds on a build server?

6,773

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:

[DEFAULT]
snapshot-number = os.popen("git-log --pretty=oneline | wc -l").readlines()[0]
Share:
6,773

Related videos on Youtube

Stefan
Author by

Stefan

Updated on September 18, 2022

Comments

  • Stefan
    Stefan almost 2 years

    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?

  • Stefan
    Stefan almost 10 years
    dch alone does neither accept -S nor --snapshot-number.
  • Stefan
    Stefan almost 10 years
    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>
  • msnfreaky
    msnfreaky almost 10 years
    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$$
  • Stefan
    Stefan almost 10 years
    How can I specify a custom control file to dpkg-buildpackage?
  • muru
    muru almost 10 years
    @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
  • Stefan
    Stefan almost 10 years
    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.
  • muru
    muru almost 10 years
    @Stefan, does setting a version manually using the --newversion option of dch work?