Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
c8ef46c772
2 zmenil súbory, kde vykonal 20 pridanie a 4 odobranie
  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:
 `@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
 ------------
 

+ 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):
         package = None
 
-        m = re.search(r"%s:(?P<package>.+?(?=\"))" % (AUTOVERSION_REGEXP), group)
+        m = re.search(r"%s:(?P<package>.+?(?=[\"@]))" % (AUTOVERSION_REGEXP), group)
         if m:
             package = m.group('package')
             return (package, True)
@@ -114,6 +114,12 @@ def swupdate_expand_auto_versions(d, s, list_for_cpio):
 
         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))
     while True:
         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)
         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"
         else:
-            version = pkgdata['PV'].split('+')[0]
+            version = pkgdata[key].split('+')[0]
 
         replace_str = AUTO_VERSION_TAG
         if pkg_name_defined:
             replace_str = replace_str + ":" + package
+        if key_defined:
+            replace_str = replace_str + "@" + key
 
         group = group.replace(replace_str, version)
         data = data[:m.start()] + group + data[m.end():]