Package: dh-nodejs
Version: 0.17.4
Severity: important
Tags: patch

Dear Maintainer,

Many packages using dh-nodejs are unreproducible right now because
dh-nodejs can generate unreproducible pkgjs-lock.json files depending
on whether nocheck is specified or not.

The potential "pissue" is that link_external_modules() / _extLinks() in
Debian::PkgJs::Utils will skip generating node_modules/foo symlinks for
test-only modules, and so when Debian::PkgJs::PackageLock goes to
generate the pkgjs-lock.json, nodepath will return different paths
that are used in the JSON.

For example, node-tsx's debian/nodes/extlinks has:

    esbuild
    chalk
    @ampproject/remapping
    chokidar
    es-module-lexer
    get-tsconfig
    magic-string
    slash
    execa test <--------------------
    memfs test
    strip-ansi test
    strip-indent test

... which results in, for instance, the links for "execa" to not be
generated if nocheck is specified.

The pkgjs-lock.json file then contains (in the nocheck case):

        "/usr/share/nodejs/execa": {
            "name": "execa",
            "version": "8.0.1"
        },

... and in the normal case (ie. when the tests are run), the
pkgjs-lock.json contains:

        "node_modules/execa": {
            "name": "execa",
            "version": "8.0.1"
        }

One fix *could* be to generate the links regardless whether nocheck is
specified. I've attached this patch, although it's a very ugly diff due
to the dedenting.

However, I lack the understanding about how nodejs paths work to know
whether this the right solution. Specifically, if a Build-Depends is
listed as <!nocheck> and the package is *not* installed as a result, I
don't know whether that will result in nodepath returning different/
broken results, or even cause a failure. (In the above example, the
node-execa package was installed in both cases which cannot be
guaranteed due to it being specified with <!nocheck>; it is hard to
test what happens if node-execa is not installed as some other packages
have transitive dependencies on it.)


Best wishes,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      [email protected] / chris-lamb.co.uk
       `-
diff --git lib/Debian/PkgJs/Utils.pm lib/Debian/PkgJs/Utils.pm
index c4d2e67..f744c19 100644
--- lib/Debian/PkgJs/Utils.pm
+++ lib/Debian/PkgJs/Utils.pm
@@ -469,68 +469,50 @@ sub _extLinks {
                     # Drop "  test" if exists
                     $_ =~ s/\s+(\S*).*?$//;
 
-                    # If "  test" exists, link/copy module only if !nocheck
-                    if (
-                            $1
-                        and $1 eq 'test'
-                        and (
-                            (
-                                    $ENV{DEB_BUILD_OPTIONS}
-                                and $ENV{DEB_BUILD_OPTIONS} =~ /\bnocheck\b/
-                            )
-                            or (    $ENV{DEB_BUILD_PROFILES}
-                                and $ENV{DEB_BUILD_PROFILES} =~ /\bnocheck\b/ )
-                        )
-                      )
-                    {
-                        print STDERR "Skipping $_ link\n";
-                    }
-                    else {
-                        # Search module using nodepath
-                        my ($src);
-                        spawn(
-                            exec       => [ 'nodepath', '-B', $_ ],
-                            wait_child => 1,
-                            to_string  => \$src,
-                            no_check   => 1,
-                            # XXX: Backwards compatibility, remove after dpkg 
1.24.0.
-                            nocheck    => 1,
-                        );
-
-                        # Fail if not found
-                        if ( $? or not $src ) {
-                            print STDERR "### $_ is required by "
-                              . "debian/nodejs/$dir/ext$type"
-                              . " but not available\n";
-                            if ( $_ =~ s#^\@types/## ) {
-                                print STDERR "# Typescript definition "
-                                  . "detected, Fallback to main module\n";
-                                spawn(
-                                    exec       => [ 'nodepath', '-B', $_ ],
-                                    wait_child => 1,
-                                    to_string  => \$src,
-                                    no_check   => 1,
-                                    # XXX: Backwards compatibility, remove 
after dpkg 1.24.0.
-                                    nocheck    => 1,
-                                );
-                                if ( $? or not $src ) {
-                                    print STDERR "### $_ isn't available 
too\n";
-                                    $exit++;
-                                }
-                                print STDERR "### You SHOULD update your "
-                                  . "debian/nodejs/$dir/ext$type file!\n";
-                            }
-                            else {
+                    # Search module using nodepath
+                    my ($src);
+                    spawn(
+                        exec       => [ 'nodepath', '-B', $_ ],
+                        wait_child => 1,
+                        to_string  => \$src,
+                        no_check   => 1,
+                        # XXX: Backwards compatibility, remove after dpkg 
1.24.0.
+                        nocheck    => 1,
+                    );
+
+                    # Fail if not found
+                    if ( $? or not $src ) {
+                        print STDERR "### $_ is required by "
+                          . "debian/nodejs/$dir/ext$type"
+                          . " but not available\n";
+                        if ( $_ =~ s#^\@types/## ) {
+                            print STDERR "# Typescript definition "
+                              . "detected, Fallback to main module\n";
+                            spawn(
+                                exec       => [ 'nodepath', '-B', $_ ],
+                                wait_child => 1,
+                                to_string  => \$src,
+                                no_check   => 1,
+                                # XXX: Backwards compatibility, remove after 
dpkg 1.24.0.
+                                nocheck    => 1,
+                            );
+                            if ( $? or not $src ) {
+                                print STDERR "### $_ isn't available too\n";
                                 $exit++;
                             }
+                            print STDERR "### You SHOULD update your "
+                              . "debian/nodejs/$dir/ext$type file!\n";
                         }
                         else {
-                            chomp $src;
-                            my $tmp = $src;
-                            $tmp =~ s#^.*?nodejs/##;
-                            $cmds{$type}->( $src, $tmp );
+                            $exit++;
                         }
                     }
+                    else {
+                        chomp $src;
+                        my $tmp = $src;
+                        $tmp =~ s#^.*?nodejs/##;
+                        $cmds{$type}->( $src, $tmp );
+                    }
                 } open_file("debian/nodejs/$dir/ext$type");
                 exit $exit if $exit;
             }
-- 
Pkg-javascript-devel mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-javascript-devel

Reply via email to