#1026974 Cannot exclude a component from consideration using !

#1026974#5
Date:
2022-12-25 12:06:40 UTC
From:
To:
I am working on a package (node-webfont) which requires a non-node
component.  The dh-nodejs tools keeps complaining, for example
debclean reports:

Found debian/nodejs/additional_components
/!\ woff2/package.json not found
Unable to load woff2
/!\ brotli/package.json not found
Unable to load brotli

My additional_components reads:
---
!brotli
!woff2
---
following the guidance in pkg-js-tools(7), if I've understood it
correctly.  But it seems that this syntax doesn't help;
list-node-components reports:

[...]
varstream
woff2
brotli
!brotli
!woff2

with the first occurrence being picked up from debian/watch and the !
occurrences being those in additional_components.  But
component_list in /usr/share/perl5/Debian/PkgJs/Utils.pm has a
different behaviour, and it would seem that that should work.
Unfortunately, though, it doesn't appear to do so, and I don't
understand why not.

Best wishes,

   Julian

#1026974#10
Date:
2022-12-25 19:36:27 UTC
From:
To:
Hi Julian,

These are some excerpts from pkg-js-tools manpage:

debian/nodejs/additional_components is used to set some subdirectories that
should be considered as components even if they are not listed in
debian/watch. Starting from pkg-js-tools version 0.12.0 and 0.12.7, the
packages field in lerna.conf and workspaces field in package.json are used
to automatically detect additional components. If a component should not be
considered i.e, not automatically detected, insert its name preceded by a
"!" in debian/nodejs/additional_components.

From the above, I don't think "!" in debian/nodejs/additional_components is
used to exclude a component listed in debian/watch.

#1026974#15
Date:
2022-12-25 19:49:25 UTC
From:
To:
Can I ask what you're trying to achieve by excluding the component listed
in debian/watch? There could be a dh command or some pkg-js-tools
functionality that can be used to achieve it.

On Sun, 25 Dec 2022 at 20:36, Israel Galadima <izzygaladima@gmail.com> wrote:

#1026974#20
Date:
2022-12-25 20:00:20 UTC
From:
To:
Hi Israel,

That is exactly the behaviour I would expect from both a reading of
that manpage and the code in /usr/share/perl5/Debian/PkgJs/Utils.pm,
lines 153-217, excerpted here:

sub component_list {
    my $lerna = $OPTS->{lerna};
    my ( @components, %packages, @toDelete );
    [...]
    if ( -e 'debian/watch' ) {
        map { push @components, $1 if (/^[^#]*component=([\w\-\.]+)/) }
          open_file('debian/watch');
    }
    [...]
    if ( -e 'debian/nodejs/additional_components' ) {
        debug "Found debian/nodejs/additional_components";
        map {
            if (s/^!//) {
                push @toDelete, $_;
            }
            else {
                debug 'Adding component(s): ' . join( ', ', glob($_) );
                push @components, glob($_);
            }
        } open_file('debian/nodejs/additional_components');
    }
    [...]
    foreach (@toDelete) {
        my $ref = $_;
        @components = grep { $_ ne $ref } @components;
        delete $packages{$ref};
    }
    return \%packages;
}

So if I understand this function correctly, the intended behaviour is
exactly as I described in the bug report: writing "!brotli" in
additional_components should cause the dh-nodejs scripts to ignore
this component.  But it's possible that some of the bits I commented
out cause the function to do something else that I don't understand.

Best wishes,

   Julian

#1026974#25
Date:
2022-12-25 20:01:25 UTC
From:
To:
Yes, these components are C++ code, not Javascript, so I want the
dh-nodejs scripts to completely ignore them.

Best wishes,

   Julian

#1026974#30
Date:
2022-12-25 20:37:02 UTC
From:
To:
Then it may be better to package these two separately. Currently I think
the components are designed work with nodejs only modules I think.

#1026974#35
Date:
2022-12-25 21:43:05 UTC
From:
To:
separately for my purposes (and they are both already packaged in
Debian): node-wawoff2 requires an emscripten/WASM build of these two
C++ libraries, so it needs the source code.

Best wishes,

   Julian

#1026974#40
Date:
2022-12-25 22:59:42 UTC
From:
To:
Quoting Julian Gilbey (2022-12-25 22:43:05)

It is sensible to expect debhelper scripts to support ignoring some
parts of a project - either because those other parts need different
tools (like here) or because those parts need custom handling for other
reasons.

Please a bugreport against dh-nodejs.


 - Jonas

#1026974#45
Date:
2022-12-26 07:36:14 UTC
From:
To:
reassign 1026974 dh-nodejs
thanks

OK; I'm reassigning this bug there, then.  (They're part of the same
source package anyway.)

   Julian

#1026974#54
Date:
2022-12-26 08:10:18 UTC
From:
To:
Hi,

I'm moving this week, will take a look at this later ;-)

Cheers,
Yadd

Le Lundi, Décembre 26, 2022 08:36 CET, Julian Gilbey <jdg@debian.org> a écrit:

#1026974#59
Date:
2022-12-26 08:58:10 UTC
From:
To:
Thanks Yadd, and it isn't breaking the build, so no particular rush!

Best wishes,

   Julian