[Pkg-javascript-devel] Bug#1110204: dh-nodejs: nodejs:BuiltUsing uses binary package names rather than source package names

Julian Gilbey jdg at debian.org
Fri Aug 1 08:01:39 BST 2025


On Thu, Jul 31, 2025 at 09:52:07PM +0100, Julian Gilbey wrote:
> Package: dh-nodejs
> Version: 0.15.23
> Severity: normal
> Tags: patch
> 
> 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

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



More information about the Pkg-javascript-devel mailing list