toaster.bbclass: improve package information collection
PATCH 1/1 toaster.bbclass: improve package information collection
The PACKAGES variable doesn't include all packages potentially generated by a recipe, not least of all because it doesn't include dynamic packages created via do_split_packages() or similar.
Instead of trying to guess which packages were generated, walk ${PKGDESTWORK}/runtime to find all package information that was written to disk. This allows us to read all information for the complete list of packages generated by the recipe.
For example before this patch we get SinglePackageInfo events for 9 packages from ncurses. With the patch applied we get 20 events for all of the packages created during an ncurses build.
As a bonus we also switch to using the same postfuncs for both do_packagedata and do_packagedata_setscene as they each result in a PKGDESTWORK with the relevant directories and files created.
[YOCTO #9115]
--- meta/classes/toaster.bbclass | 50 +++++++++++++------------------------------- 1 file changed, 15 insertions(+), 35 deletions(-)
meta/classes/toaster.bbclass +15 -35
@@ -112,45 +112,25 @@ def _toaster_load_pkgdatafile(dirpath, filepath): pass # ignore lines without valid key: value pairs return pkgdata -python toaster_package_dumpdata_setscene() { - """ - Dumps the data created by package_setscene - """ - # replicate variables from the package.bbclass - packages = d.getVar('PACKAGES', True) - pkgdatadir = d.getVar('PKGDATA_DIR', True) - # scan and send data for each package - lpkgdata = {} - for pkg in packages.split(): - try: - lpkgdata = _toaster_load_pkgdatafile(pkgdatadir + "/runtime/", pkg) - except: - # these are typically foo-locale which actually point into foo-locale-<language> in runtime-rprovides - bb.note("toaster_package_dumpdata_setscene: failed to load pkg information for: %s:%s"%(pkg,sys.exc_info()[0])) - # Fire an event containing the pkg data - bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d) - -} - - python toaster_package_dumpdata() { """ - Dumps the data created by emit_pkgdata + Dumps the data about the packages created by a recipe """ - # replicate variables from the package.bbclass - - packages = d.getVar('PACKAGES', True) - pkgdatadir = d.getVar('PKGDESTWORK', True) - # scan and send data for each package + # No need to try and dumpdata if the recipe isn't generating packages + if not d.getVar('PACKAGES', True): + return + pkgdatadir = d.getVar('PKGDESTWORK', True) lpkgdata = {} - for pkg in packages.split(): - - lpkgdata = _toaster_load_pkgdatafile(pkgdatadir + "/runtime/", pkg) - - # Fire an event containing the pkg data - bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d) + datadir = os.path.join(pkgdatadir, 'runtime') + + # scan and send data for each generated package + for datafile in os.listdir(datadir): + if not datafile.endswith('.packaged'): + lpkgdata = _toaster_load_pkgdatafile(datadir, datafile) + # Fire an event containing the pkg data + bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d) } # 2. Dump output image files information
@@ -401,8 +381,8 @@ toaster_collect_task_stats[eventmask] = "bb.event.BuildCompleted bb.build.TaskSu addhandler toaster_buildhistory_dump toaster_buildhistory_dump[eventmask] = "bb.event.BuildCompleted" -do_packagedata_setscene[postfuncs] += "toaster_package_dumpdata_setscene " -do_packagedata_setscene[vardepsexclude] += "toaster_package_dumpdata_setscene " +do_packagedata_setscene[postfuncs] += "toaster_package_dumpdata " +do_packagedata_setscene[vardepsexclude] += "toaster_package_dumpdata " do_package[postfuncs] += "toaster_package_dumpdata " do_package[vardepsexclude] += "toaster_package_dumpdata "
Signature · 1 line
2.5.5
Looks good to me. Tested, and the package counts match for the cases I tried.
Added to toaster-next and sent to OpenEmbedded mailing list ( [email protected]).
Thanks.
Elliot
Quoted 118 lines · Joshua Lock
The PACKAGES variable doesn't include all packages potentially generated by a recipe, not least of all because it doesn't include dynamic packages created via
do_split_packages()or similar.Instead of trying to guess which packages were generated, walk ${PKGDESTWORK}/runtime to find all package information that was written to disk. This allows us to read all information for the complete list of packages generated by the recipe.
For example before this patch we get SinglePackageInfo events for 9 packages from ncurses. With the patch applied we get 20 events for all of the packages created during an ncurses build.
As a bonus we also switch to using the same postfuncs for both
do_packagedataanddo_packagedata_setsceneas they each result in a PKGDESTWORK with the relevant directories and files created.[YOCTO #9115]
Signed-off-by Joshua Lock <[email protected]>--- meta/classes/toaster.bbclass | 50 +++++++++++++------------------------------- 1 file changed, 15 insertions(+), 35 deletions(-)meta/classes/toaster.bbclass +0
-14@@ -112,45 +112,25 @@ def _toaster_load_pkgdatafile(dirpath, filepath): pass # ignore lines without valid key: value pairs return pkgdata -python toaster_package_dumpdata_setscene() { - """ - Dumps the data created by package_setscene - """ - # replicate variables from the package.bbclass - packages = d.getVar('PACKAGES', True) - pkgdatadir = d.getVar('PKGDATA_DIR', True) - # scan and send data for each package - lpkgdata = {} - for pkg in packages.split(): - try: - lpkgdata = _toaster_load_pkgdatafile(pkgdatadir + "/runtime/", pkg) - except: - # these are typically foo-locale which actually point intofoo-locale-<language> in runtime-rprovides
- bb.note("toaster_package_dumpdata_setscene: failed to load pkg
information for: %s:%s"%(pkg,sys.exc_info()[0]))meta/classes/toaster.bbclass +0
-2- # Fire an event containing the pkg data - bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo",lpkgdata), d)
meta/classes/toaster.bbclass +5
-13- -} - - python toaster_package_dumpdata() { """ - Dumps the data created by emit_pkgdata + Dumps the data about the packages created by a recipe """ - # replicate variables from the package.bbclass - - packages = d.getVar('PACKAGES', True) - pkgdatadir = d.getVar('PKGDESTWORK', True) - # scan and send data for each package + # No need to try and dumpdata if the recipe isn't generating packages + if not d.getVar('PACKAGES', True): + return + pkgdatadir = d.getVar('PKGDESTWORK', True) lpkgdata = {} - for pkg in packages.split(): - - lpkgdata = _toaster_load_pkgdatafile(pkgdatadir + "/runtime/",pkg)
meta/classes/toaster.bbclass +0
-3- - # Fire an event containing the pkg data - bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo",lpkgdata), d)
meta/classes/toaster.bbclass +8
-0+ datadir = os.path.join(pkgdatadir, 'runtime') + + # scan and send data for each generated package + for datafile in os.listdir(datadir): + if not datafile.endswith('.packaged'): + lpkgdata = _toaster_load_pkgdatafile(datadir, datafile) + # Fire an event containing the pkg data + bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo",lpkgdata), d)
}# 2. Dump output image files information
meta/classes/toaster.bbclass +0
-0@@ -401,8 +381,8 @@ toaster_collect_task_stats[eventmask] ="bb.event.BuildCompleted bb.build.TaskSu
addhandlertoaster_buildhistory_dumptoaster_buildhistory_dump[eventmask] = "bb.event.BuildCompleted"meta/classes/toaster.bbclass +0
-2-do_packagedata_setscene[postfuncs] += "toaster_package_dumpdata_setscene " -do_packagedata_setscene[vardepsexclude] +="
toaster_package_dumpdata_setscene"meta/classes/toaster.bbclass +2
-1+do_packagedata_setscene[postfuncs] += "toaster_package_dumpdata " +do_packagedata_setscene[vardepsexclude] += "toaster_package_dumpdata " do_package[postfuncs] += "toaster_package_dumpdata " do_package[vardepsexclude] += "toaster_package_dumpdata " --2.5.5
--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster
Signature · 3 lines
Elliot Smith Software Engineer Intel Open Source Technology Centre