#1110204 dh-nodejs: nodejs:BuiltUsing uses binary package names rather than source package names

Package:
dh-nodejs
Source:
dh-nodejs
Submitter:
Julian Gilbey
Date:
2025-08-04 15:27:02 UTC
Severity:
normal
Tags:
#1110204#5
Date:
2025-07-31 20:52:07 UTC
From:
To:
The Built-Using dpkg field requires source package names, not binary
package names, whereas dh-nodejs currently emits binary package
names.

My Perl is quite rusty, but I think what would solve it is modifying
the builtUsing function in
/usr/share/perl5/Debian/PkgJs/PackageLock.pm
as follows; I can submit this as a MR on salsa if you would prefer:

sub builtUsing {
    [...]
                    spawn(
                        exec => [
                            'dpkg-query', '--showformat=${Version},${Source}',
                            '--show',     $pkg,
                        ],
                        wait_child      => 1,
                        to_string       => \$version_source,
                        error_to_string => \$err,
                    );
                    chomp $version_source;
                    my @vs = split /,/, $version_source;
                    # Source is empty if the binary package has the same name
                    $vs[1] ||= $pkg;
                    $res{$pkg} = \@vs;
                    debug("Add $vs[1] (= $vs[0]) in \${nodejs:BuiltUsing}");
    [...]
    return join( ',', map { "$res{$_}[1] (= $res{$_}[0])" } sort keys %res );
}


Best wishes,

   Julian

#1110204#10
Date:
2025-08-01 07:01:39 UTC
From:
To:
I realise that if two packages built from the same source are used,
then there may be duplication in the output.  It's not an error, but
it would be nicer if that weren't the case.  Here is an improved
version of the whole function.

sub builtUsing {
    my ( %res, %seen );
    my $nodePaths = nodepathNoError( 0, ( $_[0] // 1 ), keys %$BUILTUSING );
    map {
        my ( $pkg, $version, $err );
        if ( $pkg = $nodePaths->{$_}->[0] ) {
            eval {
                unless ( $seen{$pkg} ) {
                    spawn(
                        exec => [
                            'dpkg-query', '--showformat=${Version},${Source}',
                            '--show',     $pkg,
                        ],
                        wait_child      => 1,
                        to_string       => \$version_source,
                        error_to_string => \$err,
                    );
                    chomp $version_source;
                    my @vs = split /,/, $version_source;
                    # Source is empty if the binary package has the same name
                    $vs[1] ||= $pkg;
                    $res{$vs[1]} = $vs[0];
                    $seen{$pkg} = 1;
                    debug("Add $vs[1] (= $vs[0]) in \${nodejs:BuiltUsing}");
                }
            };
        }
    } keys %$BUILTUSING;
    return join( ',', map { "$_ (= $res{$_})" } sort keys %res );
}


Best wishes,

   Julian

#1110204#13
Date:
2025-08-01 07:29:20 UTC
From:
To:
Hello,

Bug #1110204 in pkg-js-tools reported by you has been fixed in the
Git repository and is awaiting an upload. You can see the commit
message below and you can check the diff of the fix at:

https://salsa.debian.org/js-team/pkg-js-tools/-/commit/c5cf8d19ec40c98d9ea4c4f32a98fe8a87dc4cc3
------------------------------------------------------------------------
Use source package names into ${nodejs:BuiltUsing}

Closes: #1110204
------------------------------------------------------------------------

(this message was generated automatically)
-- 
Greetings

https://bugs.debian.org/1110204

#1110204#20
Date:
2025-08-04 15:25:03 UTC
From:
To:
Dear Yadd,

It may be that this patch will need unapplying - see the discussion
I've just contributed to at
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1069256

Best wishes,

   Julian