2ff057
To build RPM you will need several other packages:
2ff057
--------------------------------------------------
2ff057
Packit Service 0cfc1f
The popt library for option parsing, must be version 1.13 or later.
Packit Service 0cfc1f
At this time, it is available at least from
Packit Service 0cfc1f
    http://ftp.rpm.org/mirror/popt/
Packit Service 0cfc1f
2ff057
The zlib library for compression support. You might also need/want
2ff057
the unzip executable for java jar dependency analysis. All available from
2ff057
    http://www.gzip.org/zlib/
2ff057
2ff057
The libmagic (aka file) library for file type detection (used by rpmbuild). 
2ff057
The source for the file utility + library is available from
2ff057
    ftp://ftp.astron.com/pub/file/
2ff057
2ff057
You will need a cryptographic library to support digests and signatures.
2ff057
This library may be Mozilla NSS, OpenSSL or beecrypt. Which library to use
2ff057
must be specified with the --with-crypto=[beecrypt|nss|openssl] argument
2ff057
to configure.
2ff057
2ff057
If using the Mozilla NSS library for encyption (and NSPR library which
2ff057
NSS uses) it must be version 3.12 or later. Both NSPR and NSS libraries and
2ff057
headers need to be installed during RPM compilation. As NSPR and NSS
2ff057
typically install their headers outside the regular include search path,
2ff057
you need to tell configure about this, eg something like:
2ff057
    ./configure <......> CPPFLAGS="-I/usr/include/nspr -I/usr/include/nss"
2ff057
2ff057
The NSPR and NSS libraries are available from 
2ff057
    http://www.mozilla.org/projects/security/pki/nss/
2ff057
    http://www.mozilla.org/projects/nspr/
2ff057
2ff057
If using the OpenSSL library for encryption, it must be version 1.0.2 or
2ff057
later. Note: when compiling against OpenSSL, there is a possible license
2ff057
incompatibility. For more details on this, see
2ff057
https://people.gnome.org/~markmc/openssl-and-the-gpl.html
2ff057
Some Linux distributions have different legal interpretations of this
2ff057
possible incompatibility. It is recommended to consult with a lawyer before
2ff057
building RPM against OpenSSL.
2ff057
Fedora: https://fedoraproject.org/wiki/Licensing:FAQ#What.27s_the_deal_with_the_OpenSSL_license.3F
2ff057
Debian: https://lists.debian.org/debian-legal/2002/10/msg00113.html
2ff057
2ff057
The OpenSSL crypto library is available from https://www.openssl.org/
2ff057
2ff057
The Berkeley DB >= 4.3.x (4.5.x or newer recommended) is required for the
2ff057
default database backend. BDB can be downloaded from
2ff057
http://www.oracle.com/technology/software/products/berkeley-db/index.html
2ff057
2ff057
RPM supports two different ways to include it, both methods have their 
2ff057
distinct advantages and disadvantages:
2ff057
2ff057
1) Building and using an internal copy of BDB
2ff057
   
2ff057
   This is the "safe" way: upgrades to system BDB can not affect your
2ff057
   rpmdb integrity and you have full control over how BDB is configured. 
2ff057
   On the other hand, any updates (security or bugfix) to BDB will require 
2ff057
   rebuilding RPM. 
2ff057
2ff057
   To use this method, download a recent version of BDB from the URL above,
2ff057
   expand the tarball into rpm source directory root and create "db" symlink
2ff057
   to it, eg:
2ff057
   $ wget http://download.oracle.com/berkeley-db/db-4.5.20.tar.gz
2ff057
   $ tar xzf db-4.5.20.tar.gz
2ff057
   $ ln -s db-4.5.20 db
2ff057
   $ ./configure [other options...]
2ff057
2ff057
2) Linking to external (system) BDB
2ff057
2ff057
   If you can control when and how system BDB is upgraded, this option
2ff057
   saves space, removes the need to rebuild RPM in case of security etc
2ff057
   updates to BDB and also makes build rpm itself much faster. On the other
2ff057
   hand, major BDB upgrades can be disruptive, especially if
2ff057
   the on-disk format changes somehow. 
2ff057
2ff057
   To use this method, simply pass in --with-external-db to ./configure
2ff057
   script. If the system BDB is installed outside compiler + linker default
2ff057
   paths, you can use CPPFLAGS and LDFLAGS to tell configure where to look,
2ff057
   for example:
2ff057
2ff057
   $ ./configure --with-external-db CPPFLAGS=-I/usr/include/db45
2ff057
2ff057
Minimal instructions for building BDB are 
2ff057
    cd build_unix 
2ff057
    ../dist/configure --with-posixmutexes
2ff057
    make
2ff057
    make install
2ff057
2ff057
For embedded Lua scripting support (recommended and enabled by default),
2ff057
you'll need Lua >= 5.1 library + development environment installed.
2ff057
Note that only the library is needed at runtime, RPM never calls external
2ff057
Lua interpreter for anything. Lua is available from 
2ff057
    http://www.lua.org
2ff057
2ff057
If SELinux support is desired, it can be enabled with --with-selinux option
2ff057
to configure and libselinux development environment installed. SELinux
2ff057
is available from
2ff057
    http://www.nsa.gov/selinux/
2ff057
2ff057
It may be desired to install bzip2, gzip, and xz/lzma so that RPM can use these
2ff057
formats.  Gzip is necessary to build packages that contain compressed
2ff057
tar balls, these are quite common on the Internet.
2ff057
These are available from
2ff057
    http://www.gzip.org
2ff057
    http://www.bzip.org
2ff057
    http://tukaani.org/xz/
2ff057
2ff057
If you want to build the Python bindings to RPM library, it can be enabled
2ff057
with --enable-python option to configure. You'll need to have Python (>= 2.3)
2ff057
runtime and C API development environment installed, this is available from 
2ff057
    http://www.python.org/
2ff057
2ff057
To enable POSIX.1e draft 15 file capabilities support, configure with
2ff057
--with-cap. You'll also need recent libcap, available from:
2ff057
    http://ftp.kernel.org/pub/linux/libs/security/linux-privs/libcap2/
2ff057
2ff057
To enable POSIX 1003.1e draft 17 ACL verification support, configure with
2ff057
--with-acl. You'll also need the ACL library, available from:
2ff057
    ftp://oss.sgi.com/projects/xfs/cmd_tars/
2ff057
2ff057
For best results you should compile with GCC and GNU Make.  Users have
2ff057
reported difficulty with other build tools (any patches to lift these
2ff057
dependencies are welcome). Both GCC and GNU Make available from 
2ff057
    http://www.gnu.org/
2ff057
2ff057
If National Language Support (NLS) is desired you will need gnu
2ff057
gettext (currently this is required to build rpm but we hope to 
2ff057
lift this requirement soon), available from 
2ff057
    http://www.gnu.org/
2ff057
2ff057
If you are going to hack the sources (or compile from source repository)
2ff057
you will need most of the GNU development tools including:
2ff057
autoconf, automake, gettext, libtool, makeinfo, perl, GNU m4, GNU tar
2ff057
available from 
2ff057
    http://www.gnu.org/
2ff057
2ff057
RPM distribution tarballs come with doxygen generated HTML documentation
2ff057
for the public RPM API, but if you want to generate documentation for
2ff057
the entire source including internal API's, use --enable-hackingdocs
2ff057
configure option. Doxygen is needed for this, it's available at
2ff057
    http://www.stack.nl/~dimitri/doxygen/
2ff057
2ff057
If you plan on using cryptographic signatures you will need a version
2ff057
of GPG, available from
2ff057
    http://www.gnupg.org/
2ff057
2ff057
To compile RPM:
2ff057
--------------
2ff057
2ff057
RPM uses a small shell script to run: libtool, autoconf,
2ff057
automake. This step should not be necessary if you are running a
2ff057
released version of rpm, however if you have gotten the rpm sources
2ff057
directly from the source code repository, you need to generate
2ff057
intermediate files by running the autogen.sh script.
2ff057
2ff057
The autogen.sh script checks that the required tools are installed.
2ff057
The autogen.sh script also runs configure for you and passes the command line
2ff057
arguments to configure.  To run it without configure type:
2ff057
2ff057
    ./autogen.sh --noconfigure
2ff057
2ff057
If your libraries are not in a standard place you will need to change
2ff057
configures environment.  These options can be passed directly to
2ff057
configure or to autogen.sh which will pass them through to configure.
2ff057
2ff057
Here is an example:
2ff057
    LIBS='-L/opt/libz/ -L/opt/BerkeleyDB/lib/' \
2ff057
    CPPFLAGS='-I/opt/libz/ -I/opt/BerkeleyDB/include' \
2ff057
    ./configure
2ff057
2ff057
If you have build tools stored in non standard places you should check
2ff057
the resulting Makefile to be sure that the tools you wish to use have
2ff057
been correctly identified.  The configure script will modify your path
2ff057
before looking for the build tools and it may find versions of these
2ff057
tools that you do not want.  It uses the following search path
2ff057
2ff057
    MYPATH="/bin:/usr/bin:/usr/local/bin:$PATH:/opt/gnu/bin"
2ff057
2ff057
now build the system with:
2ff057
2ff057
    make
2ff057
2ff057
and then install with:
2ff057
2ff057
    make install
2ff057
2ff057
Rpm comes with an automated self-test suite. The test-suite relies heavily
2ff057
on fakechroot (https://github.com/dex4er/fakechroot/) and cannot be executed
2ff057
without it. Provided that fakechroot was found during configure,
2ff057
it can be executed after a successful build with:
2ff057
2ff057
    make check
2ff057
2ff057
Finally, if you wish to prepare an rpm source tar ball, you should do
2ff057
2ff057
    make dist
2ff057
2ff057
To package RPM:
2ff057
--------------
2ff057
2ff057
After RPM has been installed you can run rpm to build an rpm package.
2ff057
Edit the rpm.spec file to mirror any special steps you needed to
2ff057
follow to make rpm compile and change the specfile to match your
2ff057
taste.  You will need to put the rpm source tar file into the
2ff057
SOURCES directory and we suggest putting the specfile in the
2ff057
SPECS directory, then run rpmbuild -ba rpm.spec.  You will end up
2ff057
with two rpms which can be found in RPMS and SRPMS.
2ff057
2ff057
If you are going to install rpm on machines with OS package managers
2ff057
other then rpm, you may choose to install the base rpm package via a
2ff057
cpio instead of a tar file.  Instead of running "make tar" during the
2ff057
build process, as described above, use the base rpm packages to create
2ff057
a cpio.  After the rpms have been created run rpm2cpio on the base rpm
2ff057
package, this will give you a cpio package which can then use to
2ff057
install rpm on a new system.
2ff057
2ff057
    rpm2cpio rpm-4.0-1.solaris2.6-sparc.rpm > rpm-4.0-1.solaris2.6-sparc.cpio
2ff057
2ff057
2ff057
Non Linux Configuration Issues:
2ff057
------------------------------
2ff057
2ff057
2ff057
OS dependencies:
2ff057
----------------
2ff057
2ff057
Under RPM based Linux distributions all libraries (in fact all files 
2ff057
distributed with the OS) are under RPM control and this section is not 
2ff057
an issue.
2ff057
2ff057
RPM will need to be informed of all the dependencies which were
2ff057
satisfied before RPM was installed.  Typically this only refers to
2ff057
libraries that are installed by the OS, but may include other
2ff057
libraries and packages which are available at the time RPM is
2ff057
installed and will not under RPM control.  Another common example of
2ff057
libraries which may need dependency provisions are precompiled
2ff057
libraries which are installed by the OS package manager during system
2ff057
build time.  The list of dependencies you will wish to load into RPM
2ff057
will depend on exactly how you bootstrap RPM onto your system and what
2ff057
parts of the system you put into packages as well as on the specific OS
2ff057
you are using.
2ff057
2ff057
The script vpkg-provides.sh can be used to generate a package which
2ff057
will satisfy the dependencies on your system.  To run it you will need
2ff057
to create a specfile header for this empty package and run the progam
2ff057
with:
2ff057
2ff057
    --spec_header '/path/to/os-base-header.spec
2ff057
2ff057
and if you wish to ensure that some directories are not traversed you
2ff057
can use the option: 
2ff057
2ff057
    --ignore_dirs 'grep-E|pattern|of|paths|to|ignore
2ff057
2ff057
By default the generated rpm will include a %verifyscript to verify
2ff057
checksum of all files traversed has not changed.  This additional
2ff057
check can be suppressed with:
2ff057
2ff057
    --no_verify
2ff057
2ff057
The result of running the script will be a specfile which will create
2ff057
a package continging all the dependencies found on the system.  There
2ff057
will be one provides line for each depednecy. The package will contain
2ff057
none of the actual OS library files as it is assumed they are already
2ff057
on your system and managed by other means.  Here is a example
2ff057
(truncated) of the provides lines used by one user of Digital Unix. (I
2ff057
have put several provides on the same line for brevity)
2ff057
2ff057
provides: /bin/sh /usr/bin/ksh /usr/bin/csh 
2ff057
provides: libc.so.osf.1 libm.so.osf.1 libcurses.so.xpg4 libdb.so.osf.1
2ff057
provides: libX11.so libXaw.so.6.0 libXext.so libXm.so.motif1.2 libXmu.so
2ff057
provides: libdnet_stub.so.osf.1 libsecurity.so.osf.1 libpthread.so.osf.1
2ff057
provides: libexc.so.osf.1 libmach.so.osf.1 libdps.so libdpstk.so 
2ff057
2ff057
2ff057
The script vpkg-provides2.sh is underdevelopment as a more advanced
2ff057
version of vpkg-provides.sh which is aware of many different unix
2ff057
vendor packaging schemes.  It will create one "dependency package" for
2ff057
each unix package your OS vendor installed.
2ff057
2ff057
2ff057
rpmfilename:
2ff057
-----------
2ff057
2ff057
If you plan on packaging for more then one OS you may want to edit
2ff057
/etc/macros or /usr/lib/rpm/macros and change the line which has
2ff057
rpmfilename to something which include both the %{_target_os} and
2ff057
%{_target_cpu}.  This will cause the name of the generated rpm files
2ff057
to the operating system name as well as the architecture which the rpm
2ff057
runs under.  The line to change looks like:
2ff057
2ff057
%_rpmfilename           %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
2ff057
2ff057
you may wish to include both the %{_target_os} and %{_target_cpu} in
2ff057
the final base name, so that it's easier to distinguish between what
2ff057
package is appropriate for a particular arch-os-version combo.  We
2ff057
suggest:
2ff057
2ff057
%_rpmfilename           %%{_target_platform/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{_target_platform}.rpm
2ff057
2ff057
There is no %{_target_os_version} tag, so if you need to also
2ff057
distinguish between RPMs for certain versions of the OS, you can
2ff057
hard-code the version in the rpmrc on the build machine, so that .rpm
2ff057
files are generated with the version as part of the filename.
2ff057
2ff057
For example when one user builds RPMs for Digital Unix 4.0b and 4.0d,
2ff057
optimization is important and he will build one set of RPMs for the
2ff057
EV4 processor and another set for the EV56 processor.  He specifies
2ff057
both the OS version (if it's important, as it is for a few packages)
2ff057
and the processor version by default by setting a special rpmfilename:
2ff057
on the particular build machine.
2ff057
2ff057
The "rpmfilename: "tag on one machine (Digital Unix 4.0d, EV56 PWS 433)
2ff057
looks like:
2ff057
2ff057
rpmfilename: %{_target_os}/4.0d/%{_target_cpu}/%{name}-%{version}-%{release}.%{_target_os}-%{_target_cpu}ev56.rpm
2ff057
2ff057
For package `foo-1.1', at build time that would translate into:
2ff057
2ff057
    osf1/4.0d/alpha/foo-1.1-1.osf1-alphaev56.rpm
2ff057
2ff057
The hyphen between the %{_target_cpu} and ev56 is left out for compatibility
2ff057
with GNU Config.guess and because `alphaev56' looks more "normal" to
2ff057
people with an alpha than alpha-ev56 for someone on an Intel Pentium
2ff057
Pro would want `i586pro' over `i586-pro', but it does make parsing
2ff057
this filename by other programs a bit more difficult.
2ff057
2ff057
2ff057
GPG
2ff057
---
2ff057
2ff057
To use the signing features of rpm, you will need to configure certain
2ff057
rpm macros in ~/.rpmmacros:
2ff057
2ff057
	%_gpg_name      <GPG UID>
2ff057
	%_gpg_path      %(echo $HOME)/.gnupg
2ff057