NAME

RPM::Make - cleanly generate an RPM

SYNOPSIS

    use RPM::Make;

    my @filelist=('tmproot/file1.txt',
		  'tmproot/file2.txt',
		  'tmproot/file3.txt',
		  'tmproot/file4.txt');

    my %doc; my %conf; my %confnoreplace; my %metadata;

    $doc{'tmproot/file1.txt'}=1;
    $conf{'tmproot/file2.txt'}=1;
    $confnoreplace{'tmproot/file3.txt'}=1;

    my $pathprefix='tmproot';
    my $tag='Test';
    my $version='0.1';
    my $release='1';

    %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/."',
 	       );

    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);

SUBROUTINES

RPM::Make::testsystem()

Check to see if RPM builder application is available

INPUT

n/a

OUTPUT

n/a

ERROR

if /usr/lib/rpm/rpmrc does not exist, print error and exit

NOTE

To date, this testing action has been fully adequate, though imperfect.

RPM::Make::execute($tag,$version,$release,$arch,$buildloc,$pathprefix,\@filelist,\%doc,\%conf,\%confnoreplace,\%metadata);

Build the RPM in one clean sweep.

INPUT

5 scalar strings, 1 array reference, and 4 hash references

OUTPUT

n/a

ERROR

n/a (specific to the other subroutines that are called)

NOTE

First calls &rpmsrc, then &compilerpm, then &cleanbuildloc.

RPM::Make::rpmsrc($tag,$version,$release,$buildloc,$pathprefix,\@filelist,\%doc,\%conf,\%confnoreplace,\%metadata);

Properly assemble the RPM source location (prior to building)

INPUT

5 scalar strings, 1 array reference, and 4 hash references

OUTPUT

n/a

ERROR

$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, else the module causes an exit(1).

NOTE

Should be called before &compilerpm and &cleanbuildloc.

RPM::Make::compilerpm($buildloc,$name,$version,$release,$arch,$currentdir,$invokingdir);

Properly assemble the RPM source location (prior to building)

INPUT

8 scalar strings

OUTPUT

n/a

ERROR

If the rpm -ba command fails when sent to the system execution shell, then print an error notice and exit(1).

NOTE

Should be called after &rpmsrc and before &cleanbuildloc.

RPM::Make::cleanbuildloc($buildloc);

Clean build location - usually TempBuildLoc (all the files normally associated with a *.src.rpm file).

INPUT

1 scalar string

OUTPUT

n/a

ERROR

If the rpm -ba command fails when sent to the system execution shell, then print an error notice and exit(1).

NOTE

Should be called after &rpmsrc and before &cleanbuildloc.

RPM::Make::find_info($file_system_location);

Recursively gather information from a directory

INPUT

1 scalar string

OUTPUT

n/a

ERROR

If $file_system_location is neither a directory, or softlink, or regular file, then abort.

NOTE

Called by &rpmsrc.

DESCRIPTION

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 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:

  • (significant) a list of files that are to be part of the software package;

  • (significant) the filesystem location of these files

  • (significant) a descriptive tag and a version tag for the naming of the RPM software package;

  • documentation and configuration files;

  • and additional metadata associated with the RPM software package.

When using RPM::Make::execute, a temporary directory named $buildloc is

  • generated under the directory from which you run your script.

  • then deleted after the *.rpm file is generated.

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 are generated inside the $buildloc directory during the construction of an RPM:

  • RPM .spec file (./$buildloc/SPECS/$name-$version.spec)

  • RPM Makefile (./$buildloc/SOURCES/$name-$version/Makefile)

    This is the Makefile that is called by the rpm command in building the .i386.rpm from the .src.rpm. The following directories are generated and/or used:

    • SOURCE directory: ./$buildloc/BinaryRoot/

    • TARGET directory: ./$buildloc/BuildRoot/

  • BinaryRootMakefile (./$buildloc/BinaryRootMakefile)

    This is the Makefile that this script creates and calls to build the $buildloc/BinaryRoot/ directory from the existing filesystem. The following directories are generated and/or used:

    • SOURCE directory: / (your entire filesystem)

    • TARGET directory: ./$buildloc/BinaryRoot/

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.*.

README

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/.

PREREQUISITES

This script requires the strict module.

AUTHOR

Scott Harrison
sharrison@users.sourceforge.net

Please let me know how/if you are finding this module useful and any/all suggestions. -Scott

LICENSE

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/.

STATUS

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/).

OSNAMES

Linux

6 POD Errors

The following errors were encountered while parsing the POD:

Around line 136:

You forgot a '=back' before '=head2'

Around line 178:

You forgot a '=back' before '=head2'

Around line 448:

You forgot a '=back' before '=head2'

Around line 520:

You forgot a '=back' before '=head2'

Around line 571:

You forgot a '=back' before '=head2'

Around line 620:

You forgot a '=back' before '=head1'