]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blobdiff - modules/ftptree.py
fix archive handling when moving packages around
[projects/pld-ftp-admin.git] / modules / ftptree.py
index b0b2a8f6366a6fb157a5b3c2bdb5be77189cb5a7..e22833117410dd7631003cdef6a28d407c6712f0 100644 (file)
@@ -46,7 +46,7 @@ def mv(src, dst, test = False):
     fsrc = src
     fdst = dst + '/' + src.split('/')[-1]
     if test:
-        if not os.path.exists(src):
+        if not os.path.exists(fsrc):
             pinfo("TEST os.rename(%s, %s): source doesn't exists" % (fsrc, fdst))
         if not os.path.exists(dst):
             pinfo("TEST destination doesn't exist: %s" % dst)
@@ -151,7 +151,7 @@ class Pkg(BasePkg):
         for arch in self.files.keys():
             for rpm in self.files[arch]:
                 f.write("file:%s:%s\n" % (arch, rpm))
-        
+
     def remove(self, test = False):
         """
         Remove package from ftp
@@ -196,7 +196,7 @@ class Pkg(BasePkg):
         """
         def rpmhdr(pkg):
             ts = rpm.ts()
-            ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
+            ts.setVSFlags(rpm.RPMVSF_NODSAHEADER)
             fdno = os.open(pkg, os.O_RDONLY)
             hdr = ts.hdrFromFdno(fdno)
             os.close(fdno)
@@ -301,7 +301,8 @@ class FtpTree(BaseFtpTree):
     def testmove(self, dsttree, archivetree = None):
         self.__checkbuild(self.marked4moving)
         self.__checkarchs(dsttree, self.marked4moving)
-        self.__checkduplicates(self.marked4moving)
+        if not dsttree.treename.count("archive"):
+            self.__checkduplicates(self.marked4moving)
 
         self.__checksigns(dsttree, self.marked4moving, test = True)
         self.__checkforobsoletes(dsttree, self.marked4moving, test = True)
@@ -309,8 +310,8 @@ class FtpTree(BaseFtpTree):
 
         if not self.treename.count("archive"):
             self.__rmolderfromsrc(test = True)
-
-        self.__rmotherfromdst(dsttree, test = True, archivetree = archivetree)
+        if not dsttree.treename.count("archive"):
+            self.__rmotherfromdst(dsttree, test = True, archivetree = archivetree)
 
         for pkg in self.marked4moving:
             pkg.move(dsttree, test = True)
@@ -328,8 +329,8 @@ class FtpTree(BaseFtpTree):
 
         if not self.treename.count("archive"):
             self.__rmolderfromsrc()
-
-        self.__rmotherfromdst(dsttree, archivetree = archivetree)
+        if not dsttree.treename.count("archive"):
+            self.__rmotherfromdst(dsttree, archivetree = archivetree)
 
         for pkg in self.marked4moving:
             pkg.move(dsttree)
@@ -355,13 +356,11 @@ class FtpTree(BaseFtpTree):
 
     def mark4moving(self, wannabepkgs):
         self.__mark4something(wannabepkgs, Pkg.mark4moving)
-        
 
     # Internal functions below
     def __arch_stringify(self, list):
         ret = []
-        # XXX: is dist line in any config?
-        dist = 'ac'
+        dist = config.ftp_dist;
         for arch in list:
             ret.append(dist + '-' + arch)
         return ' '.join(ret)
@@ -439,9 +438,16 @@ class FtpTree(BaseFtpTree):
                     pkg.error('moving would remove archs: %s' % self.__arch_stringify(missingarchs))
             else:
                 # warn if a package isn't built for all archs
-                if (config.separate_noarch and 'noarch' in pkg.files.keys() and len(pkg.files.keys()) == 2):
-                    continue
-                elif len(pkg.files.keys()) != len(config.ftp_archs) + 1:
+                # ftp_archs + SRPMS
+                ftp_archs_num = len(config.ftp_archs) + 1
+                if (config.separate_noarch and 'noarch' in pkg.files.keys()):
+                    # ftp_archs + SRPMS + noarch subpackages
+                    ftp_archs_num += 1
+                    # plain simple noarch package
+                    if (len(pkg.files.keys()) == 2):
+                        continue
+
+                if len(pkg.files.keys()) != ftp_archs_num:
                     missingarchs = []
                     for arch in config.ftp_archs:
                         if arch not in pkg.files.keys():
This page took 0.027384 seconds and 4 git commands to generate.