From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6655521619015892992 X-Received: by 2002:adf:ff92:: with SMTP id j18mr1106160wrr.3.1549609382738; Thu, 07 Feb 2019 23:03:02 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:b754:: with SMTP id h81ls604892wmf.7.canary-gmail; Thu, 07 Feb 2019 23:03:02 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibx0UgfKGq8OwfjHOHZ30tjBaHYlu6gv0fmtnUyrSceDcdnnuXYdt6rMjrl67d2dOiW/era X-Received: by 2002:a05:600c:2257:: with SMTP id a23mr493004wmm.8.1549609382152; Thu, 07 Feb 2019 23:03:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549609382; cv=none; d=google.com; s=arc-20160816; b=j1dd8Cp3zOpR8CY5rkki+iWkZa1mkFbV6c+aVIAfGHLoyiVsCCs0WY9B/QYkTLfrOG 74SH0WSBy7aNtCb4QVFlNRZmshdrQ6bL9zOMyTi2PHIuSoEBf+fW1oolfKcKO9OK/ERg EeIm8UUKWL7XDCsJ1P5EId72wNcoNDUFBbb1u+Pxl1azOzXAoU4Xj47SpJ3IFMXpVlFP 8B6fZMOCP6deCJYwo/HyaGaKW+lIA0pgeJEQZA2Ii8mfF6CGMIuna/IKquZWhRQsY2Ou DTwe2Y9A60AUnsC5PbOSejOYwOkyaJC8GVr5H0T0n8hRs+/XFc3iSD5N0+sn16rcj/nj Ghtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:date:subject:cc:to:from; bh=luM9eu5d05adVhbPR2+ovocDYuvbvCJRh4HJ61C8bbU=; b=YC3rRkIofuaRemc+bv/AXy1sSl5BV57YS8+dQVP0rdHCxhkzRmmYr8iG7GP6RTp/Jm 2HYbGPG1Xg+x6dBM4m5t411hQ9OS+oUzXgBojtO6HRGRmWpMw+WBNbHaN7RRBWxH9AKZ P6NkjBnZaX0g7U+h++pjPQqEwNCxKcSmwZ7CEldQq3G5XvMH2ajuMFIH/mH2eLmz/ef1 foXTHsAQkGNcFFPwMBA2IeqMDwBZhboA1nmnHBaUMC7YLlTQmnAiefgdQzxAiQ/AOwbi vilBudgNvGLPel+9/lw9gU4+kw4ZQWPwWrn9CIOHa2BiRM5kgMw7XlT+JOOSKX+T197a cbnA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com Return-Path: Received: from relay1.mentorg.com (relay1.mentorg.com. [192.94.38.131]) by gmr-mx.google.com with ESMTPS id d6si43399wro.4.2019.02.07.23.03.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 23:03:02 -0800 (PST) Received-SPF: pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) client-ip=192.94.38.131; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-02.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1gs0Bg-0003P5-Qa from Cedric_Hombourger@mentor.com for isar-users@googlegroups.com; Thu, 07 Feb 2019 23:03:00 -0800 Received: from FRG-W10-HOMBOUR.world.mentorg.com (137.202.0.90) by svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Fri, 8 Feb 2019 07:02:57 +0000 From: Cedric Hombourger To: CC: Cedric Hombourger Subject: [PATCH] wic-img: handle variables in .wks files Date: Fri, 8 Feb 2019 08:02:47 +0100 Message-ID: <1549609367-1025-1-git-send-email-Cedric_Hombourger@mentor.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) X-TUID: e8z4pxp7jNls Isar will now generate .wks from user-specified templates with variables such as $ROOTFS_TYPE or $ROOTFS_SIZE replaced with their values. Custom variables may be substituted by adding them to WKSVARS (WKSVAR += FOO) Signed-off-by: Cedric Hombourger --- doc/user_manual.md | 2 ++ meta/classes/wic-img.bbclass | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/doc/user_manual.md b/doc/user_manual.md index ebc31c6..ea3b4bd 100644 --- a/doc/user_manual.md +++ b/doc/user_manual.md @@ -197,6 +197,8 @@ A bootable disk image is generated if you set IMAGE_TYPE to 'wic-img'. Behind th $ bitbake multiconfig:qemuamd64-stretch:isar-image-base ``` +Note: `.wks` files may use the ROOTFS_SIZE and ROOTFS_TYPE variables (as well as any other bitbake variables added to WKSVARS). + In order to run the EFI images with `qemu`, an EFI firmware is required and available at the following address: https://github.com/tianocore/edk2/tree/3858b4a1ff09d3243fea8d07bd135478237cb8f7 diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass index 76602d8..16bbc53 100644 --- a/meta/classes/wic-img.bbclass +++ b/meta/classes/wic-img.bbclass @@ -81,6 +81,32 @@ addtask do_rootfs_wicenv after do_copy_boot_files before do_wic_image do_rootfs_wicenv[vardeps] += "${WICVARS}" do_rootfs_wicenv[prefuncs] = 'set_image_size' +WKSVARS += "ROOTFS_SIZE ROOTFS_TYPE" + +python do_rootfs_wksenv () { + wksvars = d.getVar('WKSVARS', True) + if not wksvars: + return + + stdir = d.getVar('STAGING_DIR', True) + outdir = os.path.join(stdir, d.getVar('MACHINE', True), 'imgdata') + bb.utils.mkdirhier(outdir) + basename = d.getVar('IMAGE_BASENAME', True) + with open(os.path.join(outdir, basename) + '-wks.sh', 'w') as envf: + for var in wksvars.split(): + value = d.getVar(var, True) + if value: + envf.write('%s="%s" \\\n' % (var, value.strip())) + envf.write("envsubst '") + for var in wksvars.split(): + envf.write('$%s ' % var) + envf.write("'\n") +} + +addtask do_rootfs_wksenv after do_rootfs_wicenv before do_wic_image +do_rootfs_wksenv[vardeps] += "${WKSVARS}" +do_rootfs_wksenv[prefuncs] = 'set_image_size' + WIC_IMAGE_FILE ="${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.wic.img" do_build[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" @@ -99,8 +125,11 @@ do_wic_image() { export BUILDDIR=${BUILDDIR} export MTOOLS_SKIP_CHECK=1 + /bin/sh ${STAGING_DIR}/${MACHINE}/imgdata/${IMAGE_BASENAME}-wks.sh \ + <${WKS_FULL_PATH} >${BUILDCHROOT_DIR}/tmp/${IMAGE_FULLNAME}.wks + sudo -E chroot ${BUILDCHROOT_DIR} \ - ${ISARROOT}/scripts/wic create ${WKS_FULL_PATH} \ + ${ISARROOT}/scripts/wic create /tmp/${IMAGE_FULLNAME}.wks \ --vars "${STAGING_DIR}/${MACHINE}/imgdata/" \ -o /tmp/${IMAGE_FULLNAME}.wic/ \ -e ${IMAGE_BASENAME} ${WIC_CREATE_EXTRA_ARGS} -- 2.11.0