Skip to content

rpmbuild rewrites shebangs in the prebuilt Node.js payload, so RPMs ship different bytes than DEBs #218

Done

Description

@mmanciop

Summary

The rpm branch of the shared OBS spec (packaging/builder/opentelemetry.spec.tmpl) turns off stripping, debuginfo, and build-id links for the prebuilt payload.
It leaves brp-mangle-shebangs on, so rpmbuild changes files in the payload after %install.
The RPMs then ship different bytes from the DEB and nfpm packages built from the same source archive.

Evidence

In the rpm-source-rebuild CI jobs of #202, both on Fedora 44 and on AlmaLinux 9, rpmbuild logs:

mangling shebang in /usr/lib/opentelemetry/nodejs/node_modules/@grpc/proto-loader/build/bin/proto-loader-gen-types.js from /usr/bin/env node to #!/usr/bin/node
mangling shebang in /usr/lib/opentelemetry/nodejs/node_modules/yaml/bin.mjs from /usr/bin/env node to #!/usr/bin/node
mangling shebang in /usr/lib/opentelemetry/nodejs/node_modules/rimraf/dist/esm/bin.mjs from /usr/bin/env node to #!/usr/bin/node
mangling shebang in /usr/lib/opentelemetry/nodejs/node_modules/systeminformation/lib/cli.js from /usr/bin/env node to #!/usr/bin/node
mangling shebang in /usr/lib/opentelemetry/nodejs/node_modules/which/bin/node-which from /usr/bin/env node to #!/usr/bin/node
mangling shebang in /usr/lib/opentelemetry/nodejs/node_modules/glob/dist/esm/bin.mjs from /usr/bin/env node to #!/usr/bin/node

Impact

The impact is small, as the agent does not run these CLI entry points itself.

  • The RPM and DEB payloads of the same version are no longer byte-identical, which defeats the point of staging one tree for both builders.
  • On a host whose node is not /usr/bin/node (nvm, /usr/local/bin, a container image), the rewritten scripts no longer start.
  • The rewritten shebang is also why the spec has to filter %{_bindir}/node out of the automatic Requires.

brp-python-bytecompile runs too, but is currently a no-op for this payload.
It is invoked as brp-python-bytecompile '' 1 0 on both distributions: no interpreter in the buildroot, and _python_bytecompile_extra set to 0.
It would start writing unpackaged __pycache__/*.pyc files if either of those changed.

Proposed fix

Add the following next to the existing debug_package and __strip overrides in the rpm branch:

%global __brp_mangle_shebangs %{nil}
%global __brp_python_bytecompile %{nil}

Then add matching assertions to packaging/builder/obsspec_test.go.

Acceptance criteria

  • make integration-test-obs-rpm-rebuild logs no mangling shebang lines on Fedora and on EL 9.
  • The Node.js files listed above have the same content in the RPM and the DEB.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions