Sfoglia il codice sorgente

Support optional argument for packagedata key in automatic versions

Increase flexibility of automatic versions by adding support for
definition of the packagedata key in version tag.

Signed-off-by: Thomas Haemmerle <thomas.haemmerle@leica-geosystems.com>
Thomas Haemmerle 4 anni fa
parent
commit
6cee493a11
2 ha cambiato i file con 20 aggiunte e 4 eliminazioni
  1. 6 0
      README
  2. 14 4
      classes/swupdate-common.bbclass

+ 6 - 0
README

@@ -37,6 +37,12 @@ the file is a container for the real package) you can append the correct package
 name to the tag:
 name to the tag:
 `@SWU_AUTO_VERSION:<package-name>`
 `@SWU_AUTO_VERSION:<package-name>`
 
 
+To insert the value of a variable from BitBake's package-data-file different to
+`PV` (e.g. `PKGV`) you can append the variable name to the tag:
+`@SWU_AUTO_VERSION@<package-data-variable>`
+or
+`@SWU_AUTO_VERSION:<package-name>@<package-data-variable>`
+
 SWU image signing
 SWU image signing
 ------------
 ------------
 
 

+ 14 - 4
classes/swupdate-common.bbclass

@@ -100,7 +100,7 @@ def swupdate_expand_auto_versions(d, s, list_for_cpio):
     def get_package_name(group, file_list):
     def get_package_name(group, file_list):
         package = None
         package = None
 
 
-        m = re.search(r"%s:(?P<package>.+?(?=\"))" % (AUTOVERSION_REGEXP), group)
+        m = re.search(r"%s:(?P<package>.+?(?=[\"@]))" % (AUTOVERSION_REGEXP), group)
         if m:
         if m:
             package = m.group('package')
             package = m.group('package')
             return (package, True)
             return (package, True)
@@ -114,6 +114,12 @@ def swupdate_expand_auto_versions(d, s, list_for_cpio):
 
 
         return (package, False)
         return (package, False)
 
 
+    def get_packagedata_key(group):
+        m = re.search(r"%s.+?(?<=@)(?P<key>.+?(?=\"))" % (AUTOVERSION_REGEXP), group)
+        if m:
+            return (m.group('key'), True)
+        return ("PV", False)
+
     regexp = re.compile(r"\{[^\{]*%s.[^\}]*\}" % (AUTOVERSION_REGEXP))
     regexp = re.compile(r"\{[^\{]*%s.[^\}]*\}" % (AUTOVERSION_REGEXP))
     while True:
     while True:
         m = regexp.search(data)
         m = regexp.search(data)
@@ -127,15 +133,19 @@ def swupdate_expand_auto_versions(d, s, list_for_cpio):
         pkg_info = os.path.join(d.getVar('PKGDATA_DIR'), 'runtime-reverse', package)
         pkg_info = os.path.join(d.getVar('PKGDATA_DIR'), 'runtime-reverse', package)
         pkgdata = oe.packagedata.read_pkgdatafile(pkg_info)
         pkgdata = oe.packagedata.read_pkgdatafile(pkg_info)
 
 
-        if not "PV" in pkgdata.keys():
-            bb.warn("\"PV\" not set for package %s - using \"1.0\"" % (package))
+        (key, key_defined) = get_packagedata_key(group)
+
+        if not key in pkgdata.keys():
+            bb.warn("\"%s\" not set for package %s - using \"1.0\"" % (key, package))
             version = "1.0"
             version = "1.0"
         else:
         else:
-            version = pkgdata['PV'].split('+')[0]
+            version = pkgdata[key].split('+')[0]
 
 
         replace_str = AUTO_VERSION_TAG
         replace_str = AUTO_VERSION_TAG
         if pkg_name_defined:
         if pkg_name_defined:
             replace_str = replace_str + ":" + package
             replace_str = replace_str + ":" + package
+        if key_defined:
+            replace_str = replace_str + "@" + key
 
 
         group = group.replace(replace_str, version)
         group = group.replace(replace_str, version)
         data = data[:m.start()] + group + data[m.end():]
         data = data[:m.start()] + group + data[m.end():]