A Rocks roll requires that all packages contained in the roll must be in the native format of the OS. For Redhat-based Rocks clusters, this means all packages must be RPMS.
This guide covers a few ways to deal with RPMs. Already built, hand-built in a directory, and compiled RPMs. The last (compiled RPMs) is by far the most common.
If the software you wish to install is already in RPM format, you can directly
put it into the roll source tree.
For example, to put the RPM unzip-5.52-3.el5.x86_64.rpm
into the Valgrind Roll, execute:
# mkdir -p /export/src/roll/valgrind/RPMS/x86_64 # cp /tmp/unzip-5.52-3.el5.x86_64.rpm /export/src/roll/valgrind/RPMS/x86_64 |
If your application is already installed on your frontend and you would like to bundle its subdirectory into and RPM, you can create an RPM that contains all the files in a subdirectory. For example, let's say you want to create an RPM from all the files under /opt/stream. You can execute:
# rocks create package /opt/stream stream |
This will create a package named stream-1.0-1.x86_64.rpm
in the current working directory.
To see the contents of the package, execute:
# rpm -qlp stream-1.0-1.x86_64.rpm / /opt /opt/stream /opt/stream/bin /opt/stream/bin/stream /opt/stream/bin/stream_f /opt/stream/docs /opt/stream/docs/HISTORY.txt /opt/stream/docs/LICENSE.txt /opt/stream/docs/Makefile /opt/stream/docs/READ.ME /opt/stream/docs/ROCKS.txt /opt/stream/docs/linux.mk /opt/stream/docs/mysecond.c /opt/stream/docs/stream.c /opt/stream/docs/stream.f /opt/stream/docs/sunos.mk /opt/stream/docs/version.mk |
There are several more options you can supply to
"rocks create package"
(execute
"rocks create package help"
to see all the options).
Now place the RPM into the correct directory within the roll:
# mkdir -p /export/src/roll/valgrind/RPMS/x86_64 # cp stream-1.0-1.x86_64.rpm /export/src/roll/valgrind/RPMS/x86_64 |
The most common way we create RPMS is from source tarballs (the classic: untar, ./configure, make, make install). Rocks has a set of Makefile includes that greatly simplifies the creation of RPMs. Most software can be packaged as an RPM without ever seeing the internals of the package format.
First, we'll download the source tarball into the correct directory:
# cd /export/src/roll/valgrind/src/valgrind # wget http://valgrind.org/downloads/valgrind-3.6.0.tar.bz2 |
Edit version.mk
and change
NAME = test
to
NAME = valgrind
, change
TARBALL_POSTFIX = tgz
to
TARBALL_POSTFIX = tar.bz2
, change
PKGROOT = /opt/valgrind
to
PKGROOT = /opt
,and change
VERSION = 1.0
to
VERSION = 3.6.0
.
Your version.mk should look like:
PKGROOT = /opt NAME = valgrind VERSION = 3.6.0 RELEASE = 1 TARBALL_POSTFIX = tar.bz2 |
Edit Makefile
and change the line:
gunzip -c
to
bzcat
(since the tarball is a bz2).
Now build the RPM:
# make rpm |
It will take several minutes to build the package. When it completes, you'll see the line:
Wrote: /export/src/roll/valgrind/RPMS/x86_64/valgrind-3.6.0-1.x86_64.rpm |
You can inspect the contents of the valgrind
RPM:
# rpm -qlp /export/src/roll/valgrind/RPMS/x86_64/valgrind-3.6.0-1.x86_64.rpm / /opt /opt/valgrind /opt/valgrind/bin /opt/valgrind/bin/callgrind_annotate /opt/valgrind/bin/callgrind_control /opt/valgrind/bin/cg_annotate /opt/valgrind/bin/cg_diff /opt/valgrind/bin/cg_merge /opt/valgrind/bin/ms_print /opt/valgrind/bin/no_op_client_for_valgrind /opt/valgrind/bin/valgrind /opt/valgrind/bin/valgrind-listener /opt/valgrind/include /opt/valgrind/include/valgrind /opt/valgrind/include/valgrind/callgrind.h . . . |
Note that the valgrind-3.6.0-1.x86_64.rpm RPM was automatically placed into the correct directory (/export/src/roll/valgrind/RPMS/x86_64).
![]() | If you want to pass different |
The Rocks Makefile include structure is invoked from the sample Makefile in the lines.
-include $(ROCKSROOT)/etc/Rules.mk include Rules.mk |
The main purpose of this structure is to create the correct files so that the
rpmbuild
can work properly. The core of Rocks builds more
than 300 different packages, and our goal was to eliminate the creation
of custom RPM spec files. Spec files are the text files that drive the overall
package creation.
Let's look at the other directories created on demand when you type
make rpm
. The roll directory structure now looks like before:
. └── valgrind ├── graphs │ └── default ├── nodes └── src ├── usersguide │ └── images └── valgrind |
and AFTER make rpm
is executed.
└── valgrind ├── BUILD │ └── valgrind-3.6.0 ├── graphs │ └── default ├── nodes ├── RPMS │ ├── noarch │ └── x86_64 ├── SOURCES ├── SPECS ├── src │ ├── usersguide │ └── valgrind └── SRPMS |
The important directories are BUILD, SOURCES, SPECS, and RPMS
. This is the structure that rpmbuild is
expecting. It is worth looking at the contents of the directories in some detail.
SPECS/valgrind.spec - created automatically. Can create in the
src/valgrid with make valgrind.spec
SOURCES/valgrind-3.6.0.tar.gz - This is a tar of src/valgrind directory
after the make pretar
target (if present)
has been evaluated. This becomes the "source" referenced in the spec
file.
BUILD/valgrind-3.6.0 - this is where the actual build/compile takes place.
Let's take a look at the contents of the BUILD directory
BUILD └── valgrind-3.6.0 ├── _arch ├── _distribution ├── Makefile ├── _os ├── python.mk ├── rocks-version-common.mk ├── rocks-version.mk ├── Rules-install.mk ├── Rules-linux-centos.mk ├── Rules-linux.mk ├── Rules.mk ├── Rules-rcfiles.mk ├── Rules-scripts.mk ├── test-1.0.tgz ├── valgrind-3.6.0 ├── valgrind-3.6.0.tar.bz2 └── version.mk |
The Makefile
is the same file as
the src/valgrind
directory. The file
valgrind-3.6.0.tar.bz2
is also the same.
Ultimately, the program rpmbuild
must be called
to do its work. The generated spec file (valgrind.spec) is used to drive the
rpmbuild process. RPM spec files can be very complicated, Rocks takes a very
simple approach, essentially ignorning many of the advanced capabilities of
RPM specification.
What follows here is an abbreviated spec file. It's beyond this guide to describe in detail options in a spec file. A number of web resources are available if more in-depth information is desired.
Summary: valgrind Name: valgrind Version: 3.6.0 Release: 1 Source: valgrind-3.6.0.tar.gz Buildroot: /export/src/roll/valgrind/src/valgrind/valgrind.buildroot %description valgrind %prep %setup %build printf "\n\n\n### build ###\n\n\n" BUILDROOT=/export/src/roll/valgrind/src/valgrind/valgrind.buildroot make -f /export/src/roll/valgrind/src/valgrind/valgrind.spec.mk build %install printf "\n\n\n### install ###\n\n\n" BUILDROOT=/export/src/roll/valgrind/src/valgrind/valgrind.buildroot make -f /export/src/roll/valgrind/src/valgrind/valgrind.spec.mk install %files / |
The generated spec file must have %build
and
%install
sections to, respectively, build and install software. The concept is very simple, the %build
section of
the spec simply directs rpmbuild
to call
make build
.
The last section is %files
which takes "/" as the default.
This will package ALL files that have installed into the BUILDROOT directory.