Sumo refresh

Update external subtrees to latest Yocto sumo.

Change-Id: I8364f32bef079841c6e57f1c587f4b1bedf62fef
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/poky/scripts/lib/devtool/sdk.py b/poky/scripts/lib/devtool/sdk.py
index f46577c..4616753 100644
--- a/poky/scripts/lib/devtool/sdk.py
+++ b/poky/scripts/lib/devtool/sdk.py
@@ -145,6 +145,9 @@
         # Fetch manifest from server
         tmpmanifest = os.path.join(tmpsdk_dir, 'conf', 'sdk-conf-manifest')
         ret = subprocess.call("wget -q -O %s %s/conf/sdk-conf-manifest" % (tmpmanifest, updateserver), shell=True)
+        if ret != 0:
+            logger.error("Cannot dowload files from %s" % updateserver)
+            return ret
         changedfiles = check_manifest(tmpmanifest, basepath)
         if not changedfiles:
             logger.info("Already up-to-date")
diff --git a/poky/scripts/lib/wic/canned-wks/qemux86-directdisk.wks b/poky/scripts/lib/wic/canned-wks/qemux86-directdisk.wks
index 1f8466a..cfa32bd 100644
--- a/poky/scripts/lib/wic/canned-wks/qemux86-directdisk.wks
+++ b/poky/scripts/lib/wic/canned-wks/qemux86-directdisk.wks
@@ -4,5 +4,5 @@
 
 include common.wks.inc
 
-bootloader  --timeout=0  --append="vga=0 uvesafb.mode_option=640x480-32 rw mem=256M ip=192.168.7.2::192.168.7.1:255.255.255.0 oprofile.timer=1 rootfstype=ext4 "
+bootloader  --timeout=0  --append="vga=0 rw mem=256M ip=192.168.7.2::192.168.7.1:255.255.255.0 oprofile.timer=1 rootfstype=ext4 "
 
diff --git a/poky/scripts/lib/wic/engine.py b/poky/scripts/lib/wic/engine.py
index edcfab3..f0c5ff0 100644
--- a/poky/scripts/lib/wic/engine.py
+++ b/poky/scripts/lib/wic/engine.py
@@ -284,8 +284,8 @@
             aname = "_%s" % name
             if aname not in self.__dict__:
                 setattr(self, aname, find_executable(name, self.paths))
-                if aname not in self.__dict__:
-                    raise WicError("Can't find executable {}".format(name))
+                if aname not in self.__dict__ or self.__dict__[aname] is None:
+                    raise WicError("Can't find executable '{}'".format(name))
             return self.__dict__[aname]
         return self.__dict__[name]
 
@@ -391,11 +391,8 @@
         def write_ptable(parts, target):
             with tempfile.NamedTemporaryFile(prefix="wic-sfdisk-", mode='w') as outf:
                 write_sfdisk_script(outf, parts)
-                cmd = "{} --no-reread {} < {} 2>/dev/null".format(self.sfdisk, target, outf.name)
-                try:
-                    subprocess.check_output(cmd, shell=True)
-                except subprocess.CalledProcessError as err:
-                    raise WicError("Can't run '{}' command: {}".format(cmd, err))
+                cmd = "{} --no-reread {} < {} ".format(self.sfdisk, target, outf.name)
+                exec_cmd(cmd, as_shell=True)
 
         if expand is None:
             sparse_copy(self.imagepath, target)
@@ -412,11 +409,14 @@
             for line in exec_cmd("{} -F {}".format(self.sfdisk, target)).splitlines():
                 if line.startswith("Unpartitioned space ") and line.endswith("sectors"):
                     free = int(line.split()[-2])
+                    # Align free space to a 2048 sector boundary. YOCTO #12840.
+                    free = free - (free % 2048)
             if free is None:
                 raise WicError("Can't get size of unpartitioned space")
 
             # calculate expanded partitions sizes
             sizes = {}
+            num_auto_resize = 0
             for num, part in enumerate(parts['partitiontable']['partitions'], 1):
                 if num in expand:
                     if expand[num] != 0: # don't resize partition if size is set to 0
@@ -426,10 +426,11 @@
                         sizes[num] = sectors
                 elif part['type'] != 'f':
                     sizes[num] = -1
+                    num_auto_resize += 1
 
             for num, part in enumerate(parts['partitiontable']['partitions'], 1):
                 if sizes.get(num) == -1:
-                    part['size'] += free // len(sizes)
+                    part['size'] += free // num_auto_resize
 
             # write resized partition table to the target
             write_ptable(parts, target)
diff --git a/poky/scripts/lib/wic/plugins/source/bootimg-efi.py b/poky/scripts/lib/wic/plugins/source/bootimg-efi.py
index beb74d7..0eb86a0 100644
--- a/poky/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/poky/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -45,7 +45,7 @@
     name = 'bootimg-efi'
 
     @classmethod
-    def do_configure_grubefi(cls, creator, cr_workdir):
+    def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params):
         """
         Create loader-specific (grub-efi) config
         """
@@ -62,6 +62,18 @@
                 raise WicError("configfile is specified but failed to "
                                "get it from %s." % configfile)
 
+        initrd = source_params.get('initrd')
+
+        if initrd:
+            bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
+            if not bootimg_dir:
+                raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
+
+            cp_cmd = "cp %s/%s %s" % (bootimg_dir, initrd, hdddir)
+            exec_cmd(cp_cmd, True)
+        else:
+            logger.debug("Ignoring missing initrd")
+
         if not custom_cfg:
             # Create grub configuration using parameters from wks file
             bootloader = creator.ks.bootloader
@@ -76,6 +88,10 @@
 
             grubefi_conf += "linux %s root=%s rootwait %s\n" \
                 % (kernel, creator.rootdev, bootloader.append)
+
+            if initrd:
+               grubefi_conf += "initrd /%s\n" % initrd
+
             grubefi_conf += "}\n"
 
         logger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg",
@@ -167,7 +183,7 @@
 
         try:
             if source_params['loader'] == 'grub-efi':
-                cls.do_configure_grubefi(creator, cr_workdir)
+                cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params)
             elif source_params['loader'] == 'systemd-boot':
                 cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
             else:
diff --git a/poky/scripts/multilib_header_wrapper.h b/poky/scripts/multilib_header_wrapper.h
index f516673..9660225 100644
--- a/poky/scripts/multilib_header_wrapper.h
+++ b/poky/scripts/multilib_header_wrapper.h
@@ -22,7 +22,9 @@
  */
 
 
-#if defined (__arm__)
+#if defined (__bpf__)
+#define __MHWORDSIZE			64
+#elif defined (__arm__)
 #define __MHWORDSIZE			32
 #elif defined (__aarch64__) && defined ( __LP64__)
 #define __MHWORDSIZE			64
diff --git a/poky/scripts/oe-pkgdata-util b/poky/scripts/oe-pkgdata-util
index aea8a57..e6c9df9 100755
--- a/poky/scripts/oe-pkgdata-util
+++ b/poky/scripts/oe-pkgdata-util
@@ -277,7 +277,7 @@
                     print("%s is in the RPROVIDES of %s:" % (pkg, f))
                 pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", f)
                 parse_pkgdatafile(pkgdatafile)
-            break
+            continue
         pkgdatafile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
         if not os.path.exists(pkgdatafile):
             logger.error("The following packages could not be found: %s" % pkg)
@@ -286,37 +286,35 @@
 
 def package_info(args):
     def parse_pkgdatafile(pkgdatafile):
+        vars = ['PKGV', 'PKGE', 'PKGR', 'PN', 'PV', 'PE', 'PR', 'PKGSIZE']
+        if args.extra:
+            vars += args.extra
         with open(pkgdatafile, 'r') as f:
-            pkge = ''
-            pkgr = ''
-            pe = ''
-            pr = ''
+            vals = dict()
+            extra = ''
             for line in f:
-                if line.startswith('PKGV:'):
-                    pkg_version = line.split(':', 1)[1].strip()
-                elif line.startswith('PKGE:'):
-                    pkge = line.split(':', 1)[1].strip()
-                elif line.startswith('PKGR:'):
-                    pkgr = line.split(':', 1)[1].strip()
-                elif line.startswith('PN:'):
-                    recipe = line.split(':', 1)[1].strip()
-                elif line.startswith('PV:'):
-                    recipe_version = line.split(':', 1)[1].strip()
-                elif line.startswith('PE:'):
-                    pe = line.split(':', 1)[1].strip()
-                elif line.startswith('PR:'):
-                    pr = line.split(':', 1)[1].strip()
-                elif line.startswith('PKGSIZE'):
-                    pkg_size = line.split(':', 1)[1].strip()
-            if pkge:
-                pkg_version = pkge + ":" + pkg_version
-            if pkgr:
-                pkg_version = pkg_version + "-" + pkgr
-            if pe:
-                recipe_version = pe + ":" + recipe_version
-            if pr:
-                recipe_version = recipe_version + "-" + pr
-            print("%s %s %s %s %s" % (pkg, pkg_version, recipe, recipe_version, pkg_size))
+                for var in vars:
+                    m = re.match(var + '(?:_\S+)?:\s*(.+?)\s*$', line)
+                    if m:
+                        vals[var] = m.group(1)
+            pkg_version = vals['PKGV'] or ''
+            recipe = vals['PN'] or ''
+            recipe_version = vals['PV'] or ''
+            pkg_size = vals['PKGSIZE'] or ''
+            if 'PKGE' in vals:
+                pkg_version = vals['PKGE'] + ":" + pkg_version
+            if 'PKGR' in vals:
+                pkg_version = pkg_version + "-" + vals['PKGR']
+            if 'PE' in vals:
+                recipe_version = vals['PE'] + ":" + recipe_version
+            if 'PR' in vals:
+                recipe_version = recipe_version + "-" + vals['PR']
+            if args.extra:
+                for var in args.extra:
+                    if var in vals:
+                        val = re.sub(r'\s+', ' ', vals[var])
+                        extra += ' "%s"' % val
+            print("%s %s %s %s %s%s" % (pkg, pkg_version, recipe, recipe_version, pkg_size, extra))
 
     # Handle both multiple arguments and multiple values within an arg (old syntax)
     packages = []
@@ -341,7 +339,7 @@
                     print("%s is in the RPROVIDES of %s:" % (pkg, f))
                 pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", f)
                 parse_pkgdatafile(pkgdatafile)
-            break
+            continue
         pkgdatafile = os.path.join(args.pkgdata_dir, "runtime-reverse", pkg)
         if not os.path.exists(pkgdatafile):
             logger.error("Unable to find any built runtime package named %s" % pkg)
diff --git a/poky/scripts/runqemu-extract-sdk b/poky/scripts/runqemu-extract-sdk
index 2a0dd50..f4286ef 100755
--- a/poky/scripts/runqemu-extract-sdk
+++ b/poky/scripts/runqemu-extract-sdk
@@ -76,7 +76,9 @@
 pseudo_state_dir="$SDK_ROOTFS_DIR/../$(basename "$SDK_ROOTFS_DIR").pseudo_state"
 pseudo_state_dir="$(readlink -f $pseudo_state_dir)"
 
-if [ -e "$pseudo_state_dir" ]; then
+debug_image="`echo $ROOTFS_TARBALL | grep '\-dbg\.tar\.'`"
+
+if [ -e "$pseudo_state_dir" -a -z "$debug_image" ]; then
 	echo "Error: $pseudo_state_dir already exists!"
 	echo "Please delete the rootfs tree and pseudo directory manually"
         echo "if this is really what you want."
diff --git a/poky/scripts/send-error-report b/poky/scripts/send-error-report
index 15b5e84..cd2e7f4 100755
--- a/poky/scripts/send-error-report
+++ b/poky/scripts/send-error-report
@@ -143,7 +143,7 @@
         logging.error(e.reason)
         sys.exit(1)
 
-    print(response.read())
+    print(response.read().decode('utf-8'))
 
 
 if __name__ == '__main__':