Skip to contentSkip to conversation

uboot-config.bbclass: overlay locally for a fix

PATCH New Denys Dmytriyenko 1 participant 2 messages Jun 9, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 uboot-config.bbclass: overlay locally for a fix

The fix was submitted upstream and once accepted, the class can be removed here

---
 meta-arago-distro/classes/uboot-config.bbclass | 62 ++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 meta-arago-distro/classes/uboot-config.bbclass
meta-arago-distro/classes/uboot-config.bbclass new file +62 -0
new file mode 100644
index 0000000..3f760f2
@@ -0,0 +1,62 @@
+# Handle U-Boot config for a machine
+#
+# The format to specify it, in the machine, is:
+#
+# UBOOT_CONFIG ??= <default>
+# UBOOT_CONFIG[foo] = "config,images,binary"
+#
+# or
+#
+# UBOOT_MACHINE = "config"
+#
+# Copyright 2013, 2014 (C) O.S. Systems Software LTDA.
+
+UBOOT_BINARY ?= "u-boot.${UBOOT_SUFFIX}"
+
+python () {
+    ubootmachine = d.getVar("UBOOT_MACHINE", True)
+    ubootconfigflags = d.getVarFlags('UBOOT_CONFIG')
+    ubootbinary = d.getVar('UBOOT_BINARY', True)
+    ubootbinaries = d.getVar('UBOOT_BINARIES', True)
+    # The "doc" varflag is special, we don't want to see it here
+    ubootconfigflags.pop('doc', None)
+
+    if not ubootmachine and not ubootconfigflags:
+        PN = d.getVar("PN", True)
+        FILE = os.path.basename(d.getVar("FILE", True))
+        bb.debug(1, "To build %s, see %s for instructions on \
+                 setting up your machine config" % (PN, FILE))
+        raise bb.parse.SkipPackage("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE", True))
+
+    if ubootmachine and ubootconfigflags:
+        raise bb.parse.SkipPackage("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.")
+
+    if ubootconfigflags and ubootbinaries:
+        raise bb.parse.SkipPackage("You cannot use UBOOT_BINARIES as it is internal to uboot_config.bbclass.")
+
+    if not ubootconfigflags:
+        return
+
+    ubootconfig = (d.getVar('UBOOT_CONFIG', True) or "").split()
+    if len(ubootconfig) > 0:
+        for config in ubootconfig:
+            for f, v in ubootconfigflags.items():
+                if config == f: 
+                    items = v.split(',')
+                    if items[0] and len(items) > 3:
+                        raise bb.parse.SkipPackage('Only config,images,binary can be specified!')
+                    d.appendVar('UBOOT_MACHINE', ' ' + items[0])
+                    # IMAGE_FSTYPES appending
+                    if len(items) > 1 and items[1]:
+                        bb.debug(1, "Appending '%s' to IMAGE_FSTYPES." % items[1])
+                        d.appendVar('IMAGE_FSTYPES', ' ' + items[1])
+                    if len(items) > 2 and items[2]:
+                        bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % items[2])
+                        d.appendVar('UBOOT_BINARIES', ' ' + items[2])
+                    else:
+                        bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % ubootbinary)
+                        d.appendVar('UBOOT_BINARIES', ' ' + ubootbinary)
+                    break
+    elif len(ubootconfig) == 0:
+       raise bb.parse.SkipPackage('You must set a default in UBOOT_CONFIG.')
+}
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 uboot-config: check UBOOT_CONFIG variable, not flags, for error conditions

Sometimes there's a need to change existing UBOOT_CONFIG setting from a recipe, distro or local config, such as an override or even switch back to UBOOT_MACHINE. Unfortunately, there's no easy way to override or unset flags, so using them as an error condition is rather heavy-handed. Change those conditions to check the UBOOT_CONFIG variable itself, not its flags.

---
 meta-arago-distro/classes/uboot-config.bbclass | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
meta-arago-distro/classes/uboot-config.bbclass +3 -8
index 3f760f2..7117701 100644
@@ -20,24 +20,21 @@ python () {
     ubootbinaries = d.getVar('UBOOT_BINARIES', True)
     # The "doc" varflag is special, we don't want to see it here
     ubootconfigflags.pop('doc', None)
+    ubootconfig = (d.getVar('UBOOT_CONFIG', True) or "").split()
 
-    if not ubootmachine and not ubootconfigflags:
+    if not ubootmachine and len(ubootconfig) == 0:
         PN = d.getVar("PN", True)
         FILE = os.path.basename(d.getVar("FILE", True))
         bb.debug(1, "To build %s, see %s for instructions on \
                  setting up your machine config" % (PN, FILE))
         raise bb.parse.SkipPackage("Either UBOOT_MACHINE or UBOOT_CONFIG must be set in the %s machine configuration." % d.getVar("MACHINE", True))
 
-    if ubootmachine and ubootconfigflags:
+    if ubootmachine and len(ubootconfig) > 0:
         raise bb.parse.SkipPackage("You cannot use UBOOT_MACHINE and UBOOT_CONFIG at the same time.")
 
     if ubootconfigflags and ubootbinaries:
         raise bb.parse.SkipPackage("You cannot use UBOOT_BINARIES as it is internal to uboot_config.bbclass.")
 
-    if not ubootconfigflags:
-        return
-
-    ubootconfig = (d.getVar('UBOOT_CONFIG', True) or "").split()
     if len(ubootconfig) > 0:
         for config in ubootconfig:
             for f, v in ubootconfigflags.items():
@@ -57,6 +54,4 @@ python () {
                         bb.debug(1, "Appending '%s' to UBOOT_BINARIES." % ubootbinary)
                         d.appendVar('UBOOT_BINARIES', ' ' + ubootbinary)
                     break
-    elif len(ubootconfig) == 0:
-       raise bb.parse.SkipPackage('You must set a default in UBOOT_CONFIG.')
 }
Signature · 1 line
2.7.4