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