Skip to content

Commit 5a89bed

Browse files
fanquakedongcarl
andcommitted
contrib: address gen-manpages feedback from bitcoin#24263
Co-authored-by: Carl Dong <contact@carldong.me>
1 parent 2618fb8 commit 5a89bed

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

contrib/devtools/gen-manpages.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
# Verify that all the required binaries are usable, and extract copyright
3434
# message in a first pass.
35-
copyright = None
3635
versions = []
3736
for relpath in BINARIES:
3837
abspath = os.path.join(builddir, relpath)
@@ -42,32 +41,31 @@
4241
print(f'{abspath} not found or not an executable', file=sys.stderr)
4342
sys.exit(1)
4443
# take first line (which must contain version)
45-
verstr = r.stdout.split('\n')[0]
44+
verstr = r.stdout.splitlines()[0]
4645
# last word of line is the actual version e.g. v22.99.0-5c6b3d5b3508
4746
verstr = verstr.split()[-1]
4847
assert verstr.startswith('v')
48+
# remaining lines are copyright
49+
copyright = r.stdout.split('\n')[1:]
50+
assert copyright[0].startswith('Copyright (C)')
4951

50-
# Only bitcoin-qt prints the copyright message on --version, so store it specifically.
51-
if relpath == 'src/qt/bitcoin-qt':
52-
copyright = r.stdout.split('\n')[1:]
52+
versions.append((abspath, verstr, copyright))
5353

54-
versions.append((abspath, verstr))
55-
56-
if any(verstr.endswith('-dirty') for (_, verstr) in versions):
54+
if any(verstr.endswith('-dirty') for (_, verstr, _) in versions):
5755
print("WARNING: Binaries were built from a dirty tree.")
5856
print('man pages generated from dirty binaries should NOT be committed.')
5957
print('To properly generate man pages, please commit your changes (or discard them), rebuild, then run this script again.')
6058
print()
6159

6260
with tempfile.NamedTemporaryFile('w', suffix='.h2m') as footer:
6361
# Create copyright footer, and write it to a temporary include file.
64-
assert copyright
62+
# Copyright is the same for all binaries, so just use the first.
6563
footer.write('[COPYRIGHT]\n')
66-
footer.write('\n'.join(copyright).strip())
64+
footer.write('\n'.join(versions[0][2]).strip())
6765
footer.flush()
6866

6967
# Call the binaries through help2man to produce a manual page for each of them.
70-
for (abspath, verstr) in versions:
68+
for (abspath, verstr, _) in versions:
7169
outname = os.path.join(mandir, os.path.basename(abspath) + '.1')
7270
print(f'Generating {outname}…')
7371
subprocess.run([help2man, '-N', '--version-string=' + verstr, '--include=' + footer.name, '-o', outname, abspath], check=True)

0 commit comments

Comments
 (0)