[projects/pld-ftp-admin] pfa-mvpkg, pfa-testmvpkg: refuse two builds of one package

arekm arekm at pld-linux.org
Sat Oct 31 14:45:55 CET 2026


commit 73c9d3d2a29f3bdcffdaf1716a65dd654b840cbe
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Oct 31 10:13:28 2026 +0100

    pfa-mvpkg, pfa-testmvpkg: refuse two builds of one package
    
    pfa-testmvpkg reports two builds of one package marked for moving as a
    duplicate, but pfa-mvpkg went ahead. It removed the older build from
    the source as an old version, removed the old version from the
    destination, and then failed with a traceback before moving anything:
    the destination lost its version and nothing came in its place.
    
    pfa-testmvpkg also skipped the check for an archive destination, yet a
    move from PLD to its archive still removes the older build from the
    source instead of archiving it.
    
    pfa-mvpkg now refuses such a move before anything is removed, and
    pfa-testmvpkg reports it, unless both trees are archives: then the
    move removes nothing.
    
    Two builds are found by name, as the move finds the other versions, so
    a pair rpm compares as equal, such as 1.0-1 and 1.0-01, counts too.

 modules/ftptree.py | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/modules/ftptree.py b/modules/ftptree.py
index bfe4058..97b079d 100644
--- a/modules/ftptree.py
+++ b/modules/ftptree.py
@@ -322,8 +322,7 @@ class FtpTree(BaseFtpTree):
     def testmove(self, dsttree, archivetree = None):
         self.__checkbuild(self.marked4moving)
         self.__checkarchs(dsttree, self.marked4moving)
-        if not dsttree.treename.count("archive"):
-            self.__checkduplicates(self.marked4moving)
+        self.__checkduplicates(dsttree, self.marked4moving)
 
         self.__checksigns(dsttree, self.marked4moving, test = True)
         self.__checkforobsoletes(dsttree, self.marked4moving, test = True)
@@ -345,6 +344,9 @@ class FtpTree(BaseFtpTree):
         self.__checkarchs(dsttree, self.marked4moving)
         bailoutonerror()
 
+        self.__checkduplicates(dsttree, self.marked4moving)
+        bailoutonerror()
+
         self.__checksigns(dsttree, self.marked4moving)
         bailoutonerror()
 
@@ -477,16 +479,21 @@ class FtpTree(BaseFtpTree):
                             missingarchs.append(arch)
                     pkg.warning(f'not built for archs: {self.__arch_stringify(missingarchs)}')
 
-    def __checkduplicates(self, marked):
+    def __checkduplicates(self, dsttree, marked):
         """
-        Checks if marked packages contain duplicate packages (with different versions)
+        Checks if marked packages contain two builds of one package, by name
         """
+        # the move would remove the older one from the source as old, or the other versions from the
+        # destination twice: only a move between archives removes nothing
+        if self.treename.count("archive") and dsttree.treename.count("archive"):
+            return
+
+        first = {}
         for pkg in marked:
-            olderpkgnames = self.__find_older_pkgs(pkg)
-            for i in olderpkgnames:
-                markednames = [str(x) for x in marked]
-                if i in markednames:
-                    pkg.error(f'duplicate package: {i}')
+            if pkg.name in first:
+                pkg.error(f'duplicate package: {first[pkg.name]}')
+            else:
+                first[pkg.name] = pkg.nvr
 
     def __rmolderfromsrc(self, test = False):
         for pkg in self.marked4moving:
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list