image-prelink.bbclass 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. do_rootfs[depends] += "prelink-native:do_populate_sysroot"
  2. IMAGE_PREPROCESS_COMMAND_append_libc-glibc = " prelink_setup; prelink_image; "
  3. python prelink_setup () {
  4. oe.utils.write_ld_so_conf(d)
  5. }
  6. inherit linuxloader
  7. prelink_image () {
  8. # export PSEUDO_DEBUG=4
  9. # /bin/env | /bin/grep PSEUDO
  10. # echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
  11. # echo "LD_PRELOAD=$LD_PRELOAD"
  12. pre_prelink_size=`du -ks ${IMAGE_ROOTFS} | awk '{size = $1 ; print size }'`
  13. echo "Size before prelinking $pre_prelink_size."
  14. # The filesystem may not contain sysconfdir so establish what is present
  15. # to enable cleanup after temporary creation of sysconfdir if needed
  16. presentdir="${IMAGE_ROOTFS}${sysconfdir}"
  17. while [ "${IMAGE_ROOTFS}" != "${presentdir}" ] ; do
  18. [ ! -d "${presentdir}" ] || break
  19. presentdir=`dirname "${presentdir}"`
  20. done
  21. mkdir -p "${IMAGE_ROOTFS}${sysconfdir}"
  22. # We need a prelink conf on the filesystem, add one if it's missing
  23. if [ ! -e ${IMAGE_ROOTFS}${sysconfdir}/prelink.conf ]; then
  24. cp ${STAGING_ETCDIR_NATIVE}/prelink.conf \
  25. ${IMAGE_ROOTFS}${sysconfdir}/prelink.conf
  26. dummy_prelink_conf=true;
  27. else
  28. dummy_prelink_conf=false;
  29. fi
  30. # We need a ld.so.conf with pathnames in,prelink conf on the filesystem, add one if it's missing
  31. ldsoconf=${IMAGE_ROOTFS}${sysconfdir}/ld.so.conf
  32. if [ -e $ldsoconf ]; then
  33. cp $ldsoconf $ldsoconf.prelink
  34. fi
  35. cat ${STAGING_DIR_TARGET}${sysconfdir}/ld.so.conf >> $ldsoconf
  36. dynamic_loader=${@get_linuxloader(d)}
  37. # prelink!
  38. if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
  39. bbnote " prelink: BUILD_REPRODUCIBLE_BINARIES..."
  40. if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
  41. export PRELINK_TIMESTAMP=`git log -1 --pretty=%ct `
  42. else
  43. export PRELINK_TIMESTAMP=$REPRODUCIBLE_TIMESTAMP_ROOTFS
  44. fi
  45. ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS} -am -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader
  46. else
  47. ${STAGING_SBINDIR_NATIVE}/prelink --root ${IMAGE_ROOTFS} -amR -N -c ${sysconfdir}/prelink.conf --dynamic-linker $dynamic_loader
  48. fi
  49. # Remove the prelink.conf if we had to add it.
  50. if [ "$dummy_prelink_conf" = "true" ]; then
  51. rm -f ${IMAGE_ROOTFS}${sysconfdir}/prelink.conf
  52. fi
  53. if [ -e $ldsoconf.prelink ]; then
  54. mv $ldsoconf.prelink $ldsoconf
  55. else
  56. rm $ldsoconf
  57. fi
  58. # Remove any directories temporarily created for sysconfdir
  59. cleanupdir="${IMAGE_ROOTFS}${sysconfdir}"
  60. while [ "${presentdir}" != "${cleanupdir}" ] ; do
  61. rmdir "${cleanupdir}"
  62. cleanupdir=`dirname ${cleanupdir}`
  63. done
  64. pre_prelink_size=`du -ks ${IMAGE_ROOTFS} | awk '{size = $1 ; print size }'`
  65. echo "Size after prelinking $pre_prelink_size."
  66. }