samwho / spacer

CLI tool to insert spacers when command output stops
https://github.com/samwho/spacer
MIT License
853 stars 9 forks source link

aarch64/linux & arm64/darwin builds #11

Closed tisba closed 11 months ago

tisba commented 1 year ago

I was wondering if you would consider offering macOS arm64 builds (esp. for homebrew). aarch64 would also be great (in my case for running linux [in VMs] on Apple Silicon).

samwho commented 1 year ago

It's certainly possible though I'm interested to hear what's wrong with the current Intel builds? I run those myself using Rosetta and it works just fine.

If you desperately want an arm64 build, you can always cargo install spacer to build locally 🙂

tisba commented 1 year ago

Trying to avoid Rosetta wherever I can - but that's just a personal sport of mine :) On other systems Raspberry and linux VPS I'm mostly using arm as well these days.

Anyway, I'll try and take a look if I can extend your homebrew formular so it can compile from source or maybe the release GH action can be extended.

tisba commented 1 year ago

In case somebody is following this: brew install spacer should now just work™ regardless of architecture (will compile on non-arm systems though).

tisba commented 1 year ago

Let's pull our discussion over here, @samwho.

https://github.com/samwho/homebrew-spacer/pull/1#pullrequestreview-1524217673

I'm shying away from doing ARM builds because the only way I know of doing them at the moment in GitHub Actions is through QEMU, which is horrendously slow. I'm open to suggestion.

I have little to no experience with that, but I do kind of see your point. I've never done any Rust development myself, but I think it should be possible to cross-compile between architectures. It's on my short list to try this out :)

tisba commented 1 year ago

Took me a little trial and error, but I got it somehow working (see for example https://github.com/tisba/spacer/actions/runs/5528712633). So it looks like you can cross compile between architectures just fine. I can take a look later to clean it up a bit and make a PR if you like.

Cross compiling between OSes seems to be a little bit more complicated, but we probably don't need that.

Also, feel free to test the binary attached to the build. On macOS you have to strip the quarantine attribute though:

chmod u+x /Users/basti/Downloads/spacer
sudo xattr -r -d com.apple.quarantine /Users/basti/Downloads/spacer
samwho commented 11 months ago

Sorry it took so long for me to reply to this.

This looks great, and works as far as I can tell. Having to remove the quarantine attribute is a little distressing. Is that a step the user would have to perform manually? Do I have to sign the binary somehow to get Apple to trust it?

Moulick commented 11 months ago

In case somebody is following this: brew install spacer should now just work™ regardless of architecture (will compile on non-arm systems though).

Geez, on darwin/arm64, the local build needs llvm and rust which were around 1.5gb and 843Mb (~39k) files.

This looks great, and works as far as I can tell. Having to remove the quarantine attribute is a little distressing. Is that a step the user would have to perform manually? Do I have to sign the binary somehow to get Apple to trust it?

Arm64 binaries do not need to be signed with an Apple issued certificate but simply any ad-hoc certificate. I checked a few binaries installed from official brew formulas and none of them are signed with a valid Apple issued certificate. https://eclecticlight.co/2021/02/18/code-signing-requirements-for-scripts-and-apps-in-big-sur/

I think I can open a PR to get this included in the official brew formula repo if you want and you'll not have to maintain this tap anymore. Homebrew's official repo builds the binaries for linux/darwin and x86/arm64 all, also for all supported macos versions individually for best dependencies support.

tisba commented 11 months ago

Most brew formulas strip the quarantine attribute. Since homebrew is using cryptographic checksums the impact is assumed minimal.

A pre compiled formula would be nice, but we can also setup a formula so you can still compile (head) from source if a user wants to. In terms of convenience that's the best for homebrew users IMO.

Moulick commented 11 months ago

Even with pre-compiled formula, a user can run brew install spacer --build-from-source if they really need to build it locally for some reason. Personally, I much prefer pre-built binaries, faster/cheaper and brew does not uninstall the build dependencies (like rust and llvm) after building,

samwho commented 11 months ago

I think I can open a PR to get this included in the official brew formula repo if you want and you'll not have to maintain this tap anymore. Homebrew's official repo builds the binaries for linux/darwin and x86/arm64 all, also for all supported macos versions individually for best dependencies support.

@Moulick I would be extremely grateful if you did this! 🙏

Moulick commented 11 months ago

Opened https://github.com/Homebrew/homebrew-core/pull/141151 and https://github.com/samwho/homebrew-spacer/pull/2

samwho commented 11 months ago

Can we close this now?

Also, when I push a new version of spacer, do I have to open a PR against homebrew-core? How does that work?

Moulick commented 11 months ago

Yep, you or anybody can locally run brew bump --open-pr spacer and brew will automatically get the latest release from github and make a PR. Though now with the move to API based homebrew, you'll also have to tap homebrew/core

Moulick commented 11 months ago

https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md#to-submit-a-version-upgrade-for-the-foo-formula