|
Home | Switchboard | Unix Administration | Red Hat | TCP/IP Networks | Neoliberalism | Toxic Managers |
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and bastardization of classic Unix |
|
RPM concept is somewhat similar to self-installable archive popular in DOS world and available in all major archivers, such a RAR. It is more structured and more tunes to software installation. Every RPM package has a package label, which contains the following pieces of information:
|
RPM file names normally have the following format:
<name>-<version>-<release>.<architecture>.rpm
For example:
nano-0.98-2.i386.rpm
A package label is contained within the file and does not necessarily need to match the name of the file. Source code may also be distributed in RPM packages. Such package labels do not have an architecture part and replace it with "src", e.g.:
libgnomeuimm-2.0-2.0.0-3.src.rpm
Additionally, libraries are distributed in two separate packages for each version. One contains the precompiled code, while the second one contains the development files such as headers, static library files, etc. for the library in question. Those packages have "-devel" appended to their name field.
RPM can also make a so-called source RPM package which contains all the stuff needed to build the binary RPM package, that is, source tarballs, patch files, and the specfile. Thus, everything you need to rebuild the package is bundled together conveniently.
The following hints assume that you have a system with installed RPM, which is true for RPM-based Linux distributions of course.
rpm --eval '%{optflags}'
Some people like highest optimization levels, but I think that GCC's -O2 is enough and can protect you from quite a few optimizer bugs.
%{_topdir}
, so
you can get an answer by issuing the commandrpm --eval '%{_topdir}'
Normally, the subdirectories of %{_topdir}
are
world-writable, so that regular users can build packages. If you prefer
to work in your own home directory, prepare a ~/.rpmmacros
file with contents like
# Use the home directory for building. # Needed dirs (or symlinks): BUILD RPMS/i386 SOURCES SPECS SRPMS %home /home/chris %_topdir %{home} %_tmppath %{_builddir} %buildroot %{_tmppath}/%{name}-root
Assume that you want to build the package foo from sources in foo-1.0.tar.gz using RPM. Assume further that you have (prepared or got) a specfile and perhaps some patches for foo-1.0.
I recommend that you capture the screen output into a logfile by refining the above command to
rpm -ba foo.spec 2>&1 | tee foo-1.0.log
The logfile can help you in case of errors, and of course it should always be scanned for warnings and other strange things.
rpm -Uvh /usr/src/packages/RPMS/i386/foo-1.0-1.i386.rpm # or whatever
Now the package is properly integrated in your system. (Note: -U means upgrade package, the -vh just prints a progress bar.)
rpm --clean foo.spec
(Note that this --clean option is not related to
the specfile's %clean
section which undoes the
pseudo-installation. When building binary RPMs, the %clean
commands are executed automatically in case of success, but the build
tree remains unless the --clean option is given.)
rpm --rmsource foo.spec
Note that this still leaves the specfile, though it is also contained in the source RPM. You can remove the specfile manually or with the option --rmspec.
rpm -ba --clean --rmsource foo.spec 2>&1 | tee foo-1.0.log
rpm -i /usr/src/packages/SRPMS/foo-1.0-1.src.rpm
In contrast to the installation of a binary RPM, the installation of a source RPM does not require extra privileges as long as the SOURCES and SPECS directories are writable.
rpm --rebuild /usr/src/packages/SRPMS/foo-1.0-1.src.rpm 2>&1 | tee foo-1.0.log
Require
directives that demand packages you have actually installed, but with a
different name. And of course, the specfile comments may contain helpful
usage information.If you update a specfile for a newer version, you should disable all previous patches. You could try to find out whether the old patches would still apply and, by careful inspection of the source code, whether they should be applied and what further adaptation could be necessary. The best result would be an updated patch file that fits properly to the new version.
The specfile can often be used with very few modifications to build later versions of the package. That's why I post specfiles and patches only. The other sources can be downloaded from the offical sites, and when you are there, you can check for the newest versions as well.
RPM packages are created from RPM spec files using the rpmbuild tool. When building an RPM pachge you need to create the directory with the name of the package and several predefined subdirectories
The key component of the RPM package is SPECS section which contains so called spec files which are very similar to makefile. It contains information required by RPM to build the package, as well as instructions telling RPM how to build it. The spec files also specify what files are a part of the package, and where they should be installed. They have the ".spec" suffix and are distributed within source packages (SRPM)
It has multiple sections. Among them:
%prep
rm -rf $RPM_BUILD_DIR/cdplayer-1.0
zcat $RPM_SOURCE_DIR/cdplayer-1.0.tgz | tar -xvf -
Or using macros
%prep
%setup
However, RPM does provide two macros to make life easier. One macro can unpack a compressed
tar file and cd into the source directory. The other
macro easily applies patches to the unpacked sources.
There are also several optional section
One example of when this capability would be required is when a package contains shared libraries. In this case, ldconfig would need to be run after the package is installed or erased. As another example, if a package contains a shell, the file /etc/shells would need to be updated appropriately when the package was installed or erased.
The RPM package is a binary format and consists of four sections:[1]
Working behind the scenes of the package manager is the RPM database, stored in /var/lib/rpm. It uses Berkeley DB as its back-end. It consists of a single database (Packages) containing all of the meta information of the installed rpms. Multiple databases are created for indexing purposes, replicating data to speed up queries. The database is used to keep track of all files that are changed and created when a user (using RPM) installs a package, thus enabling the user (via RPM) to reverse the changes and remove the package later. If the database gets corrupted, the index databases can be recreated with the rpm --rebuilddb command.
To build RPMs your system should have the rpmbuild command. (If the command "which rpmbuild" does not display anything, you don't have rpmbuild.). On Red Hat and Fedora systems, the rpmbuild command is provided by the rpm-build package. (You can give the command "rpm -q rpm-build" to check if it is installed.) .
It is better to use some close example (prototype RPM), especially in the source form then to build your RPM from scratch.
In this case you need first to install "prototype" RPM to your home directory. To placing the package files under $HOME/MyRPM and the rpm database in the $HOME/MyRPM/var/rpm directory use the command:
rpm -ivh --nodeps --relocate /=$HOME/MyRPM --root=/$HOME/MyRPM package.rpm
To study RPM you can also unpack it You can do it using Midnight commander, or rom2cpio (in the latter case only content of cpio archi will be unpackaed.
# rpm2cpio emacs-common-21.4-20.el5.x86_64.rpm | cpio -idmv
The rpm2cpio command extracts a cpio archive from an RPM file, and cpio command extract files from the cpio archive.
The options used with the cpio command are described as follows.
All source packages of SUSE LINUX carry a .src.rpm extension (source RPM).
The following directories must be available for rpm and rpmbuild in /usr/src/packages (unless you specified custom settings in a file like /etc/rpmrc):
When you install a source package all the necessary components will be installed in /usr/src/packages: the sources and the adjustments in SOURCES and the relevant .spec file in SPECS.
The following example uses the wget.src.rpm package. After installing the package with YaST, you should have the following files:
/usr/src/packages/SPECS/wget.spec /usr/src/packages/SOURCES/wget-1.4.5.dif /usr/src/packages/SOURCES/wget-1.4.5.tar.gz
rpmbuild -b X /usr/src/packages/SPECS/wget.spec starts the compilation. X is a wild card for various stages of the build process (see the output of --help or the RPM documentation for details). The following is merely a brief explanation:
The binary RPM created can now be installed with rpm -i or, preferably, with rpm -U. Installation with rpm makes it appear in the RPM database.
The danger with many packages is that unwanted files are added to the running system during the build process. To prevent this, use build, which creates a defined environment in which the package is built. To establish this chroot environment, the build script must be provided with a complete package tree. This tree can be made available on the hard disk, via NFS, or from DVD. The respective position is specified with build --rpms <path>. Unlike rpm, the build command looks for the SPEC file in the source directory. To build wget anew (like in the above example) with the DVD mounted in the system under /media/dvd, use the following commands as root:
cd /usr/src/packages/SOURCES/ mv ../SPECS/wget.spec . build --rpms /media/dvd/suse/ wget.spec
Subsequently, a minimum environment is established at /var/tmp/build-root. The package is built in this environment. Upon completion, the resulting packages are located in /var/tmp/build-root/usr/src/packages/RPMS.
The build script offers a number of additional options. For example, cause the script to prefer your own RPMs, omit the initialization of the build environment, or limit the rpm command to one of the above-mentioned stages. Access additional information with build --help and man build.
Midnight Commander (mc) can display the contents of RPM archives and copy parts of them. It represents archives as virtual file systems, offering all usual menu options of Midnight Commander. Display the HEADER with F3. View the archive structure with the cursor keys and Enter. Copy archive components with F5.
A front-end for rpm is also available for Emacs. KDE offers the kpackage tool. GNOME offers gnorpm.
Using the Alien (alien) Perl script, it is possible to convert or install an alien binary package. This tries to convert old TGZ archives to RPM before installing. This way, the RPM database can keep track of such a package after it has been installed. Beware: alien is still alpha software, according to its author even if it already has a high version number.
|
Switchboard | ||||
Latest | |||||
Past week | |||||
Past month |
RPMs can be a great way to manage the packages you install on your system. Unfortunately, not everything you might want to install is available in RPM form. Perhaps you need a more recent version of a program than the one that ships with your distribution; or maybe it's a program you wrote yourself; or perhaps it's just something that's very obscure. Similar dilemmas can occur with non-program packages, such as font or clip art collections.
Whatever the case, if you're installing a program for a single computer, chances are you'll just install it the old-fashioned way, by typing make && make install (or some similar set of commands) in the source directory. make gets the job done, but it means you're giving up the benefits of the RPM system. What's more, if you're maintaining several computers, running around installing the same package on all of them can be tedious.
Life would be much easier if you could create your own RPM, giving you the ability to easily install the package on many systems and the benefits of its package tracking. Fortunately, RPM includes tools that enable you to do just that. Creating an RPM isn't as easy as creating a tarball, but the task isn't insurmountable.
This month's column covers the files and file formats involved in creating RPMs. Next month's column will present practical examples, including how to build both binary and architecture-independent RPMs.
- Log into your machine as a regular user.
- create a mirror image of the main RPM directory structure in your $HOME and
- tell RPM to use these directories instead of the original ones.
This document explains how to build packages without root-access. This might be useful in case you have a build environment where different users need to build packages without interfering each other.
Customizing your RPM build environment
To make RPM use your environment definitions, you need to override the default macros RPM uses. The only one that is crucial for this is %_topdir (which by default would point to /usr/src/redhat).The obvious catchYou can do this by adding the following to ~/.rpmmacros.
As a consequence, RPM will need the default directory structure underneath. So you can do as user:%_topdir /home/dag/redhat/mkdir -p ~/redhat/{BUILD,RPMS/{i386,i686,noarch},SOURCES,SPECS,SRPMS}And now you're set to go.
Beware that you don't have the same permissions as root, which means you can't chown files to other users. So if the default Makefile uses chown or install to change ownership, this will obviously fail. As a workaround, you can't use %makeinstall, and instead use install yourself without changing owners. Ownerships should be in the %files section.Customize even more !Since you now can build packages yourself, you can also customize the default packager, vendor and other information by defining more macros.%packager Dag Wieers <[email protected]> %vendor Dag Wieers <[email protected]> %_tmppath /home/dag/tmp/ %_topdir /home/dag/redhat/ %prefix /usr/local/There are much more macros for changing default paths, programs or even function-macros. See our links for more specific information.
If you are familiar with the make-based way to build and install software packages in Unix systems, this page should enable you to step to a higher level, using RedHat's Package Manager (RPM).
May 9, 2007
(See French version.)
Getting the rpmbuild command
Your system may currently have the rpm command but not the rpmbuild command. (If the command "which rpmbuild" does not display anything, you don't have rpmbuild.) On Red Hat and Fedora systems, the rpmbuild command is provided by the rpm-build RPM package. (You can give the command "rpm -q rpm-build" to check if it is installed.) Avoiding root
By default, one needs to be root to build RPM packages under the /usr/src/redhat directory. To avoid that, give the following command under root:
chown -fR someuser /usr/src/redhatThis step is only needed once. However, you can build RPM packages in any directory owned by someuser by writing an appropriate ~/.rpmmacros file. For example, put the following line in that file:
By default, RPM packages are built in the /usr/src/redhat directory, which is only writable by root. You can have the rpmbuild command use another directory (e.g., /home/your_userid/rpm) by putting this line in a file called .rpmmacros in your home directory:
%_topdir /home/your_userid/rpmYou must then create the following subdirectories in that directory:
cd /home/your_userid/rpm mkdir SOURCES SPECS BUILD SRPMS mkdir -p RPMS/i386 RPMS/athlon RPMS/i486 RPMS/i586 RPMS/i686 RPMS/noarchSee the RPM reference documentation for details.
Building from a source RPM (SRPM)
Install the .src.rpm file this way:
rpm -i somepackage-1.0-1.src.rpmThis will create files in the SOURCES directory of your RPM building directory tree, and a .spec file in the SPECS directory.
Then go the SPECS directory and give the command to build the RPM:
cd /home/your_userid/rpm/SPECS rpmbuild -bb somepackage.specGive the -ba option instead if you also want to build the SRPM. The binary RPM packages will typically be created in the RPMS/i386 directory (on a PC-based system).
Building from a source archive
When a source archive (e.g., somepackage-1.0.tar.gz) contains a .spec file, one can give the following command to build the RPM without having to deploy the archive:
rpmbuild -tb somepackage-1.0.tar.gzGive the -ta option instead if you also want to build the SRPM.
(The source archives that I publish are supposed to contain a functional .spec file. If I omitted this, please complain to me.)
Google matched content |
...
AAA Development-Tasks-Packaging-Tools-RPM-Howto - Mandriva Community Wiki a very good tutorial
Red Hat Package Manager 4 information
RPM HOWTO (Red Hat 1999)
Better Living Through RPM, Part 2
Society
Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy
Quotes
War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda : SE quotes : Language Design and Programming Quotes : Random IT-related quotes : Somerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose Bierce : Bernard Shaw : Mark Twain Quotes
Bulletin:
Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law
History:
Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds : Larry Wall : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOS : Programming Languages History : PL/1 : Simula 67 : C : History of GCC development : Scripting Languages : Perl history : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history
Classic books:
The Peter Principle : Parkinson Law : 1984 : The Mythical Man-Month : How to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haters Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor
The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D
Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
|
You can use PayPal to to buy a cup of coffee for authors of this site |
Disclaimer:
The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.
Last modified: March 12, 2019