Skip to content
Snippets Groups Projects

Add supportability class and configuration

Open Pavel Zhukov requested to merge landgraf/oniro:supportability_single_conf into kirkstone
Files
3
+ 98
0
SUPPORT_DIRECTORY ?= "${DEPLOY_DIR}/supportability"
### Print warnings if package is unsupported
### Note: Warn only if package is defined as
###:unsupported and not for default policy
WARN_IF_UNSUPPORTED ?= "1"
ONIRO_SUPPORT_REPORT_FMT ?= "text"
def getrecipereverse(d, pkg):
pkgdata_dir = d.getVar("PKGDATA_DIR")
pkgdatafile = os.path.join(pkgdata_dir, 'runtime-reverse', pkg)
if not os.path.exists(pkgdatafile):
bb.warn("Package data file of {} doesn't exist. Unable to lookup recipe name".format(pkgdatafile))
return None
with open(pkgdatafile) as f:
pn = f.readline()
if pn is None or not pn.startswith("PN:") or len(pn) < 5:
bb.warn("Wrong format of pkgdatafile {}".format(pkgdatafile))
return None
return pn[pn.index(":") + 1:].strip()
def get_supportability_status(d, recipe, pkg):
## "default policy" for packages
ONIRO_DEFAULT_POLICY = d.getVar("ONIRO_SUPPORT_DEFAULT_POLICY")
if recipe is None:
return "unsupported"
## Packages which are marked as unsupported (not affected by default policy)
ONIRO_SUPPORT_UNSUPPORTED = d.getVar("ONIRO_SUPPORT_UNSUPPORTED")
WARN_IF_UNSUPPORTED = d.getVar("WARN_IF_UNSUPPORTED") != 0
if ONIRO_SUPPORT_UNSUPPORTED is not None and \
recipe in ONIRO_SUPPORT_UNSUPPORTED.split():
if WARN_IF_UNSUPPORTED:
bb.warn("Supportability class: package {} is unsupported".format(recipe))
return "unsupported"
## Packages which are in Oniro reference images are always supported
## Not affected by default policy
ONIRO_SUPPORT_REF = d.getVar("ONIRO_SUPPORT_REF")
if ONIRO_SUPPORT_REF is not None and recipe in ONIRO_SUPPORT_REF.split():
return "supported"
ONIRO_SUPPORT_SUPPORTED = d.getVar("ONIRO_SUPPORT_SUPPORTED")
if ONIRO_SUPPORT_SUPPORTED is not None and recipe in ONIRO_SUPPORT_SUPPORTED.split():
return "supported"
return ONIRO_DEFAULT_POLICY
def build_deps_list(items):
deps = []
for item in items.split('\n'):
splitted = item.split('|')
depend = ' '.join(splitted[1:]).lstrip('|')
deps.append(depend)
return deps
def generate_report_txt(data):
report = []
for pkg in data:
report.append("{} : {} => {} \n".format(pkg["package"], pkg["recipe"], pkg["supportstatus"]))
return report
python supportability_report () {
sreport_dir = d.expand('${SUPPORT_DIRECTORY}/${IMAGE_NAME}')
sreport_latest_link = d.expand('${SUPPORT_DIRECTORY}/latest')
report_file = os.path.join(sreport_dir, 'supportability.report.txt')
bb.utils.mkdirhier(sreport_dir)
from oe.rootfs import image_list_installed_packages
packages = image_list_installed_packages(d)
supportabilitydata = []
for pkg in packages:
pkgdata = {}
pkgdata["package"] = pkg
pkgdata["recipe"] = getrecipereverse(d, pkg)
pkgdata["supportstatus"] = get_supportability_status(d, pkgdata["package"], pkgdata["recipe"])
supportabilitydata.append(pkgdata)
with open(report_file, "w+") as report:
report_format = d.getVar("ONIRO_SUPPORT_REPORT_FMT")
if report_format is None or report_format == "text":
report.write(" ".join(generate_report_txt(supportabilitydata)))
else:
bb.warn("Format {} is not implemeted yet".format(report_format))
## TODO Move into oe-core (widely used flow accross the distributionn
if os.path.exists(sreport_latest_link):
os.remove(sreport_latest_link)
os.symlink(report_file, sreport_latest_link);
}
ROOTFS_POSTPROCESS_COMMAND += " supportability_report; "
Loading