• Fwd: How to injecting user-defined fields in binary package control fil

    From Nicholas Brown@21:1/5 to All on Tue May 25 10:50:01 2021
    Forwarding to a more topic specific mailing list.

    ---------- Forwarded message ---------
    From: Nicholas Brown <nickbroon@gmail.com>
    Date: Mon, 24 May 2021 at 11:16
    Subject: How to injecting user-defined fields in binary package control
    files
    To: <debian-user@lists.debian.org>


    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.
    ```
    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?

    Thanks,
    Nick

    [1]: https://www.debian.org/doc/debian-policy/ch-controlfields.html#user-defined-fields
    [2]:
    https://manpages.debian.org/buster/dpkg-dev/dpkg-buildpackage.1.en.html

    <div dir="ltr">Forwarding to a more topic specific mailing list.<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">Nicholas Brown</strong> <span
    dir="auto">&lt;<a href="mailto:nickbroon@gmail.com">nickbroon@gmail.com</a>&gt;</span><br>Date: Mon, 24 May 2021 at 11:16<br>Subject: How to injecting user-defined fields in binary package control files<br>To: &lt;<a href="mailto:debian-user@lists.
    debian.org">debian-user@lists.debian.org</a>&gt;<br></div><br><br><div dir="ltr">It&#39;s possible to add user-defined fields in the debian/control file using the `XBS-` method, as defined in the Policy Manual[1].<br><br>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&#39;t contain debian/control as they generate it (kernel etc) so this is not always reliable.<br>```<br>sed -i &quot;0,/^\s*$/s//XBS-
    Git-Branch: ${CI_COMMIT_BRANCH}\n/&quot; debian/control<br>dpkg-buildpackage<br>```<br><br>It&#39;s also possible to inject the user-defined field into the generated source package using options passed to dpkg-source[2]:<br>```<br>dpkg-buildpackage --
    source-option=-DGit-Branch=${CI_COMMIT_BRANCH}<br>```<br><br>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?<br><br>
    Thanks,<div>Nick<br><br>  [1]: <a href="https://www.debian.org/doc/debian-policy/ch-controlfields.html#user-defined-fields" target="_blank">https://www.debian.org/doc/debian-policy/ch-controlfields.html#user-defined-fields</a><br>  [2]: <a href="https:/
    /manpages.debian.org/buster/dpkg-dev/dpkg-buildpackage.1.en.html" target="_blank">https://manpages.debian.org/buster/dpkg-dev/dpkg-buildpackage.1.en.html</a><br></div></div>
    </div></div>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Guillem Jover@21:1/5 to Nicholas Brown on Wed May 26 02:20:02 2021
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)