[v5,3/8] wic-img: Satisfy the quirks of latest wic

Message ID 20201005165307.14668-4-Vijaikumar_Kanagarajan@mentor.com
State Superseded, archived
Headers show
Series WIC update | expand

Commit Message

Vijai Kumar K Oct. 5, 2020, 7:53 a.m. UTC
The latest WIC doesnot use fakeroot if pseudo_dir(IMAGE_ROOTFS/../pseudo)
is non-existent. This results in wic_fakeroot not being used. Create a
dummy pseudo_dir to satisfy wic.

WIC hardcodes the python(/usr/bin/python3-native/python3) to be used
while running bmaptool. The above path is OE specific and hence breaks
build in ISAR. Create a symbolic link in the above location to satisfy
wic.

In case of stretch, bmaptool is based on python2. In case of buster
and beyond it is python3. Grep the first line of bmaptool to find out
which version of python is used and symlink the appropriate binary
to /usr/bin/python3-native/python3.

Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
---
 meta/classes/wic-img.bbclass | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

vijai kumar Oct. 13, 2020, 11:59 p.m. UTC | #1
On Monday, October 5, 2020 at 10:23:52 PM UTC+5:30 
vijaikumar_...@mentor.com wrote:

> The latest WIC doesnot use fakeroot if pseudo_dir(IMAGE_ROOTFS/../pseudo) 
> is non-existent. This results in wic_fakeroot not being used. Create a 
> dummy pseudo_dir to satisfy wic. 
>
> WIC hardcodes the python(/usr/bin/python3-native/python3) to be used 
> while running bmaptool. The above path is OE specific and hence breaks 
> build in ISAR. Create a symbolic link in the above location to satisfy 
> wic. 
>
> In case of stretch, bmaptool is based on python2. In case of buster 
> and beyond it is python3. Grep the first line of bmaptool to find out 
> which version of python is used and symlink the appropriate binary 
> to /usr/bin/python3-native/python3. 
>
> Signed-off-by: Vijai Kumar K <Vijaikumar_...@mentor.com> 
> --- 
> meta/classes/wic-img.bbclass | 16 +++++++++++++--- 
> 1 file changed, 13 insertions(+), 3 deletions(-) 
>
> diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass 
> index 0ec9575..29956e5 100644 
> --- a/meta/classes/wic-img.bbclass 
> +++ b/meta/classes/wic-img.bbclass 
> @@ -143,6 +143,7 @@ EOSUDO 
> export FAKEROOTCMD=${FAKEROOTCMD} 
> export BUILDDIR=${BUILDDIR} 
> export MTOOLS_SKIP_CHECK=1 
> + mkdir -p ${IMAGE_ROOTFS}/../pseudo 
>
> # create the temp dir in the buildchroot to ensure uniqueness 
> WICTMP=$(cd ${BUILDCHROOT_DIR}; mktemp -d -p tmp) 
> @@ -158,22 +159,31 @@ EOSUDO 
> IMAGE_FULLNAME="$7" 
> IMAGE_BASENAME="$8" 
> shift 8 
> - 
> + # The python path is hard-coded as /usr/bin/python3-native/python3 in 
> wic. Handle that. 
> + mkdir -p /usr/bin/python3-native/ 
> + if [ $(head -1 $(which bmaptool) | grep python3) ];then 
> + ln -s /usr/bin/python3 /usr/bin/python3-native/python3 
> + else 
> + ln -s /usr/bin/python2 /usr/bin/python3-native/python3 
> + fi 
> export PATH="$BITBAKEDIR/bin:$PATH" 
> "$SCRIPTSDIR"/wic create "$WKS_FULL_PATH" \ 
> --vars "$STAGING_DIR/$MACHINE/imgdata/" \ 
> -o "/$WICTMP/${IMAGE_FULLNAME}.wic/" \ 
> --bmap \ 
> - -e "$IMAGE_BASENAME" $@' \ 
> + -e "$IMAGE_BASENAME" $@ 
> + rm -rf /usr/bin/python3-native' \ 
> my_script "${BITBAKEDIR}" "${SCRIPTSDIR}" "${WKS_FULL_PATH}" 
> "${STAGING_DIR}" \ 
> "${MACHINE}" "${WICTMP}" "${IMAGE_FULLNAME}" "${IMAGE_BASENAME}" \ 
> ${WIC_CREATE_EXTRA_ARGS} 
> - sudo chown -R $(stat -c "%U" ${LAYERDIR_core}) ${LAYERDIR_core} 
> ${LAYERDIR_isar} ${SCRIPTSDIR} || true 
> + 
> + sudo chown -R $(stat -c "%U" ${ISARROOT}) ${ISARROOT}/meta 
> ${ISARROOT}/meta-isar ${ISARROOT}/scripts || true 
>

This is the issue. Atleast one. ISARROOT is no more. Rebase gone wrong. 
Will send a new version.

Thanks,
Vijai Kumar K 

WIC_DIRECT=$(ls -t -1 
> ${BUILDCHROOT_DIR}/$WICTMP/${IMAGE_FULLNAME}.wic/*.direct | head -1) 
> sudo chown -R $(id -u):$(id -g) ${BUILDCHROOT_DIR}/${WICTMP} 
> mv -f ${WIC_DIRECT} ${WIC_IMAGE_FILE} 
> mv -f ${WIC_DIRECT}.bmap ${WIC_IMAGE_FILE}.bmap 
> rm -rf ${BUILDCHROOT_DIR}/${WICTMP} 
> + rm -rf ${IMAGE_ROOTFS}/../pseudo 
> } 
>
> do_wic_image[file-checksums] += "${WKS_FILE_CHECKSUM}" 
> -- 
> 2.17.1 
>
>

Patch

diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass
index 0ec9575..29956e5 100644
--- a/meta/classes/wic-img.bbclass
+++ b/meta/classes/wic-img.bbclass
@@ -143,6 +143,7 @@  EOSUDO
     export FAKEROOTCMD=${FAKEROOTCMD}
     export BUILDDIR=${BUILDDIR}
     export MTOOLS_SKIP_CHECK=1
+    mkdir -p ${IMAGE_ROOTFS}/../pseudo
 
     # create the temp dir in the buildchroot to ensure uniqueness
     WICTMP=$(cd ${BUILDCHROOT_DIR}; mktemp -d -p tmp)
@@ -158,22 +159,31 @@  EOSUDO
           IMAGE_FULLNAME="$7"
           IMAGE_BASENAME="$8"
           shift 8
-
+          # The python path is hard-coded as /usr/bin/python3-native/python3 in wic. Handle that.
+          mkdir -p /usr/bin/python3-native/
+          if [ $(head -1 $(which bmaptool) | grep python3) ];then
+            ln -s /usr/bin/python3 /usr/bin/python3-native/python3
+          else
+            ln -s /usr/bin/python2 /usr/bin/python3-native/python3
+          fi
           export PATH="$BITBAKEDIR/bin:$PATH"
           "$SCRIPTSDIR"/wic create "$WKS_FULL_PATH" \
             --vars "$STAGING_DIR/$MACHINE/imgdata/" \
             -o "/$WICTMP/${IMAGE_FULLNAME}.wic/" \
             --bmap \
-            -e "$IMAGE_BASENAME" $@' \
+            -e "$IMAGE_BASENAME" $@
+          rm -rf /usr/bin/python3-native' \
               my_script "${BITBAKEDIR}" "${SCRIPTSDIR}" "${WKS_FULL_PATH}" "${STAGING_DIR}" \
               "${MACHINE}" "${WICTMP}" "${IMAGE_FULLNAME}" "${IMAGE_BASENAME}" \
               ${WIC_CREATE_EXTRA_ARGS}
-    sudo chown -R $(stat -c "%U" ${LAYERDIR_core}) ${LAYERDIR_core} ${LAYERDIR_isar} ${SCRIPTSDIR} || true
+
+    sudo chown -R $(stat -c "%U" ${ISARROOT}) ${ISARROOT}/meta ${ISARROOT}/meta-isar ${ISARROOT}/scripts || true
     WIC_DIRECT=$(ls -t -1 ${BUILDCHROOT_DIR}/$WICTMP/${IMAGE_FULLNAME}.wic/*.direct | head -1)
     sudo chown -R $(id -u):$(id -g) ${BUILDCHROOT_DIR}/${WICTMP}
     mv -f ${WIC_DIRECT} ${WIC_IMAGE_FILE}
     mv -f ${WIC_DIRECT}.bmap ${WIC_IMAGE_FILE}.bmap
     rm -rf ${BUILDCHROOT_DIR}/${WICTMP}
+    rm -rf ${IMAGE_ROOTFS}/../pseudo
 }
 
 do_wic_image[file-checksums] += "${WKS_FILE_CHECKSUM}"