git: 076249c79910 - main - dns/dnsmasq-devel: Revise files/update.py script.

From: Matthias Andree <mandree_at_FreeBSD.org>
Date: Wed, 28 May 2025 08:41:49 UTC
The branch main has been updated by mandree:

URL: https://cgit.FreeBSD.org/ports/commit/?id=076249c799105fe08a1a2a090be5104e897ae3b4

commit 076249c799105fe08a1a2a090be5104e897ae3b4
Author:     Matthias Andree <mandree@FreeBSD.org>
AuthorDate: 2025-05-28 08:41:24 +0000
Commit:     Matthias Andree <mandree@FreeBSD.org>
CommitDate: 2025-05-28 08:41:48 +0000

    dns/dnsmasq-devel: Revise files/update.py script.
---
 dns/dnsmasq-devel/files/update.py | 41 ++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/dns/dnsmasq-devel/files/update.py b/dns/dnsmasq-devel/files/update.py
index 5657cd9bc06d..df81cdd3880b 100755
--- a/dns/dnsmasq-devel/files/update.py
+++ b/dns/dnsmasq-devel/files/update.py
@@ -1,13 +1,11 @@
 #!/usr/bin/env python3
 """update.py for dnsmasq-devel - (C) 2025 Matthias Andree, placed under MIT license
-To use, edit Makefile with the new version and possibly URLBASE below when switching to release-candidates,
-then run python update.py, which will download, check sigs, if GnuPG checks out, update makesum,
+To use, edit Makefile with the new version,
+then run files/update.py, which will download, check sigs, if GnuPG checks out, update makesum,
 upload tarball and sig to my public_distfiles/ because upstream has low bandwidth, and test build.
 
 If things work out, commit manually and push."""
 
-URLBASE = 'https://www.thekelleys.org.uk/dnsmasq/test-releases/'
-
 import os
 import shutil
 import subprocess
@@ -15,25 +13,28 @@ import sys
 
 def trace(func):
     def wrapper(*args, **kwargs):
-        print(f"> {func.__name__}({args}, {kwargs})", file=sys.stderr)
+        print(f"\n> {func.__name__}({args}, {kwargs})", file=sys.stderr)
         retval = func(*args, **kwargs)
         print(f"< {func.__name__} -> {retval!r}", file=sys.stderr)
         return retval
     return wrapper
 
-subprocess.run = trace(subprocess.run)
+traced_run = trace(subprocess.run)
+
+cleanenv={'LC_ALL': 'C.UTF-8',
+          'PATH': os.environ["PATH"]}
+defargs={"check": "True", "env": cleanenv, "encoding": 'UTF-8'}
 
-completed_distname = subprocess.run('make -V DISTNAME'.split(), capture_output=True, check=True, env={"LC_ALL": "C.UTF-8", "PATH": f'{os.environ["PATH"]}'}, encoding='UTF-8')
-name = completed_distname.stdout.splitlines()[0].strip()
-fnt = name + '.tar.xz'
-fns = fnt + '.asc'
-urt = URLBASE + fnt
-urs = URLBASE + fns
-subprocess.run(['fetch', urt, urs], check=True)
-subprocess.run(['gpg', '--verify', fns, fnt], check=True)
-subprocess.run(['rsync', '-avHP', '--chmod=0644', fnt, fns, 'freefall.freebsd.org:public_distfiles/'], check=True)
-shutil.move(fnt, '/usr/ports/distfiles/' + fnt)
-os.remove(fns)
-subprocess.run(['make', 'makesum'], check=True)
-subprocess.run(['make', 'clean'], check=True)
-subprocess.run(['make', 'check-plist', 'package'], check=True)
+distdir, master_site = map(str.strip, traced_run(['make', '-V', 'DISTDIR', '-V', 'MASTER_SITES:N*FreeBSD*'], capture_output=True, **defargs).stdout.splitlines())
+filename_tarball = traced_run('make -V DISTFILES'.split(), capture_output=True, **defargs).stdout.splitlines()[0].strip()
+filename_signature = filename_tarball + '.asc'
+uri_tarball = master_site + filename_tarball
+uri_signature = master_site + filename_signature
+traced_run(['fetch', uri_tarball, uri_signature], **defargs)
+traced_run(['gpg', '--verify', filename_signature, filename_tarball], **defargs)
+traced_run(['rsync', '-avHPW', '--chmod=0644', filename_tarball, filename_signature, 'freefall.freebsd.org:public_distfiles/'], **defargs)
+shutil.move(filename_tarball, '/usr/ports/distfiles/' + filename_tarball)
+os.remove(filename_signature)
+traced_run(['make', 'makesum', 'clean'], **defargs)
+traced_run(['make', 'check-plist', 'package'], **defargs)
+print("\nSUCCESS\n")