Chip Turner > RPM-Specfile-1.51 > RPM::Specfile

Download:
RPM-Specfile-1.51.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  13
Open  0
View/Report Bugs
Module Version: 1.51   Source  

NAME ^

RPM::Specfile - Perl extension for creating RPM Specfiles

SYNOPSIS ^

  use RPM::Specfile;

DESCRIPTION ^

This is a simple module for creation of RPM Spec files. Most of the methods in this module are the same name as the RPM Spec file element they represent but in lower case. Furthermore the the methods are divided into two groups:

Simple Accessors

These methods have the have the exact name as the element they represent (in lower case). If passed no arguments return a scalar representing the element. If an argument is passed they will set the value of the element.

List Accessors

These methods manipulate items in the spec file that are lists (e.g. the list of patches maintained by the spec file). Each element that is represented by a list accessor will have at least three methods associated with it.

  • A method to directly manipulate individual members of the list. These methods take as a first argument the index into the list, and as a second argument the element value. If no arguments are given it simply returns the list. If only the index is given it returns the list member at that index. If the value is also given it will set the list member associated with the index.
  • A method to push a member onto the list. Each of these methods have push_ at the begining of their name.
  • A method to clear the list. Each of these methods have clear_ at the begining of their name.

RPM SPEC FILE ORGANIZATION ^

This section describes the basic structure of an RPM Spec file and how that applies to RPM::Specfile. It does not attempt to give a full description of RPM Spec file syntax.

RPM Spec files are divided into the following sections:

Preamble

This is where the meta information for the rpm is stored, such as its name version and description. Also, macro definitions are generally put at the top of the preamble. The methods that are used to create this section are listed below:

        buildarch(), buildrequire(), buildrequires(), buildroot(),
        clear_buildrequire(), clear_changelog(), clear_patch(), clear_prefix(),
        clear_provide(), clear_require(), clear_source(), description(), distribution(),
        epoch(), group(), license(), macros(), name(), packager(), patch(), prefix(),
        provide(), push_buildrequire(), push_patch(), push_prefix(), push_provide(),
        push_require(), push_source(), release(), require(), requires(), source(),
        summary(), url(), vendor(), version()

Many of the elements of the Preamble are required. See Maximum RPM for documentation on which one are required and which ones are not.

Build Scriptlets

When rpms are built the install scriptlets are invoked. These install scriptlets are %prep, %build, %install, and %clean. The contents of these scripts can be set with the following methods:

        build(), clean(), install(), prep()

The %prep, %build, and %install scriptlets are required, but may be null.

Install/Erase Scriplets

When an RPM is installed or erased various scriplets may be invoked. These scriplets can be set via the following methods:

        post(), postun(), pre(), preun()

The install scriptlets are not required.

Files

The %files section is used to define what files should be delivered to the system. It further defines what the permsisions and ownership of the files should be. The methods that work with the %files sections are:

        file(), push_file(), clear_file(), file_param()

Note, a files section is required, but it may contain no entries.

Change Log

The last section in the spec file is the change log. Methods to modify this are:

        add_changelog_entry(), changelog(), push_changelog(), clear_changelog()

EXPORT

None by default.

METHODS ^

build

Not sure what this one does.

buildarch([$arch])

Returns the build arch. If $arch is given will set build arch to $arch.

        $spec->buildarch('noarch');
buildrequire([$index, $requirement])

Returns a list of build requirement entries. If $index and $requirement are provided, it will set the entry referenced by $index to $requirement.

        @buildRequires = $spec->buildrequire();
buildrequires([$requirement])

Returns the build requires. If $requirement is given, will set build requires line to $requirement.

        $spec->buildrequires('noarch');
buildroot([$root])

Returns the build root (this is where rpm will build the package). If $root is given, will set the build root to $root.

        $spec->buildroot('/tmp/%{name}-%{version}-%{release}');
clean([$scriptlet])

Returns the %clean scriptlet. If $scriptlet is given, will make the contents of $scriptlet the %clean scriptlet.

        $spec->clean('rm -rf $RPM_BUILD_ROOT');
changelog([$index, $entry])

Returns a list of changelog entries. If $index and $entry are provided it will set the entry referenced by $index to $entry.

        @entries = $spec->changelog();
clear_buildrequire()

Clears the build requirement list.

        $spec->clear_buildrequire();
clear_changelog()

Clears the list of changelog entries.

        $spec->clear_changelog();
clear_file()

Clears the file list.

        $spec->clear_file();
clear_patch()

Clears the patch list.

        $spec->clear_patch();
clear_prefix()

Clears the prefix list.

        $spec->clear_prefix();
clear_provide()

Clears the list of provisions.

        $spec->clear_provide();
clear_require()

Clears the requirements list.

        $spec->clear_require();
clear_source()

Clears the list of sources.

        $spec->clear_source();
description([$desc])

Returns the description of the rpm. If $desc is given, sets the description of the rpm.

        $spec->description('An automatically generated RPM');
distribution([$distro])

Returns the distribution of the rpm. If $distro is given, sets the distribution of the rpm.

        $spec->distribution('RedHat');
epoch([$epoch])

Returns the epoch of the rpm. If $epoch is given sets the epoch of the rpm to $epoch.

        $spec->epoch('0');
file([$index, $file])

Returns a list of %file entries. If $index and $file are provided, it will set the entry referenced by $index to $file.

        @files = $spec->file();
file_param([$param])

Returns the parameters to add to the %files macro invocation. If $param is given, $param will be appended to the %files macro.

        $spec->file_param('-f file_list');
group([$group])

Returns the group in which the rpm belongs. If $group is given, group will be set to $group.

        $spec->group("Development/Libraries");
install([$scriptlet])

Returns the %install scriptlet. If $scriptlet is given, the %install scriptlet will be set to this.

        $spec->group('mkdir -p $RPM_BUILD_ROOT/usr/local/mypkg');
license([$license])

Returns the type of license the rpm is will be released under. If $license is given, license will be set to $license.

macros([$macro_defs])

Returns the macro definitions that are before the preamble of the specfile. If $macro_defs is given, the macro definitions will be set to it.

        $spec->macros("%define x 1\n%define y 2");
name([$name])

Returns the name of the rpm. If $name is given, the name is set to $name.

        $spec->name('perl-RPM-Specfile');
packager([$packager])

Returns the email address of the packager. If $packager is set, packager is set to $packager.

        $spec->packager('someone@some.where');
patch([$index, $patch])

Returns a list of patches. If $index and $patch are provided it will set the entry referenced by $index to $patch.

        @patches = $spec->patch();
post([$scriptlet])

Returns the contents of the %post scriptlet. If $scriptlet is given, %post is set to the value of $scriptlet.

        $spec->post("echo Running %%post...\nexit 0");
postun([$scriptlet])

Returns the contents of the %postun scriptlet. If $scriptlet is given, %postun is set to the value of $scriptlet.

        $spec->postun("echo Running %%postun...\nexit 0");
pre([$scriptlet])

Returns the contents of the %pre scriptlet. If $scriptlet is given, %pre is set to the value of $scriptlet.

        $spec->pre("echo Running %%pre...\nexit 0");
prefix([$index, $prefix])

Returns a list of prefix/relocation entries. If $index and $prefix are provided it will set the entry referenced by $index to $prefix.

        @prefixes = $spec->prefix();
preun([$scriptlet])

Returns the contents of the %preun scriptlet. If $scriptlet is given, %preun is set to the value of $scriptlet.

        $spec->preun("echo Running %%preun...\nexit 0");
prep([$scriptlet])

Returns the contents of the %prep scriptlet. If $scriptlet is given, %prep is set to the value of $scriptlet.

        $spec->prep("echo Running %%prep...\nexit 0");
provide([$index, $provision])

Returns a list of provision entries. If $index and $provision are provided it will set the entry referenced by $index to $provision.

        @provides = $spec->provide();
push_buildrequire([$entry])

Push a build requirement onto the list of build requirments.

        $spec->push_buildrequire('gcc >= 3.2');
push_changelog([$entry])

Pushes a changelog entry onto the list of changelog entries.

push_file([$entry])

Pushes a file onto the list of files.

        $spec->push_file('%attr(0664, root, root) %dir /usr/local/mypkg');
        $spec->push_file('%attr(0664, root, root) /usr/local/mypkg/myfile');
push_patch([$entry])

Pushes a patch onto the list of patches.

        $spec->push_patch('autorollback.patch');

Note, adding a patch implicitly adds entries to the %prep script.

push_prefix([$prefix])

Push a prefix onto to the list of valid relocations.

        $spec->clear_prefix('/usr/local/mypkg');
push_provide([$entry])

Pushes a provision onto the list of provisions.

        $spec->push_provide('kernel-tools = 2.6');
push_require([$entry])

Pushes a requirement onto the list of requirements.

        $spec->push_require('perl(RPM::Specfile)');
push_source([$entry])

Pushes a source entry onto the list of sources.

        $spec->push_source('wget-1.8.2.tar.gz');
release([$release])

Returns the release of the rpm. If $release is specified, release is set to $release.

        $spec->release('1.1');
require([$index, $requirement])

Returns a list of requirement entries. If $index and $requirement are provided it will set the entry referenced by $index to $requirement.

        @requires = $spec->require();
requires([$requires])

Returns the value of the Requires line. If $requires is set, the Requires line will be set to $requires.

        $spec->requires('xdelta > 0:1.1.3-11, vlock > 0:1.3-13');
source([$index, $source])

Returns a list of source entries. If $index and $source are provided it will set the entry referenced by $index to $source.

        @sources = $spec->source();
summary([$summary])

Returns the value of the Summary line. If $summary is set, the Summary line will be set to $summary.

url([$url])

Returns the url of the rpm. If $usr is set, the url is set to $url.

        $spec->url('http://www.cpan.org');
vendor([$vendor])

Returns the vendor of the rpm. If $vendor is set, the vendor is set to $vendor.

        $spec->vendor('Perfect Distro, Inc.');
version([$version])

Returns the version of the rpm. If $version is set, the version is set to $version.

new

Constructor of an RPM::Specfile object.

        $spec = RPM::Specfile->new();
add_changelog_entry($who, $entry, $version)

Adds an entry to the change log. $who should be set to something like:

        your name<your_email@somewhere.com>

$entry is the list of changes, and $version is the version to which the change log applies.

        $spec->add_changelog('John Smith <jsmith@smiths.com>',
                '- Added a great bit of functionality',
                '1.0');

This method will automatically generate the time of the entry.

generate_specfile()

Generates the specfile and returns it as a scalar.

write_specfile($file)

Writes specfile to $file.

NOTE ^

A good example of the use of RPM::Specfile is cpanflute2 which comes with the RPM::Specfile cpan archive.

AUTHOR ^

Chip Turner <cturner@pattern.net>

LICENSE ^

This module is distributed under the same terms as Perl itself:

http://dev.perl.org/licenses/

SEE ALSO ^

perl cpanflute2 Maximum RPM (http://www.rpm.org/max-rpm/)

syntax highlighting: