Open JohannesKaufmann opened 6 days ago
Unfortunately I am not a Linux user, so any help is appreciated!
Warning: Linux is a an endless rabbit hole. Proceed with caution if you don't have very much free time. :upside_down_face:
For transparency, I have to admit I am heavily biased in favor of Arch Linux over any other distribution. Arch is the Best. However, I have used quite a few different distributions and may be able to offer some general insight.
Almost every Linux distribution is open source and free to use. There are many options for installing Linux, including dual-booting if you want to try it out. Or, you can experiment with many distributions in a virtual machine. If you just want to focus on how to release Linux packages, it isn't necessary to use Linux at all (but it is fun).
Since you're already familiar with go, you could use Docker to test your packages in different Linux environments without needing to dual-boot or fully install Linux.
- What are the most common distros/package managers?
There are many Linux distributions, each using different package management systems. Here are the most common:
- How are they distributed/hosted?
Most distributions have official repositories that serve as the primary source of packages. For Debian and Ubuntu, .deb packages are hosted in APT repositories. For Fedora, CentOS, and openSUSE, .rpm packages are hosted in DNF/YUM or Zypper repositories. Arch Linux uses the Arch User Repository (AUR) as well as official repositories for package hosting.
- Which choice/combination would serve the most users?
Debian-based and Arch-based distributions are the most most popular among developers, and these distributions are almost always supported by popular software releases. Red Hat-based distributions are also commonly supported. There are many other smaller and niche distributions, but by focusing on these three you’ll cover most Linux users with minimal effort.
You're already doing great with GoReleaser and I think you're on the right track with nfpm
. Use nfpm
to generate .deb
packages for Ubuntu, Debian, and related distros and .rpm
packages for Fedora, RHEL, and CentOS.
For Arch, it appears that you can use nfpm
to generate .pkg.tar.zst
packages. However, this method isn’t as common as providing a PKGBUILD. I highly recommend spending time learning how to package programs for the AUR because this would showcase your tool to many potential contributors and early adopters. A PKGBUILD file is a script that defines how to build and install your program on Arch Linux. Arch users expect software to be available in the AUR, even if not officially packaged. The AUR allows users to build packages directly from source, ensuring compatibility with their system. You only need to provide a PKGBUILD file (a simple build script), and the Arch community handles the rest.
Here's a dummy PKGBUILD for a made-up go package (I don't know go, but this might give you a better idea of what a PKGBUILD looks like):
# Maintainer: Your Name <your.email@example.com>
pkgname=mycli
pkgver=1.0.0
pkgrel=1
pkgdesc="A CLI tool built in Go"
arch=('x86_64')
url="https://github.com/yourusername/mycli"
license=('MIT')
depends=('glibc') # List runtime dependencies here
source=("$pkgname-$pkgver.tar.gz::https://github.com/yourusername/mycli/archive/v$pkgver.tar.gz")
sha256sums=('SKIP') # Replace with real checksum if needed
build() {
cd "$srcdir/$pkgname-$pkgver"
go build -o mycli
}
package() {
cd "$srcdir/$pkgname-$pkgver"
install -Dm755 mycli "$pkgdir/usr/bin/mycli"
}
After you have a PKGBUILD, follow the AUR Guidelines to create and submit your package. If your project updates frequently, you can automate AUR updates using tools like aurpublish or a custom GitHub Action.
@kielmarj Wow, thanks a lot for the detailed information!
There is now already everything configured for Debian. Building the deb
packages & uploading them to Cloudsmith.
See the Setup Instructions
Others will follow soon. Will definitely have to spend some more time on this...
Describe the improvement
Right now, I am using GoReleaser to build the CLI and publish it. This automatically adds it 1) to the releases page and 2) to JohannesKaufmann/homebrew-tap.
It would be great to also release for your favourite distro. For that nfpm could be used.
Unfortunately I am not a Linux user, so any help is appreciated!