[jhbuild/desrt/packagedb: 18/21] packagedb: store a separate 'info' file



commit 94c846e78b4eec1ee7ac2b816ae54bd96441d4ec
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Jan 18 10:25:50 2015 -0500

    packagedb: store a separate 'info' file
    
    Store a separate XML file for each package in the info/ subdirectory.
    
    This will allow the entire content of a package to be easily turned into
    a .tar file (since we don't have to deal with splitting out the separate
    information from the packagedb).

 jhbuild/utils/packagedb.py |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/jhbuild/utils/packagedb.py b/jhbuild/utils/packagedb.py
index 0ce956b..964fbba 100644
--- a/jhbuild/utils/packagedb.py
+++ b/jhbuild/utils/packagedb.py
@@ -77,12 +77,24 @@ class PackageEntry:
     manifest = property(get_manifest, set_manifest)
 
     def write(self):
+        # write info file
+        fileutils.mkdir_with_parents(os.path.join(self.dirname, 'info'))
+        writer = fileutils.SafeWriter(os.path.join(self.dirname, 'info', self.package))
+        ET.ElementTree(self.to_xml()).write(writer.fp)
+        writer.fp.write('\n')
+        writer.commit()
+
+        # write manifest
         fileutils.mkdir_with_parents(os.path.join(self.dirname, 'manifests'))
         writer = fileutils.SafeWriter(os.path.join(self.dirname, 'manifests', self.package))
         writer.fp.write('\n'.join(self.manifest) + '\n')
         writer.commit()
 
     def remove(self):
+        # remove info file
+        fileutils.ensure_unlinked(os.path.join(self.dirname, 'info', self.package))
+
+        # remove manifest
         fileutils.ensure_unlinked(os.path.join(self.dirname, 'manifests', self.package))
 
     def to_xml(self):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]