[projects/pld-ftp-admin] pfa-signpkg, pfa-checksign, pfa-lintpkg: find packages without marking them for a move

arekm arekm at pld-linux.org
Thu Nov 12 00:29:01 CET 2026


commit f0f51b4f65cdffd92042e4d10e359be0a751e080
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Wed Nov 11 23:26:47 2026 +0100

    pfa-signpkg, pfa-checksign, pfa-lintpkg: find packages without marking them for a move
    
    These tools move nothing, yet chose their packages with mark4moving()
    and read them back from the tree's list of packages to move.
    
    FtpTree.find() now gives the packages of the given names, with the
    same "not found" error; mark4moving() and mark4removal() mark what it
    finds. FtpTree.rpmfiles(), which listed the files of the packages to
    move, has no caller left and goes. No change in behaviour.

 bin/pfa-checksign  |  6 +++---
 bin/pfa-lintpkg    |  4 ++--
 bin/pfa-signpkg    |  3 +--
 modules/ftptree.py | 51 +++++++++++++++++++++++++--------------------------
 4 files changed, 31 insertions(+), 33 deletions(-)
---
diff --git a/bin/pfa-checksign b/bin/pfa-checksign
index 7076f28..faf0006 100755
--- a/bin/pfa-checksign
+++ b/bin/pfa-checksign
@@ -36,7 +36,7 @@ if not ftpio.lock(treename, True):
 try:
     # no packages given: all of the tree
     tree = ftptree.FtpTree(treename, loadall = not packages)
-    tree.mark4moving(packages or tree.loadedpkgs)
+    pkgs = tree.find(packages or tree.loadedpkgs)
 
 except ftptree.SomeError:
     sys.exit(1)
@@ -45,11 +45,11 @@ finally:
     ftpio.unlock(treename)
 
 print(f"Checking signatures of {len(tree.loadedpkgs)} packages")
-files = [file for pkg in tree.marked4moving for file in pkg.rpmfiles()]
+files = [file for pkg in pkgs 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:
+for pkg in pkgs:
     unsigned = sum(not signed[file] for file in pkg.rpmfiles())
 
     if unsigned != 0:
diff --git a/bin/pfa-lintpkg b/bin/pfa-lintpkg
index 6ea0327..e9ff8c0 100755
--- a/bin/pfa-lintpkg
+++ b/bin/pfa-lintpkg
@@ -51,8 +51,8 @@ if not ftpio.lock(treename, True):
 try:
     # no packages given: all of the tree
     tree = ftptree.FtpTree(treename, loadall = not packages)
-    tree.mark4moving(packages or tree.loadedpkgs)
-    files = tree.rpmfiles(debugfiles = debugfiles, sourcefiles = False)
+    files = [file for pkg in tree.find(packages or tree.loadedpkgs)
+             for file in pkg.rpmfiles(debugfiles = debugfiles, sourcefiles = False)]
 
 except (ftptree.SomeError, KeyboardInterrupt):
     sys.exit(1)
diff --git a/bin/pfa-signpkg b/bin/pfa-signpkg
index a086934..7785875 100755
--- a/bin/pfa-signpkg
+++ b/bin/pfa-signpkg
@@ -48,8 +48,7 @@ if not ftpio.lock(treename, True):
 try:
     # no packages given: all of the tree
     tree = ftptree.FtpTree(treename, loadall = not packages)
-    tree.mark4moving(packages or tree.loadedpkgs)
-    files = tree.rpmfiles()
+    files = [file for pkg in tree.find(packages or tree.loadedpkgs) for file in pkg.rpmfiles()]
 
 except ftptree.SomeError:
     sys.exit(1)
diff --git a/modules/ftptree.py b/modules/ftptree.py
index c065b51..d2e6281 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -375,12 +375,6 @@ class FtpTree(BaseFtpTree):
         for pkg in self.marked4moving:
             pkg.move(dsttree)
 
-    def rpmfiles(self, debugfiles = True, sourcefiles = True):
-        files = []
-        for pkg in self.marked4moving:
-            files += pkg.rpmfiles(debugfiles = debugfiles, sourcefiles = sourcefiles)
-        return files
-
     def removepkgs(self, checkbuild = True):
         if checkbuild:
             self.__checkbuild(self.marked4removal)
@@ -388,11 +382,34 @@ class FtpTree(BaseFtpTree):
         for pkg in self.marked4removal:
             pkg.remove()
 
+    def find(self, wannabepkgs):
+        """The packages of the given names, each once, in that order; raises SomeError when one is not in the tree"""
+        def chopoffextension(pkg):
+            found = pkg.find('.src.rpm')
+            if found == -1:
+                return pkg
+            else:
+                return pkg[:found]
+
+        pkgs = {}
+        for wannabepkg in wannabepkgs:
+            pkgname = chopoffextension(wannabepkg)
+            if pkgname in self.pkgnames:
+                if not pkgname in self.loadedpkgs:
+                    self.loadedpkgs[pkgname]=Pkg(pkgname, self)
+                pkgs[pkgname] = self.loadedpkgs[pkgname]
+            else:
+                perror(f'{pkgname} not found in source tree')
+        bailoutonerror()
+        return list(pkgs.values())
+
     def mark4removal(self, wannabepkgs):
-        self.__mark4something(wannabepkgs, Pkg.mark4removal)
+        for pkg in self.find(wannabepkgs):
+            pkg.mark4removal()
 
     def mark4moving(self, wannabepkgs):
-        self.__mark4something(wannabepkgs, Pkg.mark4moving)
+        for pkg in self.find(wannabepkgs):
+            pkg.mark4moving()
 
     # Internal functions below
     def __arch_stringify(self, list):
@@ -408,24 +425,6 @@ class FtpTree(BaseFtpTree):
         pkglist = list(filter(checkfiletype, os.listdir(self.basedir+'/SRPMS/.metadata')))
         self.pkgnames = [x[:-13] for x in pkglist]
 
-    def __mark4something(self, wannabepkgs, markfunction):
-        def chopoffextension(pkg):
-            found = pkg.find('.src.rpm')
-            if found == -1:
-                return pkg
-            else:
-                return pkg[:found]
-
-        for wannabepkg in wannabepkgs:
-            pkgname = chopoffextension(wannabepkg)
-            if pkgname in self.pkgnames:
-                if not pkgname in self.loadedpkgs:
-                    self.loadedpkgs[pkgname]=Pkg(pkgname, self)
-                markfunction(self.loadedpkgs[pkgname])
-            else:
-                perror(f'{pkgname} not found in source tree')
-        bailoutonerror()
-
     def __checkbuild(self, marked):
         """
         Checks queue file if all arches are built, and their files are in the tree
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list