1RPM::Specfile(3)      User Contributed Perl Documentation     RPM::Specfile(3)
2
3
4

NAME

6       RPM::Specfile - Perl extension for creating RPM Specfiles
7

SYNOPSIS

9         use RPM::Specfile;
10

DESCRIPTION

12       This is a simple module for creation of RPM Spec files.  Most of the
13       methods in this module are the same name as the RPM Spec file element
14       they represent but in lower case.  Furthermore the the methods are
15       divided into two groups:
16
17       Simple Accessors
18           These methods have the have the exact name as the element they
19           represent (in lower case).  If passed no arguments return a scalar
20           representing the element.  If an argument is passed they will set
21           the value of the element.
22
23       List Accessors
24           These methods manipulate items in the spec file that are lists
25           (e.g. the list of patches maintained by the spec file).  Each
26           element that is represented by a list accessor will have at least
27           three methods associated with it.
28
29           ·       A method to directly manipulate individual members of the
30                   list.  These methods take as a first argument the index
31                   into the list, and as a second argument the element value.
32                   If no arguments are given it simply returns the list.  If
33                   only the index is given it returns the list member at that
34                   index.  If the value is also given it will set the list
35                   member associated with the index.
36
37           ·       A method to push a member onto the list.  Each of these
38                   methods have "push_" at the begining of their name.
39
40           ·       A method to clear the list.  Each of these methods have
41                   "clear_" at the begining of their name.
42

RPM SPEC FILE ORGANIZATION

44       This section describes the basic structure of an RPM Spec file and how
45       that applies to RPM::Specfile.  It does not attempt to give a full
46       description of RPM Spec file syntax.
47
48       RPM Spec files are divided into the following sections:
49
50       Preamble
51           This is where the meta information for the rpm is stored, such as
52           its name version and description.  Also, macro definitions are
53           generally put at the top of the preamble.  The methods that are
54           used to create this section are listed below:
55
56                   buildarch(), buildrequire(), buildrequires(), buildroot(),
57                   clear_buildrequire(), clear_changelog(), clear_patch(), clear_prefix(),
58                   clear_provide(), clear_require(), clear_source(), description(), distribution(),
59                   epoch(), group(), license(), macros(), name(), packager(), patch(), prefix(),
60                   provide(), push_buildrequire(), push_patch(), push_prefix(), push_provide(),
61                   push_require(), push_source(), release(), require(), requires(), source(),
62                   summary(), url(), vendor(), version()
63
64           Many of the elements of the Preamble are required.  See Maximum RPM
65           for documentation on which one are required and which ones are not.
66
67       Build Scriptlets
68           When rpms are built the install scriptlets are invoked.  These
69           install scriptlets are %prep, %build, %install, and %clean.  The
70           contents of these scripts can be set with the following methods:
71
72                   build(), clean(), install(), prep()
73
74           The %prep, %build, and %install scriptlets are required, but may be
75           null.
76
77       Install/Erase Scriplets
78           When an RPM is installed or erased various scriplets may be
79           invoked.  These scriplets can be set via the following methods:
80
81                   post(), postun(), pre(), preun()
82
83           The install scriptlets are not required.
84
85       Files
86           The %files section is used to define what files should be delivered
87           to the system.  It further defines what the permsisions and
88           ownership of the files should be.  The methods that work with the
89           %files sections are:
90
91                   file(), push_file(), clear_file(), file_param()
92
93           Note, a files section is required, but it may contain no entries.
94
95       Change Log
96           The last section in the spec file is the change log.  Methods to
97           modify this are:
98
99                   add_changelog_entry(), changelog(), push_changelog(), clear_changelog()
100
101   EXPORT
102       None by default.
103

METHODS

105       build
106           Not sure what this one does.
107
108       buildarch([$arch])
109           Returns the build arch.  If $arch is given will set build arch to
110           $arch.
111
112                   $spec->buildarch('noarch');
113
114       buildrequire([$index, $requirement])
115           Returns a list of build requirement entries.  If $index and
116           $requirement are provided, it will set the entry referenced by
117           $index to $requirement.
118
119                   @buildRequires = $spec->buildrequire();
120
121       buildrequires([$requirement])
122           Returns the build requires.  If $requirement is given, will set
123           build requires line to $requirement.
124
125                   $spec->buildrequires('noarch');
126
127       buildroot([$root])
128           Returns the build root (this is where rpm will build the package).
129           If $root is given, will set the build root to $root.
130
131                   $spec->buildroot('/tmp/%{name}-%{version}-%{release}');
132
133       clean([$scriptlet])
134           Returns the %clean scriptlet.  If $scriptlet is given, will make
135           the contents of $scriptlet the %clean scriptlet.
136
137                   $spec->clean('rm -rf $RPM_BUILD_ROOT');
138
139       changelog([$index, $entry])
140           Returns a list of changelog entries.  If $index and $entry are
141           provided it will set the entry referenced by $index to $entry.
142
143                   @entries = $spec->changelog();
144
145       clear_buildrequire()
146           Clears the build requirement list.
147
148                   $spec->clear_buildrequire();
149
150       clear_changelog()
151           Clears the list of changelog entries.
152
153                   $spec->clear_changelog();
154
155       clear_file()
156           Clears the file list.
157
158                   $spec->clear_file();
159
160       clear_patch()
161           Clears the patch list.
162
163                   $spec->clear_patch();
164
165       clear_prefix()
166           Clears the prefix list.
167
168                   $spec->clear_prefix();
169
170       clear_provide()
171           Clears the list of provisions.
172
173                   $spec->clear_provide();
174
175       clear_require()
176           Clears the requirements list.
177
178                   $spec->clear_require();
179
180       clear_source()
181           Clears the list of sources.
182
183                   $spec->clear_source();
184
185       description([$desc])
186           Returns the description of the rpm.  If $desc is given, sets the
187           description of the rpm.
188
189                   $spec->description('An automatically generated RPM');
190
191       distribution([$distro])
192           Returns the distribution of the rpm.  If $distro is given, sets the
193           distribution of the rpm.
194
195                   $spec->distribution('RedHat');
196
197       epoch([$epoch])
198           Returns the epoch of the rpm.  If $epoch is given sets the epoch of
199           the rpm to $epoch.
200
201                   $spec->epoch('0');
202
203       file([$index, $file])
204           Returns a list of %file entries.  If $index and $file are provided,
205           it will set the entry referenced by $index to $file.
206
207                   @files = $spec->file();
208
209       file_param([$param])
210           Returns the parameters to add to the %files macro invocation.  If
211           $param is given, $param will be appended to the %files macro.
212
213                   $spec->file_param('-f file_list');
214
215       group([$group])
216           Returns the group in which the rpm belongs.  If $group is given,
217           group will be set to $group.
218
219                   $spec->group("Development/Libraries");
220
221       install([$scriptlet])
222           Returns the %install scriptlet.  If $scriptlet is given, the
223           %install scriptlet will be set to this.
224
225                   $spec->group('mkdir -p $RPM_BUILD_ROOT/usr/local/mypkg');
226
227       license([$license])
228           Returns the type of license the rpm is will be released under.  If
229           $license is given, license will be set to $license.
230
231       macros([$macro_defs])
232           Returns the macro definitions that are before the preamble of the
233           specfile.  If $macro_defs is given, the macro definitions will be
234           set to it.
235
236                   $spec->macros("%define x 1\n%define y 2");
237
238       name([$name])
239           Returns the name of the rpm.  If $name is given, the name is set to
240           $name.
241
242                   $spec->name('perl-RPM-Specfile');
243
244       packager([$packager])
245           Returns the email address of the packager.  If $packager is set,
246           packager is set to $packager.
247
248                   $spec->packager('someone@some.where');
249
250       patch([$index, $patch])
251           Returns a list of patches.  If $index and $patch are provided it
252           will set the entry referenced by $index to $patch.
253
254                   @patches = $spec->patch();
255
256       post([$scriptlet])
257           Returns the contents of the %post scriptlet.  If $scriptlet is
258           given, %post is set to the value of $scriptlet.
259
260                   $spec->post("echo Running %%post...\nexit 0");
261
262       postun([$scriptlet])
263           Returns the contents of the %postun scriptlet.  If $scriptlet is
264           given, %postun is set to the value of $scriptlet.
265
266                   $spec->postun("echo Running %%postun...\nexit 0");
267
268       pre([$scriptlet])
269           Returns the contents of the %pre scriptlet.  If $scriptlet is
270           given, %pre is set to the value of $scriptlet.
271
272                   $spec->pre("echo Running %%pre...\nexit 0");
273
274       prefix([$index, $prefix])
275           Returns a list of prefix/relocation entries.  If $index and $prefix
276           are provided it will set the entry referenced by $index to $prefix.
277
278                   @prefixes = $spec->prefix();
279
280       preun([$scriptlet])
281           Returns the contents of the %preun scriptlet.  If $scriptlet is
282           given, %preun is set to the value of $scriptlet.
283
284                   $spec->preun("echo Running %%preun...\nexit 0");
285
286       prep([$scriptlet])
287           Returns the contents of the %prep scriptlet.  If $scriptlet is
288           given, %prep is set to the value of $scriptlet.
289
290                   $spec->prep("echo Running %%prep...\nexit 0");
291
292       provide([$index, $provision])
293           Returns a list of provision entries.  If $index and $provision are
294           provided it will set the entry referenced by $index to $provision.
295
296                   @provides = $spec->provide();
297
298       push_buildrequire([$entry])
299           Push a build requirement onto the list of build requirments.
300
301                   $spec->push_buildrequire('gcc >= 3.2');
302
303       push_changelog([$entry])
304           Pushes a changelog entry onto the list of changelog entries.
305
306       push_file([$entry])
307           Pushes a file onto the list of files.
308
309                   $spec->push_file('%attr(0664, root, root) %dir /usr/local/mypkg');
310                   $spec->push_file('%attr(0664, root, root) /usr/local/mypkg/myfile');
311
312       push_patch([$entry])
313           Pushes a patch onto the list of patches.
314
315                   $spec->push_patch('autorollback.patch');
316
317           Note, adding a patch implicitly adds entries to the %prep script.
318
319       push_prefix([$prefix])
320           Push a prefix onto to the list of valid relocations.
321
322                   $spec->clear_prefix('/usr/local/mypkg');
323
324       push_provide([$entry])
325           Pushes a provision onto the list of provisions.
326
327                   $spec->push_provide('kernel-tools = 2.6');
328
329       push_require([$entry])
330           Pushes a requirement onto the list of requirements.
331
332                   $spec->push_require('perl(RPM::Specfile)');
333
334       push_source([$entry])
335           Pushes a source entry onto the list of sources.
336
337                   $spec->push_source('wget-1.8.2.tar.gz');
338
339       release([$release])
340           Returns the release of the rpm.  If $release is specified, release
341           is set to $release.
342
343                   $spec->release('1.1');
344
345       require([$index, $requirement])
346           Returns a list of requirement entries.  If $index and $requirement
347           are provided it will set the entry referenced by $index to
348           $requirement.
349
350                   @requires = $spec->require();
351
352       requires([$requires])
353           Returns the value of the Requires line.  If $requires is set, the
354           Requires line will be set to $requires.
355
356                   $spec->requires('xdelta > 0:1.1.3-11, vlock > 0:1.3-13');
357
358       source([$index, $source])
359           Returns a list of source entries.  If $index and $source are
360           provided it will set the entry referenced by $index to $source.
361
362                   @sources = $spec->source();
363
364       summary([$summary])
365           Returns the value of the Summary line.  If $summary is set, the
366           Summary line will be set to $summary.
367
368       url([$url])
369           Returns the url of the rpm.  If $usr is set, the url is set to
370           $url.
371
372                   $spec->url('http://www.cpan.org');
373
374       vendor([$vendor])
375           Returns the vendor of the rpm.  If $vendor is set, the vendor is
376           set to $vendor.
377
378                   $spec->vendor('Perfect Distro, Inc.');
379
380       version([$version])
381           Returns the version of the rpm.  If $version is set, the version is
382           set to $version.
383
384       new Constructor of an RPM::Specfile object.
385
386                   $spec = RPM::Specfile->new();
387
388       add_changelog_entry($who, $entry, $version)
389           Adds an entry to the change log.  $who should be set to something
390           like:
391
392                   your name<your_email@somewhere.com>
393
394           $entry is the list of changes, and $version is the version to which
395           the change log applies.
396
397                   $spec->add_changelog('John Smith <jsmith@smiths.com>',
398                           '- Added a great bit of functionality',
399                           '1.0');
400
401           This method will automatically generate the time of the entry.
402
403       generate_specfile()
404           Generates the specfile and returns it as a scalar.
405
406       write_specfile($file)
407           Writes specfile to $file.
408

NOTE

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

AUTHOR

414       Chip Turner <cturner@pattern.net>
415

LICENSE

417       This module is distributed under the same terms as Perl itself:
418
419       http://dev.perl.org/licenses/
420

SEE ALSO

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

POD ERRORS

425       Hey! The above document had some coding errors, which are explained
426       below:
427
428       Around line 379:
429           '=item' outside of any '=over'
430
431       Around line 727:
432           You forgot a '=back' before '=head1'
433
434
435
436perl v5.32.0                      2020-07-28                  RPM::Specfile(3)
Impressum