Bug 2303804

Summary: Spectool fails to download source and stays silent about it
Product: [Fedora] Fedora Reporter: Renich Bon Ciric <renich>
Component: rpmdevtoolsAssignee: Neal Gompa <ngompa13>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 40CC: bugs.michael, decathorpe, kevin, ngompa13, twoerner
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: 2024-08-09 09:42:19 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 Renich Bon Ciric 2024-08-08 22:40:31 UTC
Description of problem:
I am trying to apply spectool to a specfile generated successfully by go2rpm. Most of the time it works, when the forge to be used is GitHub. But, when using any other, it fails. 

Version-Release number of selected component (if applicable):

$ rpm -q rpmdevtools
rpmdevtools-9.6-7.fc40.noarch

$ spectool --version
spectool 1.1.0

How reproducible:
cat << 'EOF' > golang-x-net.spec
# Generated by go2rpm 1.14.0
%bcond check 1
%bcond bootstrap 0

%if %{with bootstrap}
%global debug_package %{nil}
%endif

%if %{with bootstrap}
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^golang\\(.*\\)$
%endif

# https://go.googlesource.com/net
%global goipath         golang.org/x/net
%global forgeurl        https://go.googlesource.com/net
Version:                v0.19.0
%global tag             v0.19.0

# REMOVE BEFORE SUBMITTING THIS FOR REVIEW
# ---
# New Fedora packages should use %%gometa -f, which makes the package
# ExclusiveArch to %%golang_arches_future and thus excludes the package from
# %%ix86. If the new package is needed as a dependency for another package,
# please consider removing that package from %%ix86 in the same way, instead of
# building more go packages for i686. If your package is not a leaf package,
# you'll need to coordinate the removal of the package's dependents first.
# ---
# REMOVE BEFORE SUBMITTING THIS FOR REVIEW
%gometa -L -f

%global common_description %{expand:
# FIXME}

%global golicenses      LICENSE PATENTS
%global godocs          CONTRIBUTING.md README.md http2/h2i/README.md

Name:           golang-x-net
Release:        %autorelease
Summary:        None

License:        BSD-3-Clause
URL:            %{gourl}
Source:         %{gosource}

%description %{common_description}

%gopkg

%prep
%goprep -A
%autopatch -p1

%if %{without bootstrap}
%generate_buildrequires
%go_generate_buildrequires
%endif

%if %{without bootstrap}
%build
for cmd in html/atom http2/h2i http2/hpack ipv4 ipv6 publicsuffix webdav; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done
%endif

%install
%gopkginstall
%if %{without bootstrap}
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
%endif

%if %{without bootstrap}
%if %{with check}
%check
%gocheck
%endif
%endif

%if %{without bootstrap}
%files
%license LICENSE PATENTS
%doc CONTRIBUTING.md README.md http2/h2i/README.md
# REMOVE BEFORE SUBMITTING THIS FOR REVIEW
# ---
# New Fedora packages should not use globs to avoid installing conflicting
# binaries.
# Write a _bindir line per each of the binaries the package will install.
# ---
# REMOVE BEFORE SUBMITTING THIS FOR REVIEW
%{_bindir}/*
%endif

%gopkgfiles

%changelog
%autochangelog

EOF

spectool -Rag golang-x-net.spec

Another way of generating the spec I generated would be:

go2rpm -t v0.19.0 -f go.googlesource.com/net golang.org/x/net

Steps to Reproduce:
1. Generate the SPEC file using go2rpm
2. Try spectool on it.

Actual results:
$ go2rpm -t v0.19.0 -f go.googlesource.com/net golang.org/x/net
$ spectool -Rag golang-x-net.spec

$ ll ~/rpmbuild/SOURCES/
total 0

$ head -n 17 golang-x-net.spec 
# Generated by go2rpm 1.14.0
%bcond check 1
%bcond bootstrap 0

%if %{with bootstrap}
%global debug_package %{nil}
%endif

%if %{with bootstrap}
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^golang\\(.*\\)$
%endif

# https://go.googlesource.com/net
%global goipath         golang.org/x/net
%global forgeurl        https://go.googlesource.com/net
Version:                v0.19.0
%global tag             v0.19.0

Expected results:
It should download the source code tarball.

Comment 1 Fabio Valentini 2024-08-09 09:42:19 UTC
This appears to be a problem in the Go macros.
%gosource is expaned to this:

> Source0: #/.%{archiveext}

Looks like some internal macros are not getting initialized with the proper values.
spectool heuristics determine that this is not a URL, so no download is attempted.

Please report this issue against the go-rpm-macros.

Comment 2 Renich Bon Ciric 2024-08-09 19:03:20 UTC
Right on. Thank you for the assessment. :)