Skip to content

feature: Avoid bundling native binaries - #93

Draft
gordonmessmer wants to merge 3 commits into
theforeman:masterfrom
gordonmessmer:binary-detection
Draft

feature: Avoid bundling native binaries#93
gordonmessmer wants to merge 3 commits into
theforeman:masterfrom
gordonmessmer:binary-detection

Conversation

@gordonmessmer

Copy link
Copy Markdown

Fedora packaging guidelines do not permit distributing pre-built
native binaries. If the primary source includes such files, they
should be deleted in the %prep stage. If dependencies include such
files, the module should be packaged on its own and not bundled.

This change introduces a command line option intended for use on
Fedora packages.

@gordonmessmer

Copy link
Copy Markdown
Author

Hi! I'm a Fedora packager. I recently noticed that Fedora's process for packaging Node.js software is flawed, and that it results in pre-compiled content being bundled and potentially shipped to users. I've been investigating alternate approaches, and npm2rpm looks like an excellent place to start!

npm2rpm doesn't yet have a feature to detect and remove native binaries and Wasm from the bundled content, which Fedora would need, so I've added it. With that addition, I think that this could replace several Fedora tools and simplify the standard process.

I'll be discussing adoption of npm2rpm with the Fedora Node.js SIG next.

@Odilhao

Odilhao commented Jun 28, 2026

Copy link
Copy Markdown
Member

Let's allow CI to run on this 😬.

@gordonmessmer
gordonmessmer marked this pull request as draft June 30, 2026 20:46
@gordonmessmer

Copy link
Copy Markdown
Author

I've added a couple of changes.

First, probably a superficial change: As a convention, source0 is normally the primary archive in a spec in Fedora.

Second: In order to support removing binaries from that archive and to support applying patches to the primary archive (which must be supported for Fedora to use this), I've added a section that extracts and then repacks the primary archive. The npm install command then refers to the re-packed archive instead of the module name@version.

@ekohl

ekohl commented Jul 31, 2026

Copy link
Copy Markdown
Member

After #100 this needs to be rethought.

gordonmessmer and others added 2 commits August 13, 2026 14:48
Make the main package Source0 instead of appearing alphabetically
in the source list with dependencies. This makes it easier to apply
patches to the main package in %prep since Source0 is the conventional
location for the primary source archive.

Filter the main package from the deps array before numbering dependency
sources to avoid duplication, since npm-remote-ls returns the main
package along with its flattened dependency tree.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Gordon Messmer <gmessmer@redhat.com>
After adding all sources to the npm cache, extract Source0 into a
temporary directory where patches can be applied or binaries removed.
Repack the modified content as a tarball in the build directory.

In %build, install from the repacked tarball path instead of by
name@version. This allows npm to use the patched content while still
resolving dependencies from the cache.

This approach avoids integrity hash conflicts since npm uses the
tarball we provide directly rather than looking it up in the cache.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Gordon Messmer <gmessmer@redhat.com>
Fedora packaging guidelines do not permit distributing pre-built
native binaries. If the primary source includes such files, they
should be deleted in the %prep stage. If dependencies include such
files, the module should be packaged on its own and not bundled.

This change introduces a command line option intended for use on
Fedora packages.

Signed-off-by: Gordon Messmer <gmessmer@redhat.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@gordonmessmer

Copy link
Copy Markdown
Author

I've rebased on the new release and adapted to the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants