LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   A Basic Question on rpmbuild (https://www.linuxquestions.org/questions/red-hat-31/a-basic-question-on-rpmbuild-893919/)

mjovanov 07-26-2011 03:54 PM

A Basic Question on rpmbuild
 
Hi, I am trying to create a binary rpm using the rpmbuild utility. Specifically, the software I am packaging is a vendor product provided in the form of a tar archive and a korn shell installer. I've managed to create a spec file that will invoke the installer script and copy all the files into virtual build dir (${RPM_BUILD_ROOT}). Now in the %files stanza, it appears I need to list all the files/dirs. My question is: is there an easy way to do this? I looked at different macros and examples, but most are assuming building from source and using standard Red Hat install dir structure (/usr/lib, /usr/bin etc.)/
Any help or suggestions would be greatly appreciated!

kbp 07-26-2011 05:43 PM

I'm usually lazy so I skip the %files section and attempt to build the package, rpmbuild will then give you a list of installed but unpackaged files. Look through the list for common directories, if the directory is app specific then include it like so:

/opt/<myapp>

If there are config files under /etc then add:

/etc/*

If there are README's and so on in the root of the tarball then use:

%doc README ...

If there are man pages then use:

%{mandir}/man1/*

..and so on until there are no files left unpackaged.

Also, please install rpmlint and run it against your package or spec file, it's output can be very helpful.

cheers

unSpawn 07-26-2011 06:08 PM

Quote:

Originally Posted by mjovanov (Post 4425957)
Now in the %files stanza, it appears I need to list all the files/dirs. My question is: is there an easy way to do this?

See http://docs.fedoraproject.org/drafts...n/ch09s05.html ? As in:
Code:

%install
# doStuff
find $RPM_BUILD_ROOT -not -type d -printf "%%%attr(%%m,root,root) %%p\n" | sed -e "s|$RPM_BUILD_ROOT||g" > %{_tmppath}/%{name}_contents.txt
# (..)
%files -f %{_tmppath}/%{name}_contents.txt


mjovanov 07-27-2011 09:03 AM

What a great tip, thanks to both!

mjovanov 07-29-2011 09:41 AM

As a quick follow-up: with the help of unSpawn and kbp, I was able to build a binary rpm. Having read the docs, I understand that rpmbuild performs automatic dependency checking (I was able to turn it off using the 'AutoReqProv: no' flag). But with the auto dependency checking, when I try to test the rpm, it fails with all kinds of dependencies, even on a machine on which it is already installed! How can that be? Is it because the dependencies were presumably installed without using RPM?

[mjovanov@eset-tan SPECS]$ rpm --test -Uvh ../RPMS/x86_64/apache_custom.x86_64.rpm
error: Failed dependencies:
/usr/local/bin/python is needed by apache_custom.x86_64
libclntsh.so.10.1()(64bit) is needed by apache_custom.x86_64
libclntsh.so.9.0()(64bit) is needed by apache_custom.x86_64
libcomn_r64.so()(64bit) is needed by apache_custom.x86_64
libcs_r64.so()(64bit) is needed by apache_custom.x86_64
libct_r64.so()(64bit) is needed by apache_custom.x86_64
libhpodbc_l64.so.2()(64bit) is needed by apache_custom.x86_64
libifcli.so()(64bit) is needed by apache_custom.x86_64
libifgls.so()(64bit) is needed by apache_custom.x86_64
libifglx.so()(64bit) is needed by apache_custom.x86_64
libimqb23gl.so()(64bit) is needed by apache_custom.x86_64
libimqc23gl.so()(64bit) is needed by apache_custom.x86_64
libimqs23gl.so()(64bit) is needed by apache_custom.x86_64
libintl_r64.so()(64bit) is needed by apache_custom.x86_64
libmqcxa64.so()(64bit) is needed by apache_custom.x86_64
libmqmxa64.so()(64bit) is needed by apache_custom.x86_64
libodbc.so()(64bit) is needed by apache_custom.x86_64
libodbc.so(VERS_3.52)(64bit) is needed by apache_custom.x86_64
libodbcinst.so()(64bit) is needed by apache_custom.x86_64
libodbcinst.so(VERS_3.52)(64bit) is needed by apache_custom.x86_64
libpxicu.so()(64bit) is needed by apache_custom.x86_64
libreadline.so.4()(64bit) is needed by apache_custom.x86_64
libsybcomn_r64.so()(64bit) is needed by apache_custom.x86_64
libsybcs_r64.so()(64bit) is needed by apache_custom.x86_64
libsybct_r64.so()(64bit) is needed by apache_custom.x86_64
libsybintl_r64.so()(64bit) is needed by apache_custom.x86_64
libsybtcl_r64.so()(64bit) is needed by apache_custom.x86_64
libsybunic64.so()(64bit) is needed by apache_custom.x86_64
libtelapi.so()(64bit) is needed by apache_custom.x86_64
libwtc9.so()(64bit) is needed by apache_custom.x86_64
[p002197@eset-tan SPECS]$

kbp 07-30-2011 12:48 AM

If you disable the auto dependency generation you'll need to add your own 'Requires: ...'. I rarely turn it off


All times are GMT -5. The time now is 04:21 PM.