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

feat(nfpm): support arm in termux #4901

Merged
merged 1 commit into from
Jun 11, 2024
Merged

Conversation

rsteube
Copy link
Contributor

@rsteube rsteube commented May 31, 2024

This adds arm support for termux (arch needs to be called arm as well).


Ok this drove me nuts, but I think I've got it working now: https://github.com/carapace-sh/carapace-bin/releases/tag/v1.0.3

  1. First of all most of the android targets need CGO_ENABLED=1.

  2. Then there's the need for a patched runtime due to the /data/data/com.termux/files prefix (adopted from the golang package).

  3. Two builds so that for termux the patched gobinary can be used. Then add a termux suffix to the archives for clarity.

builds:
  - id: default
    env:
      - CGO_ENABLED=0
    goos:
      - linux
      - windows
      - darwin
    main: ./cmd/carapace
    binary: carapace
    tags:
      - release
  - id: termux
    env:
      - CGO_ENABLED=1
    goos:
      - android
    goarch:
      - amd64
      - arm64
      - arm
      - "386"
    main: ./cmd/carapace
    binary: carapace
    tags:
      - release
    gobinary: go-termux
archives:
  - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
    builds:
     - default
    format_overrides:
      - goos: windows
        format: zip
  - id: termux
    builds:
      - termux
    name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}.termux'
  1. Compiling needs the Android NDK with the CC environment variable set. I used a script for this (/usr/local/bin/go-termux).
#!/bin/bash

bindir="/opt/android-sdk/ndk/${NDK_VERSION}/toolchains/llvm/prebuilt/linux-x86_64/bin"
[ "$GOARCH" = "amd64" ] && export CC="$bindir/x86_64-linux-android${ANDROID_VERSION}-clang"
[ "$GOARCH" = "arm64" ] && export CC="$bindir/aarch64-linux-android${ANDROID_VERSION}-clang"
[ "$GOARCH" = "arm" ] && export CC="$bindir/armv7a-linux-androideabi${ANDROID_VERSION}-clang"
[ "$GOARCH" = "386" ] && export CC="$bindir/i686-linux-android${ANDROID_VERSION}-clang"

exec /usr/local/go-termux/bin/go "$@"
  1. There's termux-apt-repo which makes repo creation pretty easy with gh_pages. Just needs a fix as goreleaser uses data.tar.gz.

related #3333
related #4812
related termux/termux-apt-repo#25

@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 31, 2024
@rsteube rsteube force-pushed the termux-arm branch 2 times, most recently from 211f449 to 84147c4 Compare June 8, 2024 08:56
Copy link

codecov bot commented Jun 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.91%. Comparing base (c68d830) to head (feab3c4).
Report is 325 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4901      +/-   ##
==========================================
+ Coverage   83.77%   83.91%   +0.14%     
==========================================
  Files         135      139       +4     
  Lines       13029    11110    -1919     
==========================================
- Hits        10915     9323    -1592     
+ Misses       1677     1334     -343     
- Partials      437      453      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thank you!

@caarlos0 caarlos0 added this to the v2.1.0 milestone Jun 9, 2024
@caarlos0 caarlos0 added the enhancement New feature or request label Jun 9, 2024
@caarlos0 caarlos0 changed the title termux: support arm feat(nfpm): support arm in termux Jun 9, 2024
@caarlos0 caarlos0 merged commit cefec7c into goreleaser:main Jun 11, 2024
11 checks passed
@aicynide
Copy link

aicynide commented Sep 2, 2024

@rsteube what about /etc/resolv.conf ? its not present in bindir

@rsteube
Copy link
Contributor Author

rsteube commented Sep 2, 2024

@aicynide I appreciate your participation in this, but your tone is slightly off.

@caarlos0
Copy link
Member

caarlos0 commented Sep 2, 2024

@aicynide your tone is very off in this, let's be more civil in the next interactions, please.

FWIW we have a CoC: https://github.com/goreleaser/goreleaser?tab=coc-ov-file#readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants