Now, from that spec file I wish to generate a
binary .rpm file somewhere, WITHOUT changing any
of the current SW installed on my RH 7.2 system.
I understand it has to be one of rpm's -b options, but
1) which one ?
2) and where will my NEW binary foo.i486.rpm file be deposited ?
Thanks!
Try this and please let me know if you have suggestions on improvements.
KBK
=========================================================================
RPM: Building Binary Packages From Source RPMs mini-HOWTO
Kurt B. Kaiser k...@shore.net
Version 0.13 24 April 2002
How to build and install RPM packages starting with a SRC RPM package instead
of a binary RPM
1. INTRODUCTION.
While binary RPMs provide a convenient way to upgrade software, it often
happens that the desired version has dependencies or incompatibilities with
the target system libraries, and the binary RPM cannot be installed without
a massive system upgrade. In that case, it may be better to build a binary
RPM on the target system from a recent source RPM.
Installing software from a source RPM has significant advantages over
building from upstream sources using the traditional ./configure, make, make
install approach. First, the RPM database is maintained, allowing query,
upgrade, and uninstall. Second, the sources have usually been patched for
your distribution and architecture.
It is sometimes desirable to make small changes to the software prior to
installation. An example would be to add support to Ghostscript for a
specific printer. Also, there will be cases where the source RPM won't
build correctly due to a typo, or a macro was used which is not recognized
by your version of RPM.
If changes to the source are made via the .spec file and patch files as
suggested below, an audit trail can be established which in the revised
source RPM. However, the audit trail is not as rigorous as CVS, and it is
up to the maintainer to leave a proper record of the changes made in the
.spec file.
The existing RPM documentation is oriented either towards simple
installation of binary RPMs or towards constructing source RPMs from the
original source archives. Learning enough to reliably create binary RPMs
from source RPMs can involve reading a large part of the rather extensive
documentation on RPM.
The purpose of this HOWTO is to provide a concise guide to this essentially
straightforward procedure.
To avoid the risks associated with building RPMs as root, this procedure
requires root permissions only when installing the binary RPM.
2. SYSTEM CONFIGURATION.
A. Create an .rpmmacros file to instruct rpm to build in a directory off
your home directory. (This version of .rpmmacros could also be placed in
/etc/skel/.bashrc)
cd
cat <<EOF > .rpmmacros
%HOME %{expand:%%(cd; pwd)}
%_topdir %{HOME}/rpm
EOF
B. Create the rpm directory structure in your home directory:
mkdir rpm
cd rpm
mkdir BUILD RPMS SOURCES SPECS SRPMS
cd
3. SOURCE RPM ACQUISITION.
Download the .src.rpm to your home directory. The www.rpmfind.net site will
probably have what you need. Be sure that the source RPM is designed for
your system. Don't forget that installation is done with root permissions,
so be careful to get your source from a trustworthy location.
4. ONE STEP BUILD PROCEDURE.
A. You can usually build the binary RPM in one step. The following command
will "install" the sources, create a binary RPM, and clean up the rpm
subdirectories when it's done (Note 1):
rpm --rebuild foo-1.0.0-1.src.rpm &> rebuild.log
Examine rebuild.log to be sure that the build completed successfully.
B. Install the binary .rpm package, updating the rpm database. The binary
RPM you just created is located in the RPMS directory tree:
cd ~/rpm/RPMS/i386 (for 386 architecture)
su
rpm -Uvh foo-1.0.0-1.i386.rpm
exit
That's all there is to it, in most cases! But if the build errors out, or
if you want to make some changes in the sources, then you need to follow the
Detailed Build Procedure.
5. DETAILED BUILD PROCEDURE.
A. Install the source RPM. rpm will place the source tar archives and
patches in ~/rpm/SOURCE. The spec file, foo.spec, will be in located
in ~/rpm/SPECS:
cd
rpm -i foo-1.0.0-1.src.rpm
B. Unpack the source tar archives into the BUILD tree and apply the patches
in SOURCE to the BUILD tree, with a record of the steps taken saved in
bp.log:
cd rpm/SPECS
rpm -bp foo.spec &> bp.log
(At this point see Appendix A for suggestions on how to make small
changes to the sources prior to building the package. However, it is
usually not necessary to make changes to get a successful build.)
C. Build the binary .rpm package (Note 2):
rpm -bb --clean foo.spec &> bb.log
Always inspect the bb.log to assure that the build was error-free!
D. Install the binary .rpm package, updating the rpm database:
cd ~/rpm/RPMS/i386 (for 386 architecture)
su
rpm -Uvh foo-1.0.0-1.i386.rpm
exit
E. Clean up the rpm/ directories. Cleaning can be done with rm commands or
the SOURCE and SPEC directories can be cleaned out with:
cd ~/rpm/SPEC
rpm --rmsource foo.spec (This switch could be added in the -bb step)
rm foo.spec
APPENDIX A - SOURCE MODIFICATION
================================
There are times when it is necessary to make changes to the sources before
building the binary RPM. If the changes are extensive, the best method is to
create a patch file and add it to the SOURCE directory and the .spec file. The
techniques for doing that are not difficult, but they are beyond the scope of
this HOWTO. You will need to study the man pages for diff and patch, read the
appropriate sections from MaximumRPM, and review several .spec files if you
want learn how to do it.
The policy when building RPMs is that changes should never be made to the
original "pristine" source archives. Instead, patch files and the .spec file
are used to modify the BUILD tree during the build process, and the .spec file
can also tailor the installation.
However, small changes can easily be made by using echo and sed commands in the
.spec file.
A1. Study the code in the BUILD tree and the ..../SPEC/foo.spec file until it
becomes clear how the build works and what changes are necessary :-)
A2. You can add commands to the at the beginning of the %build section of the
.spec file to make changes to the Makefile (or any other file in the BUILD
tree). Use echo with >> to append lines to the end of a file, and sed to
make simple changes in the middle of a file. Study .spec files to see
examples of how to do this.
A3. Add comments to the top of the %changelog script (with the date in the
proper format) describing the changes which have been made.
A4. Change the Release tag in the .spec file: e.g. 1 to 1a. An alpha suffix is
recommended for changes not made by the package owner.
A5. Repeat the rpm -bp command, inspect the new BUILD tree, and iterate until
you get the BUILD tree the way you want it.
A6. In the following step rpm will do the equivalent of a "make install", but
in a temporary staging area (Note 3):
rpm -bi --short-circuit foo.spec &> bi.log
A7. If all is well, you will want to build both a binary RPM and a new source
RPM. The latter will contain your changes, and will be found in rpm/SRPMS.
rpm -ba foo.spec &> ba.log
Always inspect the ba.log to be sure that everything completed without
error.
NOTES
=====
1. The &> redirection operator is a bash shortcut. If it doesn't work for you,
modify the command as follows:
rpm --rebuild foo-1.0.0-1.src.rpm > rebuild.log 2>&1
2. If the .src.rpm was not designed to install in a "staging area," (i.e. make
its working install in a world-writable location like /var/tmp by setting
the Buildroot macro in the .spec file), you will get a permissions error.
If you can do so, fix the .src.rpm. However, this may be a sizeable job,
and you may decide to do -bi, -bb, -bs, and -ba as the root user :-( .
Always check the bX.log to make sure rpm completed without errors! If it is
necessary to go root, use
su -p
to preserve the environment set by .rpmmacros. Otherwise, rpm will be
looking in /usr/src/redhat/SOURCES for its files! (It will also be
necessary to do the cleanup as root.)
The install phase of a .src.rpm build is only used to set up the
configuration which will be packaged in the binary .rpm, and really should
be deleted after the .rpm is created. It is not intended to be the system
install, since the RPM database is not updated. Nonetheless, sometimes this
install is done in standard locations like /usr/bin and not properly
removed.
Troubleshooting hint: GNU make supports using the DESTDIR variable to
specify a staging area, and a typical %install script command is
make DESTDIR=$BUILD_ROOT install
Another approach is to use the %makeinstall macro in the %install script.
3. If problems are experienced with -bi, it may be useful to do compiles with
-bc until the bugs are worked out. The --short-circuit switch is helpful
when building big source packages since it avoids going back to the unpack
stage each time -bc or -bi is run.
4. For further documentation, consult the RPM-HOWTO, the RPM man page, the book
_Maximum RPM_ by Ed Bailey, and the www.rpm.org web site. Much of this
documentation is rather out of date as of this writing, so also review the
files in your /usr/lib/rpm-x.x.x and also the /usr/src/rpm/macros file.
Searching the linux.redhat.rpm group on groups.google.com is helpful if all
else fails.
ACKNOWLEDGEMENTS
================
The documentation at www.rpm.org, the participants on rpm-...@redhat.com
(Usenet linux.redhat.rpm) and particularly:
John Thompson showed the way and got me started on .src RPMs
Ned Ulbricht clarified how to install source RPMs and build without being root
Jim Knoble provided a relocatable way of creating the .rpmmacros file
Tzafrir Cohen reviewed the draft and made many helpful suggestions.
Any errors are my responsibility and due to my lack of understanding of what
these people tried to explain to me. Corrections and suggestions will be
appreciated.
HISTORY
=======
27 Jan 2002 - Kurt B. Kaiser - Initial release
30 Apr 2002 - Kurt B. Kaiser - Change title, update, submit for review
COPYING
=======
(C) Copyright 2002 Kurt B. Kaiser
Permission is granted to copy, distribute and/or modify this document under the
terms of the GNU Free Documentation License, Version 1.1 or any later version
published by the Free Software Foundation; there are no Invariant Sections, no
Front-Cover Texts and no Back-Cover Texts. The contents of the
Acknowledgements, History, and Copying sections must be preserved, but may be
appended.
$Id: src_rpm_minihowto.txt,v 1.4 2002/05/01 01:22:15 kbk Exp $
Easy way I do it:
rpm --rebuild mtools-3.9.7-4.src.rpm
will produce a new binary rpm ready for installation. It is usually
placed in /usr/src/redhat/RPMS/i386/
In RH 8.0 it seems the --rebuild option is gone. In it's place is a
command rpmbuild. To find out how to use, man rpmbuild
Cheers,
Michael
>
> Thanks!
just like in previous redhats
rpmbuild --recompile
or use --rebuild
--
Mayday - The Religion
In music & dance I express myself as a member of a higher community....
I have forgotten how to walk and speak and I'm to odd(??) to flying in the air
Ravin'
Only just in case, rpmbuild is included in earlier version of redhat too.
//Aho
> I understand it has to be one of rpm's -b options, but
> 1) which one ?
I believe it is :
rpmbuild -ba foo.i486.rpm
> 2) and where will my NEW binary foo.i486.rpm file be deposited ?
in ../RPMS
>
> Thanks!
You have to give the spec file as argument
rpmbuild -ba foo.spec
You find it in the /usr/src/redhat/SPEC
>> 2) and where will my NEW binary foo.i486.rpm file be deposited ?
>
>
> in ../RPMS
.../RPMS/i486 if you have the default RPM set to do i486, otherwise you will
have i386 version and it will be found in ../RPMS/i386.
if you default want to compile something else than i386, you have to edit
/etc/rpmrc
---start---
buildarchtranslate: osfmach3_i686: i686
buildarchtranslate: osfmach3_i586: i686
buildarchtranslate: osfmach3_i486: i686
buildarchtranslate: osfmach3_i386: i686
buildarchtranslate: athlon: i686
buildarchtranslate: i686: i686
buildarchtranslate: i586: i686
buildarchtranslate: i486: i686
buildarchtranslate: i386: i686
--- end ----
As you see, I have choosen to get i686 as default, just change the i686 to
your prefeared system.
//Aho
I have been trying to create some of these rpm files from the above
axpalination but when i execute this rpm --rebuild [filename].src.rpm i
get -
[filename]: No such file or directory
I checked the typing etc and all is sweet but have i forgotten to install
something before trying to execute the command??
Any help appreciated
Michael
"J.O. Aho" <us...@example.net> wrote in message
news:anpujn$g8iqe$1...@ID-130698.news.dfncis.de...
> I have been trying to create some of these rpm files from the above
> axpalination but when i execute this rpm --rebuild [filename].src.rpm i
> get -
> [filename]: No such file or directory
>
> I checked the typing etc and all is sweet but have i forgotten to
> install something before trying to execute the command??
You have to be in the same directory as the file, unlike with some
other rpm commands. Or give the full path.
A typical rpm src filename is python2-2.2.1-2.src.rpm
and you need all of it. That is the source rpm for the python2
package. The extra numbers are the version (2.2.1) and the release (2)
On Linux, if you are in the directory with the file a good approach is
rpm --rebuild python2<TAB> [or even rpm --rebuild py<TAB> ]
which will expand the filename if it's unique in the directory.
Otherwise you may have to type another character or so and hit TAB
again.
KBK
If you have RH8.0, then you have to use the rpmbuild instead of rpm.
You have to be in the same directory as where the src.rpm file is in, or give
the full path to it.
You have to be root.
rpm/rpmbuild is installed default, no matter what, as Redhat won't really work
without it.
//Aho
Michael
"Kurt B. Kaiser" <k...@shore.net> wrote in message
news:m3r8f2l...@float.attbi.com...
> But again i can't get it to work. The files I am trying to convert r
> kdebase-3.0.3-0.7.src.rpm and the rest of the update files. I am in the same
> directory and doing the tab thing and hitting enter and coming up with "No
> such file or directory".
What happens when you do
ls kde<TAB><ENTER> ?
Paste a copy of your command and the error message into a posting here.
KBK
The kde files were downloaded onto a Windows XP machine then copied overa
network to a directory on the linux machine.
I can install the rpms but then i can't do anything with the source files.
"No such file or directory" comes up again.
Michael
ps i would buy a book on linux if i didn't live 3 hours drive from a
bookstore:(
"Kurt B. Kaiser" <k...@shore.net> wrote in message
news:m3n0pql...@float.attbi.com...
Hmm... sounds really strange, are you sure you spell it right? You know, linux
is case sensitive?
Do a simple 'ls' (without any '), do the rpm, you want to compile, come up in
that list? If not, then you are in the wrong directory.
//Aho
> I did the command from the directory the files r in and i returned
> ls: kde: No such file or directory
You have a basic problem which is not rpm related. When you ls
the directory do you see the file?
i.e. ls -l<ENTER>
When you ls kde<TAB> does the filename complete itself?
(That's an indication that the shell can find the file. If it does
complete, then ls should return the name when you hit <ENTER>. If it
doesn't complete, then it's either spelled wrong or the file is
missing.)
When you ls kde* what do you get?
As Aho points out, Linux file names are case sensitive.
> The kde files were downloaded onto a Windows XP machine then copied
> overa network to a directory on the linux machine. I can install
> the rpms but then i can't do anything with the source files. "No
> such file or directory" comes up again.
>
> Michael
> ps i would buy a book on linux if i didn't live 3 hours drive from a
> bookstore:(
Try this online Linux book, it's excellent:
When you get to the bookstore you can buy a copy to support the
guy (you may have to preorder) :)
KBK
p.s. interleaved posting makes it easier to quote and read a thread
in the order it occurred....I know the Outlook default is top post but
IMO they made the wrong choice :)
> You have a basic problem which is not rpm related. When you ls
> the directory do you see the file?
>
> i.e. ls -l<ENTER>
>
> When you ls kde<TAB> does the filename complete itself?
>
> (That's an indication that the shell can find the file. If it does
> complete, then ls should return the name when you hit <ENTER>. If it
> doesn't complete, then it's either spelled wrong or the file is
> missing.)
You missed one option, if you have several files starting with the same
characters, eg:
kde-1.2.2.rpm
kde-devel-1.2.2.rpm
then the if you do 'ls kde<TAB>' you would end with 'ls kde-', if you press
the tab again (is it once ot twice), you will get listed all currently avaible
options, so that you can see what character you should add to get the autofill
function back.
//Aho
Michael
"Kurt B. Kaiser" <k...@shore.net> wrote in message
news:m3lm579...@float.attbi.com...