Message ID | 20210617154346.23097-2-thomas.haemmerle@leica-geosystems.com |
---|---|
State | Accepted |
Headers | show |
Series | [meta-swupdate,1/2] Fix error message in automatic versions | expand |
Hi Thomas, On 17.06.21 17:43, 'Thomas Haemmerle' via swupdate wrote: > 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> > --- > README | 6 ++++++ > classes/swupdate-common.bbclass | 18 ++++++++++++++---- > 2 files changed, 20 insertions(+), 4 deletions(-) > > diff --git a/README b/README > index 2fbb0fe..a785b72 100644 > --- a/README > +++ b/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 > ------------ > > diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass > index eb3ebd6..8cfd11b 100644 > --- a/classes/swupdate-common.bbclass > +++ b/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():] > Reviewed-by : Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/README b/README index 2fbb0fe..a785b72 100644 --- a/README +++ b/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 ------------ diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass index eb3ebd6..8cfd11b 100644 --- a/classes/swupdate-common.bbclass +++ b/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():]
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> --- README | 6 ++++++ classes/swupdate-common.bbclass | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-)