Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [RFC PATCH 2/2] sanity.bbclass: add optional untested host distro warning
Date: Wed, 17 Aug 2011 19:37:38 +0100	[thread overview]
Message-ID: <5e4613d910b644db95a096b7637ceecf85e2c179.1313606178.git.paul.eggleton@linux.intel.com> (raw)
In-Reply-To: <cover.1313606178.git.paul.eggleton@linux.intel.com>
In-Reply-To: <cover.1313606178.git.paul.eggleton@linux.intel.com>

SANITY_TESTED_DISTROS, if specified, is expected to be a
newline-delimited list of distro identifier strings, e.g.

SANITY_TESTED_DISTROS = " \
        Ubuntu 11.04 \
        Fedora release 14 (Laughlin) \
        "

(spaces, tabs etc. are trimmed)

If SANITY_TESTED_DISTROS is defined, we will attempt to detect the host
distribution. If the distribution is not in SANITY_TESTED_DISTROS or we
could not detect the distribution then we show a warning during sanity
checking.

Provides the mechanism for fixing [YOCTO #1096].

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 meta/classes/sanity.bbclass |   48 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index d50c843..16af029 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -118,6 +118,52 @@ def check_connectivity(d):
 
     return retval
 
+def check_supported_distro(e):
+    tested_distros = e.data.getVar('SANITY_TESTED_DISTROS', True)
+    if not tested_distros:
+        return
+
+    if os.path.exists("/etc/redhat-release"):
+        f = open("/etc/redhat-release", "r")
+        try:
+            distro = f.readline()
+        finally:
+            f.close()
+    elif os.path.exists("/etc/SuSE-release"):
+        f = open("/etc/SuSE-release", "r")
+        try:
+            distro = f.readline()
+            # Remove the architecture suffix e.g. (i586)
+            distro = re.sub(r' \([a-zA-Z0-9\-_]*\)$', '', distro).strip()
+        finally:
+            f.close()
+    else:
+        # Use LSB method
+        import subprocess as sub
+        try:
+            p = sub.Popen(['lsb_release','-d','-s'],stdout=sub.PIPE,stderr=sub.PIPE)
+            out, err = p.communicate()
+            distro = out.rstrip()
+        except Exception:
+            distro = None
+
+        if not distro:
+            if os.path.exists("/etc/lsb-release"):
+                f = open("/etc/lsb-release", "r")
+                try:
+                    for line in f:
+                        lns = line.split('=')
+                        if lns[0] == "DISTRIB_DESCRIPTION":
+                            distro = lns[1].strip('"\n')
+                            break
+                finally:
+                    f.close()
+    if distro:
+        if distro not in [x.strip() for x in tested_distros.split('\n')]:
+            bb.warn('Host distribution "%s" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.' % distro)
+    else:
+        bb.warn('Host distribution could not be determined; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.')
+
 def check_sanity(e):
     from bb import note, error, data, __version__
 
@@ -249,6 +295,8 @@ def check_sanity(e):
     if pseudo_msg != "":
         messages = messages + pseudo_msg + '\n'
 
+    check_supported_distro(e)
+
     # Check if DISPLAY is set if IMAGETEST is set
     if not data.getVar( 'DISPLAY', e.data, True ) and data.getVar( 'IMAGETEST', e.data, True ) == 'qemu':
         messages = messages + 'qemuimagetest needs a X desktop to start qemu, please set DISPLAY correctly (e.g. DISPLAY=:1.0)\n'
-- 
1.7.4.1




  parent reply	other threads:[~2011-08-17 18:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-17 18:37 [RFC PATCH 0/2] Couple of fixes to help new users Paul Eggleton
2011-08-17 18:37 ` [RFC PATCH 1/2] image.bbclass, kernel.bbclass: create warning file about deleting deploydir files Paul Eggleton
2011-08-17 18:41   ` Phil Blundell
2011-08-19 10:27     ` Paul Eggleton
2011-08-23 19:08       ` Darren Hart
2011-08-23 20:07         ` Paul Eggleton
2011-08-23 21:39           ` Koen Kooi
2011-08-23 21:52             ` Paul Eggleton
2011-08-22 21:01   ` Koen Kooi
2011-08-23  6:44     ` Anders Darander
2011-08-23  8:33       ` Koen Kooi
2011-08-23  9:22       ` Phil Blundell
2011-08-23  9:32         ` Paul Eggleton
2011-08-23 10:37           ` Phil Blundell
2011-08-17 18:37 ` Paul Eggleton [this message]
2011-08-23 15:14 ` [RFC PATCH 0/2] Couple of fixes to help new users Saul Wold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5e4613d910b644db95a096b7637ceecf85e2c179.1313606178.git.paul.eggleton@linux.intel.com \
    --to=paul.eggleton@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox