Building my first RPM

Blaxton blaxxton at yahoo.com
Tue Feb 24 04:51:06 UTC 2015


It is AIX with RPM version 3.0.5 and that is the reason started to create the .spec file from scratch.tried .spec file that comes with python source, but that spec file is out of date and developers just
removed it from source tree. then tried Fedora spec file, but got lots of error and I think most 
of errors were related to version of rpm but can't be sure, my knowledge of packaging is notat that level yet. once I have a better knowledge of packaging then might try upgrading the RPMit self on AIX and try the Fedora spec file to compile python3.

For now, I am able to create the rpm binary, but need guidance as to how to know which fileand suffixes should be copied from RPM_BUILD_ROOT to system.
easiest way was choosing all files from RPM_BUILD_ROOT/usr/local/bin/* and /lib/* and /include/* and /share/*
but when I check other spec files, there are specific files that are being selected to copy, for example:%files tkinter
%defattr(-,root,root,755)%{pylibdir}/turtledemo/*.py
%{pylibdir}/turtledemo/*.cfg
%dir %{pylibdir}/turtledemo/__pycache__/
%{pylibdir}/turtledemo/__pycache__/*%{bytecode_suffixes}


What is your recommendation to find out the files that need to be copied
in %files section of .spec file ?


One way is checking install or bininstall section of Makefile which is time consuming
the other way running some kind of script before running make install and record all
files that are being copied.

Thanks

 DB
      From: Tim Mooney <Tim.Mooney at ndsu.edu>
 To: Blaxton <blaxxton at yahoo.com> 
Cc: General discussion about the RPM package manager <rpm-list at lists.rpm.org> 
 Sent: Monday, February 23, 2015 1:26 PM
 Subject: Re: Building my first RPM
   
In regard to: Re: Building my first RPM, Blaxton said (at 3:24am on Feb 23,...:

> editted cgi.py and then tried building the RPM, but the cgi.py file is
> being recreated evenby using rpm --short-circuit -bb myspec.spec.

Yeah, that's very much intentional.  If short-circuit allowed you to
proceed to building a binary RPM, it would just make it that much easier
for people to generate non-reproducible builds.

The right way to fix this is to

1) do your make install in the %install section, to your $RPM_BUILD_ROOT,
so all the files are laid out waiting to be scooped up and packaged into
the binary RPM.

2) add code after "make install" to "fix up" any files that have problems.
For example:

     # after make install has dropped everything into the buildroot

     cd $RPM_BUILD_ROOT/path/to/some/dir
     mv cgi.py cgi.py.BAK
     sed -e 's@/usr/local/bin/python@/path/to/your/python@' \
         < cgi.py.BAK > cgi.py
     # may need to fix permissions on cgi.py, does it need +x?
     rm -f cgi.py.BAK

3) do your rpmbuild -bb as normal.

Disabling requires and provides entirely should only be used as a last
resort.

> while I was reading  find-requires file, noticed the find-requires originally is written by you.
> # Original Author: Ralph Goers(rgoer at Candle.Com)
> # Borrowed heavily from Tim Mooney's HP version.

Ralph and I collaborated on that, yeah.  He did most of the work, though.
You must be using a really ancient version of RPM, because the attribution
at the top of the most recent one that I have looks a little different.



Tim

> # This file is distributed under the terms of the GNU General Public License
>      From: Tim Mooney <Tim.Mooney at ndsu.edu>
> To: Blaxton <blaxxton at yahoo.com>; General discussion about the RPM package manager <rpm-list at lists.rpm.org>
> Sent: Friday, February 20, 2015 10:39 AM
> Subject: Re: Building my first RPM
>
> 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

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-list/attachments/20150224/ea6dfb84/attachment-0001.html>


More information about the Rpm-list mailing list