| RPM-Tools documentation | view source | Contained in the RPM-Tools distribution. |
RPM::Make - cleanly generate an RPM
use RPM::Make;
# The "Manifest": list of files that will comprise the software package.
my @filelist=('tmproot/file1.txt',
'tmproot/file2.txt',
'tmproot/file3.txt',
'tmproot/file4.txt');
my %doc; my %conf; my %confnoreplace; my %metadata;
# Define special handling of files.
$doc{'tmproot/file1.txt'}=1;
$conf{'tmproot/file2.txt'}=1;
$confnoreplace{'tmproot/file3.txt'}=1;
# Bare minimum metadata (descriptive data of the software package).
my $pathprefix='tmproot'; # Location of files to be included in package.
my $tag='Test'; # Default name of the software package.
my $version='0.1'; # Version number.
my $release='1'; # Release number (versions can have multiple releases).
# Highly descriptive metadata.
%metadata=(
'vendor'=>'Excellence in Perl Laboratory',
'summary'=>'Test Software Package',
'name'=>$tag,
'copyrightname'=>'...',
'group'=>'Utilities/System',
'AutoReqProv'=>'no',
'requires'=>[('PreReq: setup',
'PreReq: passwd',
'PreReq: util-linux'
)],
'description'=>'This package is generated by RPM::Make. '.
'This implements the '.$tag.' software package',
'pre'=>'echo "You are installing a package built by RPM::Make; '.
'RPM::Make is available at http://www.cpan.org/."',
);
# Temporary "sandbox" (this should not be /tmp because this is deleted!).
my $buildloc='TempBuildLoc';
# The "execute" subroutine coordinates all of the RPM building steps.
RPM::Make::execute($tag,$version,$release,$arch,$buildloc,$pathprefix,
\@filelist,\%doc,\%conf,\%confnoreplace,
\%metadata);
# You can also build an RPM in more atomic steps; these three smaller
# steps are equivalent to the execute command.
# Step 1: Generate the rpm source location.
RPM::Make::rpmsrc($tag,$version,$release,$buildloc,$pathprefix,
\@filelist,\%doc,\%conf,\%confnoreplace,
\%metadata);
# Step 2: Build the rpm and copy into the invoking directory.
RPM::Make::compilerpm($buildloc,$metadata{'name'},$version,
$release,$arch,
$currentdir,$invokingdir);
# Step 3: Clean the location used to gather and build the rpm.
RPM::Make::cleanbuildloc($buildloc);
Check to see if RPM builder application is available.
n/a
n/a
If /usr/lib/rpm/rpmrc does not exist, then print error and exit.
To date, this testing action has been fully adequate, though imperfect.
Build the RPM in one clean sweep.
6 scalar strings, 1 array reference, and 4 hash references.
n/a
Errors are monitored by the other subroutines that are called.
First calls &rpmsrc, then &compilerpm, then &cleanbuildloc.
Properly assemble the RPM source location (prior to building).
5 scalar strings, 1 array reference, and 4 hash references.
n/a
$version, $release, and $buildloc variables need to have a string length greater than zero, else the module causes an exit(1).
$tag must only consist of alphanumeric characters and dash signs '-', else the module causes an exit(1).
Should be called before &compilerpm and &cleanbuildloc.
Properly assemble the RPM source location (prior to building).
7 scalar strings
n/a
If one "rpm" command syntax fails, then try another. If all "rpm" command syntaxes fail, then print error and exit.
If copying the built rpm fails, then print error and exit.
Should be called after &rpmsrc and before &cleanbuildloc.
Clean build location - usually TempBuildLoc (all the files normally associated with a *.src.rpm file).
1 scalar string
n/a
If the input argument is empty, then abort. Also should abort if cannot remove the location specified by the input argument.
Should be called after &rpmsrc and after &compilerpm.
Recursively gather information from a directory. (Ideally, I would use the prune invocation of the find command, however older versions of 'find' do not have prune (< 4.1.7). Therefore, the work-around is to use maxdepth 0.)
1 scalar string.
n/a
If $file_system_location is neither a directory, or softlink, or regular file, then abort.
Called by &rpmsrc.
Automatically generate an RPM software package from a list of files.
RPM::Make builds the RPM in a very clean and configurable fashion. (Finally! Making RPMs outside of /usr/src/redhat without a zillion file intermediates left over!)
RPM::Make should work with both rpm 3.x and rpm 4.x (it has been tested on redhat 6.x, redhat 7.x, and redhat 8.x as well as other un*x variants).
RPM::Make generates and then deletes temporary files needed to build an RPM with. It works cleanly and independently from pre-existing directory trees such as /usr/src/redhat/*.
RPM::Make accepts five kinds of information, three of which are significant:
When using RPM::Make::execute, a temporary directory named $buildloc is
The RPM will typically be named "$metadata{'name'}-$version-$release.i386.rpm". If $metadata{'name'} is not specified, then $tag is used.
Here are some of the items that are generated inside the $buildloc directory during the construction of an RPM:
The final output of RPM::Make::execute is a binary .rpm file. The ./buildloc directory is deleted (along with the .src.rpm file). The typical file name generated by RPM::Make is $tag-$version-$release.i386.rpm.
RPM::Make is compatible with either rpm version 3.* or rpm version 4.*.
Automatically generate an RPM software package from a list of files.
RPM::Make builds the RPM in a very clean and configurable fashion without using /usr/src/redhat or any other filesystem dependencies.
RPM::Make generates and then deletes temporary files (and binary root directory tree) to build an RPM with.
RPM::Make was originally based on a script "make_rpm.pl" available at http://www.cpan.org/scripts/.
This script requires the strict module.
Scott Harrison sharrison@users.sourceforge.net
Please let me know how/if you are finding this module useful and any/all suggestions. -Scott
Written by Scott Harrison, sharrison@users.sourceforge.net.
Copyright Michigan State University Board of Trustees
This file is part of the LearningOnline Network with CAPA (LON-CAPA).
This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
The GNU Public License is available for review at http://www.gnu.org/copyleft/gpl.html.
For information on the LON-CAPA project, please visit http://www.lon-capa.org/.
This module is new. It is based on a well-tested (and well-used) script that I wrote (make_rpm.pl; available at http://www.cpan.org/scripts/).
Linux
| RPM-Tools documentation | view source | Contained in the RPM-Tools distribution. |