[Merge] ~lamoura/update-notifier:update-esm-handling into update-notifier:master

Chad Smith chad.smith at canonical.com
Tue Apr 13 17:41:20 UTC 2021



Diff comments:

> diff --git a/data/apt_check.py b/data/apt_check.py
> index 2c18ef6..15dea73 100755
> --- a/data/apt_check.py
> +++ b/data/apt_check.py
> @@ -73,11 +83,88 @@ def write_package_names(outstream, cache, depcache):
>      outstream.write("\n".join([p.name for p in pkgs]))
>  
>  
> +def is_esm_distro():

I think we can drop this function for two reasons:
 If we can, we should limit subprocess calls because it costs more than just working in python, since all we are needed is a bool about whether we are an esm distro here. We can just from distro_info import UbuntuDistroInfo; di = UbuntuDistroInfo(); bool(DISTRO in di.supported_esm())`   this'll allow us to avoid two subproccess calls and get's us the same strict is_esm_distro boolean.

> +    proc = subprocess.Popen(
> +        ["ubuntu-distro-info", "--series", DISTRO, "-yeol-esm"],
> +        stdout=subprocess.PIPE, stderr=subprocess.PIPE
> +    )
> +    valid_esm_distro, _ = proc.communicate()
> +
> +    # Some ubuntu releases do not go into ESM mode
> +    # For example, groovyu (20.10).
> +    if valid_esm_distro.strip().decode("utf-8") == "(unknown)":
> +        return False
> +
> +    proc = subprocess.Popen(
> +        ["ubuntu-distro-info", "--series", DISTRO, "-yeol"],
> +        stdout=subprocess.PIPE, stderr=subprocess.PIPE
> +    )
> +    days_until_esm, _ = proc.communicate()
> +
> +    return True if int(days_until_esm.strip()) <= 0 else False

This check incorrectly returns False on Xenial/Bionic and Focal because those LTS releases haven't entered esm stage of the distro lifecycle yet. I think we need to drop this conditional in general since we still want this banner before entering ESM right?

> +
> +
> +def _output_esm_package_count(outstream, service_type, esm_pkg_count):
> +    if esm_pkg_count > 0:
> +        outstream.write("\n")
> +        outstream.write(gettext.dngettext("update-notifier",
> +                                          "%i of these updates is fixed "
> +                                          "through UA %s: ESM.",
> +                                          "%i of these updates are "
> +                                          "fixed through UA "
> +                                          "%s: ESM.",
> +                                          esm_pkg_count) %
> +                        (esm_pkg_count, service_type))
> +
> +
> +def _output_esm_package_alert(
> +    outstream, service_type, esm_distro, disabled_pkg_count
> +):
> +    if esm_distro:
> +        outstream.write("\n")
> +        if disabled_pkg_count > 0:
> +            outstream.write("\n")
> +            outstream.write(gettext.dngettext("update-notifier",
> +                                              "%i additional security "
> +                                              "updates can be applied "
> +                                              "with UA %s: ESM\nLearn "
> +                                              "more about enabling UA "
> +                                              "%s: ESM service at "
> +                                              "https://ubuntu.com/esm",
> +                                              "%i additional security "
> +                                              "updates can be applied "
> +                                              "with UA %s: ESM\nLearn "
> +                                              "more about enabling UA "
> +                                              "%s: ESM service at "
> +                                              "https://ubuntu.com/esm",
> +                                              disabled_pkg_count) %
> +                            (disabled_pkg_count, service_type, service_type))
> +        else:
> +            outstream.write("\n")
> +            outstream.write(gettext.dgettext("update-notifier",
> +                                             "Enable UA %s: ESM to "
> +                                             "receive additional future "
> +                                             "security updates.") %
> +                            service_type)
> +
> +            outstream.write("\n")
> +            outstream.write(
> +                gettext.dgettext("update-notifier",
> +                                 "See https://ubuntu.com/security/esm "
> +                                 "or run: sudo ua status")
> +            )
> +
> +
>  def write_human_readable_summary(outstream, upgrades, security_updates,
> -                                 esm_updates, have_esm, disabled_esm_updates):
> +                                 esm_infra_updates, esm_apps_updates,
> +                                 have_esm_infra, have_esm_apps,
> +                                 disabled_esm_infra_updates,
> +                                 disabled_esm_apps_updates):
> +
> +    esm_distro = is_esm_distro()
>      " write out human summary summary to outstream "
> -    if have_esm is not None:
> -        if have_esm:
> +    if have_esm_infra is not None and esm_distro:
> +        if have_esm_infra:
>              outstream.write(gettext.dgettext("update-notifier",
>                                               "UA Infra: Extended "
>                                               "Security Maintenance (ESM) is "


-- 
https://code.launchpad.net/~lamoura/update-notifier/+git/update-notifier/+merge/401002
Your team Ubuntu Core Development Team is subscribed to branch update-notifier:master.



More information about the Ubuntu-reviews mailing list