All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] sanity: getstatusoutput returns an int, not a string
@ 2017-12-05 17:53 Ross Burton
  2017-12-05 17:53 ` [PATCH 2/2] classes/sanity: check we don't have an ancient GNU patch Ross Burton
  0 siblings, 1 reply; 2+ messages in thread
From: Ross Burton @ 2017-12-05 17:53 UTC (permalink / raw)
  To: openembedded-core

This code is an error path so nobody noticed that oe.utils.getstatusoutput() is
just a wrapper around subprocess.getstatusoutput() which returns an (int,
string) pair not (string, string).

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/sanity.bbclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 1feb7949daa..1410af29017 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -462,7 +462,7 @@ def check_make_version(sanity_data):
     from distutils.version import LooseVersion
     status, result = oe.utils.getstatusoutput("make --version")
     if status != 0:
-        return "Unable to execute make --version, exit code %s\n" % status
+        return "Unable to execute make --version, exit code %d\n" % status
     version = result.split()[2]
     if LooseVersion(version) == LooseVersion("3.82"):
         # Construct a test file
@@ -498,7 +498,7 @@ def check_tar_version(sanity_data):
     from distutils.version import LooseVersion
     status, result = oe.utils.getstatusoutput("tar --version")
     if status != 0:
-        return "Unable to execute tar --version, exit code %s\n" % status
+        return "Unable to execute tar --version, exit code %d\n" % status
     version = result.split()[3]
     if LooseVersion(version) < LooseVersion("1.24"):
         return "Your version of tar is older than 1.24 and has bugs which will break builds. Please install a newer version of tar.\n"
@@ -511,7 +511,7 @@ def check_git_version(sanity_data):
     from distutils.version import LooseVersion
     status, result = oe.utils.getstatusoutput("git --version 2> /dev/null")
     if status != 0:
-        return "Unable to execute git --version, exit code %s\n" % status
+        return "Unable to execute git --version, exit code %d\n" % status
     version = result.split()[2]
     if LooseVersion(version) < LooseVersion("1.8.3.1"):
         return "Your version of git is older than 1.8.3.1 and has bugs which will break builds. Please install a newer version of git.\n"
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] classes/sanity: check we don't have an ancient GNU patch
  2017-12-05 17:53 [PATCH 1/2] sanity: getstatusoutput returns an int, not a string Ross Burton
@ 2017-12-05 17:53 ` Ross Burton
  0 siblings, 0 replies; 2+ messages in thread
From: Ross Burton @ 2017-12-05 17:53 UTC (permalink / raw)
  To: openembedded-core

We depend on the host GNU patch, but patch < 2.7 can't handle git-style patches.
This results in patches that fail to apply, or worse apply incorrectly.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/sanity.bbclass | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 1410af29017..d0f507e0c50 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -456,6 +456,22 @@ def check_sanity_validmachine(sanity_data):
 
     return messages
 
+# Patch before 2.7 can't handle all the features in git-style diffs.  Some
+# patches may incorrectly apply, and others won't apply at all.
+def check_patch_version(sanity_data):
+    from distutils.version import LooseVersion
+    import re, subprocess
+
+    try:
+        result = subprocess.check_output(["patch", "--version"], stderr=subprocess.STDOUT, universal_newlines=True)
+        version = re.search(r"[0-9.]+", result.splitlines()[0]).group()
+        if LooseVersion(version) < LooseVersion("2.7"):
+            return "Your version of patch is older than 2.7 and has bugs which will break builds. Please install a newer version of patch.\n"
+        else:
+            return None
+    except subprocess.CalledProcessError as e:
+        return "Unable to execute patch --version, exit code %d:\n%s\n" % (e.returncode, e.output)
+
 # Unpatched versions of make 3.82 are known to be broken.  See GNU Savannah Bug 30612.
 # Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate.
 def check_make_version(sanity_data):
@@ -596,6 +612,7 @@ def check_sanity_version_change(status, d):
     import stat
 
     status.addresult(check_make_version(d))
+    status.addresult(check_patch_version(d))
     status.addresult(check_tar_version(d))
     status.addresult(check_git_version(d))
     status.addresult(check_perl_modules(d))
-- 
2.11.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-05 17:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-05 17:53 [PATCH 1/2] sanity: getstatusoutput returns an int, not a string Ross Burton
2017-12-05 17:53 ` [PATCH 2/2] classes/sanity: check we don't have an ancient GNU patch Ross Burton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.