[oe] [meta-oe][PATCH 2/3] oe.headrevs: save and restore the bitbake URI headrevs

Christopher Larson kergoth at gmail.com
Tue Dec 15 19:37:46 UTC 2015


From: Christopher Larson <chris_larson at mentor.com>

This module provides functions to save and restore the BB_URI_HEADREVS from/to
the persist_data database. The BB_URI_HEADREVS are the mappings between git
refs and the revisions they refer to.

This is useful to fully support BB_NO_NETWORK when AUTOREV is involved, as we
can use the dumped mappings rather than contacting upstream at parse time.

Signed-off-by: Christopher Larson <chris_larson at mentor.com>
---
 meta-oe/lib/oe/headrevs.py | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 meta-oe/lib/oe/headrevs.py

diff --git a/meta-oe/lib/oe/headrevs.py b/meta-oe/lib/oe/headrevs.py
new file mode 100644
index 0000000..9245300
--- /dev/null
+++ b/meta-oe/lib/oe/headrevs.py
@@ -0,0 +1,38 @@
+"""Save and restore the bitbake URI headrevs.
+
+This module provides functions to save and restore the BB_URI_HEADREVS from/to
+the persist_data database. The BB_URI_HEADREVS are the mappings between git
+refs and the revisions they refer to.
+
+This is useful to fully support BB_NO_NETWORK when AUTOREV is involved, as we
+can use the dumped mappings rather than contacting upstream at parse time. See
+also restore_headrevs.bbclass.
+
+By default, any existing mapping will not be overwritten, as we assume the
+user's mappings are more current than any dumped content.
+"""
+
+
+def copy_persist_domain(d, domain, other_db_path, restore=False, overwrite=False):
+    import contextlib
+
+    source_table = bb.persist_data.persist(domain, d)
+    dest_table = bb.persist_data.SQLTable(other_db_path, domain)
+    if restore:
+        source_table, dest_table = dest_table, source_table
+
+    with contextlib.nested(source_table, dest_table):
+        if overwrite:
+            dest_table.update(source_table)
+        else:
+            for key in source_table:
+                if key not in dest_table:
+                    dest_table[key] = source_table[key]
+
+
+def dump_headrevs(d, dump_db_path):
+    copy_persist_domain(d, 'BB_URI_HEADREVS', dump_db_path)
+
+
+def restore_headrevs(d, dump_db_path):
+    copy_persist_domain(d, 'BB_URI_HEADREVS', dump_db_path, restore=True)
-- 
2.2.1




More information about the Openembedded-devel mailing list