Re: [OE-core] [poky][master][PATCH] buildhistory.bbclass: Enable exporting more recipe and package data

2021-08-08 Thread sana kazi
Hi,

Could you please review the patch for master branch to enable exporting
more recipe and package data?

Regards,
Sana Kazi

On Mon, 26 Jul 2021 at 09:15, Sana Kazi  wrote:

> From: Sana Kazi 
>
> Used BUILDHISTORY_EXPORT_RECIPE_VARIABLES and
> BUILDHISTORY_EXPORT_PACKAGE_VARIABLES to export recipe and package
> data to the latest file of buildhistory and sorted it alphabetically.
>
> This makes extending data in buildhistory git tree simple and avoids
> patches to it for users who care about things like SRC_URI and like
> to track it in buildhistory git tree.
>
> Now we can add additional information as per our requirement to the
> buildhistory like LICENSE, SRC_URI AND MAINTAINER to the buildhistory
> by appending them in a recipe or distro specific conf file as follows:
>
> BUILDHISTORY_EXPORT_RECIPE_VARIABLES += "MAINTAINER"
> BUILDHISTORY_EXPORT_PACKAGE_VARIABLES += "MAINTAINER"
>
> Signed-off-by: Sana Kazi 
> ---
>  meta-poky/conf/distro/poky.conf   |   3 +
>  meta/classes/buildhistory.bbclass | 107 +++---
>  2 files changed, 71 insertions(+), 39 deletions(-)
>
> diff --git a/meta-poky/conf/distro/poky.conf
> b/meta-poky/conf/distro/poky.conf
> index 522cc92f74..2280e95569 100644
> --- a/meta-poky/conf/distro/poky.conf
> +++ b/meta-poky/conf/distro/poky.conf
> @@ -76,3 +76,6 @@ INHERIT += "reproducible_build"
>
>  BB_SIGNATURE_HANDLER ?= "OEEquivHash"
>  BB_HASHSERVE ??= "auto"
> +
> +BUILDHISTORY_EXPORT_RECIPE_VARIABLES ?= "PR PV PE LAYER DEPENDS PACKAGES
> LICENSE SRC_URI CONFIG"
> +BUILDHISTORY_EXPORT_PACKAGE_VARIABLES ?= "PE PV PR PKG PKGE PKGV PKGR
> RPROVIDES RDEPENDS RRECOMMENDS RSUGGESTS RREPLACES RCONFLICTS PKGSIZE FILES
> FILELIST"
> diff --git a/meta/classes/buildhistory.bbclass
> b/meta/classes/buildhistory.bbclass
> index 55b12d7893..9b1542643e 100644
> --- a/meta/classes/buildhistory.bbclass
> +++ b/meta/classes/buildhistory.bbclass
> @@ -220,7 +220,6 @@ python buildhistory_emit_pkghistory() {
>  pv = d.getVar('PV')
>  pr = d.getVar('PR')
>  layer = bb.utils.get_file_layer(d.getVar('FILE'), d)
> -license = d.getVar('LICENSE')
>
>  pkgdata_dir = d.getVar('PKGDATA_DIR')
>  packages = ""
> @@ -258,12 +257,11 @@ python buildhistory_emit_pkghistory() {
>  rcpinfo.pe = pe
>  rcpinfo.pv = pv
>  rcpinfo.pr = pr
> -rcpinfo.depends = sortlist(oe.utils.squashspaces(d.getVar('DEPENDS')
> or ""))
>  rcpinfo.packages = packages
>  rcpinfo.layer = layer
> -rcpinfo.license = license
>  rcpinfo.config =
> sortlist(oe.utils.squashspaces(d.getVar('PACKAGECONFIG') or ""))
> -rcpinfo.src_uri = oe.utils.squashspaces(d.getVar('SRC_URI') or "")
> +export_recipe_variables =
> d.getVar('BUILDHISTORY_EXPORT_RECIPE_VARIABLES') or ''
> +rcpinfo.export_recipe_variables = export_recipe_variables
>  write_recipehistory(rcpinfo, d)
>
>  bb.build.exec_func("read_subpackage_metadata", d)
> @@ -317,6 +315,9 @@ python buildhistory_emit_pkghistory() {
>
>  pkginfo.size = int(localdata.getVar('PKGSIZE') or '0')
>
> +export_package_variables =
> d.getVar('BUILDHISTORY_EXPORT_PACKAGE_VARIABLES') or ''
> +pkginfo.export_package_variables = export_package_variables
> +
>  write_pkghistory(pkginfo, d)
>
>  # Create files-in-.txt files containing a list of files
> of each recipe's package
> @@ -365,17 +366,22 @@ def write_recipehistory(rcpinfo, d):
>  pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE')
>
>  infofile = os.path.join(pkghistdir, "latest")
> +export_recipe_variables = set(rcpinfo.export_recipe_variables.split())
> +ret = []
>  with open(infofile, "w") as f:
> -if rcpinfo.pe != "0":
> -f.write(u"PE = %s\n" %  rcpinfo.pe)
> -f.write(u"PV = %s\n" %  rcpinfo.pv)
> -f.write(u"PR = %s\n" %  rcpinfo.pr)
> -f.write(u"DEPENDS = %s\n" %  rcpinfo.depends)
> -f.write(u"PACKAGES = %s\n" %  rcpinfo.packages)
> -f.write(u"LAYER = %s\n" %  rcpinfo.layer)
> -f.write(u"LICENSE = %s\n" %  rcpinfo.license)
> -f.write(u"CONFIG = %s\n" %  rcpinfo.config)
> -f.write(u"SRC_URI = %s\n" %  rcpinfo.src_uri)
> +for var in export_recipe_variables:
> +if var == "PE":
> +if rcpinfo.pe != "0":
> +ret.append("%s = %s" % (var, rcpinfo.pe))
> +elif var == "LAYER":
> +ret.append("%s = %s" % (var, rcpinfo.layer))
> +elif var == "CONFIG":
> +ret.append("%s = %s" % (var, rcpinfo.config))
> +else:
> +ret.append("%s = %s" % (var,"
> ".join((str(d.getVar(var)).split()
> +ret.sort()
> +for element in ret:
> +f.write(element + "\n")
>
>  write_latest_srcrev(d, pkghistdir)
>
> @@ -389,32 +395,55 @@ def write_pkghistory(pkginfo, d):
>  bb.utils.mkdirhier(pkgpath)
>
>  infofile = os.path.join(pkgpath, "latest")
> +export_package_variables 

[OE-core] [poky][master][PATCH] buildhistory.bbclass: Enable exporting more recipe and package data

2021-07-25 Thread sana kazi
From: Sana Kazi 

Used BUILDHISTORY_EXPORT_RECIPE_VARIABLES and
BUILDHISTORY_EXPORT_PACKAGE_VARIABLES to export recipe and package
data to the latest file of buildhistory and sorted it alphabetically.

This makes extending data in buildhistory git tree simple and avoids
patches to it for users who care about things like SRC_URI and like
to track it in buildhistory git tree.

Now we can add additional information as per our requirement to the
buildhistory like LICENSE, SRC_URI AND MAINTAINER to the buildhistory
by appending them in a recipe or distro specific conf file as follows:

BUILDHISTORY_EXPORT_RECIPE_VARIABLES += "MAINTAINER"
BUILDHISTORY_EXPORT_PACKAGE_VARIABLES += "MAINTAINER"

Signed-off-by: Sana Kazi 
---
 meta-poky/conf/distro/poky.conf   |   3 +
 meta/classes/buildhistory.bbclass | 107 +++---
 2 files changed, 71 insertions(+), 39 deletions(-)

diff --git a/meta-poky/conf/distro/poky.conf b/meta-poky/conf/distro/poky.conf
index 522cc92f74..2280e95569 100644
--- a/meta-poky/conf/distro/poky.conf
+++ b/meta-poky/conf/distro/poky.conf
@@ -76,3 +76,6 @@ INHERIT += "reproducible_build"
 
 BB_SIGNATURE_HANDLER ?= "OEEquivHash"
 BB_HASHSERVE ??= "auto"
+
+BUILDHISTORY_EXPORT_RECIPE_VARIABLES ?= "PR PV PE LAYER DEPENDS PACKAGES 
LICENSE SRC_URI CONFIG"
+BUILDHISTORY_EXPORT_PACKAGE_VARIABLES ?= "PE PV PR PKG PKGE PKGV PKGR 
RPROVIDES RDEPENDS RRECOMMENDS RSUGGESTS RREPLACES RCONFLICTS PKGSIZE FILES 
FILELIST"
diff --git a/meta/classes/buildhistory.bbclass 
b/meta/classes/buildhistory.bbclass
index 55b12d7893..9b1542643e 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -220,7 +220,6 @@ python buildhistory_emit_pkghistory() {
 pv = d.getVar('PV')
 pr = d.getVar('PR')
 layer = bb.utils.get_file_layer(d.getVar('FILE'), d)
-license = d.getVar('LICENSE')
 
 pkgdata_dir = d.getVar('PKGDATA_DIR')
 packages = ""
@@ -258,12 +257,11 @@ python buildhistory_emit_pkghistory() {
 rcpinfo.pe = pe
 rcpinfo.pv = pv
 rcpinfo.pr = pr
-rcpinfo.depends = sortlist(oe.utils.squashspaces(d.getVar('DEPENDS') or 
""))
 rcpinfo.packages = packages
 rcpinfo.layer = layer
-rcpinfo.license = license
 rcpinfo.config = sortlist(oe.utils.squashspaces(d.getVar('PACKAGECONFIG') 
or ""))
-rcpinfo.src_uri = oe.utils.squashspaces(d.getVar('SRC_URI') or "")
+export_recipe_variables = d.getVar('BUILDHISTORY_EXPORT_RECIPE_VARIABLES') 
or ''
+rcpinfo.export_recipe_variables = export_recipe_variables
 write_recipehistory(rcpinfo, d)
 
 bb.build.exec_func("read_subpackage_metadata", d)
@@ -317,6 +315,9 @@ python buildhistory_emit_pkghistory() {
 
 pkginfo.size = int(localdata.getVar('PKGSIZE') or '0')
 
+export_package_variables = 
d.getVar('BUILDHISTORY_EXPORT_PACKAGE_VARIABLES') or ''
+pkginfo.export_package_variables = export_package_variables
+
 write_pkghistory(pkginfo, d)
 
 # Create files-in-.txt files containing a list of files of 
each recipe's package
@@ -365,17 +366,22 @@ def write_recipehistory(rcpinfo, d):
 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE')
 
 infofile = os.path.join(pkghistdir, "latest")
+export_recipe_variables = set(rcpinfo.export_recipe_variables.split())
+ret = []
 with open(infofile, "w") as f:
-if rcpinfo.pe != "0":
-f.write(u"PE = %s\n" %  rcpinfo.pe)
-f.write(u"PV = %s\n" %  rcpinfo.pv)
-f.write(u"PR = %s\n" %  rcpinfo.pr)
-f.write(u"DEPENDS = %s\n" %  rcpinfo.depends)
-f.write(u"PACKAGES = %s\n" %  rcpinfo.packages)
-f.write(u"LAYER = %s\n" %  rcpinfo.layer)
-f.write(u"LICENSE = %s\n" %  rcpinfo.license)
-f.write(u"CONFIG = %s\n" %  rcpinfo.config)
-f.write(u"SRC_URI = %s\n" %  rcpinfo.src_uri)
+for var in export_recipe_variables:
+if var == "PE":
+if rcpinfo.pe != "0":
+ret.append("%s = %s" % (var, rcpinfo.pe))
+elif var == "LAYER":
+ret.append("%s = %s" % (var, rcpinfo.layer))
+elif var == "CONFIG":
+ret.append("%s = %s" % (var, rcpinfo.config))
+else:
+ret.append("%s = %s" % (var," 
".join((str(d.getVar(var)).split()
+ret.sort()
+for element in ret:
+f.write(element + "\n")
 
 write_latest_srcrev(d, pkghistdir)
 
@@ -389,32 +395,55 @@ def write_pkghistory(pkginfo, d):
 bb.utils.mkdirhier(pkgpath)
 
 infofile = os.path.join(pkgpath, "latest")
+export_package_variables = set(pkginfo.export_package_variables.split())
+ret = []
 with open(infofile, "w") as f:
-if pkginfo.pe != "0":
-f.write(u"PE = %s\n" %  pkginfo.pe)
-f.write(u"PV = %s\n" %  pkginfo.pv)
-f.write(u"PR = %s\n" %  pkginfo.pr)
-
-if pkginfo.pkg != pkginfo.name:
-f.write(u"PKG = %s\n" % pkginfo.pkg)
-if pkginfo.