[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fwd: How to injecting user-defined fields in binary package control files



On Tue, 2021-05-25 at 09:24:17 +0100, Nicholas Brown wrote:
> It's possible to add user-defined fields in the debian/control file using
> the `XBS-` method, as defined in the Policy Manual[1].
> 
> Something like this before calling dpkg-buildpackage will work to inject a
> new field into both the Source and Binary packages. But some packages don't
> contain debian/control as they generate it (kernel etc) so this is not
> always reliable.

All source packages must contain a debian/control, and all binary
packages that can be generated should be listed in it, so the list of
binary packages must not be autogenerated at build-time.

For Debian this is explicitly disallowed by the ftp-masters:

  <https://ftp-master.debian.org/REJECT-FAQ.html>

For dpkg usage outside Debian, generating or updating parts of the
debian/control file during the build process (from within debian/rules)
might work, depending on the changes, but it can also make some tools
misbehave.

> ```
> sed -i "0,/^\s*$/s//XBS-Git-Branch: ${CI_COMMIT_BRANCH}\n/" debian/control
> dpkg-buildpackage
> ```
> 
> It's also possible to inject the user-defined field into the generated
> source package using options passed to dpkg-source[2]:
> ```
> dpkg-buildpackage --source-option=-DGit-Branch=${CI_COMMIT_BRANCH}
> ```
> 
> However, that will only inject the field into the generated source package,
> not the generated binary packages. Is there a method to reliably inject
> fields into the binary packages?

Because binary package generation is currently off-loaded to
debian/rules, the dpkg tools driving the build externally have no way
to affect those fields. So your best way would be to automatically
modify the source package before the build, yes.

Regards,
Guillem


Reply to: