Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add binary_relocation: false #428

Closed
pavelzw opened this issue Dec 18, 2023 · 6 comments · Fixed by #479
Closed

Add binary_relocation: false #428

pavelzw opened this issue Dec 18, 2023 · 6 comments · Fixed by #479

Comments

@pavelzw
Copy link
Collaborator

pavelzw commented Dec 18, 2023

Would be nice to be able to disable binary relocation.

@brad-jones
Copy link

So I started playing around with pixi that other day, attempting to put together a dev env for my team.
One of the packages we use lefthook didn't seem to to be published on conda-forge so I figured I'd have a go at building a conda package with rattler myself.

This is my recipe.

# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json

context:
  version: "1.5.4"

package:
  name: lefthook
  version: ${{ version }}

source:
  - if: linux and x86_64
    then:
      url: https://github.com/evilmartians/lefthook/releases/download/v${{ version }}/lefthook_${{ version }}_Linux_x86_64
      sha256: 1a359b807fe6dec3f796a62c436348749697571a992cd24c3f646529e20bce71
  - if: osx and x86_64
    then:
      url: https://github.com/evilmartians/lefthook/releases/download/v${{ version }}/lefthook_${{ version }}_MacOS_x86_64
      sha256: c26d50de48d3c4e70fb5ba629f0906b5a3effbb73f7daef2688ff4f4625cc8d2
  - if: osx and arm64
    then:
      url: https://github.com/evilmartians/lefthook/releases/download/v${{ version }}/lefthook_${{ version }}_MacOS_arm64
      sha256: 358be965ed88a52c53e7cdc8d8d4f5e95d592f07d9ab1015483ac2c9520d2490
  - if: win and x86_64
    then:
      url: https://github.com/evilmartians/lefthook/releases/download/v${{ version }}/lefthook_${{ version }}_Windows_x86_64.exe
      sha256: 5e27ecf5a78b13f8b3b23faf938da2f28a7310a98475a60bfc782fe1becb5132

build:
  script:
    - mkdir -p $PREFIX/bin
    - mv ./lefthook* $PREFIX/bin/lefthook
    - chmod +x $PREFIX/bin/lefthook

test:
  commands:
    - test "$(lefthook version)" = "1.5.4"

But I get this error from patchelf: 2023-12-23T10:36:08.599972Z ERROR rattler_build::linux::link: patchelf failed: patchelf: cannot find section '.dynamic'. The input file is most likely statically linked

Now perhaps the manner in which I have written my recipe is not the typical workflow. ie: I'm not building anything just downloading an already built binary. But I guess the outcome would be the same if I had done the go build myself & set CGO_ENABLED=0 right?

So yeah the ability to disable this binary relocation step seems sensible. That is whats causing my problem right?

@pavelzw
Copy link
Collaborator Author

pavelzw commented Dec 23, 2023

When repackaging binaries, it makes sense to enable binary_relocation: false. This would fix the problem you're having.

@wolfv
Copy link
Member

wolfv commented Dec 23, 2023

I think there are two things:

  • we should add the option
  • we should detect if the ELF file / executable does not have a .dynamic section and not attempt to patch anything.

@wolfv
Copy link
Member

wolfv commented Dec 23, 2023

@brad-jones I think this should fix your issue: #443

@brad-jones
Copy link

Can confirm this works. Couple of things I noticed though.

Your versioning in the github releases appears to be out of sync?
image

Anyway I downloaded the new rattler-build binary from https://github.com/prefix-dev/rattler-build/actions/runs/7309118178

The JSON Schema accepts the property.
image

But rattler-build it's self does not.
image

@pavelzw
Copy link
Collaborator Author

pavelzw commented Dec 24, 2023

Your versioning in the github releases appears to be out of sync?

Fixed with #424 but in the 0.6.1 case, only the version number is broken, the rest works.

But rattler-build it's self does not.

That's why the issue itself is still open 😄
Wolf only fixed the error about the .dynamic stuff

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 a pull request may close this issue.

3 participants