diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2011-08-17 18:48:15 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-08-19 09:29:18 -0700 |
| commit | e043c9d1ce56dfa35d4d31454af303f9d482ec3c (patch) | |
| tree | fc780aab9e20d94eef2b7b3440410473cd329a89 | |
| parent | 333d571b360e112d7ade0b4ae3bacbda9c8b228d (diff) | |
| download | poky-e043c9d1ce56dfa35d4d31454af303f9d482ec3c.tar.gz | |
sanity.bbclass: add optional untested host distro warning
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].
(From OE-Core rev: 75e3875341ddc8940e9ee2ccbbb2ec18194a68e6)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | 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 d50c8434ac..16af0293d9 100644 --- a/meta/classes/sanity.bbclass +++ b/meta/classes/sanity.bbclass | |||
| @@ -118,6 +118,52 @@ def check_connectivity(d): | |||
| 118 | 118 | ||
| 119 | return retval | 119 | return retval |
| 120 | 120 | ||
| 121 | def check_supported_distro(e): | ||
| 122 | tested_distros = e.data.getVar('SANITY_TESTED_DISTROS', True) | ||
| 123 | if not tested_distros: | ||
| 124 | return | ||
| 125 | |||
| 126 | if os.path.exists("/etc/redhat-release"): | ||
| 127 | f = open("/etc/redhat-release", "r") | ||
| 128 | try: | ||
| 129 | distro = f.readline() | ||
| 130 | finally: | ||
| 131 | f.close() | ||
| 132 | elif os.path.exists("/etc/SuSE-release"): | ||
| 133 | f = open("/etc/SuSE-release", "r") | ||
| 134 | try: | ||
| 135 | distro = f.readline() | ||
| 136 | # Remove the architecture suffix e.g. (i586) | ||
| 137 | distro = re.sub(r' \([a-zA-Z0-9\-_]*\)$', '', distro).strip() | ||
| 138 | finally: | ||
| 139 | f.close() | ||
| 140 | else: | ||
| 141 | # Use LSB method | ||
| 142 | import subprocess as sub | ||
| 143 | try: | ||
| 144 | p = sub.Popen(['lsb_release','-d','-s'],stdout=sub.PIPE,stderr=sub.PIPE) | ||
| 145 | out, err = p.communicate() | ||
| 146 | distro = out.rstrip() | ||
| 147 | except Exception: | ||
| 148 | distro = None | ||
| 149 | |||
| 150 | if not distro: | ||
| 151 | if os.path.exists("/etc/lsb-release"): | ||
| 152 | f = open("/etc/lsb-release", "r") | ||
| 153 | try: | ||
| 154 | for line in f: | ||
| 155 | lns = line.split('=') | ||
| 156 | if lns[0] == "DISTRIB_DESCRIPTION": | ||
| 157 | distro = lns[1].strip('"\n') | ||
| 158 | break | ||
| 159 | finally: | ||
| 160 | f.close() | ||
| 161 | if distro: | ||
| 162 | if distro not in [x.strip() for x in tested_distros.split('\n')]: | ||
| 163 | 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) | ||
| 164 | else: | ||
| 165 | bb.warn('Host distribution could not be determined; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.') | ||
| 166 | |||
| 121 | def check_sanity(e): | 167 | def check_sanity(e): |
| 122 | from bb import note, error, data, __version__ | 168 | from bb import note, error, data, __version__ |
| 123 | 169 | ||
| @@ -249,6 +295,8 @@ def check_sanity(e): | |||
| 249 | if pseudo_msg != "": | 295 | if pseudo_msg != "": |
| 250 | messages = messages + pseudo_msg + '\n' | 296 | messages = messages + pseudo_msg + '\n' |
| 251 | 297 | ||
| 298 | check_supported_distro(e) | ||
| 299 | |||
| 252 | # Check if DISPLAY is set if IMAGETEST is set | 300 | # Check if DISPLAY is set if IMAGETEST is set |
| 253 | if not data.getVar( 'DISPLAY', e.data, True ) and data.getVar( 'IMAGETEST', e.data, True ) == 'qemu': | 301 | if not data.getVar( 'DISPLAY', e.data, True ) and data.getVar( 'IMAGETEST', e.data, True ) == 'qemu': |
| 254 | messages = messages + 'qemuimagetest needs a X desktop to start qemu, please set DISPLAY correctly (e.g. DISPLAY=:1.0)\n' | 302 | messages = messages + 'qemuimagetest needs a X desktop to start qemu, please set DISPLAY correctly (e.g. DISPLAY=:1.0)\n' |
