• Support for optional substvars

    From Guillem Jover@21:1/5 to All on Mon Apr 11 23:30:01 2022
    Hi Niels!

    Several months ago you asked on IRC about extending the substvars file
    format to be able to mark substvars as optional (so that they would not
    warn in case they end up not being used, like how several of the built-in
    ones are handled). At the time I mentioned that I'd need to ponder about
    it but had no energy (or motivation) do work on stuff.

    I've not forgotten about it, and it has been on the back of my head,
    and I've been converging on using «?=» as operator. Then rechecked the
    IRC logs, and noticed that was exactly one of the formats you proposed
    at the time (so either it stuck in the background and subconsciously
    surfaced, or I came to the same conclusion :). In any case, I've prepared
    the attached patch, which I'd be happy to include for 1.21.8, in case
    something like this works for you?

    Thanks,
    Guillem

    From 5c0820933a3d8dcf9b28bbce818f853e317b2468 Mon Sep 17 00:00:00 2001
    From: Guillem Jover <guillem@debian.org>
    Date: Mon, 11 Apr 2022 23:10:58 +0200
    Subject: [PATCH] Dpkg::Substvars: Add support for optional substvars assigned
    with ?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit

    Some packaging helpers (namely debhelper) set various substvars that
    might usually be used by the packaging, but not necessarily always.

    In the same way we mark some of the built-in variables as used, we add
    a new operator =C2=AB?=3D=C2=BB to make it possible for other tools to mark=
    those
    other variables as optional too. Track those internally too so that they
    can be printed back properly.

    Proposed-by: Niels Thykier <niels@thykier.net>
    ---
    man/deb-substvars.pod | 5 ++++-
    scripts/Dpkg/Substvars.pm | 13 ++++++++++---
    scripts/t/Dpkg_Substvars.t | 4 +++-
    scripts/t/Dpkg_Substvars/substvars1 | 1 +
    4 files changed, 18 insertions(+), 5 deletions(-)

    diff --git a/man/deb-substvars.pod b/man/deb-substvars.pod
    index c8fcb4c24..f8b80fecd 100644
    --- a/man/deb-substvars.pod
    +++ b/man/deb-substvars.pod
    @@ -90,7 +90,10 @@ B<debian/substvars>
    (or whatever other file is specified using the
    B<-T>
    option). This file consists of lines of the form
    -I<name>B<=3D>I<value>.
    +I<name>B<=3D>I<value> or I<name>B<?=3D>I<value>.
    +The B<=3D> operator assigns a normal substitution variable, while the B<?=

    +operator (since dpkg 1.21.8) assigns an optional substitution variable
    +which will emit no warnings even if unused.
    Trailing whitespace on each line, blank lines, and
    lines starting with a

    diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm
    index 497d51a9a..177cfd5bf 100644
  • From Niels Thykier@21:1/5 to All on Fri Apr 15 10:40:01 2022
    Guillem Jover:
    Hi Niels!

    Several months ago you asked on IRC about extending the substvars file
    format to be able to mark substvars as optional (so that they would not
    warn in case they end up not being used, like how several of the built-in ones are handled). At the time I mentioned that I'd need to ponder about
    it but had no energy (or motivation) do work on stuff.

    I've not forgotten about it, and it has been on the back of my head,
    and I've been converging on using «?=» as operator. Then rechecked the
    IRC logs, and noticed that was exactly one of the formats you proposed
    at the time (so either it stuck in the background and subconsciously surfaced, or I came to the same conclusion :). In any case, I've prepared
    the attached patch, which I'd be happy to include for 1.21.8, in case something like this works for you?

    Thanks,
    Guillem

    Hi Guillem,

    Thanks for coming back to me on this. :)

    I would definitely still love to have this feature, so please do go
    ahead with it if you are okay with it. :) I will look into making
    debhelper support/understand the new syntax soon.

    Thanks,
    ~Niels

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Niels Thykier@21:1/5 to All on Sun Apr 17 13:00:01 2022
    Guillem Jover:
    Hi Niels!

    Several months ago you asked on IRC about extending the substvars file
    format to be able to mark substvars as optional (so that they would not
    warn in case they end up not being used, like how several of the built-in ones are handled). At the time I mentioned that I'd need to ponder about
    it but had no energy (or motivation) do work on stuff.

    I've not forgotten about it, and it has been on the back of my head,
    and I've been converging on using «?=» as operator. Then rechecked the
    IRC logs, and noticed that was exactly one of the formats you proposed
    at the time (so either it stuck in the background and subconsciously surfaced, or I came to the same conclusion :). In any case, I've prepared
    the attached patch, which I'd be happy to include for 1.21.8, in case something like this works for you?

    Thanks,
    Guillem

    Possibly related. I had a look at deb-substvars(5). While it lists the debian/substvars file in the synopsis, the manpage does not actually
    cover the contents/syntax of that file at all. Instead it details how
    and when substitutions are applied in the build artefacts (which is
    valuable knowledge, but does not match the synopsis at all as far as I
    can tell).

    Thanks,
    ~Niels

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Guillem Jover@21:1/5 to Niels Thykier on Sun Apr 17 18:20:01 2022
    Hi!

    On Sun, 2022-04-17 at 12:52:50 +0200, Niels Thykier wrote:
    Possibly related. I had a look at deb-substvars(5). While it lists the debian/substvars file in the synopsis, the manpage does not actually
    cover the contents/syntax of that file at all.

    There's the following part, but it seems a bit overshadowed by the other content and in the middle of the text (which is what I updated with
    the proposed patch):

    ,---
    Variables can be set using the -V common option. They can be also specified
    in the file debian/substvars (or whatever other file is specified using the
    -T option). This file consists of lines of the form name=value. Trailing
    whitespace on each line, blank lines, and lines starting with a # symbol
    (comments) are ignored.
    `---

    Checking the man page again, it seems it might need some cleanup work, as
    I think this is just the remnants of the split out from some of the tool
    man pages. F.ex. the above options should perhaps be qualified, as those
    are tool specific. Various parts (built-in variables, examples, substvars
    and file syntaxes) should probably be placed on their own sub-sections.
    Or things like «${}» be reworded as something other than “not legal”.

    I'll get on that.

    Instead it details how
    and when substitutions are applied in the build artefacts (which is
    valuable knowledge, but does not match the synopsis at all as far as I
    can tell).

    I guess in this case the problem is that this covers both a file
    format, and substvars syntax "convention" (similar to deb-version(7)).
    Will try to think how to express that in the SYNOPSIS.

    Thanks,
    Guillem

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From J P@21:1/5 to guillem@debian.org on Mon Apr 18 04:10:01 2022
    Unsubscribe

    On Mon., Apr. 11, 2022, 2:26 p.m. Guillem Jover, <guillem@debian.org> wrote:

    Hi Niels!

    Several months ago you asked on IRC about extending the substvars file
    format to be able to mark substvars as optional (so that they would not
    warn in case they end up not being used, like how several of the built-in ones are handled). At the time I mentioned that I'd need to ponder about
    it but had no energy (or motivation) do work on stuff.

    I've not forgotten about it, and it has been on the back of my head,
    and I've been converging on using «?=» as operator. Then rechecked the
    IRC logs, and noticed that was exactly one of the formats you proposed
    at the time (so either it stuck in the background and subconsciously surfaced, or I came to the same conclusion :). In any case, I've prepared
    the attached patch, which I'd be happy to include for 1.21.8, in case something like this works for you?

    Thanks,
    Guillem


    <div dir="auto">Unsubscribe </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon., Apr. 11, 2022, 2:26 p.m. Guillem Jover, &lt;<a href="mailto:guillem@debian.org">guillem@debian.org</a>&gt; wrote:<br></div><blockquote class="gmail_
    quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Niels!<br>

    Several months ago you asked on IRC about extending the substvars file<br> format to be able to mark substvars as optional (so that they would not<br> warn in case they end up not being used, like how several of the built-in<br> ones are handled). At the time I mentioned that I&#39;d need to ponder about<br>
    it but had no energy (or motivation) do work on stuff.<br>

    I&#39;ve not forgotten about it, and it has been on the back of my head,<br> and I&#39;ve been converging on using «?=» as operator. Then rechecked the<br>
    IRC logs, and noticed that was exactly one of the formats you proposed<br>
    at the time (so either it stuck in the background and subconsciously<br> surfaced, or I came to the same conclusion :). In any case, I&#39;ve prepared<br>
    the attached patch, which I&#39;d be happy to include for 1.21.8, in case<br> something like this works for you?<br>

    Thanks,<br>
    Guillem<br>
    </blockquote></div>

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