Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I download github source code in my spec file

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.

like image 410
Pensu Avatar asked Dec 09 '25 04:12

Pensu


2 Answers

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).

like image 200
Aaron D. Marasco Avatar answered Dec 11 '25 19:12

Aaron D. Marasco


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.*
like image 25
Jeff Johnson Avatar answered Dec 11 '25 19:12

Jeff Johnson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!