From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6613620343774904320 Date: Mon, 22 Oct 2018 05:49:30 -0700 (PDT) From: cedric_hombourger@mentor.com To: isar-users Message-Id: In-Reply-To: <1539883436-305-1-git-send-email-Cedric_Hombourger@mentor.com> References: <27912c86-2c53-4986-bf9c-2f9b9796bd50@siemens.com> <1539883436-305-1-git-send-email-Cedric_Hombourger@mentor.com> Subject: Re: [PATCH v2] image: include image name in the kernel/initrd image copies MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_4359_892609639.1540212570654" X-Google-Token: ENqOt94FiCDBMIim64c0 X-Google-IP: 95.176.90.117 X-TUID: hIhnD6DbIH4X ------=_Part_4359_892609639.1540212570654 Content-Type: multipart/alternative; boundary="----=_Part_4360_1222254512.1540212570654" ------=_Part_4360_1222254512.1540212570654 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Jan, Did you have a chance to look at v2? Did I manage to address your initial review findings? Thanks Cedric On Thursday, October 18, 2018 at 7:24:12 PM UTC+2, Cedric Hombourger wrote: > > The kernel and initrd images are really image-specific (especially the > later > as the initrd is created/updated as packages get installed into the root > file-system). Make sure we retain a per-image copy of these images in the > image deploy directory by inserting the name of the image (${PN}) into the > full name of the artifacts (set in ${KERNEL_IMAGE} and ${INITRD_IMAGE}). > > In addition, an IMAGE_FULLNAME variable is introduced to combine the three > components of the image name: the (base) name of the image, the name of > the > distribution and the name of the machine. This variable is now used in the > start_vm script and the image classes (image, ext4-img and wic-img). > > Signed-off-by: Cedric Hombourger > --- > meta/classes/ext4-img.bbclass | 2 +- > meta/classes/image.bbclass | 7 ++++--- > meta/classes/wic-img.bbclass | 6 +++--- > 3 files changed, 8 insertions(+), 7 deletions(-) > > diff --git a/meta/classes/ext4-img.bbclass b/meta/classes/ext4-img.bbclass > index 78036a2..29e5f77 100644 > --- a/meta/classes/ext4-img.bbclass > +++ b/meta/classes/ext4-img.bbclass > @@ -1,7 +1,7 @@ > # This software is a part of ISAR. > # Copyright (C) 2015-2017 ilbers GmbH > > -EXT4_IMAGE_FILE = > "${DEPLOY_DIR_IMAGE}/${PN}-${DISTRO}-${MACHINE}.ext4.img" > +EXT4_IMAGE_FILE = "${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.ext4.img" > > do_ext4_image[stamp-extra-info] = "${DISTRO}-${MACHINE}" > > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 05ff06f..ad19f3d 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -7,6 +7,9 @@ IMAGE_ROOTFS = "${WORKDIR}/rootfs" > > IMAGE_INSTALL += "${@ ("linux-image-" + d.getVar("KERNEL_NAME", True)) if > d.getVar("KERNEL_NAME", True) else ""}" > > +# Name of the image including distro&machine names > +IMAGE_FULLNAME = "${PN}-${DISTRO}-${MACHINE}" > + > # These variables are used by wic and start_vm > KERNEL_IMAGE ?= "${@get_image_name(d, 'vmlinuz')[1]}" > INITRD_IMAGE ?= "${@get_image_name(d, 'initrd.img')[1]}" > @@ -21,9 +24,7 @@ def get_image_name(d, name_link): > path_link = os.path.join(S, name_link) > if os.path.exists(path_link): > base = os.path.basename(os.path.realpath(path_link)) > - full = base > - full += "_" + d.getVar("DISTRO", True) > - full += "-" + d.getVar("MACHINE", True) > + full = d.getVar("IMAGE_FULLNAME", True) + "." + base > return [base, full] > if os.path.islink(path_link): > return get_image_name(d, > os.path.relpath(os.path.realpath(path_link), > diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass > index d0747e2..e7527c8 100644 > --- a/meta/classes/wic-img.bbclass > +++ b/meta/classes/wic-img.bbclass > @@ -63,7 +63,7 @@ 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' > > -WIC_IMAGE_FILE ="${DEPLOY_DIR_IMAGE}/${PN}-${DISTRO}-${MACHINE}.wic.img" > +WIC_IMAGE_FILE ="${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.wic.img" > > do_build[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" > > @@ -81,10 +81,10 @@ do_wic_image() { > sudo -E chroot ${BUILDCHROOT_DIR} \ > ${ISARROOT}/scripts/wic create ${WKS_FULL_PATH} \ > --vars "${STAGING_DIR}/${MACHINE}/imgdata/" \ > - -o /tmp/${PN}-${DISTRO}-${MACHINE}.wic/ \ > + -o /tmp/${IMAGE_FULLNAME}.wic/ \ > -e ${IMAGE_BASENAME} ${WIC_CREATE_EXTRA_ARGS} > sudo chown -R $(stat -c "%U" ${ISARROOT}) ${ISARROOT}/meta > ${ISARROOT}/meta-isar ${ISARROOT}/scripts || true > - cp -f $(ls -t -1 > ${BUILDCHROOT_DIR}/tmp/${PN}-${DISTRO}-${MACHINE}.wic/*.direct | head -1) > ${WIC_IMAGE_FILE} > + cp -f $(ls -t -1 > ${BUILDCHROOT_DIR}/tmp/${IMAGE_FULLNAME}.wic/*.direct | head -1) > ${WIC_IMAGE_FILE} > } > > do_wic_image[file-checksums] += "${WKS_FULL_PATH}:True" > -- > 2.11.0 > > ------=_Part_4360_1222254512.1540212570654 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi Jan,

Did you have a chance to look a= t v2?
Did I manage to address your initial review findings?
=

Thanks
Cedric

On Thursday, October 18,= 2018 at 7:24:12 PM UTC+2, Cedric Hombourger wrote:
The kernel and initrd images are really image-specific= (especially the later
as the initrd is created/updated as packages get installed into the roo= t
file-system). Make sure we retain a per-image copy of these images in t= he
image deploy directory by inserting the name of the image (${PN}) into = the
full name of the artifacts (set in ${KERNEL_IMAGE} and ${INITRD_IMAGE})= .

In addition, an IMAGE_FULLNAME variable is introduced to combine the th= ree
components of the image name: the (base) name of the image, the name of= the
distribution and the name of the machine. This variable is now used in = the
start_vm script and the image classes (image, ext4-img and wic-img).

Signed-off-by: Cedric Hombourger <Cedr= ic_Hombourger@mentor.com>
---
=C2=A0meta/classes/ext4-img.bbclass | 2 +-
=C2=A0meta/classes/image.bbclass =C2=A0 =C2=A0| 7 ++++---
=C2=A0meta/classes/wic-img.bbclass =C2=A0| 6 +++---
=C2=A03 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/meta/classes/ext4-img.bbclass b/meta/classes/ext4-img= .bbclass
index 78036a2..29e5f77 100644
--- a/meta/classes/ext4-img.bbclass
+++ b/meta/classes/ext4-img.bbclass
@@ -1,7 +1,7 @@
=C2=A0# This software is a part of ISAR.
=C2=A0# Copyright (C) 2015-2017 ilbers GmbH
=C2=A0
-EXT4_IMAGE_FILE =3D "${DEPLOY_DIR_IMAGE}/${PN}-${DISTRO}-${M= ACHINE}.ext4.img"
+EXT4_IMAGE_FILE =3D "${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.e= xt4.img"
=C2=A0
=C2=A0do_ext4_image[stamp-extra-info] =3D "${DISTRO}-${MACHIN= E}"
=C2=A0
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 05ff06f..ad19f3d 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -7,6 +7,9 @@ IMAGE_ROOTFS =C2=A0 =3D "${WORKDIR}/rootfs"
=C2=A0
=C2=A0IMAGE_INSTALL +=3D "${@ ("linux-image-" + d.getVar= ("KERNEL_NAME", True)) if d.getVar("KERNEL_NAME", True)= else ""}"
=C2=A0
+# Name of the image including distro&machine names
+IMAGE_FULLNAME =3D "${PN}-${DISTRO}-${MACHINE}"
+
=C2=A0# These variables are used by wic and start_vm
=C2=A0KERNEL_IMAGE ?=3D "${@get_image_name(d, 'vmlinuz')[1= ]}"
=C2=A0INITRD_IMAGE ?=3D "${@get_image_name(d, 'initrd.img'= )[1]}"
@@ -21,9 +24,7 @@ def get_image_name(d, name_link):
=C2=A0 =C2=A0 =C2=A0path_link =3D os.path.join(S, name_link)
=C2=A0 =C2=A0 =C2=A0if os.path.exists(path_link):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0base =3D os.path.basename(os.path.realpath(path_link))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0full =3D base
- =C2=A0 =C2=A0 =C2=A0 =C2=A0full +=3D "_" + d.getVar("D= ISTRO", True)
- =C2=A0 =C2=A0 =C2=A0 =C2=A0full +=3D "-" + d.getVar("M= ACHINE", True)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0full =3D d.getVar("IMAGE_FULLNAME&quo= t;, True) + "." + base
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return [base, full]
=C2=A0 =C2=A0 =C2=A0if os.path.islink(path_link):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return get_image_name(d, os.path.relp= ath(os.path.realpath(path_link),
diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclas= s
index d0747e2..e7527c8 100644
--- a/meta/classes/wic-img.bbclass
+++ b/meta/classes/wic-img.bbclass
@@ -63,7 +63,7 @@ addtask do_rootfs_wicenv after do_copy_boot_files bef= ore do_wic_image
=C2=A0do_rootfs_wicenv[vardeps] +=3D "${WICVARS}"
=C2=A0do_rootfs_wicenv[prefuncs] =3D 'set_image_size'
=C2=A0
-WIC_IMAGE_FILE =3D"${DEPLOY_DIR_IMAGE}/${PN}-${DISTRO}-${MAC= HINE}.wic.img"
+WIC_IMAGE_FILE =3D"${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.wic= .img"
=C2=A0
=C2=A0do_build[stamp-extra-info] =3D "${DISTRO}-${DISTRO_ARCH}&quo= t;
=C2=A0
@@ -81,10 +81,10 @@ do_wic_image() {
=C2=A0 =C2=A0 =C2=A0sudo -E chroot ${BUILDCHROOT_DIR} \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0${ISARROOT}/scripts/wic create ${WKS_= FULL_PATH} \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--vars "${STAGING_= DIR}/${MACHINE}/imgdata/" \
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-o /tmp/${PN}-${DISTRO}-${MACHINE}.wic/ \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-o /tmp/${IMAGE_FULLNAME}.wi= c/ \
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-e ${IMAGE_BASENAME} ${= WIC_CREATE_EXTRA_ARGS}
=C2=A0 =C2=A0 =C2=A0sudo chown -R $(stat -c "%U" ${ISARROOT})= ${ISARROOT}/meta ${ISARROOT}/meta-isar ${ISARROOT}/scripts || true
- =C2=A0 =C2=A0cp -f $(ls -t -1 ${BUILDCHROOT_DIR}/tmp/${PN}-${DIS= TRO}-${MACHINE}.wic/*.direct | head -1) ${WIC_IMAGE_FILE}
+ =C2=A0 =C2=A0cp -f $(ls -t -1 ${BUILDCHROOT_DIR}/tmp/${IMAGE_FUL= LNAME}.wic/*.direct | head -1) ${WIC_IMAGE_FILE}
=C2=A0}
=C2=A0
=C2=A0do_wic_image[file-checksums] +=3D "${WKS_FULL_PATH}:True&quo= t;
--=20
2.11.0

------=_Part_4360_1222254512.1540212570654-- ------=_Part_4359_892609639.1540212570654--