RPM::Specfile(3)
π RPM::Specfile(3) π
bestie, welcome to the User Contributed Perl Documentation for RPM::Specfile, and this is part 1. More parts are coming, so don't go anywhere. π
β¨ NAME β¨
RPM::Specfile β a Perl extension for creating RPM Specfiles. That's the whole main character energy right there. π
π¦ SYNOPSIS π¦
okay so you load it like this:
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 methods are divided into two groups:
π Simple Accessors π
These methods have the exact name as the element they represent (in lower case). If passed no arguments, they return a scalar representing the element. If an argument is passed, they will set the value of the element. So like, no args = read, one arg = write. Iconic. β¨
π 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. So flexible, lowkey obsessed. π
- A method to push a member onto the list. Each of these methods have
push_at the beginning of their name. - A method to clear the list. Each of these methods have
clear_at the beginning 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. Just the vibes, not the whole encyclopedia. π
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. So like, go check that if you need the required tea. π«
π οΈ 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. No cap. π―
π§ 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. So if you don't need them, you don't need them, bestie. π
π Files π
The %files section is used to define what files should be delivered to the system. It further defines what the permissions 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. So required but can be empty? The way that works is giving required but optional energy. π
π 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. Periodt. π
part 2 is all the methods, and it's long. Stay tuned. π₯
β¨ METHODS β¨
okay bestie, this is the big one β every single method this module gives you. buckle up, we're going through all of them π
πΈ build
Not sure what this one does. That's it. That's the whole description. The original docs literally say this. iconic honestly π«Ά
π¦ buildarch([$arch])
Gives you back the build arch. If you hand it $arch, it sets the build arch to $arch. slay.
$spec->buildarch('noarch');
π buildrequire([$index, $requirement])
Returns a list of build requirement entries. If you pass both $index and $requirement, it sets the entry referenced by $index to $requirement. bestie behaviour fr fr.
@buildRequires = $spec->buildrequire();
β buildrequires([$requirement])
Returns the build requires. Give it $requirement and it will set the build requires line to $requirement. no cap.
$spec->buildrequires('noarch');
π§ buildroot([$root])
Returns the build root β that's where rpm will build the package, iykyk. Pass $root and it sets the build root to $root.
$spec->buildroot('/tmp/%{name}-%{version}-%{release}');
π clean([$scriptlet])
Returns the %clean scriptlet. Pass $scriptlet and the contents of $scriptlet become the %clean scriptlet. periodt.
$spec->clean('rm -rf $RPM_BUILD_ROOT');
π changelog([$index, $entry])
Returns a list of changelog entries. Give it $index and $entry and it sets the entry referenced by $index to $entry.
@entries = $spec->changelog();
π
clear_buildrequire()
Clears the build requirement list. so satisfying honestly.
$spec->clear_buildrequire();
π
clear_changelog()
Clears the list of changelog entries. bye bye history β¨
$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 you give it $desc, it sets the description of the rpm. main character energy for your package π
$spec->description('An automatically generated RPM');
πΈ distribution([$distro])
Returns the distribution of the rpm. If $distro is given, it sets the distribution of the rpm.
$spec->distribution('RedHat');
β epoch([$epoch])
Returns the epoch of the rpm. If $epoch is given it 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 sets 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 gets appended to the %files macro.
$spec->file_param('-f file_list');
π group([$group])
Returns the group the rpm belongs to. If $group is given, group gets set to $group.
$spec->group("Development/Libraries");
π§ install([$scriptlet])
Returns the %install scriptlet. If $scriptlet is given, the %install scriptlet gets set to it.
$spec->group('mkdir -p $RPM_BUILD_ROOT/usr/local/mypkg');
okay so β yes, this example callsgroup, notinstall. That's literally what the docs say. not me editing the original, we just report it π
π license([$license])
Returns the type of license the rpm is going to be released under. If $license is given, license gets set to $license. (no example here, the docs just vibe.)
π macros([$macro_defs])
Returns the macro definitions that sit before the preamble of the specfile. If $macro_defs is given, the macro definitions get 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 gets set to $name.
$spec->name('perl-RPM-Specfile');
π packager([$packager])
Returns the email address of the packager. If $packager is set, packager gets set to $packager.
$spec->packager('someone@some.where');
π patch([$index, $patch])
Returns a list of patches. If $index and $patch are provided it sets the entry referenced by $index to $patch.
@patches = $spec->patch();
π₯ post([$scriptlet])
Returns the contents of the %post scriptlet. If $scriptlet is given, %post gets 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 gets 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 gets 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 sets the entry referenced by $index to $prefix.
@prefixes = $spec->prefix();
π₯ preun([$scriptlet])
Returns the contents of the %preun scriptlet. If $scriptlet is given, %preun gets 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 gets 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 sets the entry referenced by $index to $provision.
@provides = $spec->provide();
β push_buildrequire([$entry])
Pushes a build requirement onto the list of build requirments. (yes, "requirments" β we don't touch the spelling, bestie π«Ά)
$spec->push_buildrequire('gcc >= 3.2');
π push_changelog([$entry])
Pushes a changelog entry onto the list of changelog entries. (no example for this one in the docs, she's mysterious like that π )
π§ 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');
heads up bestie: adding a patch implicitly adds entries to the %prep script. noted. π₯
π push_prefix([$prefix])
Pushes a prefix onto the list of valid relocations.
$spec->clear_prefix('/usr/local/mypkg');
and yes β the example underpush_prefixcallsclear_prefix. that is verbatim what the original says. we simply report, we do not judge π
π 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 gets set to $release.
$spec->release('1.1');
π₯ require([$index, $requirement])
Returns a list of requirement entries. If $index and $requirement are provided it sets 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 gets 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 sets 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 gets set to $summary.
π url([$url])
Returns the url of the rpm. If $usr is set, the url gets set to $url. (yes, $usr β that's the original's typo and we keep it fr fr.)
$spec->url('http://www.cpan.org');
π§ vendor([$vendor])
Returns the vendor of the rpm. If $vendor is set, the vendor gets set to $vendor.
$spec->vendor('Perfect Distro, Inc.');
π version([$version])
Returns the version of the rpm. If $version is set, the version gets set to $version.
π new
Constructor of an RPM::Specfile object. the birth of a legend β¨
$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. so convenient, we love her π
π generate_specfile()
Generates the specfile and returns it as a scalar. one call, whole specfile, iconic.
π 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. go look, bestie π
π AUTHOR
Chip Turner <cturner@pattern.net>
π LICENSE
This module is distributed under the same terms as Perl itself:
π SEE ALSO
perl cpanflute2 Maximum RPM (http://www.rpm.org/max-rpm/)
π POD ERRORS
Hey! The above document had some coding errors, which are explained below:
- Around line 379:
'=item' outside of any '=over'
- Around line 727:
- You forgot a
'=back'before a'=head1'
- You forgot a
and that's a wrap bestie π this page came to you from perl v5.42.0, dated 2025-07-25, and it's page RPM::Specfile(3) of your friendly neighbourhood manual. go forth and generate specfiles, you absolute icon πβ¨π¦
π¦ where this page comes from
- fedora 43: perl-RPM-Specfile 1.51-51.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms