I have a spec with two source files where I do not create the second, it's not mine:
Source0: %{name}-%{version}.tar.gz Source1: foo-bar.tar.xz
My prep sections looks like:
%setup -q %setup -q -T -D -a 1
The tar.xz for Source1 has an unversioned name however it unpacks to a versioned directory so I am trying to do something like:
%define foo-bar_dir %(ls -d %{_builddir}/%{name}-%{version}/foo-bar-*-baz |grep -o '[^/]*$')
so I can leverage %{foo-bar_dir} in the %files section. How does one properly accomplish this so that the define is invoked after the unpack so it actually works? When I build now it's done immediately and produces an empty variable?
Thanks, jlc
On Sun, 10 Jan 2016 03:16:24 +0000, Joseph L. Casale wrote:
I have a spec with two source files where I do not create the second, it's not mine:
Source0: %{name}-%{version}.tar.gz Source1: foo-bar.tar.xz
My prep sections looks like:
%setup -q %setup -q -T -D -a 1
The tar.xz for Source1 has an unversioned name however it unpacks to a versioned directory so I am trying to do something like:
%define foo-bar_dir %(ls -d %{_builddir}/%{name}-%{version}/foo-bar-*-baz |grep -o '[^/]*$')
so I can leverage %{foo-bar_dir} in the %files section.
That approach sounds too complicated. %setup is a macro in the %prep section, where you can run more commands to _set up_ your builddir. The most obvious choice IMO would be to _rename_ the versioned dir to something unique. You could also avoid the second invocation of %setup and extract Source1 yourself using "tar". The parameters of the second %setup call don't define builddir anymore, but only extract into the builddir from the first invocation.
That approach sounds too complicated. %setup is a macro in the %prep section, where you can run more commands to _set up_ your builddir. The most obvious choice IMO would be to _rename_ the versioned dir to something unique. You could also avoid the second invocation of %setup and extract Source1 yourself using "tar". The parameters of the second %setup call don't define builddir anymore, but only extract into the builddir from the first invocation.
Hi Michael, Yeah you are right, having the original folder name is not relevant. I removed the macro and used a wildcard instead.
For the academic sake only, does a facility exist to defer evaluation for this use case?
Thanks, jlc
On Sun, 10 Jan 2016 21:57:21 +0000, Joseph L. Casale wrote:
For the academic sake only, does a facility exist to defer evaluation for this use case?
It would get kinda ugly, but you could re-expand the macro body:
%global foo-bar_dir %{expand:%(ls -d %{_builddir}/%{name}-%{version}/foo-bar-*-baz |grep -o '[^/]*$')}