I'm using go2rpm to generate some RPMs. I noticed that when it detects a package that has multiple subcommands, it inserts the following snippet into the %build step:
for cmd in cmd/* ; do %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd done
This glob doesn't get expanded and the RPM ends up failing to build because it can't find a Go package "cmd/*". Is there some escaping that's needed here to get that glob to expand properly?
+ go build -buildmode pie -compiler gc '-tags=rpm_crashtraceback ' -ldflags ' -X git.sr.ht/~spc/mqttcli/version=0.1.0 -B 0x2d42bc91df6bf113dbdb6ac7671c6fa1f1ede4d0 -extldflags '''-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '''' -a -v -x -o '/builddir/build/BUILD/mqttcli-0.1.0/_build/bin/*' 'git.sr.ht/~spc/mqttcli/cmd/*' WORK=/tmp/go-build841317380 cannot find package "git.sr.ht/~spc/mqttcli/cmd/*" in any of: /usr/lib/golang/src/git.sr.ht/~spc/mqttcli/cmd/* (from $GOROOT) /builddir/build/BUILD/mqttcli-0.1.0/_build/src/git.sr.ht/~spc/mqttcli/cmd/* (from $GOPATH) /usr/share/gocode/src/git.sr.ht/~spc/mqttcli/cmd/* error: Bad exit status from /var/tmp/rpm-tmp.Kfe0UU (%build) Bad exit status from /var/tmp/rpm-tmp.Kfe0UU (%build)
On Thu, 24 Jun 2021 at 23:40, Link Dupont link@sub-pop.net wrote:
I'm using go2rpm to generate some RPMs. I noticed that when it detects a package that has multiple subcommands, it inserts the following snippet into the %build step:
for cmd in cmd/* ; do %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd done
This glob doesn't get expanded and the RPM ends up failing to build because it can't find a Go package "cmd/*". Is there some escaping that's needed here to get that glob to expand properly?
Well that's just regular shell globbing. Did you cd before hand, or are those directories missing from the tarball? You should post the entire spec to see fully what's going on.
- go build -buildmode pie -compiler gc '-tags=rpm_crashtraceback ' -ldflags ' -X git.sr.ht/~spc/mqttcli/version=0.1.0 -B 0x2d42bc91df6bf113dbdb6ac7671c6fa1f1ede4d0 -extldflags '''-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld '''' -a -v -x -o '/builddir/build/BUILD/mqttcli-0.1.0/_build/bin/*' 'git.sr.ht/~spc/mqttcli/cmd/*'
WORK=/tmp/go-build841317380 cannot find package "git.sr.ht/~spc/mqttcli/cmd/*" in any of: /usr/lib/golang/src/git.sr.ht/~spc/mqttcli/cmd/* (from $GOROOT) /builddir/build/BUILD/mqttcli-0.1.0/_build/src/git.sr.ht/~spc/mqttcli/cmd/* (from $GOPATH) /usr/share/gocode/src/git.sr.ht/~spc/mqttcli/cmd/* error: Bad exit status from /var/tmp/rpm-tmp.Kfe0UU (%build) Bad exit status from /var/tmp/rpm-tmp.Kfe0UU (%build)
On Fri, 2021-06-25 at 00:01 -0400, Elliott Sales de Andrade wrote:
You should post the entire spec to see fully what's going on.
Fair point. https://linkdupont.fedorapeople.org/mqttcli.spec
And here's a COPR build that failed
https://copr.fedorainfracloud.org/coprs/linkdupont/mqttcli/build/2304072/
I think I found the source of the problem. It's not cd'ing into the right directory, so the cmd/* glob isn't expanding. Instead, it's resolving to a literal cmd/*.
+ cd /builddir/build/BUILD + cd mqttcli-0.1.0 + for cmd in cmd/*
If I'm reading the commands executed during %prep correctly, the correct path should be /builddir/build/BUILD/mqttcli-0.1.0/mqttcli-0.1.0. I'll keep studying these go macros to see if it's something I need to tweak to support the git.sr.ht forge.
I think this might be because my source tarball is including a directory at its root and the macro isn't expecting that.
On 6/25/21 8:32 PM, Link Dupont wrote: to support the git.sr.ht forge. See https://src.fedoraproject.org/rpms/golang-sr-sircmpwn-getopt/blob/rawhide/f/... for example on how to support it.
It should go like this:
# https://git.sr.ht/~spc/mqttcli %global goipath git.sr.ht/~spc/mqttcli %global forgeurl https://git.sr.ht/~spc/mqttcli Version: 0.1.0 %global repo mqttcli %global archivename %{repo}-%{version} %global archiveext tar.gz %global archiveurl %{forgeurl}/archive/%{version}.%{archiveext} %global topdir %{repo}-%{version} %global extractdir %{repo}-%{version} %global scm git
- Also there is a bug where go macro do not support ~ in import path package name. Current workaround is to specify name manually:
%global goname golang-sr-spc-mqttcli %global godevelname golang-sr-spc-mqttcli-devel
- Although in your case you could probably get rid of the devel package altogether by removing:
%gopkg %gopkginstall %gopkgfiles
since it seems it won't be used as a library.
- Then there's a failure in install:
+ install -m 0755 -vp /builddir/build/BUILD/mqttcli-0.1.0/_build/bin/pub /builddir/build/BUILDROOT/mqttcli-0.1.0-1.fc34.x86_64/usr/bin/mqttclicmd/pub '/builddir/build/BUILD/mqttcli-0.1.0/_build/bin/pub' -> '/builddir/build/BUILDROOT/mqttcli-0.1.0-1.fc34.x86_64/usr/bin/mqttclicmd/pub' install: cannot create regular file '/builddir/build/BUILDROOT/mqttcli-0.1.0-1.fc34.x86_64/usr/bin/mqttclicmd/pub': No such file or directory
This should be fixed by adding the basename again here:
for cmd in cmd/* ; do install -m 0755 -vp %{gobuilddir}/bin/$(basename $cmd) %{buildroot}%{_bindir}/%{name}$(basename $cmd) done
After this, it build fine.
Best regards,
Robert-André
Thank you! That was the working example I needed.
On Sat, Jun 26 2021 at 01:02:46 AM +0200, Robert-André Mauchin zebob.m@gmail.com wrote:
On 6/25/21 8:32 PM, Link Dupont wrote: to support the git.sr.ht forge. See https://src.fedoraproject.org/rpms/golang-sr-sircmpwn-getopt/blob/rawhide/f/... for example on how to support it.
It should go like this:
# https://git.sr.ht/~spc/mqttcli %global goipath git.sr.ht/~spc/mqttcli %global forgeurl https://git.sr.ht/~spc/mqttcli Version: 0.1.0 %global repo mqttcli %global archivename %{repo}-%{version} %global archiveext tar.gz %global archiveurl %{forgeurl}/archive/%{version}.%{archiveext} %global topdir %{repo}-%{version} %global extractdir %{repo}-%{version} %global scm git
- Also there is a bug where go macro do not support ~ in import path
package name. Current workaround is to specify name manually:
%global goname golang-sr-spc-mqttcli %global godevelname golang-sr-spc-mqttcli-devel
- Although in your case you could probably get rid of the devel
package altogether by removing:
%gopkg %gopkginstall %gopkgfiles
since it seems it won't be used as a library.
- Then there's a failure in install:
- install -m 0755 -vp
/builddir/build/BUILD/mqttcli-0.1.0/_build/bin/pub /builddir/build/BUILDROOT/mqttcli-0.1.0-1.fc34.x86_64/usr/bin/mqttclicmd/pub '/builddir/build/BUILD/mqttcli-0.1.0/_build/bin/pub' -> '/builddir/build/BUILDROOT/mqttcli-0.1.0-1.fc34.x86_64/usr/bin/mqttclicmd/pub' install: cannot create regular file '/builddir/build/BUILDROOT/mqttcli-0.1.0-1.fc34.x86_64/usr/bin/mqttclicmd/pub': No such file or directory
This should be fixed by adding the basename again here:
for cmd in cmd/* ; do install -m 0755 -vp %{gobuilddir}/bin/$(basename $cmd) %{buildroot}%{_bindir}/%{name}$(basename $cmd) done
After this, it build fine.
Best regards,
Robert-André _______________________________________________ golang mailing list -- golang@lists.fedoraproject.org To unsubscribe send an email to golang-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/golang@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
golang@lists.fedoraproject.org