2

We have a software project, which we release as a debian package. The project has a debian/ folder which contains files like changelog compat control copyright rules. We're creating debian packages with the command:

dpkg-buildpackage -us -uc -b --changes-option=-u./dist

which prints a stream of output. What we need to know, for the next step of the process, is the name of the .deb file created.

I know that debians have a predictable filename structure like [package name]_[version]_[architecture].deb but I don't have a way to get these parameters anyway.

There must be another dpkg command that can generate the would-be package name just from looking in the debian folder?

0

2 Answers 2

5

As you point out, the generated .deb files all share a common format: ${package}_${version}_${arch}.deb.

The package name comes from the Package: entries in debian/control; for a full build, one .deb file will be generated for every Package: entry. You can retrieve the values with

awk '/^Package:/ { print $2 }' debian/control

The version is based by default on the value given in debian/changelog; you can extract that with

dpkg-parsechangelog -S version

(It is possible for a build to specify a different version, but that is unusual.)

Finally, the architecture will be either all (for an Architecture: all package) or by default that of your build system (for any other Architecture:, typically Architecture: any). You can determine the architecture of your build system using

dpkg-architecture -qDEB_BUILD_ARCH

(Strictly speaking that should be -qDEB_HOST_ARCH, but in the general case BUILD and HOST are the same. I'm also ignoring cross-compilation here; if that's an issue use DEB_TARGET_ARCH instead of DEB_BUILD_ARCH.)

Thus for a fully generic solution you'd need to parse the control file to determine which package goes with which architecture; if your control file only builds one package that's not necessary.

dpkg-parsechangelog and dpkg-architecture are provided by the dpkg-dev package.

9
  • Seems weird there isn't a single command to do this in 1 step. But I'm grateful for your answer, and will try this out asap.
    – Tom Viner
    Apr 7, 2015 at 17:16
  • You're a star @stephen-kitt : $ echo "$(awk '/^Package:/ { print $2 }' debian/control)_$(dpkg-parsechangelog --show-field version)_$(dpkg-architecture -qDEB_BUILD_ARCH).deb" mypackage_3.8.2_amd64.deb
    – Tom Viner
    Apr 8, 2015 at 11:23
  • To get the package name by itself could you also not simply do dpkg-parsechangelog -S Source ?
    – Nicholi
    Nov 7, 2018 at 2:18
  • @Nicholi that gives you the source package name, but here we’re looking for all the binary package names. For simple packages there will only be one binary package with the same name as the source package, but that’s not always the case. Nov 7, 2018 at 5:20
  • Gotcha, which generally would be the same but no guarantee.
    – Nicholi
    Nov 7, 2018 at 21:04
3

This is dpkg-name:

$dpkg-name foo.deb
dpkg-name: info: moved 'foo.deb' to './feature-dev_1.4.177_armhf.deb'

Original name foo taken from DEBIAN/ directory parent

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .