RPM Package
- https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang/
I tried the following
podman run --rm -it fedora:41
cd
dnf install -y rpmdevtools rpm-build go2rpm
rpmdev-setuptree
go2rpm --name tiup -p vendor --download github.com/pingcap/tiup
mv tiup.spec rpmbuild/SPECS/
mv tiup-1.16.1* rpmbuild/SOURCES/
cp go-vendor-tools.toml rpmbuild/SOURCES/
rpmbuild -bs rpmbuild/SPECS/tiup.spec
rpmbuild -bb rpmbuild/SPECS/tiup.spec
Using -p vendor is needed as many dependencies are not packaged. See also https://lwn.net/Articles/1005655/
However I encountered the following issues:
- github.com/pingcap/check has a
godropbox_licensebut noLICENSE. - github.com/shirou/gopsutil LICENSE detection failed.
- gopkg.in/yaml.v3 LICENSE detection failed.
- honnef.co/go/tools LICENSE detection failed.
This can be fixed with a go-vendor-tools.toml file like this:
[archive]
[licensing]
detector = "askalono"
[[licensing.licenses]]
path = "vendor/github.com/pingcap/check/godropbox_license"
sha256sum = "185effe24905321d45fe84c7087b05fbcee850caf42a72e037d318cdcb700f8d"
expression = "BSD-3-Clause"
[[licensing.licenses]]
path = "vendor/github.com/shirou/gopsutil/LICENSE"
sha256sum = "8db64481897d4b1604821103bf9621244fa257c0a80eecb643630ae22e890289"
expression = "BSD-3-Clause"
[[licensing.licenses]]
path = "vendor/gopkg.in/yaml.v3/LICENSE"
sha256sum = "d18f6323b71b0b768bb5e9616e36da390fbd39369a81807cca352de4e4e6aa0b"
expression = "MIT"
[[licensing.licenses]]
path = "vendor/honnef.co/go/tools/LICENSE-THIRD-PARTY"
sha256sum = "3e7ed5dc00f1b3518b99284123bfc3e3c65b82c62988c0dcda5c86c13d913f7c"
expression = "MIT"
This file is created mostly by answering questions from go2rpm except for pingcap/check. This file is read by go2rpm.
The next issue I faced is build failures, which can be fixed by removing one for cmd in loop in the spec file.
Then the next issue is that github.com/xo/usql and github.com/gizak/termui/v3 aren't vendored as they aren't in the go.mod in the root, but in components/client/go.mod. And I haven't found a way to fix that yet.
Now that #2517 is merged we can try this again. Probably best to wait until after the next release.
@dveeden This issue is not assigned to anyone. Is somebody at PingCAP planning to work on this? If so, you are likely going to run into the same issues what are currently making the Debian packaging challening and outlined in https://github.com/pingcap/tiup/issues/2508#issuecomment-2924913261
Upcoming change in Fedora that might affect this: https://fedoraproject.org/wiki/Changes/GolangPackagesVendoredByDefault
The current plan is to concentrate on DEB/APT packages first and fix issues with dependencies on the way. That should also make it easier to build an RPM package eventually.