Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/dns/dnsmasq-devel/files/update.py
18157 views
1
#!/usr/bin/env python3
2
"""update.py for dnsmasq-devel - (C) 2025 Matthias Andree, placed under MIT license
3
To use, edit Makefile with the new version,
4
then run files/update.py, which will download, check sigs, if GnuPG checks out, update makesum,
5
upload tarball and sig to my public_distfiles/ because upstream has low bandwidth, and test build.
6
7
If things work out, commit manually and push."""
8
9
import os
10
import shutil
11
import subprocess
12
import sys
13
14
def trace(func):
15
def wrapper(*args, **kwargs):
16
print(f"\n> {func.__name__}({args}, {kwargs})", file=sys.stderr)
17
retval = func(*args, **kwargs)
18
print(f"< {func.__name__} -> {retval!r}", file=sys.stderr)
19
return retval
20
return wrapper
21
22
traced_run = trace(subprocess.run)
23
24
cleanenv={'LC_ALL': 'C.UTF-8',
25
'PATH': os.environ["PATH"]}
26
defargs={"check": "True", "env": cleanenv, "encoding": 'UTF-8'}
27
28
try:
29
distdir, master_site, files_dir, dist_dir = map(str.strip, traced_run(['make', '-V', 'DISTDIR',
30
'-V', 'MASTER_SITES:N*FreeBSD*',
31
'-V', 'FILESDIR',
32
'-V', 'DISTDIR'],
33
capture_output=True, **defargs).stdout.splitlines())
34
filename_tarball = traced_run('make -V DISTFILES'.split(), capture_output=True, **defargs).stdout.splitlines()[0].strip()
35
filename_signature = filename_tarball + '.asc'
36
uri_tarball = master_site + filename_tarball
37
uri_signature = master_site + filename_signature
38
traced_run(['fetch', uri_tarball, uri_signature], **defargs)
39
traced_run(['gpg', '--no-options', '--with-colons', '--status-fd', '1',
40
'--no-default-keyring', '--keyring', files_dir + '/simon-kelley-keyring.asc',
41
'--verify', filename_signature, filename_tarball], **defargs)
42
traced_run(['rsync', '-avHPW', '--chmod=0644', filename_tarball, filename_signature, 'freefall.freebsd.org:public_distfiles/'], **defargs)
43
shutil.move(filename_tarball, dist_dir + '/' + filename_tarball)
44
traced_run(['make', 'makesum', 'clean'], **defargs)
45
os.remove(filename_signature)
46
traced_run(['make', 'check-plist', 'package'], **defargs)
47
print("\nSUCCESS\n")
48
except Exception as cpe:
49
print("\nERROR\n")
50
print(repr(cpe))
51
print("\nERROR\n")
52
sys.exit(1)
53
54