[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
how to build a noarch RPM
- From: rpjday <rpjday mindspring com>
- To: rpm list <rpm-list redhat com>
- Subject: how to build a noarch RPM
- Date: Sat, 29 Dec 2001 06:16:53 -0500 (EST)
[on a regular basis, i've seen people asking how to build
an RPM for just text files, not based on making or installing
or anything of the sort. so, two hours ago, i decided to learn
how to build these things, and here's the results. i'd appreciate
any feedback on how to clean it up before i unleash it on the
world.
[if you're wondering about the format, it was produced with
emacs in outline mode.]
* Overview -- building a noarch RPM
This document explains, with a concrete example, how to build
a "noarch" RPM; that is, an RPM that consists solely of
non-program files, such as image files, text files and the
like. The resulting RPM can be used to simply install files
on a new host -- there is no concept of "source", building or
anything of the sort.
Obviously, this is a fairly restrictive thing to do, but I've
noticed enough people asking about how to do this on various
mailing lists that it seemed worth documenting.
For the rest of this document, assume your username is "fred".
* The necessary RPMs
In addition to the "rpm" RPM itself, you need to install
the "rpm-build" RPM. And if you're feeling ambitious, there's
always "rpmlint" that you can use to validate your RPM.
* Building an RPM as a regular user
It's generally considered a hanging offense to build a new
RPM as root, so you should first create your own RPM-building
environment. Take a look at the directory structure under
/usr/src/redhat, and duplicate that in your home directory
(assuming you're currently logged in as fred):
$ mkdir -p ~/rpm/{BUILD,RPMS,SOURCES,SRPMS,SPECS,tmp}
$ mkdir ~/rpm/RPMS/{i386,i586,i686,noarch}
Obviously, this is more than you really need, but you might
as well build the entire structure for the day when you really
will build your own RPMs from source.
Everything above should look familiar except for the directory
~/rpm/tmp, which you'll set up shortly as a temp directory for
future source-based builds. Once again, you don't really need
it for "noarch" RPM construction, but put it in anyway.
Once you've created the directory structure, create the following
file with the contents shown, which forces "rpm" to use your
home directory for all of its work:
~/.rpmmacros
%_topdir /home/fred/rpm
%_tmppath /home/fred/rpm/tmp
Obviously, you have some freedom in that you can call this top-level
directory for your RPM stuff anything you want.
* The spec file
Assuming you're bundling up a collection of image files and want
them to be installed under, say, /tmp/wonderpics, here's a sample
spec file for building an RPM containing nothing but those image
files. (You would typically keep your spec files in the directory
~/rpm/SPECS, but that's not mandatory -- you can create this file
anywhere):
----- file wonderpics.spec -----
%define name wonderpics
%define version 1.0
%define release 1
Summary: WonderPics, a collection of images
Name: %{name}
Version: %{version}
Release: %{release}
Copyright: GPL
Group: Amusements/Graphics
BuildArch: noarch
BuildRoot: %{_builddir}/%{name}-root
URL: http://www.wonderpics.com/wonderpics
Distribution: whatever
Vendor: WonderPics, Inc.
Packager: fred@wonderpics.com
Provides: WonderPics
Requires: ee
%description
This package contains WonderPics, just random images as
a test for building a non-source RPM.
%prep
exit 0
%build
exit 0
%install
exit 0
%clean
exit 0
%files
%defattr(-,root,root)
/tmp/wonderpics
----- end of wonderpics.spec -----
Some comments about the above:
- Obviously, you should select the appropriate copyright value
for this RPM.
- Standard groups and subgroups are listed in the doc file
/usr/share/doc/rpm-4???/GROUPS, but nothing says you have
to take one of these values.
- Note the BuildArch directive, which specifies that this will be
a "noarch" RPM -- that is, not tied to a particular architecture.
- Note also that, since this is a noarch RPM, the prep, build,
install and clean steps are null.
* Defining a "build root"
If you look at the %files section of the spec file, it refers
to the contents of the directory /tmp/wonderpics, which is
typically:
1) where the files will be collected from to build the RPM, and
2) where the files will be installed on the target host
It's generally more convenient to collect all of the files and
directories elsewhere, then create the RPM to install those
files in a different location. You do this by defining a
"BuildRoot", which will contain a simulation of the entire
directory structure to be installed on the target machine.
Consider the spec file directive:
BuildRoot: %{_builddir}/${name}-root
As it is, the "builddir" macro refers to your directory
/home/fred/rpm/BUILD, so you would, for example, create the
directory structure (containing all your image files):
/home/fred/rpm/BUILD/wonderpics-root/tmp/wonderpics/<image files>
Once you do this, all you have to put in the %files section is a
reference to the directory /tmp/wonderpics, and the resulting RPM
will be built to install directly into /tmp/wonderpics.
(If you already have the proposed RPM contents under another
directory, just point the build root at that directory. But make
sure you've constructed a directory image that reflects the
destination on the target host from the root directory on down.)
* Building the noarch RPM
To build the noarch RPM, run:
$ rpm -bb wonderpics.spec
then cd to your RPMS/noarch directory, where you should find a
file with the name "wonderpics-1.0-1.noarch.rpm". Check its
attributes and contents with:
$ rpm -qpi wonderpics-1.0-1.noarch.rpm
$ rpm -qpl wonderpics-1.0-1.noarch.rpm
Note well that the file listing shows that the files will be
installed under /tmp/wonderpics -- all of the BuildRoot information
was stripped off when you created the RPM.
* The %files section
(I guess I should say something about some of the basic directives
you can have in the %files section ...)
* Copyright
This doc copyright Robert P. J. Day, 2001. All rights reserved.
To be placed under the GPL for documentation once it's finished.
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]