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