From 7fcf92a2a4ec563799a794529833bd67215a37f4 Mon Sep 17 00:00:00 2001 From: Rod Smith Date: Fri, 8 May 2020 14:28:21 -0400 Subject: Revised calls to external programs in check-prerelease script --- bin/check-prerelease | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'bin') diff --git a/bin/check-prerelease b/bin/check-prerelease index 1e5ce02..5e24902 100755 --- a/bin/check-prerelease +++ b/bin/check-prerelease @@ -45,27 +45,21 @@ def check_kernel_status(): retval = True command = "apt-cache showpkg linux-image-{}".format(kernel_release) - aptinfo = [] - aptinfo_bytes = check_output(shlex.split(command)) - aptinfo = (aptinfo_bytes.decode(encoding="utf-8", errors="ignore") - .splitlines()) + aptinfo = check_output(shlex.split(command), universal_newlines=True) # Exclude kernels that come from obvious PPAs.... - if any("ppa.launchpad.net" in s for s in aptinfo): + if "ppa.launchpad.net" in aptinfo: print("* Kernel appears to have come from a PPA!") retval = False # Exclude kernels that don't come from the main repo - if not any("main_binary" in s for s in aptinfo): + if "main_binary" not in aptinfo: print("* Kernel does not come from the main Ubuntu repository!") retval = False try: command = "apt-cache show linux-image-{}".format(kernel_release) - aptinfo = [] - aptinfo_bytes = check_output(shlex.split(command)) - aptinfo = (aptinfo_bytes.decode(encoding="utf-8", errors="ignore") - .splitlines()) + aptinfo = check_output(shlex.split(command), universal_newlines=True) except CalledProcessError: # "apt-cache show" returns an error status if called on a # non-existent package. @@ -75,16 +69,16 @@ def check_kernel_status(): # Exclude 'edge' kernels, which are identified via the 'Source:' line # in the apt-cache show output.... - if any("Source: linux-signed-hwe-edge" in s for s in aptinfo): + if "Source: linux-signed-hwe-edge" in aptinfo: print("* Kernel is an 'edge' kernel!") retval = False - if any("Source: linux-hwe-edge" in s for s in aptinfo): + if "Source: linux-hwe-edge" in aptinfo: print("* Kernel is an 'edge' kernel!") retval = False # Exclude kernels that aren't from the "linux" (or variant, like # "linux-hwe" or "linux-signed") source.... - if not any("Source: linux" in s for s in aptinfo): + if "Source: linux" not in aptinfo: print("* Kernel is not a Canonical kernel!") retval = False @@ -110,9 +104,7 @@ def check_os_status(): """ retval = True command = "lsb_release -s -d" - lsbinfo = [] - lsbinfo_bytes = check_output(shlex.split(command)) - lsbinfo = lsbinfo_bytes.decode(encoding="utf-8", errors="ignore") + lsbinfo = check_output(shlex.split(command), universal_newlines=True) # OS information include '(development branch)' on pre-release # installations. Such installations should fail this test. -- cgit v1.2.3