[projects/pld-ftp-admin] pfa-checksign: check the signatures in parallel

arekm arekm at pld-linux.org
Thu Oct 29 09:18:11 CET 2026


commit 16c6c5f2d4269aef64813afc632c36b5ce242afa
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Wed Oct 28 22:53:07 2026 +0100

    pfa-checksign: check the signatures in parallel
    
    pfa-checksign read the header of each file in turn, with a new rpm
    transaction set per file: 13 s for 6020 files here. It now reads them
    with read_rpms(), as pfa-signpkg and the move checks do: 0.4 s.
    A missing file no longer stops the check with a traceback: it counts as
    not signed.
    
    is_signed() has no user left and goes.

 bin/pfa-checksign | 11 +++++------
 modules/sign.py   | 24 ++++--------------------
 2 files changed, 9 insertions(+), 26 deletions(-)
---
diff --git a/bin/pfa-checksign b/bin/pfa-checksign
index 3e83f94..3e3b112 100755
--- a/bin/pfa-checksign
+++ b/bin/pfa-checksign
@@ -17,7 +17,6 @@ import ftpio
 import ftptree
 from common import checkdir
 from config import sign_key
-from sign import is_signed
 
 if sign_key == None:
     print("ERR: sign_key not defined in config", file=sys.stderr)
@@ -46,12 +45,12 @@ finally:
     ftpio.unlock(treename)
 
 print(f"Checking signatures of {len(tree.loadedpkgs)} packages")
-sign = []
+files = [file for pkg in tree.marked4moving for file in pkg.rpmfiles()]
+# a missing file counts as not signed
+signed = {file: info is not None and bool(info.signed)
+          for file, info in zip(files, ftptree.read_rpms(files), strict=True)}
 for pkg in tree.marked4moving:
-    unsigned = 0
-    for file in pkg.rpmfiles():
-        if not is_signed(file):
-            unsigned += 1
+    unsigned = sum(not signed[file] for file in pkg.rpmfiles())
 
     if unsigned != 0:
         print(f'{pkg.nvr}: {unsigned} files NOT signed')
diff --git a/modules/sign.py b/modules/sign.py
index b93c8b3..9e1a90b 100644
--- a/modules/sign.py
+++ b/modules/sign.py
@@ -25,27 +25,11 @@ def getSigInfo(hdr):
         return ''
     return fields[2].lstrip()
 
-def is_signed(rpm_file):
-    """Returns rpm information is package signed by the same key"""
-    # http://code.activestate.com/recipes/306705/
-
-    if sign_key == None:
-        return None
-
-    ts = rpm.ts()
-    ts.setVSFlags(rpm.RPMVSF_NODSAHEADER)
-    fdno = os.open(rpm_file, os.O_RDONLY)
-    try:
-        hdr = ts.hdrFromFdno(fdno)
-    except rpm.error:
-        hdr = None
-    finally:
-        os.close(fdno)
-
-    return signed_by_key(hdr)
-
 def signed_by_key(hdr):
-    """is_signed() of a header already read, given as None when rpm refused to read it"""
+    """Is the package of hdr signed by sign_key: None when it is not signed or no sign_key is set
+
+    hdr is None when rpm refused to read it.
+    """
     if sign_key == None:
         return None
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-ftp-admin.git/commitdiff/16c6c5f2d4269aef64813afc632c36b5ce242afa



More information about the pld-cvs-commit mailing list