-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgear-rules.5.in
More file actions
657 lines (657 loc) · 16 KB
/
gear-rules.5.in
File metadata and controls
657 lines (657 loc) · 16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
.\" Copyright (C) 2007 Sergey Vlasov <vsu@altlinux.org>
.\" Copyright (C) 2007-2017 Dmitry V. Levin <ldv@altlinux.org>
.\" Copyright (C) 2008-2021 Alexey Gladkov <legion@altlinux.org>
.\" Copyright (C) 2020 Vladimir D. Seleznev <vseleznv@altlinux.org>
.\"
.\" Documentation for the .gear-rules file format.
.\"
.\" This file is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program 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 General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
.
.TH "GEAR-RULES" "5" "March 2017" "gear @VERSION@" "File Formats"
.SH NAME
gear\-rules \- rule file for gear
.
.
.SH DESCRIPTION
.
The rule file specifies actions of
.BR gear (1)
required to extract source files from the package repository.
.
.
.SH FORMAT
.
A rule file consists of 0 or more lines of the following format:
.RS 4
.PP
.IB directive\^ :
.IR arguments ...
.RE
.
.PP
Empty lines and lines beginning with \*(lq#\*(rq are ignored.
Directive arguments are delimited by whitespace characters.
Whitespaces between the directive name and \*(lq:\*(rq are optional;
whitespaces between \*(lq:\*(rq and the first argument are also optional.
Arguments may contain special characters quoted using shell-alike quoting.
There is no support for line continuation.
.
.
.SH PATHS
.
Unless specified otherwise, all paths used in the rule file are
relative to the
.I main tree,
which is a subtree of the
.I main commit
specified by the
.B \-t
option to
.BR gear (1).
Paths are not allowed to contain \*(lq..\*(rq, and therefore can refer
only to objects inside the main tree.
.PP
However, some directives can accept a
.IR tree_path ,
which can be either a plain path relative to the main tree, or a path
with an explicit base tree specification:
.RS 4
.PP
.IB base_tree\^ : \^path_in_tree
.RE
.PP
The
.I base_tree
part can be in one of the following forms:
.RS 2
.IP \(en 2
A single period character \*(lq.\*(rq specifies the main tree.
In most cases just omitting the \*(lq\fIbase_tree\^\fB:\fR\*(rq part
gives the same effect; adding \*(lq.:\*(rq explicitly is required only
if the
.I path_in_tree
part itself contains the \*(lq:\*(rq character.
.IP \(en
A full
.SM SHA-1
object name of a commit (40 hex characters) specifies the root tree of
that commit.
The specified commit must be an ancestor of the main commit.
.IP \(en
A name of a tag listed in the tag list specifies the root tree of the
commit pointed to by the specified tag (directly or indirectly through
a chain of tag objects).
The specified commit must be an ancestor of the main commit, and all
tag objects in the chain must be stored in the tag directory.
.RE
.PP
The restrictions on references to other commits ensure that a correct
git repository which contains the main commit also contains everything
which is required to extract source files from the repository.
.
.
.SH KEYWORDS
.
Arguments of some directives can contain keywords in the
.BI @ keyword @
format, which are replaced by real values before use.
Values for keywords can be obtained from the main spec file or from
other arguments of the same directive.
.PP
The following keywords are available in all directives which perform
keyword replacement:
.TP 12
.B @name@
Package name extracted from spec file.
.TP
.B @version@
Package version extracted from spec file.
.TP
.B @release@
Package release extracted from spec file.
.PP
Other keywords are specific to each directive.
.
.
.SH DIRECTIVES
.
.TP
.BI "spec: " path_to_file
Specify path of the main spec file within the main tree.
This directive may be omitted if the main spec file is the only file in
the main tree which matches the
.B *.spec
glob pattern; in this case
.BR gear (1)
can find the spec file automatically.
.
.TP
.BI "tags: " path_to_directory
Specify another path of the directory with the list of named tags and
stored tag objects instead of
.BR .gear\-tags " and " .gear/tags .
.
.TP
.BI "type: " spec_type
Specify the type of the spec file instead of an unspecified default.
This information is saved in the volume header of the output tar archive
produced by
.BR gear (1).
.TP
.BI "copy: " glob_pattern\fR...
Copy files matching the specified glob patterns to the output
directory, except files which match any of glob patterns specified by
.B exclude
directives.
Every
.I glob_pattern
must match at least one file in the main tree.
.IP
Glob patterns specified in this directive may contain multiple directory
components separated by \*(lq/\*(rq.
Wildcards are interpreted only in the last component of the pattern.
.
.TP
.BI "gzip: " glob_pattern\fR...
.PD 0
.TP
.BI "bzip2: " glob_pattern\fR...
.TP
.BI "lzma: " glob_pattern\fR...
.TP
.BI "xz: " glob_pattern\fR...
.TP
.BI "zstd: " glob_pattern\fR...
.PD
Like
.BR copy ,
but additionally compress the copied files with
.BR gzip "(1), " bzip2 "(1), " lzma "(1), " xz "(1), or " zstd (1),
and add the appropriate suffix to the copied file name.
.
.TP
.BI "compress: " \fRtype=\fITYPE \ \fR[name=\fINAME\fR]\ \fR[\fIoptions\fR]\ --\ \fIglob_pattern\fR...
Like
.BR copy ,
but can additionally compress the copied files with
.I TYPE
method.
.RS
.TP
.BI type= TYPE
Specify compression method.
Supported values are: copy, bzip2, gzip, lzma, xz, and zstd.
.TP
.BI name= <NAME>
Specify destination file name in output directory. In this case
.I glob_pattern
should match only one file.
.RE
.IP
All methods except copy accept compress options.
.
.TP
.BI "copy?: " glob_pattern\fR...
.PD 0
.TP
.BI "gzip?: " glob_pattern\fR...
.TP
.BI "bzip2?: " glob_pattern\fR...
.TP
.BI "lzma?: " glob_pattern\fR...
.TP
.BI "xz?: " glob_pattern\fR...
.TP
.BI "zstd?: " glob_pattern\fR...
.TP
.BI "compress?: " \fRtype=\fITYPE \ \fR[name=\fINAME\fR]\ \fR[\fIoptions\fR]\ --\ \fIglob_pattern\fR...
.PD
Like the corresponding directives without \*(lq?\*(rq, but unmatched
patterns are ignored instead of causing errors.
.
.TP
.BI "exclude: " glob_pattern\fR...
Ignore files matching the specified glob patterns in all
.BR copy -like
directives.
Affects all directives in the rule file irrespective of the order.
Specifying a glob pattern which does not match any files in the tree
is not an error.
.IP
When copying files from subdirectories of the main tree, the whole path
including the subdirectory name is matched against exclude patterns.
The \*(lq/\*(rq characters in the path are not treated as special and
can be matched by wildcards.
.
.TP
.BI "tar: " "tree_path " \fR[ options \fR...]
Create a
.BR tar (1)
archive of the tree specified by
.IR tree_path .
The specified tree must exist.
.IP
Valid options are:
.RS
.TP
.BI spec= path_to_file
Use another file instead of the main spec file to define keyword values.
.TP
.BI name= archive_name
Set name of the tar archive.
The
.B .tar
suffix is added automatically unless another suffix is specified by
the
.B suffix
option.
.IP
The default value of this option is
.BR @dir@\-@version@ ,
unless the
path part of
.I tree_path
is \*(lq.\*(rq, in which case the default is
.BR @name@\-@version@ .
.TP
.BI base= base_name
Add
.I base_name
as a leading path to all files in the generated archive.
If this option is not specified, by default the archive name without
the suffix (set by the
.B name
option) is used.
.TP
.BI suffix= suffix
Add
.I suffix
to the archive file name instead of the default
.B .tar
suffix.
.TP
.BI exclude= glob_pattern
All files matching the
.I glob_pattern
are excluded from the generated tar file.
This option can be specified multiple times.
The
.I glob_pattern
syntax is described in
.I glob
section of
.IR /usr/share/doc/git/user-manual.html .
.RE
.IP
Values of the
.B name
and
.B base
options and
.I tree_path
can contain keywords.
In addition to the common keywords, the following keyword is supported:
.RS
.TP
.B @dir@
Expands to
.RI basename(path( tree_path )).
Not allowed when
.RI path( tree_path )
is \*(lq.\*(rq and must not be used in the path part of
.IR tree_path .
.RE
.
.TP
.BI "tar.gz: " "tree_path " \fR[ options \fR...]
.PD 0
.TP
.BI "tar.bz2: " "tree_path " \fR[ options \fR...]
.TP
.BI "tar.lzma: " "tree_path " \fR[ options \fR...]
.TP
.BI "tar.xz: " "tree_path " \fR[ options \fR...]
.TP
.BI "tar.zst: " "tree_path " \fR[ options \fR...]
.PD
Like
.BR tar ,
but additionally compress the generated tar archive with
.BR gzip "(1), " bzip2 "(1), " lzma "(1), " xz "(1), or " zstd (1),
and add the appropriate suffix to the archive file name (unless the
.B suffix
option is specified, which overrides both the
.B .tar
part and the suffix for the compression method).
.
.TP
.BI "zip: " "tree_path " \fR[ options \fR...]
Like
.BR tar ,
but create a
.BR zip (1)
archive instead of
.BR tar (1)
and add the
.B .zip
suffix to the archive file name instead of
.BR .tar .
.
.TP
.BI "tar?: " "tree_path " \fR[ options \fR...]
.PD 0
.TP
.BI "tar.gz?: " "tree_path " \fR[ options \fR...]
.TP
.BI "tar.bz2?: " "tree_path " \fR[ options \fR...]
.TP
.BI "tar.lzma?: " "tree_path " \fR[ options \fR...]
.TP
.BI "tar.xz?: " "tree_path " \fR[ options \fR...]
.TP
.BI "tar.zst?: " "tree_path " \fR[ options \fR...]
.TP
.BI "zip?: " "tree_path " \fR[ options \fR...]
.PD
Like the corresponding directives without \*(lq?\*(rq, but do not fail
if the path specified in
.I tree_path
is not present in the tree.
However, if
.I tree_path
specifies a non-default base tree, this tree still must be valid.
.
.TP
.BI "diff: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
Create a diff in the unified format between trees specified by
.I old_tree_path
and
.IR new_tree_path .
Both trees must exist.
.IP
Valid options are:
.RS
.TP
.BI spec= path_to_file
Use another file instead of the main spec file to define keyword values.
.TP
.BI name= diff_name
Set name of the generated diff file.
The
.B .patch
suffix must be specified explicitly if required.
.IP
The default name is
.BR @new_dir@\-@version@\-@release@.patch ,
unless the path part of
.I new_tree_path
is \*(lq.\*(rq, in which case the default is
.BR @name@\-@version@\-@release@.patch .
.TP
.BI exclude= glob_pattern
All files matching the
.I glob_pattern
are excluded from the generated tar file.
This option can be specified multiple times.
The
.I glob_pattern
syntax is described in
.I glob
section of
.IR /usr/share/doc/git/user-manual.html .
.RE
.IP
Value of the
.B name
option and the base tree components of
.I old_tree_path
and
.I new_tree_path
can contain keywords.
In addition to the common keywords, the following keywords are
supported:
.RS
.TP
.B @old_dir@
Expands to
.RI basename(path( old_tree_path )).
Not allowed when
.RI path( old_tree_path )
is \*(lq.\*(rq.
.TP
.B @new_dir@
Expands to
.RI basename(path( new_tree_path )).
Not allowed when
.RI path( new_tree_path )
is \*(lq.\*(rq.
.RE
.
.TP
.BI "diff.gz: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.PD 0
.TP
.BI "diff.bz2: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.TP
.BI "diff.lzma: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.TP
.BI "diff.xz: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.TP
.BI "diff.zst: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.PD
Like
.BR diff ,
but additionally compress the generated diff file with
.BR gzip "(1), " bzip2 "(1), " lzma "(1), " xz "(1), or " zstd (1),
and add the appropriate suffix to the diff file name.
.
.TP
.BI "diff?: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.PD 0
.TP
.BI "diff.gz?: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.TP
.BI "diff.bz2?: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.TP
.BI "diff.lzma?: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.TP
.BI "diff.xz?: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.TP
.BI "diff.zst?: " "old_tree_path new_tree_path \fR[\fIoptions\fR...]"
.PD
Like the corresponding directives without \*(lq?\*(rq, but do not fail
if paths specified by
.I old_tree_path
or
.I new_tree_path
are not present in the tree.
However, if
.I old_tree_path
or
.I new_tree_path
specify non-default base trees, these trees still must be valid.
.TP
.BI "specsubst: " variables...
Specify whitespace-separated list of variables that should be substituted
in specfile. Variable names may contain letters, digits and underscore
characters. For each
.I variable
every occurrence of
.I @variable@
in specfile is substituted with its value.
Values for these variables are obtained from the tag object passed to
.BR gear (1),
therefore a tag object is required when
.BR specsubst :
directive is used.
.
.
.SH SPECSUBST TAG FORMAT
A tag object may contain definitions for variables to be substituted during
.BR specsubst :
directive processing. These definitions have the following format:
.RS 4
.PP
.BR X-gear-specsubst :
.IR variable = value
.RE
.PP
Values are treated literally, there is no support of quoting
or line continuation.
.
.
.ne 5
.SH EXAMPLES
.
.SS "Archive with modified sources"
A simple rule file can contain just a single
.B tar
directive to archive everything in the tree:
.RS 4
.PP
.ft CW
.nf
tar: .
.fi
.ft R
.RE
.PP
If the project has a separate upstream, adding
.B @release@
to the archive name is recommended to make the name different from
upstream:
.RS 4
.PP
.ft CW
.nf
tar: . name=@name@\-@version@\-@release@
.fi
.ft R
.RE
.
.SS "Archive with unmodified sources and patch with local modifications"
If you prefer to create a tar archive with unmodified upstream sources
and a separate patch with local modifications, you need to create a
tag for the commit with upstream sources (or use the upstream tag if
upstream also uses git), specify the tag name in the rule file and
store this tag in the repository using
.BR gear\-store\-tags (1).
In this case the default archive name used by the
.B tar
directive should be correct, unless the package name or version format
is different from upstream.
.PP
Usually the tag name can be based on the package version:
.RS 4
.PP
.ft CW
.nf
tar: v@version@:.
diff: v@version@:. .
.fi
.ft R
.RE
.PP
(other tag naming conventions may be used, like
.B @name@\-@version@
or plain
.BR @version@ ).
However, if a prerelease version is packaged, parts like
\*(lqpreN\*(rq or \*(lqrcN\*(rq should not be included in the package
version, therefore the rule file will need some modifications for such
versions.
.PP
You may want to exclude
.I .gear
subdirectory and spec file from diff generation:
.RS 4
.PP
.ft CW
.nf
tar: v@version@:.
diff: v@version@:. . exclude=.gear/** exclude=*.spec
.fi
.RE
.PP
.
.SS "Archive with unmodified sources and separate patch files"
If you prefer to maintain patch files for local modifications instead
of committing modified source files to the git repository, you can
store unmodified upstream sources in a subdirectory of the main tree
and put patch files directly into the main tree:
.RS 4
.PP
.ft CW
.nf
tar: \fIpackage_name\fP
copy: *.patch
.fi
.ft R
.RE
.PP
This layout is used by
.BR gear\-srpmimport (1).
The
.BR gear\-update (1)
utility can be used to update sources stored in the git repository to
a new upstream release.
.PP
If you don't like lots of patch files cluttering the main tree, you can
move them into a subdirectory:
.RS 4
.PP
.ft CW
.nf
tar: \fIpackage_name\fP
copy: patches/*.patch
.fi
.ft R
.RE
.
.
.SH FILES
.TP
.BR .gear\-rules ", " .gear/rules
The list of file names where
.BR gear (1),
.BR gear\-commit (1),
.BR gear\-create\-tag (1),
.BR gear\-srpmimport (1)
and
.BR gear\-store\-tags (1)
expect to find rules (first non-empty file from this list is used),
unless another name is specified by the
.BI \-\-rules= filename
option.
.
.
.SH AUTHOR
.PP
This manual page written by Sergey Vlasov <vsu@altlinux.org>.
.PP
Authors and contributors of the programs included in the
.B gear
package are listed in the manual pages for these programs.
.
.
.SH SEE ALSO
.PP
.na
.nh
.tr -\(hy
.BR gear (1),
.BR gear\-srpmimport (1),
.BR gear\-update (1),
.BR gear\-store\-tags (1).