Let's say I have this section in my spec file:
%global yyyymmdd %{lua: print(os.date("%Y%m%d"))} Source10: https://github.com/kwk/llvm-project/releases/download/source-snapshot/llvm-release-%{yyyymmdd}.txt
Then spectool -R -f -a -g test.spec will correctly download the source into ~/rpmbuild/SOURCES
spectool -R -f -a -g test.spec
~/rpmbuild/SOURCES
Downloading: https://github.com/kwk/llvm-project/releases/download/source-snapshot/llvm-release-20210416.txt 100% of 7.0 B |######################################################################################################| Elapsed Time: 0:00:00 Time: 0:00:00 Downloaded: llvm-release-20210416.txt
But when I put the Source0 into a conditional, I don't see a chance to download it. Should this be made possible, maybe?
Source0
%bcond_with snapshot_build %if %{with snapshot_build} %global yyyymmdd %{lua: print(os.date("%Y%m%d"))} Source10: https://github.com/kwk/llvm-project/releases/download/source-snapshot/llvm-release-%{yyyymmdd}.txt %endif
Should it be possible to have spectool understand --with=snapshot_build?
spectool
--with=snapshot_build
To make things worse, a constructed Source10 tag fails with the error below.
Source10
%global yyyymmdd %{lua: print(os.date("%Y%m%d"))} Source10: https://github.com/kwk/llvm-project/releases/download/source-snapshot/llvm-release-%{yyyymmdd}.txt %global llvm_version %{lua: print(io.lines(rpm.expand("%{SOURCE10}"))());} %{echo: llvm_version=%{llvm_version}} Name: mytest Version: %{llvm_version} Release: 1 Summary: My summary License: GPL %description My Description
Here's the error:
$ spectool -g test.spec error: lua script failed: [string "<lua>"]:1: cannot open file '/home/kkleine/rpmbuild/SOURCES/llvm-release-20210416.txt' (No such file or directory) error: test.spec: line 3: Macro %llvm_version failed to expand Traceback (most recent call last): File "/usr/bin/spectool", line 521, in <module> exit(main()) File "/usr/bin/spectool", line 446, in main spec = Spec(path) File "/usr/bin/spectool", line 283, in __init__ self.spec = rpm.spec(self.path) ValueError: can't parse specfile
When I change the llvm_version global to %global llvm_version 13.0.0, it works perfectly fine. I don't know why that is. Of course this version is supposed to be stored and fetched from the Source10.
llvm_version
%global llvm_version 13.0.0
I found out that you can run spectool --define "_with_snapshot_build 1" (similar to rpmbuild --with=snapshot_build) in order to have a source defined in a conditional build. Nevertheless I'm closing this in favor of #7
spectool --define "_with_snapshot_build 1"
rpmbuild --with=snapshot_build
Metadata Update from @kkleine: - Issue close_status updated to: Fixed - Issue status updated to: Closed (was: Open)
Metadata Update from @kkleine: - Issue status updated to: Open (was: Closed)
Metadata Update from @kkleine: - Issue close_status updated to: Invalid - Issue status updated to: Closed (was: Open)
Login to comment on this ticket.