Bug 2049514

Summary: go-rpm-macros: %goworkdir is set incorrectly if use %gopkgfiles in the middle of the spec
Product: [Fedora] Fedora Reporter: Mikhail Novosyolov <m.novosyolov>
Component: go-rpm-macrosAssignee: Nicolas Mailhot <nicolas.mailhot>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: go-sig, jcajka, maxwell, nicolas.mailhot, quantum.analyst, tommi.t.rantala, zebob.m
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-02-02 20:29:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mikhail Novosyolov 2022-02-02 11:24:24 UTC
I have made the following spec:

#-------------------------------
%global goipath github.com/OpenPrinting/goipp
%global golicenses LICENSE
%global godocs README.md index.md

Summary:	IPP core protocol in pure Go (RFC 8010)
Name:		golang-github-openprinting-goipp
Group:		Development/Other
License:	BSD
Version:	1.0.0
Release:	1
Url:		https://github.com/OpenPrinting/goipp
Source0:	https://github.com/OpenPrinting/goipp/archive/refs/tags/v%{version}.tar.gz?/goipp-%{version}.tar.gz
BuildRequires:	go-srpm-macros
%gometa

%description
Package goipp implements the IPP core protocol in pure Go (RFC 8010).

%gopkg
%gopkgfiles

%prep
%goprep

%install
%gopkginstall

%check
%gocheck
#----------------------------------

I build it using go-rpm-macros 3.0.15 and get an error:
Could not open %files file /tmp/abf/rpmbuild/BUILD/goipp-1.0.0/tmp/abf/rpmbuild/BUILD/goipp-1.0.0/golang-github-openprinting-goipp-devel.file-list: no such file or directory

This files does exist but %_builddir is duplicated in the path to it.

No I put %gopkgfiles into the end of the spec above instead of its current place. And this error goes away!

I can't understand why this happens...

Comment 1 Maxwell G 2022-02-02 20:29:23 UTC
Your specfile is in the wrong order. `%gopkgfiles` should be at the end of the specfile, as it relies on values that are defined in `%gopkginstall`. You should use go2rpm[2] or consult the examples in the Golang Packaging Guidelines[1] to generate a properly formatted specfile. Besides the misplaced `%gopkgfiles`, there are a couple other problems with your specfile.

[1]: https://docs.fedoraproject.org/en-US/packaging-guidelines/Golang/
[2]: https://pagure.io/GoSIG/go2rpm

Thanks,
Maxwell