fix adding group/pattern files to repo
authorZhang Qiang <qiang.z.zhang@intel.com>
Wed, 29 May 2013 05:20:09 +0000 (13:20 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Wed, 29 May 2013 05:21:20 +0000 (13:21 +0800)
Change-Id: I047b6d68e851dde94b63168b9f749e9d5093b42b

common/repomaker.py

index c7f9a6e..fab5bd2 100644 (file)
@@ -44,12 +44,14 @@ def collect(in_dir):
     archs = set()
     for fname in find_files(in_dir):
         ftype = fname.split('.')[-2]
+        basename = os.path.basename(fname)
         if ftype not in ("src", "noarch"):
             archs.add(ftype)
 
         is_debug = "-debugsource-" in fname or "-debuginfo-" in fname
-        is_group = fname.startswith("package-groups-")
-        is_imageconf = fname.startswith("image-configurations-")
+        is_group = basename.startswith("package-groups-") and not is_debug
+        is_imageconf = basename.startswith("image-configurations-") and \
+                       not is_debug
         files.append((fname, ftype, is_debug, is_group, is_imageconf))
     return files, archs
 
@@ -166,11 +168,14 @@ class RepoMaker(object):
 
             # For package-groups package update package groups and patterns
             if is_group:
+                repodata_dir = os.path.join(repo_dir, ftype, "packages",
+                                            "repodata")
+                if not os.path.exists(repodata_dir):
+                    os.makedirs(repodata_dir)
                 for filename in ("group.xml", "patterns.xml"):
                     os.system("rpm2cpio %s | cpio -i --to-stdout "\
                               "./usr/share/package-groups/%s > %s" % \
-                              (fpath, filename, os.path.join(repo_dir, ftype,
-                                                             "repodata",
+                              (fpath, filename, os.path.join(repodata_dir,
                                                              filename)))
             # get names and content of .ks files from rpm
             if is_imageconf:
@@ -194,6 +199,11 @@ class RepoMaker(object):
         for _rtype, _rarch, rpath in dirs:
             # run createrepo
             os.system('createrepo --quiet %s' % rpath)
+            for filename in ("group.xml", "patterns.xml"):
+                metafile = os.path.join(rpath, "repodata", filename)
+                if os.path.exists(metafile):
+                    os.system('modifyrepo %s %s' % (metafile,
+                              os.path.join(rpath, "repodata")))
 
         # sign if gpg_key is provided
         if gpg_key and os.path.exists(signer) and os.access(signer, os.X_OK):