Skip to content

Commit

Permalink
scripts/machine-summary: show patch count in the overview
Browse files Browse the repository at this point in the history
Instead of simply adding a tag saying "Patched", include the patch count
and make a judgement call on whether the patches are "safe" or not. For
example, patches which are entirely backports or inappropriate are
"safe", pending and denied patches are not.

Signed-off-by: Ross Burton <[email protected]>
  • Loading branch information
rossburton committed Jan 25, 2022
1 parent 38cd9b6 commit 72bb1ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions scripts/machine-summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def needs_update(version, upstream):
version = version.replace("+git", "")
return version != upstream

def safe_patches(patches):
for info in patches:
if info["status"] in ("Denied", "Pending", "Unknown"):
return False
return True

def layer_path(layername, d):
"""
Return the path to the specified layer, or None if the layer isn't present.
Expand Down Expand Up @@ -100,6 +106,7 @@ def harvest_data(machines, recipes):
details["fullversion"] = d.getVar("PV")
details["patches"] = [extract_patch_info(p, d) for p in oe.patch.src_patches(d)]
details["patched"] = bool(details["patches"])
details["patches_safe"] = safe_patches(details["patches"])

# Now backfill the upstream versions
for machine in versions:
Expand Down Expand Up @@ -148,11 +155,15 @@ def get_template(self, name):
template_dir = os.path.dirname(os.path.abspath(__file__))
env = jinja2.Environment(
loader=jinja2.FileSystemLoader(template_dir),
extensions=['jinja2.ext.i18n'],
autoescape=jinja2.select_autoescape(),
trim_blocks=True,
lstrip_blocks=True
)

# We only need i18n for plurals
env.install_null_translations()

return env.get_template(name)

class TextOverview(Format):
Expand Down
8 changes: 7 additions & 1 deletion scripts/report-index.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
{% if details.patches or details.needs_update %}
<br>
{% if details.patches %}
<span class="tag is-info">Patched</span>
<span class="tag {{ "is-info" if details.patches_safe else "is-danger" }}">
{% trans count=details.patches|length %}
{{ count }} Patch
{% pluralize %}
{{ count }} Patches
{% endtrans %}
</span>
{% endif %}
{% if details.needs_update %}
<span class="tag is-danger">Upgrade</span>
Expand Down

0 comments on commit 72bb1ad

Please sign in to comment.