Fedpkg can't fetch source from spec file?

I am attempting to package a fairly basic program (Elvish), but i am running into trouble following the packaging guide, which is very scant on details.

My spec file is at the bottom of this post. I put the file in ~/Projects/packaging/fedora/elvish/elvish.spec, and I ran fedpkg local. I got the following output and was unable to proceed:

sources file doesn't exist. Source files download skipped.
Failed to get ns from Git url or pushurl

error: Bad source: /home/mg/Projects/dev/packaging/fedora/elvish/v0.17.0.tar.gz: No such file or directory
Could not execute local: rpmbuild --define '_sourcedir /home/mg/Projects/dev/packaging/fedora/elvish' --define '_specdir /home/mg/Projects/dev/packaging/fedora/elvish' --define '_builddir /home/mg/Projects/dev/packaging/fedora/elvish' --define '_srcrpmdir /home/mg/Projects/dev/packaging/fedora/elvish' --define '_rpmdir /home/mg/Projects/dev/packaging/fedora/elvish' --define '_rpmfilename %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' --define 'dist %{?distprefix}.fc35' --define 'fedora 35' --eval '%undefine rhel' --define 'fc35 1' -ba /home/mg/Projects/dev/packaging/fedora/elvish/elvish.spec 2>&1 | tee .build-0.17.0-1.fc35.log

The contents of the .build-0.17.0-1.fc35.log file:

error: Bad source: /home/mg/Projects/dev/packaging/fedora/elvish/v0.17.0.tar.gz: No such file or directory

Obviously i can fetch the source tarball manually. But the error makes no sense to me, and I couldn’t find any information about this problem anywhere in the Fedora documentation or any other site.

Clearly I am doing something wrong that isn’t explained in the docs, but what is it?

This is the spec file:

Name:    elvish
Version: 0.17.0
Release: 1%{?dist}
Summary: Elvish - A friendly and expressive Unix shell

Group:   System Environment/Shells
License: BSD 2-Clause
URL:     https://github.com/elves/elvish
Source0: https://github.com/elves/elvish/archive/refs/tags/v%{version}.tar.gz
BuildRequires: golang-bin

%description
Elvish is an expressive programming language and a versatile interactive shell, combined into one seamless package.

ELVISH = Expressive Language + Versatile Interactive SHell.

%prep
%setup -n %{name}-%{version}

%build
make get
go build -o elvish ./cmd/elvish

%install
install -Dm 0755 elvish %{buildroot}%{_bindir}/elvish

%files
%defattr(-,root,root,-)
%doc README.md
%license LICENSE
%{_bindir}/elvish
2 Likes

It complains about not finding the source tarball. I use spectool to get source files when doing local builds:

spectool -gR ~/Projects/packaging/fedora/elvish/elvish.spec
  • -g option gets the sources/patches that are listed with a URL.
  • -R option downloads them into rpm’s %{_sourcedir}
1 Like

I suppose that fedpkg is intended to interact with Fedora dist-git https://src.fedoraproject.org
So if you are working outside of such git repository, yes, the source file should be manually downloaded and placed in the project directory.
In addition, once the source tar.gz is in place, I think that the correct command is fedpkg --release f35 local

4 Likes

Thanks, that worked! I was able to use fedpkg --release f35 mockbuild afterward.

I omitted the -R option because it looks like fedpkg sets %{_srcdir} to the current directory anyway. I should also probably set things up with ~/.rpmmacros, but I am happy with this for now.

Also thank you @alciregi for clarifying the context and reason for this. Is Source0 merely “informative” then? It does seem like fetching source archives is out of scope for rpmbuild and fedpkg.

2 Likes

It is to document the location of the source code that is being used to build the package. Maintainers must upload this manually to the Fedora “look aside cache” where sources for all Fedora packages are stored (using fedpkg new-sources). This implies that we package maintainers review the sources (also for each new version of the package) etc. before we upload them and use them for package builds.

1 Like