suzaku / shonenjump

A faster way to change directory and improve command line productivity.
Other
90 stars 8 forks source link

AUR build ? #5

Closed hiimdoublej closed 3 years ago

hiimdoublej commented 3 years ago

As title, an AUR build would make it easier to install for Arch Linux users.

suzaku commented 3 years ago

Thanks for your suggestion. But I don't use Arch Linux in a daily base, could you share a tutorial with me on how to create a AUR build and how to test it?

suzaku commented 3 years ago

Would a Snapcraft build make your life easier? If it is, I can set up one.

graysky2 commented 3 years ago

@suzaku @hiimdoublej - I took a stab at one: https://aur.archlinux.org/packages/shonenjump/

I am not very experienced with go for builds so I do not know if my invocation is correct. Further, namcap is complaining about my LDFLAGS:

% namcap shonenjump-0.7.20-1-x86_64.pkg.tar.zst 
shonenjump W: ELF file ('usr/bin/shonenjump') lacks FULL RELRO, check LDFLAGS.

Thoughts?

suzaku commented 3 years ago

@graysky2 Thanks very much.

I'm not familiar with AUR, where can I see your configuration? I can try my best to figure out what might be wrong there.

graysky2 commented 3 years ago

https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=shonenjump

The go command is on line 18 as you see.

suzaku commented 3 years ago

Do we have to use -v -buildmode=pie -ldflags "-extldflags \"$LDFLAGS\"" when building a Go binary for AUR? I only use go build . when building in my development environment.

graysky2 commented 3 years ago

@suzaku - I get warnings from the distro package audit util if I do not:

% namcap shonenjump-0.7.20-2-x86_64.pkg.tar.zst
shonenjump W: ELF file ('usr/bin/shonenjump') lacks FULL RELRO, check LDFLAGS.
shonenjump W: ELF file ('usr/bin/shonenjump') lacks PIE.

I also think my -ldflags ... part might be wrong.

suzaku commented 3 years ago

Can you try something like go build -v -ldflags "-buildmode=pie"? I see a similar configuration here

graysky2 commented 3 years ago

That syntax seems fine for the PIE warning but it does not fix up the FULL RELRO one.

  export CGO_LDFLAGS="$LDFLAGS"
  go build -v -ldflags "-buildmode=pie"

Do I have to tell go to use the newly defined variable or is that implied?

suzaku commented 3 years ago

How about this go build -buildmode=pie -ldflags '-linkmode=external -extldflags=-Wl,-z,relro,-z,now'? (ref)

graysky2 commented 3 years ago

That did it, thanks.

go build -buildmode=pie -ldflags "-linkmode=external -extldflags=$LDFLAGS"

No warnings from namcap on the resulting package.

You might wanna edit your README to point Arch Linux users to the AUR package.

suzaku commented 3 years ago

Does the j command work now in your environment? You can try cd around and then run j -stat and j -purge.

graysky2 commented 3 years ago

Yes, it works. Tested under zsh and bash.

suzaku commented 3 years ago

Cool, thanks very much!

I'm not familiar with AUR, could you please add a AUR subsection under the Linux section?

graysky2 commented 3 years ago

https://github.com/suzaku/shonenjump/pull/6

suzaku commented 3 years ago

Thanks. I can close this issue now. @hiimdoublej

graysky2 commented 3 years ago

https://github.com/suzaku/shonenjump/pull/6

The AUR (Arch User Repository) is just a place where Arch Linux users can submit an Arch-specific PKGBUILD for software. It's like a gentoo ebuild.

suzaku commented 3 years ago

I see. Is there a command like apt install for AUR?

graysky2 commented 3 years ago

No, the AUR does not store binary packages. It stores the recipe for users to build them. That is the PKGBUILD which keeps track of dependencies, and along with the Arch-specific build tool makepkg builds the binary package.

suzaku commented 3 years ago

Good to learn that, thanks.

graysky2 commented 3 years ago

The advantage of using the PKGBUILD method is that it produces a package for use with the distro package manager, pacman so that all files are tracked and easily updated/removed. A bit more sophisticated vs downloading and placing files manually :wink:

suzaku commented 3 years ago

How can I post new versions of this package on AUR? Ideally, I should integrate it into the build pipeline.

graysky2 commented 3 years ago

You can take over the PKGBUILD if you want to maintain it. It's just git. Not sure how to do any integration though.

suzaku commented 3 years ago

I use goreleaser to push updates to my Homebrew tap, but AUR is not supported, so I guess I have to do the same manually.

graysky2 commented 3 years ago

It's up to you. Alternatively, I can continue to maintain it. When you push a new release, just flag it out-of-date. If you want to maintain it, let me know when you have an AUR account and I will disown the package; you can then adopt it and it's all yours.

suzaku commented 3 years ago

OK, thank you. Please continue to maintain it now, I guess I'll play with Arch Linux a little bit when I get a new non-Mac laptop.

graysky2 commented 3 years ago

OK, let me know. If you're using debian/ubuntu, transitioning to Arch is pretty straight forward. I made the switch years ago and haven't looked back. The Arch Way is very appealing to me and the package manager (pacman) and the build tools are very simple and elegant compared to how other distros do it.

If you want to read up a bit, the Arch wiki is a spectacular resource and the forums are very helpful/really friendly user base.

suzaku commented 3 years ago

I'm using macOS now. I have tried Manjaro for a short time before and it looked great.

graysky2 commented 3 years ago

Be aware that Manjaro is not Arch. It is based on Arch but a different distro.

suzaku commented 3 years ago

I see. For me, it's like a newbie-friendly Arch.

graysky2 commented 3 years ago

That's fine. I believe Arch is more flexible but if you want something more friendly, that is your decision.