Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
129 lines (73 sloc) 2.88 KB


RPM::Spec - A very simplistic read-only method of accessing RPM spec files


use RPM::Spec;

my $spec = RPM::Spec->new('path/to/my.spec');

say 'Version is: ' . $spec->version;
say 'Spec has an epoch' if $spec->has_epoch;


WARNING: This code is actively being worked on, and the API may change.

RPM::Spec provides simplistic access to the different bits of information a spec file provides... It is basically a collection of different parsing routines that were scattered through a bunch of other modules.


  • new(specfile => [Str|File])

Create a new RPM::Specfile object. The only required parameter is 'specfile', which is either a string or Path::Class::File object pointing to the location of the specfile.


Tag Functions

These methods each return the value of the given tag. If the tag is not present, undef is returned.

  • license

  • epoch

  • release

  • version

  • source0

Note this will pick up from either of "Source" or "Source0" tags.

  • name

  • url

  • summary

  • middle

The "middle" of a spec; e.g. everything from the first %description until the changelog starts.

Dependency Functions

Documentation as this interface is likely to change in the Very Near Future.

Content Functions

  • content()

Returns an array of strings representing the specfile.

  • has_content

Is the file empty?

  • num_lines_in_content

Returns the line count of the specfile.

  • grep_content(sub { ... })

Given a coderef, greps through the content with it. See also grep.


No macro parsing

Macros are not evaluated. e.g., if "Release: 1%{?dist}" is in your spec file, "1%{?dist}" will be returned by release().

Read only!

We can't make any changes.




Please report problems to Chris Weyl, or (preferred) to this package's RT tracker at

Patches are welcome.


Chris Weyl


Copyright (c) 2009 Chris Weyl

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the

Free Software Foundation, Inc.
59 Temple Place, Suite 330
Boston, MA  02111-1307  USA