Update debug and packages directory structure
authorZhuoX Li <zhuox.li@intel.com>
Thu, 8 May 2014 04:33:25 +0000 (12:33 +0800)
committerLin Yang <lin.a.yang@intel.com>
Thu, 8 May 2014 09:40:14 +0000 (17:40 +0800)
Delete the subdirectory is named for archs in debug directory.
Original .rpm are in subdirectory will be put directly into parent directory.
And use the archs name of OBS replaces the unified archs name 'ia32',
to name the subdirectory in packages directory.

Change-Id: Iec48ec926639dc153bd88d6b8fd53591bd450099

common/repomaker.py
job_create_snapshot.py
tests/test_repomaker.py

index 45124c7..cf0a9a5 100644 (file)
@@ -58,8 +58,6 @@ def collect(in_dir, archs, repo_name = None):
         ftype = fname.split('.')[-2]
 
         # Unify arch name
-        ftype = ARCH_MAP.get(ftype, ftype)
-
         if ftype not in ("src", "noarch"):
             if ftype not in archs:
                 # skip packages for unknown architectures
@@ -79,11 +77,12 @@ def create_dirs(repo_dir, archs):
     """Create directory structure of the repos."""
     dirs =  [("binary", arch, os.path.join(repo_dir, subdir, arch)) \
                  for arch in archs \
-                     for subdir in ('packages', 'debug')]
+                     for subdir in ['packages']]
     dirs.append(("noarch", "noarch", os.path.join(repo_dir,
                                                   "packages",
                                                   "noarch")))
     dirs.append(("source", None, os.path.join(repo_dir, "source")))
+    dirs.append(("debug", None, os.path.join(repo_dir, "debug")))
 
     repo_dirs = set([])
     # create and get repo_dirs
@@ -104,8 +103,10 @@ def gen_target_dirs(repo_dir, ftype, is_debug):
     """Prepare list of target dirs depending on type of package."""
     if ftype ==  "src":
         return [os.path.join(repo_dir, "source")]
+    elif is_debug:
+        return [os.path.join(repo_dir, "debug")]
     else:
-        return [os.path.join(repo_dir, ["packages", "debug"][is_debug], ftype)]
+        return [os.path.join(repo_dir, "packages", ftype)]
 
 def move_or_hardlink(fpath, target_dirs, move=False):
     """Move or hardlink file to target directories."""
@@ -170,6 +171,14 @@ class RepoMaker(object):
         if name not in self.repos:
             self.repos[name] = {'archs': list(set(archs))}
 
+        # translate unified archs name 'ia23' to 'i586' 'i686' matched
+        # with OBS archs
+        if set(archs).intersection(set(ARCH_MAP.values())):
+            new_archs = [arch for arch in ARCH_MAP
+                            if ARCH_MAP.get(arch) in archs]
+            archs = new_archs + \
+                    list(set(archs).difference(set(ARCH_MAP.values())))
+
         files = collect(in_dir, archs, name)
 
         # Create directory structure
index 2292d19..9dc34e7 100755 (executable)
@@ -105,7 +105,7 @@ def make_repo(project, backenddb, base_path, live_repo_base, buildconf=None):
         if not repomaker.imagedata:
             raise LocalError("Image configuration not found in %s" % snapshot.path)
 
-        repos[repo['Name']] = repomaker.repos
+        repos.update(repomaker.repos)
         imagedatas[repo['Name']] = repomaker.imagedata
 
         # Generate image info to builddata/ dir
index 08612d7..2536f1a 100644 (file)
@@ -121,18 +121,18 @@ class RepoMakerTest(unittest.TestCase):
                          'pkg2-0.1-2.3.src.rpm', 'pkg2-1.2-3.4.src.rpm',
                          'pkg3-0.1-2.3.src.rpm', 'pkg3-1.2-3.4.src.rpm'],
                     'packages':
-                        ['ia32/pkg1-0.1-2.3.i586.rpm',
-                         'ia32/pkg1-0.1-2.3.i686.rpm',
-                         'ia32/pkg1-1.2-3.4.i586.rpm',
-                         'ia32/pkg1-1.2-3.4.i686.rpm',
-                         'ia32/pkg2-0.1-2.3.i586.rpm',
-                         'ia32/pkg2-0.1-2.3.i686.rpm',
-                         'ia32/pkg2-1.2-3.4.i586.rpm',
-                         'ia32/pkg2-1.2-3.4.i686.rpm',
-                         'ia32/pkg3-0.1-2.3.i586.rpm',
-                         'ia32/pkg3-0.1-2.3.i686.rpm',
-                         'ia32/pkg3-1.2-3.4.i586.rpm',
-                         'ia32/pkg3-1.2-3.4.i686.rpm',
+                        ['i586/pkg1-0.1-2.3.i586.rpm',
+                         'i586/pkg1-1.2-3.4.i586.rpm',
+                         'i586/pkg2-0.1-2.3.i586.rpm',
+                         'i586/pkg2-1.2-3.4.i586.rpm',
+                         'i586/pkg3-0.1-2.3.i586.rpm',
+                         'i586/pkg3-1.2-3.4.i586.rpm',
+                         'i686/pkg1-0.1-2.3.i686.rpm',
+                         'i686/pkg1-1.2-3.4.i686.rpm',
+                         'i686/pkg2-0.1-2.3.i686.rpm',
+                         'i686/pkg2-1.2-3.4.i686.rpm',
+                         'i686/pkg3-0.1-2.3.i686.rpm',
+                         'i686/pkg3-1.2-3.4.i686.rpm',
                          'noarch/pkg1-0.1-2.3.noarch.rpm',
                          'noarch/pkg1-1.2-3.4.noarch.rpm',
                          'noarch/pkg2-0.1-2.3.noarch.rpm',