Patchwork [2/2] module.bbclass: Create a new depmodwrapper to assist cross-installs

login
register
mail settings
Submitter Mark Hatle
Date Feb. 28, 2013, 6:09 p.m.
Message ID <1362074946-7062-3-git-send-email-mark.hatle@windriver.com>
Download mbox | patch
Permalink /patch/45309/
State New
Headers show

Comments

Mark Hatle - Feb. 28, 2013, 6:09 p.m.
Previously the build path to STAGING_KERNEL_DIR was being embedded into the
package post install scripts.  We avoid this behavior by generating a special
depmodwrapper script.  This script contains that hard-coded path, ensuring
that re-use of the sstate-cache (and/or packages) will always run through the
wrapper generated by the current build with a checksum that includes
STAGING_KERNEL_DIR.

[ YOCTO #3962 ]

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
 meta/classes/image.bbclass                         |    4 +-
 meta/classes/kernel.bbclass                        |    8 ++--
 meta/classes/module.bbclass                        |    4 +-
 .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |   34 ++++++++++++++++++++
 4 files changed, 42 insertions(+), 8 deletions(-)
 create mode 100644 meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
Bruce Ashfield - Feb. 28, 2013, 7:12 p.m.
On Thu, Feb 28, 2013 at 1:09 PM, Mark Hatle <mark.hatle@windriver.com> wrote:
> Previously the build path to STAGING_KERNEL_DIR was being embedded into the
> package post install scripts.  We avoid this behavior by generating a special
> depmodwrapper script.  This script contains that hard-coded path, ensuring
> that re-use of the sstate-cache (and/or packages) will always run through the
> wrapper generated by the current build with a checksum that includes
> STAGING_KERNEL_DIR.
>
> [ YOCTO #3962 ]
>
> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
> ---
>  meta/classes/image.bbclass                         |    4 +-
>  meta/classes/kernel.bbclass                        |    8 ++--
>  meta/classes/module.bbclass                        |    4 +-
>  .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |   34 ++++++++++++++++++++
>  4 files changed, 42 insertions(+), 8 deletions(-)
>  create mode 100644 meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index dd78acb..af17331 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -10,7 +10,7 @@ inherit gzipnative
>
>  LICENSE = "MIT"
>  PACKAGES = ""
> -DEPENDS += "${MLPREFIX}qemuwrapper-cross"
> +DEPENDS += "${MLPREFIX}qemuwrapper-cross depmodwrapper-cross"
>  RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} ${NORMAL_FEATURE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL}"
>  RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}"
>
> @@ -283,7 +283,7 @@ fakeroot do_rootfs () {
>                 KERNEL_VERSION=`cat ${STAGING_KERNEL_DIR}/kernel-abiversion`
>
>                 mkdir -p ${IMAGE_ROOTFS}/lib/modules/$KERNEL_VERSION
> -               depmod -a -b ${IMAGE_ROOTFS} -F ${STAGING_KERNEL_DIR}/System.map-$KERNEL_VERSION $KERNEL_VERSION
> +               depmodwrapper -a -b ${IMAGE_ROOTFS} $KERNEL_VERSION
>         fi
>
>         ${IMAGE_PREPROCESS_COMMAND}
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index e8c585b..2bdc2fc 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -1,7 +1,7 @@
>  inherit linux-kernel-base module_strip
>
>  PROVIDES += "virtual/kernel"
> -DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native"
> +DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross"
>
>  # we include gcc above, we dont need virtual/libc
>  INHIBIT_DEFAULT_DEPS = "1"
> @@ -272,7 +272,7 @@ if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>         mkdir -p $D/lib/modules/${KERNEL_VERSION}
>  fi
>  if [ -n "$D" ]; then
> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>  else
>         depmod -a ${KERNEL_VERSION}
>  fi
> @@ -282,7 +282,7 @@ pkg_postinst_modules () {
>  if [ -z "$D" ]; then
>         depmod -a ${KERNEL_VERSION}
>  else
> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>  fi
>  }
>
> @@ -290,7 +290,7 @@ pkg_postrm_modules () {
>  if [ -z "$D" ]; then
>         depmod -a ${KERNEL_VERSION}
>  else
> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>  fi
>  }
>
> diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass
> index e2174a1..2c1888c 100644
> --- a/meta/classes/module.bbclass
> +++ b/meta/classes/module.bbclass
> @@ -28,7 +28,7 @@ module_pkg_postinst () {
>  if [ -z "$D" ]; then
>         depmod -a ${KERNEL_VERSION}
>  else
> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>  fi
>  }
>
> @@ -36,7 +36,7 @@ module_pkg_postrm () {
>  if [ -z "$D" ]; then
>         depmod -a ${KERNEL_VERSION}
>  else
> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>  fi
>  }
>
> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> new file mode 100644
> index 0000000..646c4cd
> --- /dev/null
> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> @@ -0,0 +1,34 @@
> +DESCRIPTION = "Depmod wrapper script"
> +LICENSE = "MIT"
> +PR = "r0"
> +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
> +
> +# We need to evaluate it to the final path for vardeps to
> +# work properly.
> +STAGING_KERNEL_DIR := "${STAGING_KERNEL_DIR}"
> +
> +do_install() {
> +       install -d ${D}${bindir_crossscripts}/
> +
> +       cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF
> +#!/bin/sh
> +# Expected to be called as: depmodwrapper -a KERNEL_VERSION

Can we remove the need for KERNEL_VERSION to be passed ? You are already
looking at ${STAGING_KERNEL_DIR}, so just pulling the kernel version
out of ${STAGING_KERNEL_DIR}/kernel-abiversion will reduce the chances
of mistakes.

Bruce


> +if [ "\$1" != "-a" -a "\$2" != "-b" ]; then
> +    echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
> +    exit 1
> +fi
> +if [ ! -r ${STAGING_KERNEL_DIR}/System.map-\$4 ]; then
> +    echo "Unable to read: ${STAGING_KERNEL_DIR}/System.map-\$4" >&2
> +    exec env depmod "\$1" "\$2" "\$3" "\$4"
> +else
> +    exec env depmod "\$1" "\$2" "\$3" -F "${STAGING_KERNEL_DIR}/System.map-\$4" "\$4"
> +fi
> +EOF
> +       chmod +x ${D}${bindir_crossscripts}/depmodwrapper
> +}
> +
> +SYSROOT_PREPROCESS_FUNCS += "depmodwrapper_sysroot_preprocess"
> +
> +depmodwrapper_sysroot_preprocess () {
> +       sysroot_stage_dir ${D}${bindir_crossscripts} ${SYSROOT_DESTDIR}${bindir_crossscripts}
> +}
> --
> 1.7.1
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core



--
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"
Mark Hatle - Feb. 28, 2013, 7:40 p.m.
On 2/28/13 1:12 PM, Bruce Ashfield wrote:
> On Thu, Feb 28, 2013 at 1:09 PM, Mark Hatle <mark.hatle@windriver.com> wrote:
>> Previously the build path to STAGING_KERNEL_DIR was being embedded into the
>> package post install scripts.  We avoid this behavior by generating a special
>> depmodwrapper script.  This script contains that hard-coded path, ensuring
>> that re-use of the sstate-cache (and/or packages) will always run through the
>> wrapper generated by the current build with a checksum that includes
>> STAGING_KERNEL_DIR.
>>
>> [ YOCTO #3962 ]
>>
>> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
>> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
>> ---
>>   meta/classes/image.bbclass                         |    4 +-
>>   meta/classes/kernel.bbclass                        |    8 ++--
>>   meta/classes/module.bbclass                        |    4 +-
>>   .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |   34 ++++++++++++++++++++
>>   4 files changed, 42 insertions(+), 8 deletions(-)
>>   create mode 100644 meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>
>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>> index dd78acb..af17331 100644
>> --- a/meta/classes/image.bbclass
>> +++ b/meta/classes/image.bbclass
>> @@ -10,7 +10,7 @@ inherit gzipnative
>>
>>   LICENSE = "MIT"
>>   PACKAGES = ""
>> -DEPENDS += "${MLPREFIX}qemuwrapper-cross"
>> +DEPENDS += "${MLPREFIX}qemuwrapper-cross depmodwrapper-cross"
>>   RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} ${NORMAL_FEATURE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL}"
>>   RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}"
>>
>> @@ -283,7 +283,7 @@ fakeroot do_rootfs () {
>>                  KERNEL_VERSION=`cat ${STAGING_KERNEL_DIR}/kernel-abiversion`
>>
>>                  mkdir -p ${IMAGE_ROOTFS}/lib/modules/$KERNEL_VERSION
>> -               depmod -a -b ${IMAGE_ROOTFS} -F ${STAGING_KERNEL_DIR}/System.map-$KERNEL_VERSION $KERNEL_VERSION
>> +               depmodwrapper -a -b ${IMAGE_ROOTFS} $KERNEL_VERSION
>>          fi
>>
>>          ${IMAGE_PREPROCESS_COMMAND}
>> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
>> index e8c585b..2bdc2fc 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -1,7 +1,7 @@
>>   inherit linux-kernel-base module_strip
>>
>>   PROVIDES += "virtual/kernel"
>> -DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native"
>> +DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross"
>>
>>   # we include gcc above, we dont need virtual/libc
>>   INHIBIT_DEFAULT_DEPS = "1"
>> @@ -272,7 +272,7 @@ if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>          mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>   fi
>>   if [ -n "$D" ]; then
>> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   else
>>          depmod -a ${KERNEL_VERSION}
>>   fi
>> @@ -282,7 +282,7 @@ pkg_postinst_modules () {
>>   if [ -z "$D" ]; then
>>          depmod -a ${KERNEL_VERSION}
>>   else
>> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   fi
>>   }
>>
>> @@ -290,7 +290,7 @@ pkg_postrm_modules () {
>>   if [ -z "$D" ]; then
>>          depmod -a ${KERNEL_VERSION}
>>   else
>> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   fi
>>   }
>>
>> diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass
>> index e2174a1..2c1888c 100644
>> --- a/meta/classes/module.bbclass
>> +++ b/meta/classes/module.bbclass
>> @@ -28,7 +28,7 @@ module_pkg_postinst () {
>>   if [ -z "$D" ]; then
>>          depmod -a ${KERNEL_VERSION}
>>   else
>> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   fi
>>   }
>>
>> @@ -36,7 +36,7 @@ module_pkg_postrm () {
>>   if [ -z "$D" ]; then
>>          depmod -a ${KERNEL_VERSION}
>>   else
>> -       depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +       depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   fi
>>   }
>>
>> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> new file mode 100644
>> index 0000000..646c4cd
>> --- /dev/null
>> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> @@ -0,0 +1,34 @@
>> +DESCRIPTION = "Depmod wrapper script"
>> +LICENSE = "MIT"
>> +PR = "r0"
>> +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
>> +
>> +# We need to evaluate it to the final path for vardeps to
>> +# work properly.
>> +STAGING_KERNEL_DIR := "${STAGING_KERNEL_DIR}"
>> +
>> +do_install() {
>> +       install -d ${D}${bindir_crossscripts}/
>> +
>> +       cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF
>> +#!/bin/sh
>> +# Expected to be called as: depmodwrapper -a KERNEL_VERSION
>
> Can we remove the need for KERNEL_VERSION to be passed ? You are already
> looking at ${STAGING_KERNEL_DIR}, so just pulling the kernel version
> out of ${STAGING_KERNEL_DIR}/kernel-abiversion will reduce the chances
> of mistakes.

I did it this way specifically so that the KERNEL_VERSION that is already
embedded into the depmod call for the "target" install, is the same as the one
used for the cross-install.  My assumption is that if one works, the other will
work.

What I can do is simply check that kernel-abiversion and verify it's the same
value, and fail (cross) if it's not... Would that be reasonable?

> Bruce
>
>
>> +if [ "\$1" != "-a" -a "\$2" != "-b" ]; then
>> +    echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>> +    exit 1
>> +fi
>> +if [ ! -r ${STAGING_KERNEL_DIR}/System.map-\$4 ]; then
>> +    echo "Unable to read: ${STAGING_KERNEL_DIR}/System.map-\$4" >&2
>> +    exec env depmod "\$1" "\$2" "\$3" "\$4"
>> +else
>> +    exec env depmod "\$1" "\$2" "\$3" -F "${STAGING_KERNEL_DIR}/System.map-\$4" "\$4"
>> +fi
>> +EOF
>> +       chmod +x ${D}${bindir_crossscripts}/depmodwrapper
>> +}
>> +
>> +SYSROOT_PREPROCESS_FUNCS += "depmodwrapper_sysroot_preprocess"
>> +
>> +depmodwrapper_sysroot_preprocess () {
>> +       sysroot_stage_dir ${D}${bindir_crossscripts} ${SYSROOT_DESTDIR}${bindir_crossscripts}
>> +}
>> --
>> 1.7.1
>>
>>
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
>
>
>
> --
> "Thou shalt not follow the NULL pointer, for chaos and madness await
> thee at its end"
>
Richard Purdie - Feb. 28, 2013, 8:53 p.m.
On Thu, 2013-02-28 at 12:09 -0600, Mark Hatle wrote:
> Previously the build path to STAGING_KERNEL_DIR was being embedded into the
> package post install scripts.  We avoid this behavior by generating a special
> depmodwrapper script.  This script contains that hard-coded path, ensuring
> that re-use of the sstate-cache (and/or packages) will always run through the
> wrapper generated by the current build with a checksum that includes
> STAGING_KERNEL_DIR.
> 
> [ YOCTO #3962 ]
> 
> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
> ---
>  meta/classes/image.bbclass                         |    4 +-
>  meta/classes/kernel.bbclass                        |    8 ++--
>  meta/classes/module.bbclass                        |    4 +-
>  .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |   34 ++++++++++++++++++++
>  4 files changed, 42 insertions(+), 8 deletions(-)
>  create mode 100644 meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> 
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index dd78acb..af17331 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -10,7 +10,7 @@ inherit gzipnative
>  
>  LICENSE = "MIT"
>  PACKAGES = ""
> -DEPENDS += "${MLPREFIX}qemuwrapper-cross"
> +DEPENDS += "${MLPREFIX}qemuwrapper-cross depmodwrapper-cross"
>  RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} ${NORMAL_FEATURE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL}"
>  RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}"
>  
> @@ -283,7 +283,7 @@ fakeroot do_rootfs () {
>  		KERNEL_VERSION=`cat ${STAGING_KERNEL_DIR}/kernel-abiversion`
>  
>  		mkdir -p ${IMAGE_ROOTFS}/lib/modules/$KERNEL_VERSION
> -		depmod -a -b ${IMAGE_ROOTFS} -F ${STAGING_KERNEL_DIR}/System.map-$KERNEL_VERSION $KERNEL_VERSION
> +		depmodwrapper -a -b ${IMAGE_ROOTFS} $KERNEL_VERSION
>  	fi
>  
>  	${IMAGE_PREPROCESS_COMMAND}
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index e8c585b..2bdc2fc 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -1,7 +1,7 @@
>  inherit linux-kernel-base module_strip
>  
>  PROVIDES += "virtual/kernel"
> -DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native"
> +DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross"
>  
>  # we include gcc above, we dont need virtual/libc
>  INHIBIT_DEFAULT_DEPS = "1"
> @@ -272,7 +272,7 @@ if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>  	mkdir -p $D/lib/modules/${KERNEL_VERSION}
>  fi
>  if [ -n "$D" ]; then
> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>  else
>  	depmod -a ${KERNEL_VERSION}
>  fi
> @@ -282,7 +282,7 @@ pkg_postinst_modules () {
>  if [ -z "$D" ]; then
>  	depmod -a ${KERNEL_VERSION}
>  else
> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>  fi
>  }
>  
> @@ -290,7 +290,7 @@ pkg_postrm_modules () {
>  if [ -z "$D" ]; then
>  	depmod -a ${KERNEL_VERSION}
>  else
> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>  fi
>  }
>  
> diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass
> index e2174a1..2c1888c 100644
> --- a/meta/classes/module.bbclass
> +++ b/meta/classes/module.bbclass
> @@ -28,7 +28,7 @@ module_pkg_postinst () {
>  if [ -z "$D" ]; then
>  	depmod -a ${KERNEL_VERSION}
>  else
> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>  fi
>  }
>  
> @@ -36,7 +36,7 @@ module_pkg_postrm () {
>  if [ -z "$D" ]; then
>  	depmod -a ${KERNEL_VERSION}
>  else
> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>  fi
>  }
>  
> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> new file mode 100644
> index 0000000..646c4cd
> --- /dev/null
> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> @@ -0,0 +1,34 @@
> +DESCRIPTION = "Depmod wrapper script"
> +LICENSE = "MIT"
> +PR = "r0"
> +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
> +
> +# We need to evaluate it to the final path for vardeps to
> +# work properly.
> +STAGING_KERNEL_DIR := "${STAGING_KERNEL_DIR}"

Please get rid of the above line. Really. You do not need to do this.
I've told you this already and I do mean it. 

No, it won't show up in the sstate dependencies directly but the sed run
over text files containing "STAGING_DIR" expressions will take care of
relocating it, hence it doesn't need to be there.

If that doesn't happen, please say why the sed expressions don't catch
it.

Cheers,

Richard

> +do_install() {
> +	install -d ${D}${bindir_crossscripts}/
> +
> +	cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF
> +#!/bin/sh
> +# Expected to be called as: depmodwrapper -a KERNEL_VERSION
> +if [ "\$1" != "-a" -a "\$2" != "-b" ]; then
> +    echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
> +    exit 1
> +fi
> +if [ ! -r ${STAGING_KERNEL_DIR}/System.map-\$4 ]; then
> +    echo "Unable to read: ${STAGING_KERNEL_DIR}/System.map-\$4" >&2
> +    exec env depmod "\$1" "\$2" "\$3" "\$4"
> +else
> +    exec env depmod "\$1" "\$2" "\$3" -F "${STAGING_KERNEL_DIR}/System.map-\$4" "\$4"
> +fi
> +EOF
> +	chmod +x ${D}${bindir_crossscripts}/depmodwrapper
> +}
> +
> +SYSROOT_PREPROCESS_FUNCS += "depmodwrapper_sysroot_preprocess"
> +
> +depmodwrapper_sysroot_preprocess () {
> +	sysroot_stage_dir ${D}${bindir_crossscripts} ${SYSROOT_DESTDIR}${bindir_crossscripts}
> +}
Mark Hatle - Feb. 28, 2013, 9:07 p.m.
On 2/28/13 2:53 PM, Richard Purdie wrote:
> On Thu, 2013-02-28 at 12:09 -0600, Mark Hatle wrote:
>> Previously the build path to STAGING_KERNEL_DIR was being embedded into the
>> package post install scripts.  We avoid this behavior by generating a special
>> depmodwrapper script.  This script contains that hard-coded path, ensuring
>> that re-use of the sstate-cache (and/or packages) will always run through the
>> wrapper generated by the current build with a checksum that includes
>> STAGING_KERNEL_DIR.
>>
>> [ YOCTO #3962 ]
>>
>> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
>> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
>> ---
>>   meta/classes/image.bbclass                         |    4 +-
>>   meta/classes/kernel.bbclass                        |    8 ++--
>>   meta/classes/module.bbclass                        |    4 +-
>>   .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |   34 ++++++++++++++++++++
>>   4 files changed, 42 insertions(+), 8 deletions(-)
>>   create mode 100644 meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>>
>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>> index dd78acb..af17331 100644
>> --- a/meta/classes/image.bbclass
>> +++ b/meta/classes/image.bbclass
>> @@ -10,7 +10,7 @@ inherit gzipnative
>>
>>   LICENSE = "MIT"
>>   PACKAGES = ""
>> -DEPENDS += "${MLPREFIX}qemuwrapper-cross"
>> +DEPENDS += "${MLPREFIX}qemuwrapper-cross depmodwrapper-cross"
>>   RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} ${NORMAL_FEATURE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL}"
>>   RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}"
>>
>> @@ -283,7 +283,7 @@ fakeroot do_rootfs () {
>>   		KERNEL_VERSION=`cat ${STAGING_KERNEL_DIR}/kernel-abiversion`
>>
>>   		mkdir -p ${IMAGE_ROOTFS}/lib/modules/$KERNEL_VERSION
>> -		depmod -a -b ${IMAGE_ROOTFS} -F ${STAGING_KERNEL_DIR}/System.map-$KERNEL_VERSION $KERNEL_VERSION
>> +		depmodwrapper -a -b ${IMAGE_ROOTFS} $KERNEL_VERSION
>>   	fi
>>
>>   	${IMAGE_PREPROCESS_COMMAND}
>> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
>> index e8c585b..2bdc2fc 100644
>> --- a/meta/classes/kernel.bbclass
>> +++ b/meta/classes/kernel.bbclass
>> @@ -1,7 +1,7 @@
>>   inherit linux-kernel-base module_strip
>>
>>   PROVIDES += "virtual/kernel"
>> -DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native"
>> +DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross"
>>
>>   # we include gcc above, we dont need virtual/libc
>>   INHIBIT_DEFAULT_DEPS = "1"
>> @@ -272,7 +272,7 @@ if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
>>   	mkdir -p $D/lib/modules/${KERNEL_VERSION}
>>   fi
>>   if [ -n "$D" ]; then
>> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   else
>>   	depmod -a ${KERNEL_VERSION}
>>   fi
>> @@ -282,7 +282,7 @@ pkg_postinst_modules () {
>>   if [ -z "$D" ]; then
>>   	depmod -a ${KERNEL_VERSION}
>>   else
>> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   fi
>>   }
>>
>> @@ -290,7 +290,7 @@ pkg_postrm_modules () {
>>   if [ -z "$D" ]; then
>>   	depmod -a ${KERNEL_VERSION}
>>   else
>> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   fi
>>   }
>>
>> diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass
>> index e2174a1..2c1888c 100644
>> --- a/meta/classes/module.bbclass
>> +++ b/meta/classes/module.bbclass
>> @@ -28,7 +28,7 @@ module_pkg_postinst () {
>>   if [ -z "$D" ]; then
>>   	depmod -a ${KERNEL_VERSION}
>>   else
>> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   fi
>>   }
>>
>> @@ -36,7 +36,7 @@ module_pkg_postrm () {
>>   if [ -z "$D" ]; then
>>   	depmod -a ${KERNEL_VERSION}
>>   else
>> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
>> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
>>   fi
>>   }
>>
>> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> new file mode 100644
>> index 0000000..646c4cd
>> --- /dev/null
>> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
>> @@ -0,0 +1,34 @@
>> +DESCRIPTION = "Depmod wrapper script"
>> +LICENSE = "MIT"
>> +PR = "r0"
>> +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
>> +
>> +# We need to evaluate it to the final path for vardeps to
>> +# work properly.
>> +STAGING_KERNEL_DIR := "${STAGING_KERNEL_DIR}"
>
> Please get rid of the above line. Really. You do not need to do this.
> I've told you this already and I do mean it.
>
> No, it won't show up in the sstate dependencies directly but the sed run
> over text files containing "STAGING_DIR" expressions will take care of
> relocating it, hence it doesn't need to be there.
>
> If that doesn't happen, please say why the sed expressions don't catch
> it.

Without that line, the thing was never modified from what was installed into the 
sysroot.  I have no idea what is supposed to change the values, but it wasn't 
working.

Very easy to reproduce with master, take that code and run it in one build, 
share the sstate, run it in the second.  Without the := bit, it keeps using the 
old path.  (I spent almost 4 hours on this yesterday before finally doing the := 
to make it work.  I'd rather the sstate code "make it work", but it wasn't.)

--Mark

> Cheers,
>
> Richard
>
>> +do_install() {
>> +	install -d ${D}${bindir_crossscripts}/
>> +
>> +	cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF
>> +#!/bin/sh
>> +# Expected to be called as: depmodwrapper -a KERNEL_VERSION
>> +if [ "\$1" != "-a" -a "\$2" != "-b" ]; then
>> +    echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
>> +    exit 1
>> +fi
>> +if [ ! -r ${STAGING_KERNEL_DIR}/System.map-\$4 ]; then
>> +    echo "Unable to read: ${STAGING_KERNEL_DIR}/System.map-\$4" >&2
>> +    exec env depmod "\$1" "\$2" "\$3" "\$4"
>> +else
>> +    exec env depmod "\$1" "\$2" "\$3" -F "${STAGING_KERNEL_DIR}/System.map-\$4" "\$4"
>> +fi
>> +EOF
>> +	chmod +x ${D}${bindir_crossscripts}/depmodwrapper
>> +}
>> +
>> +SYSROOT_PREPROCESS_FUNCS += "depmodwrapper_sysroot_preprocess"
>> +
>> +depmodwrapper_sysroot_preprocess () {
>> +	sysroot_stage_dir ${D}${bindir_crossscripts} ${SYSROOT_DESTDIR}${bindir_crossscripts}
>> +}
>
>
Martin Jansa - Feb. 28, 2013, 9:23 p.m.
On Thu, Feb 28, 2013 at 03:07:19PM -0600, Mark Hatle wrote:
> On 2/28/13 2:53 PM, Richard Purdie wrote:
> > On Thu, 2013-02-28 at 12:09 -0600, Mark Hatle wrote:
> >> Previously the build path to STAGING_KERNEL_DIR was being embedded into the
> >> package post install scripts.  We avoid this behavior by generating a special
> >> depmodwrapper script.  This script contains that hard-coded path, ensuring
> >> that re-use of the sstate-cache (and/or packages) will always run through the
> >> wrapper generated by the current build with a checksum that includes
> >> STAGING_KERNEL_DIR.
> >>
> >> [ YOCTO #3962 ]
> >>
> >> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
> >> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
> >> ---
> >>   meta/classes/image.bbclass                         |    4 +-
> >>   meta/classes/kernel.bbclass                        |    8 ++--
> >>   meta/classes/module.bbclass                        |    4 +-
> >>   .../recipes-kernel/kmod/depmodwrapper-cross_1.0.bb |   34 ++++++++++++++++++++
> >>   4 files changed, 42 insertions(+), 8 deletions(-)
> >>   create mode 100644 meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> >>
> >> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> >> index dd78acb..af17331 100644
> >> --- a/meta/classes/image.bbclass
> >> +++ b/meta/classes/image.bbclass
> >> @@ -10,7 +10,7 @@ inherit gzipnative
> >>
> >>   LICENSE = "MIT"
> >>   PACKAGES = ""
> >> -DEPENDS += "${MLPREFIX}qemuwrapper-cross"
> >> +DEPENDS += "${MLPREFIX}qemuwrapper-cross depmodwrapper-cross"
> >>   RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} ${NORMAL_FEATURE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL}"
> >>   RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}"
> >>
> >> @@ -283,7 +283,7 @@ fakeroot do_rootfs () {
> >>   		KERNEL_VERSION=`cat ${STAGING_KERNEL_DIR}/kernel-abiversion`
> >>
> >>   		mkdir -p ${IMAGE_ROOTFS}/lib/modules/$KERNEL_VERSION
> >> -		depmod -a -b ${IMAGE_ROOTFS} -F ${STAGING_KERNEL_DIR}/System.map-$KERNEL_VERSION $KERNEL_VERSION
> >> +		depmodwrapper -a -b ${IMAGE_ROOTFS} $KERNEL_VERSION
> >>   	fi
> >>
> >>   	${IMAGE_PREPROCESS_COMMAND}
> >> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> >> index e8c585b..2bdc2fc 100644
> >> --- a/meta/classes/kernel.bbclass
> >> +++ b/meta/classes/kernel.bbclass
> >> @@ -1,7 +1,7 @@
> >>   inherit linux-kernel-base module_strip
> >>
> >>   PROVIDES += "virtual/kernel"
> >> -DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native"
> >> +DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross"
> >>
> >>   # we include gcc above, we dont need virtual/libc
> >>   INHIBIT_DEFAULT_DEPS = "1"
> >> @@ -272,7 +272,7 @@ if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
> >>   	mkdir -p $D/lib/modules/${KERNEL_VERSION}
> >>   fi
> >>   if [ -n "$D" ]; then
> >> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> >> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
> >>   else
> >>   	depmod -a ${KERNEL_VERSION}
> >>   fi
> >> @@ -282,7 +282,7 @@ pkg_postinst_modules () {
> >>   if [ -z "$D" ]; then
> >>   	depmod -a ${KERNEL_VERSION}
> >>   else
> >> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> >> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
> >>   fi
> >>   }
> >>
> >> @@ -290,7 +290,7 @@ pkg_postrm_modules () {
> >>   if [ -z "$D" ]; then
> >>   	depmod -a ${KERNEL_VERSION}
> >>   else
> >> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> >> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
> >>   fi
> >>   }
> >>
> >> diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass
> >> index e2174a1..2c1888c 100644
> >> --- a/meta/classes/module.bbclass
> >> +++ b/meta/classes/module.bbclass
> >> @@ -28,7 +28,7 @@ module_pkg_postinst () {
> >>   if [ -z "$D" ]; then
> >>   	depmod -a ${KERNEL_VERSION}
> >>   else
> >> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> >> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
> >>   fi
> >>   }
> >>
> >> @@ -36,7 +36,7 @@ module_pkg_postrm () {
> >>   if [ -z "$D" ]; then
> >>   	depmod -a ${KERNEL_VERSION}
> >>   else
> >> -	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
> >> +	depmodwrapper -a -b $D ${KERNEL_VERSION}
> >>   fi
> >>   }
> >>
> >> diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> >> new file mode 100644
> >> index 0000000..646c4cd
> >> --- /dev/null
> >> +++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
> >> @@ -0,0 +1,34 @@
> >> +DESCRIPTION = "Depmod wrapper script"
> >> +LICENSE = "MIT"
> >> +PR = "r0"
> >> +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
> >> +
> >> +# We need to evaluate it to the final path for vardeps to
> >> +# work properly.
> >> +STAGING_KERNEL_DIR := "${STAGING_KERNEL_DIR}"
> >
> > Please get rid of the above line. Really. You do not need to do this.
> > I've told you this already and I do mean it.
> >
> > No, it won't show up in the sstate dependencies directly but the sed run
> > over text files containing "STAGING_DIR" expressions will take care of
> > relocating it, hence it doesn't need to be there.
> >
> > If that doesn't happen, please say why the sed expressions don't catch
> > it.
> 
> Without that line, the thing was never modified from what was installed into the 
> sysroot.  I have no idea what is supposed to change the values, but it wasn't 
> working.
> 
> Very easy to reproduce with master, take that code and run it in one build, 
> share the sstate, run it in the second.  Without the := bit, it keeps using the 
> old path.  (I spent almost 4 hours on this yesterday before finally doing the := 
> to make it work.  I'd rather the sstate code "make it work", but it wasn't.)

Did you append depmodwrapper to SSTATE_SCAN_FILES?

> --Mark
> 
> > Cheers,
> >
> > Richard
> >
> >> +do_install() {
> >> +	install -d ${D}${bindir_crossscripts}/
> >> +
> >> +	cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF
> >> +#!/bin/sh
> >> +# Expected to be called as: depmodwrapper -a KERNEL_VERSION
> >> +if [ "\$1" != "-a" -a "\$2" != "-b" ]; then
> >> +    echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
> >> +    exit 1
> >> +fi
> >> +if [ ! -r ${STAGING_KERNEL_DIR}/System.map-\$4 ]; then
> >> +    echo "Unable to read: ${STAGING_KERNEL_DIR}/System.map-\$4" >&2
> >> +    exec env depmod "\$1" "\$2" "\$3" "\$4"
> >> +else
> >> +    exec env depmod "\$1" "\$2" "\$3" -F "${STAGING_KERNEL_DIR}/System.map-\$4" "\$4"
> >> +fi
> >> +EOF
> >> +	chmod +x ${D}${bindir_crossscripts}/depmodwrapper
> >> +}
> >> +
> >> +SYSROOT_PREPROCESS_FUNCS += "depmodwrapper_sysroot_preprocess"
> >> +
> >> +depmodwrapper_sysroot_preprocess () {
> >> +	sysroot_stage_dir ${D}${bindir_crossscripts} ${SYSROOT_DESTDIR}${bindir_crossscripts}
> >> +}
> >
> >
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Patch

diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index dd78acb..af17331 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -10,7 +10,7 @@  inherit gzipnative
 
 LICENSE = "MIT"
 PACKAGES = ""
-DEPENDS += "${MLPREFIX}qemuwrapper-cross"
+DEPENDS += "${MLPREFIX}qemuwrapper-cross depmodwrapper-cross"
 RDEPENDS += "${IMAGE_INSTALL} ${LINGUAS_INSTALL} ${NORMAL_FEATURE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL}"
 RRECOMMENDS += "${NORMAL_FEATURE_INSTALL_OPTIONAL}"
 
@@ -283,7 +283,7 @@  fakeroot do_rootfs () {
 		KERNEL_VERSION=`cat ${STAGING_KERNEL_DIR}/kernel-abiversion`
 
 		mkdir -p ${IMAGE_ROOTFS}/lib/modules/$KERNEL_VERSION
-		depmod -a -b ${IMAGE_ROOTFS} -F ${STAGING_KERNEL_DIR}/System.map-$KERNEL_VERSION $KERNEL_VERSION
+		depmodwrapper -a -b ${IMAGE_ROOTFS} $KERNEL_VERSION
 	fi
 
 	${IMAGE_PREPROCESS_COMMAND}
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index e8c585b..2bdc2fc 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -1,7 +1,7 @@ 
 inherit linux-kernel-base module_strip
 
 PROVIDES += "virtual/kernel"
-DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native"
+DEPENDS += "virtual/${TARGET_PREFIX}gcc kmod-native depmodwrapper-cross"
 
 # we include gcc above, we dont need virtual/libc
 INHIBIT_DEFAULT_DEPS = "1"
@@ -272,7 +272,7 @@  if [ ! -e "$D/lib/modules/${KERNEL_VERSION}" ]; then
 	mkdir -p $D/lib/modules/${KERNEL_VERSION}
 fi
 if [ -n "$D" ]; then
-	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
+	depmodwrapper -a -b $D ${KERNEL_VERSION}
 else
 	depmod -a ${KERNEL_VERSION}
 fi
@@ -282,7 +282,7 @@  pkg_postinst_modules () {
 if [ -z "$D" ]; then
 	depmod -a ${KERNEL_VERSION}
 else
-	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
+	depmodwrapper -a -b $D ${KERNEL_VERSION}
 fi
 }
 
@@ -290,7 +290,7 @@  pkg_postrm_modules () {
 if [ -z "$D" ]; then
 	depmod -a ${KERNEL_VERSION}
 else
-	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
+	depmodwrapper -a -b $D ${KERNEL_VERSION}
 fi
 }
 
diff --git a/meta/classes/module.bbclass b/meta/classes/module.bbclass
index e2174a1..2c1888c 100644
--- a/meta/classes/module.bbclass
+++ b/meta/classes/module.bbclass
@@ -28,7 +28,7 @@  module_pkg_postinst () {
 if [ -z "$D" ]; then
 	depmod -a ${KERNEL_VERSION}
 else
-	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
+	depmodwrapper -a -b $D ${KERNEL_VERSION}
 fi
 }
 
@@ -36,7 +36,7 @@  module_pkg_postrm () {
 if [ -z "$D" ]; then
 	depmod -a ${KERNEL_VERSION}
 else
-	depmod -a -b $D -F ${STAGING_KERNEL_DIR}/System.map-${KERNEL_VERSION} ${KERNEL_VERSION}
+	depmodwrapper -a -b $D ${KERNEL_VERSION}
 fi
 }
 
diff --git a/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
new file mode 100644
index 0000000..646c4cd
--- /dev/null
+++ b/meta/recipes-kernel/kmod/depmodwrapper-cross_1.0.bb
@@ -0,0 +1,34 @@ 
+DESCRIPTION = "Depmod wrapper script"
+LICENSE = "MIT"
+PR = "r0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+# We need to evaluate it to the final path for vardeps to
+# work properly.
+STAGING_KERNEL_DIR := "${STAGING_KERNEL_DIR}"
+
+do_install() {
+	install -d ${D}${bindir_crossscripts}/
+
+	cat > ${D}${bindir_crossscripts}/depmodwrapper << EOF
+#!/bin/sh
+# Expected to be called as: depmodwrapper -a KERNEL_VERSION
+if [ "\$1" != "-a" -a "\$2" != "-b" ]; then
+    echo "Usage: depmodwrapper -a -b rootfs KERNEL_VERSION" >&2
+    exit 1
+fi
+if [ ! -r ${STAGING_KERNEL_DIR}/System.map-\$4 ]; then
+    echo "Unable to read: ${STAGING_KERNEL_DIR}/System.map-\$4" >&2
+    exec env depmod "\$1" "\$2" "\$3" "\$4"
+else
+    exec env depmod "\$1" "\$2" "\$3" -F "${STAGING_KERNEL_DIR}/System.map-\$4" "\$4"
+fi
+EOF
+	chmod +x ${D}${bindir_crossscripts}/depmodwrapper
+}
+
+SYSROOT_PREPROCESS_FUNCS += "depmodwrapper_sysroot_preprocess"
+
+depmodwrapper_sysroot_preprocess () {
+	sysroot_stage_dir ${D}${bindir_crossscripts} ${SYSROOT_DESTDIR}${bindir_crossscripts}
+}