Package: dh-builtusing
Version: 0.0.7
Severity: normal
Control: affects -1 src:tsocks
X-Debbugs-Cc: [email protected]

Dear Maintainer,

I'd like to give some context here by referring to a specific package (tsocks).

I was trying to make tsocks cross-buildable which was failing with (cross 
compiling from
amd64 to arm64):

|   dh_builtusing -a
| dh_builtusing: error: libc-dev-bin should match one installed package, got:
| glibc,2.41-8,amd64

And it had "Built-Using: ${dh-builtusing:libc-dev-bin}" in its d/control.

This fails because libc-dev-bin is marked "M-A: foreign" and can therefore pull
in the binary that's present in amd64. The code in dh-builtusing tries to match
the architecture of B-U package (in this case, amd64) with the host arch (in 
this case
arm64) here [1] and it therefore fails here.

Next step was to look for an alternative. "Built-Using: 
${dh-builtusing:libc6-dev}" works
fine but it is a no-go as well because this breaks cross-builds for ports 
(libc6-dev package
is not available on hurd-any and alpha).

The next step was to try to replace it with libc-dev. This does not work because
dh-builtusing issues a `dpkg-query` in its code here [2] which does not work 
for virtual packages.

Finally, we had to resort to something fairly manual [3] - i.e. manually adding
substvars in d/rules to get it working.

But, I think (and Helmut seems to concur) that this ought to be easier than 
doing manual
workarounds here.

If a fix can be made in dh-builtusing itself that would be helpful. One idea is 
to
somehow add in support for virtual packages.

I'd like to hear from you about it, and would be happy to discuss any ideas you
may have regarding the same.

On a somewhat related note, I also noticed that using libc-dev-bin in d/rules
for Built-Using field is also something that other packages do [4]. So there are
at least a few more packages that could profit from a fix here.

The related mailing list thread and all the discussion about it can be found 
here [5] for
your reference.

PS: Please consider to cc: debian-cross@ mailing list for further 
correspondence.

[1] 
https://salsa.debian.org/debian/dh-builtusing/-/blob/master/dh_builtusing?ref_type=heads#L92
 
and the code in question is:

```
        my @x = split qr/ , /;
        if ( @x == 2 or $x[2] eq 'all' or $x[2] eq hostarch ) {
            push @result, $x[0], $x[1];
        }
```

[2] 
https://salsa.debian.org/debian/dh-builtusing/-/blob/master/dh_builtusing?ref_type=heads#L87
and the relevant code:

```
    my $format =
      $glob =~ m/ : /
      ? "\${source:Package},\${source:Version}\n"
      : "\${source:Package},\${source:Version},\${Architecture}\n";
    my @out = qx_cmd( 'dpkg-query', '-Wf', $format, $glob );    # _;
    my @result;

```

[3] 
https://salsa.debian.org/debian/tsocks/-/commit/5fe61d74c10dcab1cdd354457e52f1b951263d57
[4] 
https://codesearch.debian.net/search?q=libc-dev-bin+path%3Adebian%2Frules&literal=0&page=1
[5] https://lists.debian.org/debian-cross/2025/08/msg00028.html

Best,
Nilesh

Reply via email to