Some firmwares are critical for the basic functions of the board, and may
be used by the bootloader. Due to the license issue, we can't integrate
it. But we do need it when creating a booting image by using WIC.
So add the support for the WIC to download a raw file from http
server and write it to a specific part. In order to restrict the
downloading behaviour, we introduce a "WKS_ALLOW_DOWNLOAD" variable and
only do the downloading when this variable is set.

Signed-off-by: Kevin Hao <[email protected]>
---
 meta/classes/image_types_wic.bbclass      |  2 +-
 scripts/lib/wic/plugins/source/rawcopy.py | 13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/meta/classes/image_types_wic.bbclass 
b/meta/classes/image_types_wic.bbclass
index 222ae004338d..70858ad5d7a1 100644
--- a/meta/classes/image_types_wic.bbclass
+++ b/meta/classes/image_types_wic.bbclass
@@ -3,7 +3,7 @@
 WICVARS ?= "\
            BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD IMAGE_BASENAME 
IMAGE_BOOT_FILES \
            IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD INITRD_LIVE 
ISODIR RECIPE_SYSROOT_NATIVE \
-           ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS"
+           ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS 
WKS_ALLOW_DOWNLOAD"
 
 WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
 WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
diff --git a/scripts/lib/wic/plugins/source/rawcopy.py 
b/scripts/lib/wic/plugins/source/rawcopy.py
index baf991fe8d5d..808c279aed4c 100644
--- a/scripts/lib/wic/plugins/source/rawcopy.py
+++ b/scripts/lib/wic/plugins/source/rawcopy.py
@@ -50,8 +50,17 @@ class RawCopyPlugin(SourcePlugin):
         if 'file' not in source_params:
             raise WicError("No file specified")
 
-        src = os.path.join(kernel_dir, source_params['file'])
-        dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], 
part.lineno))
+        if source_params['file'].startswith('http://') or 
source_params['file'].startswith('https://'):
+            # Only download the image from remote site when explicilty 
requesting so
+            if get_bitbake_var("WKS_ALLOW_DOWNLOAD") != "1":
+                return
+            src = os.path.join(cr_workdir, "%s" % 
source_params['file'].rsplit('/',1)[-1])
+            dst = "%s.dst" % src
+            download_cmd = "wget -r -O %s %s" %(src, source_params['file'])
+            exec_cmd(download_cmd)
+        else:
+            src = os.path.join(kernel_dir, source_params['file'])
+            dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], 
part.lineno))
 
         skip = 0 if 'skip' not in source_params else int(source_params['skip'])
         seek = 0 if 'seek' not in source_params else int(source_params['seek'])
-- 
2.9.3

-- 
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to