Building my first RPM

Tim Mooney Tim.Mooney at ndsu.edu
Fri Feb 20 16:39:01 UTC 2015


In regard to: Re: Building my first RPM, Blaxton said (at 12:53pm on Feb...:

> How may find which script has this line #!/usr/local/bin/python ?

It's one of the files that are getting copied into your build root, so
instead of doing a full package build (rpmbuild -ba yourspec.spec)
run the process through the install step (rpmbuild -bi yourspec.spec)
and then use UNIX tools to find which scripts reference the incorrect
path, e.g.

 	find /your/RPM/BUILD/ROOT -type f \
 		-exec egrep '#!/usr/local/bin/python' {} /dev/null \;

When you build a package, RPM searches the files in your build root, using
various methods depending on platform, to find what dependencies those
files have.  To control what gets recorded in the binary RPM, you need
to control what's discovered for dependencies during the build process.

One trick that's often used: files that are really meant as documentation
or *examples* shouldn't have the execute bit set on them; if they're
not executable, the script that checks for the sh-bang (#!) header
in a script will ignore them.  So having your %install do something like

 	find $RPM_BUILD_ROOT/usr/local/share/python \
 		-type f -name '*.py' -exec chmod a-x {} \;

(or any other directory that has docs/examples that are being found and
included by the dependency generator) is common when packaging
interpreters.  Packaging interpreters (python, perl, ruby, etc.) often
has this type of issue.

>Where or which script checks dependencies when we install RPM and how to
> retrieve it ?

That depends on platform and version of RPM, as well as what RPM macros
are set in your build environment, but way back in previous century, I
had a hand in the find-provides and find-requires that were used on AIX. 
Wherever RPM has its "lib" directory, there's probably a file named
"find-requires" or "find-requires.sh", and that's likely what's getting
called to search the buildroot for dependencies.

Also, note that find-requires and find-provides are run when you *build*
the RPM.  Their output is then encoded in the binary package, and it's
RPM itself that checks as part of the install process to see that
everything that the package claims it needs is present.  And before you
ask: it doesn't check the filesystem -- it checks its database
(primarily), and it probably also checks files in its personal config
directory (/etc/rpm or its equivalent for your build).

Tim

>     From: Florian Festi <ffesti at redhat.com>
> To: rpm-list at lists.rpm.org
> Sent: Friday, February 20, 2015 2:04 AM
> Subject: Re: Building my first RPM
>
> On 02/20/2015 05:49 AM, Blaxton wrote:
>> I am trying to build Python RPM and trying to keep .spec file as simple
>> as I can.
>>
>> build, compile, install and package is completed and now I have the
>> binary RPM
>> to install, but getting below error at the time of installation:
>>
>> error: failed dependencies:
>>         /usr/local/bin/python is needed by Python-3.4.2-1
>>
>> any idea what I am doing wrong ?
>
> There is probably a script somewhere having a #!/usr/local/bin/python
> line. Either include a symlink link /usr/local/bin/python -> python3
> (which may break other packages you might build later and expect Python
> 2) or change the #! line.
>
> As you are kinda building your own distribution you kinda can decide on
> your own what /usr/local/bin/python should mean. But a lot of other
> distros are still on Python2 as default and the plain "python" binary is
> Python 2.
>
>
>
>> Do I need to have python 2 ? to have python 3 installed ?
>> or I am missing some thing in .spec file ?
>>
>> For now I am packaging what ever it is in buildroot directory.
>>
>> make DESTDIR=${RPM_BUILD_ROOT} install
>>
>>
>> %files
>> %defattr(-,root,system,-)
>> /usr/local/bin/*
>> /usr/local/lib/*
>> /usr/local/share/*
>> /usr/local/include/*
>>
>> thanks
>>
>>
>>
>>
>> _______________________________________________
>> Rpm-list mailing list
>> Rpm-list at lists.rpm.org
>> http://lists.rpm.org/mailman/listinfo/rpm-list
>>
>
>
>

-- 
Tim Mooney                                             Tim.Mooney at ndsu.edu
Enterprise Computing & Infrastructure                  701-231-1076 (Voice)
Room 242-J6, Quentin Burdick Building                  701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164


More information about the Rpm-list mailing list