-
Notifications
You must be signed in to change notification settings - Fork 0
/
bs-update.1
484 lines (481 loc) · 8.93 KB
/
bs-update.1
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
.\" This document is in the public domain.
.\" vim: fdm=marker
.
.\" FRONT MATTER {{{
.Dd Jul 16, 2012
.Os
.Dt BS-UPDATE 1
.
.Sh NAME
.Nm bs-update
.Nd Update packages in a Build Service from upstream sources.
.\" FRONT MATTER }}}
.
.\" SYNOPSIS {{{
.Sh SYNOPSIS
.Nm
.Fl h
.Nm
.Op Fl A Ar BSAPI
.Oo Fl B Ar BUILDARGS Oc Ns ...
.Op Fl C
.Op Fl P Ar PROJECT
.Op Fl b
.Op Fl d Ar URL
.Op Fl m Ar COMMITMSG
.Op Fl n
.Op Fl p Ar PACKAGE
.Oo Fl s Ar SPECFILE Oc Ns ...
.Op Fl t Ar TARBALL
.Ar TAG
.Op Ar VERSION
.\" SYNOPSIS }}}
.
.\" DESCRIPTION {{{
.Sh DESCRIPTION
.Nm
makes it easier to keep packages in a Build Service
up-to-date with respect to their upstream sources.
.
.Pp
.
Given a Build Service API URL, project and package names, a tarball
URL, and a version number,
.Nm
will
.
.Pp
.
.Bl -enum -compact
.It
figure out the target version from operands and the optional
.Fn bsu_version_hook ,
.It
check out the package from the Build Service into a temporary directory,
.It
fetch the tarball from the URL,
.It
update the tarball source with the downloaded tarball,
after possible modification by the optional
.Fn bsu_tarball_hook ,
.It
update package descriptions (specfile, PKGBUILD, etc) from their
templates extracted from the tarball or provided by the optional
.Fn bsu_specfile_hook ,
.It
.Pq optionally
build the package locally,
.It
.Pq optionally
commit the changes.
.El
.
.Pp
.
.Nm
aborts on failure in any step.
.
.Ss Options
All options beside
.Fl h
have their configuration variable counterparts.
See the
.Sx FILES
section for more information.
.
.Bl -tag -width "xx"
.It Fl h
Display a usage description.
.
.It Fl A Ar BSAPI
Use Build Service at
.Ar BSAPI
(URL or alias).
Passed to
.Xr osc 1 .
.
.It Fl B Ar BUILDARGS
Use
.Ar BUILDARGS
.Pq after field splitting
as arguments to
.Nm osc Cm build
.Pq see Fl b .
May be given more than once,
each instance yields a separate
.Nm osc Cm build .
.
.It Fl C
Skip the
.Nm osc Cm commit
step.
.
.It Fl P Ar PROJECT
Update Build Service package of
.Ar PROJECT .
.
.It Fl b
Run
.Nm osc Cm build
before
.Nm osc Cm commit .
If the build fails,
.Nm
aborts.
See
.Va $bsu_osc_build .
.
.It Fl d Ar URL
Retrieve the source tarball from
.Ar URL .
If
.Ar URL
is
.Dq \&. ,
.Nm
uses
.Xr git-archive 1
or
.Xr hg-archive 1
in
.Ev PWD
as appropriate.
Otherwise,
.Nm
uses
.Xr wget 1 .
.
.It Fl m Ar COMMITMSG
Use
.Ar COMMITMSG
for the commit in Build Service.
Defaults to
.Dq Update to version Ar VERSION .
.
.It Fl n
Report values derived from
configuration files and command line arguments, then exit.
.
.It Fl p Ar PACKAGE
Update Build Service
.Ar PACKAGE .
.
.It Fl s Ar SPECFILE
Use
.Ar SPECFILE Ns Li .in
from
.Ar TARBALL ,
commit
.Ar SPECFILE
into the Build Service.
All occurrences of
.Li __VERSION__
in
.Ar SPECFILE
are replaced with
.Ar VERSION .
.Ar SPECFILE
can be a real
.Li .spec
file (RPM) or a
.Pa PKGBUILD
file (ArchLinux).
May be given more than once, all files are processed.
.
.It Fl t Ar TARBALL
Use
.Ar TARBALL
for the name of the downloaded file.
.El
.
.Ss Operands
.
.Bl -tag -width "xx"
.
.It Ar TAG
Update the package from
.Ar TAG .
Substituted for
.Ev $bsu_tag
in values derived from command line
options and configuration files.
.
.It Ar VERSION
Update the package to
.Ar VERSION .
.
If
.Ar VERSION
is not given, it is generated using
.Fn bsu_version_hook
if it exists, otherwise
from
.Ar TAG
by stripping the initial
.Dq Li v
if any.
Substituted for
.Ev $bsu_version
in values derived from command line
options and configuration files.
.El
.
.Ss Hooks
.
.Nm
allows tailoring the update process through shell functions,
see the
.Sx FILES
section for more information.
.
.\" DESCRIPTION }}}
.\" .Sh IMPLEMENTATION NOTES
.\" ENVIRONMENT {{{
.Sh ENVIRONMENT
.Nm
itself does not use any environment variables.
It is, however, implemented in terms of third-party commands
which
.Em do
use them.
This means
.Nm
may be influenced by environment variables used by
.Xr git 1 ,
.Xr hg 1 ,
.Xr osc 1 ,
.Xr tar 1 ,
.Xr wget 1 ,
.Xr zsh 1 ,
possibly others.
.\" ENVIRONMENT }}}
.\" FILES {{{
.Sh FILES
.Nm
recognizes two optional configuration files,
.Pa .bs-update-hooks
and
.Pa .bs-update .
They are read, in order, from the current directory before
command line arguments are processed.
Either file may define any of hooks and/or configuration
variables, last definition wins.
.
.Pp
.
Each configuration variable has a corresponding command line option.
Command line options and arguments take precedence over configuration
files. Resulting values are subject to shell parameter expansion.
.
.Pp
.
Syntactically, the configuration files are limited shell scripts
recognizing two kinds of statements: parameter assignments, and
function definitions.
.
.Ss Shell Functions (Hooks)
. Bl -ohang
. It Fn bsu_specfile_hook
If this function exists, it is responsible for providing a
. Va $s Ns .in
file for each
. Va $s
in
. Va $bsu_specfiles .
.Nm
will invoke it with arguments consisting of
.Va $bsu_version ,
.Va $bsu_tag ,
.Va $bsu_tarball
and
.Va $bsu_specfiles .
.
. It Fn bsu_tarball_hook
The tarball may need finalization before it is checked into
the Build Service, eg.
.Nm autoconf ,
.Nm git
submodules
or
.Nm npm .
If this function exists it is executed in the root of the checked out
package, with the tarball name in the first argument.
.
. It Fn bsu_version_hook
If the
.Ar VERSION
argument is not given and this function exists it is executed with
.Ar $1
set to the value of the
.Ar TAG
argument, and its output is used as the final version string.
. El
.Ss Variables
. Bl -tag -compact -width "x"
. It Va bsu_bs_apiurl Pq Fl A
. It Va bsu_bs_commit Pq Fl C
. It Va bsu_bs_commitmsg Pq Fl m
. It Va bsu_bs_package Pq Fl p
. It Va bsu_bs_project Pq Fl P
. It Va bsu_dloadurl Pq Fl d
. It Va bsu_dryrun Pq Fl n
. It Va bsu_specfiles Pq Fl s
. It Va bsu_tarball Pq Fl t
. It Va bsu_test_build Pq Fl b
. It Va bsu_osc_build Pq Fl B
Array of strings where each item is used
.Pq after field splitting
as arguments to
.Nm osc Cm build
.Pq see Fl b .
. El
.\" FILES }}}
.\" EXAMPLES {{{
.Sh EXAMPLES
.
.Ss Interactive Use by Upstream Maintainer
.
This is a real-world example showing common
.Pa .bs-update
setup and the use of
.Nm
to test changes in the package and finally produce
a new package version.
It assumes the user maintains both the upstream software
and its package in the Build Service.
.Pp
We need a working copy to hack on:
.
.Bd -literal -offset 2n
git clone git@github.com:roman-neuhauser/bs-update.git
cd bs-update
.Ed
.
.Pp
Since we're going to use
.Nm
repeatedly, it makes sense to employ a configuration file,
.Pa .bs-update .
Everything can still be overridden using options on the command line:
.
.Bd -literal -offset 2n
cat > .bs-update
usr=roman-neuhauser
pkg=bs-update
bsu_bs_apiurl=https://api.opensuse.org
bsu_bs_package='$pkg'
bsu_bs_project='home:$usr'
bsu_dloadurl='https://github.com/$usr/$pkg/tarball/$bsu_tag'
bsu_osc_build=(
'ArchLinux x86_64 PKGBUILD'
'SLE_12 x86_64 $pkg.spec'
'openSUSE_Tumbleweed x86_64 $pkg.spec'
)
^D
.Ed
.
.Pp
Commit some changes:
.
.Bd -literal -offset 2n
vim bs-update.in
make check
git commit bs-update.in
.Ed
.
.Pp
Build the package locally, using the currently checked out revision.
Does not commit into the Build Service:
.
.Bd -literal -offset 2n
bs-update -Cbd . HEAD
.Ed
.
.Pp
If it was ok we can tag it and publish the tag:
.
.Bd -literal -offset 2n
git tag -a v42.69
git push origin master v42.69
.Ed
.
.Pp
Commit the new release into the Build Service:
.
.Bd -literal -offset 2n
bs-update v42.69
.Ed
.
.Ss Snapshot-generating Cronjob
.
This example demonstrates using
.Fn bsu_tarball_hook
to generate snapshot tarballs of a Git branch.
A new version of the package is created, based on a tarball
of the upstream master branch.
.
.Bd -literal -offset 2n
mkdir /snapshots
cat > /snapshots/.bs-update-hooks <<'EOF'
bsu_tarball_hook()
(
set -e
local tarball=./${1?}
local dir=${tarball%.tar.gz}
mkdir $dir
tar -xzf $tarball --strip-components=1 -C $dir
tar -czf $tarball -- ${dir#./}
rm -rf $dir
)
EOF
cat > /etc/cron.weekly/mk-snapshot <<'EOF'
#!/bin/sh
set -eu
ts=$(date +%Y%m%d%H%M%S)
cd /snapshots
bs-update \\
-P home:roman-neuhauser \\
-p bs-update-snapshot \\
-d https://github.com/roman-neuhauser/bs-update/tarball/master \\
-t bs-update-$ts.tar.gz \\
master $ts
EOF
chmod a+x /etc/cron.weekly/mk-snapshot
.Ed
.\" EXAMPLES }}}
.\" DIAGNOSTICS {{{
.Sh DIAGNOSTICS
.Nm
exits with
.Li 0
on success, and with
.Li >0
otherwise.
.\" DIAGNOSTICS }}}
.\" .Sh COMPATIBILITY
.\" SEE ALSO {{{
.Sh SEE ALSO
.Xr git 1 ,
the openSUSE Build Service
.Aq https://build.opensuse.org/ ,
and its wiki
.Aq http://en.opensuse.org/Portal:Build_Service .
.\" SEE ALSO }}}
.\" .Sh STANDARDS
.\" .Sh HISTORY
.\" AUTHORS {{{
.Sh AUTHORS
.
.Nm
and this manual page are written by
.An Roman Neuhauser Aq Mt neuhauser@sigpipe.cz .
.Pp
See
.Lk https://github.com/roman-neuhauser/bs-update/ .
.\" AUTHORS }}}
.\" BUGS {{{
.Sh BUGS
No doubt plentiful.
Please report them at
.Lk https://github.com/roman-neuhauser/bs-update/issues .
.\" BUGS }}}