2

I have been trying to create an rpm using a spec file. I want to use github code with that. I am providing Source0: as http://github.com/some_project.tat.gz, but it's downloading that, it's looking for tat.gz in /root/rpmbuild/SOURCES.

I want my spec file to download the source code from git and not get it from SOURCE directory. Any idea how can I do that? Do I need to add some other option to the spec file?

TIA.

Pensu
  • 3,263
  • 10
  • 46
  • 71
  • Possible duplicate of [How do I get rpmbuild to download all of the sources for a particular .spec?](https://stackoverflow.com/questions/33177450/how-do-i-get-rpmbuild-to-download-all-of-the-sources-for-a-particular-spec) – Piotr Dobrogost Nov 23 '17 at 12:27

2 Answers2

3

You can do the checkout in %prep without using %setup. Here are the important details to do a checkout of libbson before building (the main issue is that you need to add an explicit "cd %{NVdir}" to script lets and to %doc when not using %setup).

It's not too hard to do either a git clone or a git pull, depending on whether the %{NVdir} directory exists.

%define NVdir   %{name}-%{version}
...
URL:    https://github.com/mongodb/libbson
...
%prep
rm -rf %{NVdir}
git clone %{url}.git %{Nadir}
cd %{NVdir}
...
%build
cd %{NVdir}
make %{?_smp_mflags}
...
%files
%doc %{NVdir}/COPYING %{NVdir}/NEWS %{NVdir}/README
%{_libdir}/*.so.*
Jeff Johnson
  • 2,310
  • 13
  • 23
1

It's not built-in. You're telling rpm where to claim the source can be found, but rpmbuild doesn't pull it for you. You'll need a wrapper script to do that, or look into something like spectool which should do it for you (I haven't used it myself, sorry).

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
  • 2
    I've used spectool and it works somewhat exactly like that. I invoke it like so: `spectool -R -g -A -C . MyFile.spec`. – Konrad Kleine Feb 03 '21 at 13:56