Update drivers
[vuplus_openembedded] / classes / sanity.bbclass
index 08b077a..d965003 100644 (file)
@@ -2,15 +2,6 @@
 # Sanity check the users setup for common misconfigurations
 #
 
-#
-# SANITY_ABI allows us to notify users when the format of TMPDIR changes in 
-# an incompatible way. Such changes should usually be detailed in the commit
-# that breaks the format and have been previously discussed on the mailing list 
-# with general agreement from the core team.
-#
-SANITY_ABI = "0"
-SANITY_ABIFILE = "${TMPDIR}/abi_version"
-
 def raise_sanity_error(msg):
        import bb
        bb.fatal(""" Openembedded's config sanity checker detected a potential misconfiguration.
@@ -20,8 +11,6 @@ def raise_sanity_error(msg):
        %s""" % msg)
 
 def check_conf_exists(fn, data):
-       import bb, os
-
        bbpath = []
        fn = bb.data.expand(fn, data)
        vbbpath = bb.data.getVar("BBPATH", data)
@@ -35,12 +24,12 @@ def check_conf_exists(fn, data):
 
 def check_sanity(e):
        from bb import note, error, data, __version__
-       from bb.event import Handled, NotHandled, getName
+
        try:
                from distutils.version import LooseVersion
        except ImportError:
                def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
-       import os, commands
+       import commands
 
        # Check the bitbake version meets minimum requirements
        minversion = data.getVar('BB_MIN_VERSION', e.data , True)
@@ -92,7 +81,7 @@ def check_sanity(e):
        if not check_app_exists('${BUILD_PREFIX}g++', e.data):
                missing = missing + "C++ Compiler (${BUILD_PREFIX}g++),"
 
-       required_utilities = "patch help2man diffstat texi2html makeinfo cvs svn bzip2 tar gzip gawk md5sum"
+       required_utilities = "patch help2man diffstat texi2html makeinfo cvs svn bzip2 tar gzip gawk md5sum sshpass"
 
        if data.getVar('TARGET_ARCH', e.data, True) == "arm":
                # qemu-native needs gcc 3.x
@@ -107,6 +96,15 @@ def check_sanity(e):
                        if not check_app_exists("qemu-arm", e.data):
                                messages = messages + "qemu-native was in ASSUME_PROVIDED but the QEMU binaries (qemu-arm) can't be found in PATH"
 
+               try:
+                       if os.path.exists("/proc/sys/vm/mmap_min_addr"):
+                               f = file("/proc/sys/vm/mmap_min_addr", "r")
+                               if (f.read().strip() != "0"):
+                                       messages = messages + "/proc/sys/vm/mmap_min_addr is not 0. This will cause problems with qemu so please fix the value (as root).\n\nTo fix this in later reboots, set vm.mmap_min_addr = 0 in /etc/sysctl.conf.\n"
+                               f.close()
+               except:
+                       pass
+
        for util in required_utilities.split():
                if not check_app_exists( util, e.data ):
                        missing = missing + "%s," % util
@@ -115,6 +113,12 @@ def check_sanity(e):
                missing = missing.rstrip(',')
                messages = messages + "Please install following missing utilities: %s\n" % missing
 
+       try:
+           if os.path.basename(os.readlink('/bin/sh')) == 'dash':
+                   print "WARNING: Using dash as /bin/sh causes various subtle build problems, please consider using bash instead."
+       except:
+               pass
+
        omask = os.umask(022)
        if omask & 0755:
                messages = messages + "Please use a umask which allows a+rx and u+rwx\n"
@@ -134,6 +138,8 @@ def check_sanity(e):
                if (f.read().strip() != tmpdir):
                        messages = messages + "Error, TMPDIR has changed location. You need to either move it back to %s or rebuild\n" % tmpdir
        else:
+               import bb
+               bb.mkdirhier(tmpdir)
                f = file(checkfile, "w")
                f.write(tmpdir)
        f.close()
@@ -141,12 +147,15 @@ def check_sanity(e):
        #
        # Check the 'ABI' of TMPDIR
        #
-       current_abi = data.getVar('SANITY_ABI', e.data, True)
+       current_abi = data.getVar('OELAYOUT_ABI', e.data, True)
        abifile = data.getVar('SANITY_ABIFILE', e.data, True)
        if os.path.exists(abifile):
                f = file(abifile, "r")
                abi = f.read().strip()
-               if (abi != current_abi):
+               if not abi.isdigit():
+                       f = file(abifile, "w")
+                       f.write(current_abi)
+               elif (abi != current_abi):
                        # Code to convert from one ABI to another could go here if possible.
                        messages = messages + "Error, TMPDIR has changed ABI (%s to %s) and you need to either rebuild, revert or adjust it at your own risk.\n" % (abi, current_abi)
        else:
@@ -154,15 +163,39 @@ def check_sanity(e):
                f.write(current_abi)
        f.close()
 
+       #
+       # Check the Distro PR value didn't change
+       #
+       distro_pr = data.getVar('DISTRO_PR', e.data, True)
+       prfile = data.getVar('SANITY_PRFILE', e.data, True)
+       if os.path.exists(prfile):
+               f = file(prfile, "r")
+               pr = f.read().strip()
+               if (pr != distro_pr):
+                       # Code to convert from one ABI to another could go here if possible.
+                       messages = messages + "Error, DISTRO_PR has changed (%s to %s) which means all packages need to rebuild. Please remove your TMPDIR so this can happen. For autobuilder setups you can avoid this by using a TMPDIR that include DISTRO_PR in the path.\n" % (pr, distro_pr)
+       else:
+               f = file(prfile, "w")
+               f.write(distro_pr)
+       f.close()
+
+
+       #
+       # Check there aren't duplicates in PACKAGE_ARCHS
+       #
+       archs = data.getVar('PACKAGE_ARCHS', e.data, True).split()
+       for arch in archs:
+               if archs.count(arch) != 1:
+                       messages = messages + "Error, Your PACKAGE_ARCHS field contains duplicates. Perhaps you set PACKAGE_EXTRA_ARCHS twice accidently through some tune file?\n"
+                       break
+
        if messages != "":
                raise_sanity_error(messages)
 
 addhandler check_sanity_eventhandler
 python check_sanity_eventhandler() {
-    from bb import note, error, data, __version__
-    from bb.event import getName
-
-    if getName(e) == "ConfigParsed":
+    from bb.event import Handled, NotHandled
+    if bb.event.getName(e) == "ConfigParsed":
         check_sanity(e)
 
     return NotHandled