[projects/pld-ftp-admin] pfa-mvpkg, pfa-testmvpkg: load only the given packages

arekm arekm at pld-linux.org
Sat Nov 21 10:42:47 CET 2026


commit 6adcd8d7d07f746738cadf9770c682b53e9372de
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Nov 21 01:29:02 2026 +0100

    pfa-mvpkg, pfa-testmvpkg: load only the given packages
    
    A move read the .info of every package in the source tree, for the
    info:move mark that is gone. Now it reads those of the given packages
    and of the versions it removes or archives, all before it changes
    anything, as before: an unreadable one still stops it with every tree
    intact.

 bin/pfa-mvpkg      |  2 +-
 bin/pfa-testmvpkg  |  2 +-
 modules/ftptree.py | 49 +++++++++++++++++++++++++++----------------------
 3 files changed, 29 insertions(+), 24 deletions(-)
---
diff --git a/bin/pfa-mvpkg b/bin/pfa-mvpkg
index 1e971a7..62dcaba 100755
--- a/bin/pfa-mvpkg
+++ b/bin/pfa-mvpkg
@@ -51,7 +51,7 @@ try:
             print(f"ERR: {name} tree already locked{ftpio.locked_by()}", file=sys.stderr)
             sys.exit(1)
         locked.append(name)
-    srctree = ftptree.FtpTree(srcname, loadall = True)
+    srctree = ftptree.FtpTree(srcname)
     dsttree = ftptree.FtpTree(dstname)
     if archivetreename != None:
         archivetree = ftptree.FtpTree(archivetreename)
diff --git a/bin/pfa-testmvpkg b/bin/pfa-testmvpkg
index fa631d2..167f683 100755
--- a/bin/pfa-testmvpkg
+++ b/bin/pfa-testmvpkg
@@ -48,7 +48,7 @@ try:
             print(f"ERR: {name} tree already locked{ftpio.locked_by()}")
             sys.exit(1)
         locked.append(name)
-    srctree = ftptree.FtpTree(srcname, loadall = True)
+    srctree = ftptree.FtpTree(srcname)
     dsttree = ftptree.FtpTree(dstname)
     if archivetreename != None:
         archivetree = ftptree.FtpTree(archivetreename)
diff --git a/modules/ftptree.py b/modules/ftptree.py
index a13e381..2f7ee52 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -337,10 +337,9 @@ class FtpTree(BaseFtpTree):
         self.__checkforobsoletes(dsttree, self.marked4moving, test = True)
         self.__checkforrelease(dsttree, self.marked4moving, test = True)
 
-        if not self.treename.count("archive"):
-            self.__rmolderfromsrc(test = True)
-        if not dsttree.treename.count("archive"):
-            self.__rmotherfromdst(dsttree, test = True, archivetree = archivetree)
+        older, other = self.__toremove(dsttree)
+        self.__rmolderfromsrc(older, test = True)
+        self.__rmotherfromdst(other, test = True, archivetree = archivetree)
 
         for pkg in self.marked4moving:
             pkg.move(dsttree, test = True)
@@ -362,10 +361,9 @@ class FtpTree(BaseFtpTree):
         self.__checksigns(dsttree, self.marked4moving)
         bailoutonerror()
 
-        if not self.treename.count("archive"):
-            self.__rmolderfromsrc()
-        if not dsttree.treename.count("archive"):
-            self.__rmotherfromdst(dsttree, archivetree = archivetree)
+        older, other = self.__toremove(dsttree)
+        self.__rmolderfromsrc(older)
+        self.__rmotherfromdst(other, archivetree = archivetree)
 
         for pkg in self.marked4moving:
             pkg.move(dsttree)
@@ -532,20 +530,27 @@ class FtpTree(BaseFtpTree):
                     for path in Pkg(nvr, dsttree).missingfiles(archivetree):
                         pkg.error(f'missing {path}, so {nvr} cannot be archived')
 
-    def __rmolderfromsrc(self, test = False):
-        for pkg in self.marked4moving:
-            olderpkgnames = self.__find_older_pkgs(pkg)
-            for i in olderpkgnames:
-                Pkg(i, self).remove(test)
-
-    def __rmotherfromdst(self, dsttree, test = False, archivetree = None):
-        for pkg in self.marked4moving:
-            pkgnames = self.__find_other_pkgs(pkg, dsttree)
-            for i in pkgnames:
-                if archivetree == None:
-                    Pkg(i, dsttree).remove(test)
-                else:
-                    Pkg(i, dsttree).move(archivetree, test = test)
+    def __toremove(self, dsttree):
+        """
+        The older versions of marked pkgs here and their other versions in dsttree, which a move
+        removes or archives, all read first: an unreadable .info stops the move before it changes anything
+        """
+        older = [] if self.treename.count("archive") else [
+            self[nvr] for pkg in self.marked4moving for nvr in self.__find_older_pkgs(pkg)]
+        other = [] if dsttree.treename.count("archive") else [
+            dsttree[nvr] for pkg in self.marked4moving for nvr in self.__find_other_pkgs(pkg, dsttree)]
+        return older, other
+
+    def __rmolderfromsrc(self, older, test = False):
+        for pkg in older:
+            pkg.remove(test)
+
+    def __rmotherfromdst(self, other, test = False, archivetree = None):
+        for pkg in other:
+            if archivetree == None:
+                pkg.remove(test)
+            else:
+                pkg.move(archivetree, test = test)
 
     # Used more than once filter functions
     def __find_other_pkgs(self, pkg, tree):
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list