prelink_git.bb 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. SECTION = "devel"
  2. # Need binutils for libiberty.a
  3. # Would need transfig-native for documentation if it wasn't disabled
  4. DEPENDS = "elfutils binutils"
  5. SUMMARY = "An ELF prelinking utility"
  6. HOMEPAGE = "http://git.yoctoproject.org/cgit.cgi/prelink-cross/about/"
  7. DESCRIPTION = "The prelink package contains a utility which modifies ELF shared libraries \
  8. and executables, so that far fewer relocations need to be resolved at \
  9. runtime and thus programs come up faster."
  10. LICENSE = "GPLv2"
  11. LIC_FILES_CHKSUM = "file://COPYING;md5=c93c0550bd3173f4504b2cbd8991e50b"
  12. SRCREV = "f9975537dbfd9ade0fc813bd5cf5fcbe41753a37"
  13. PV = "1.0+git${SRCPV}"
  14. #
  15. # The cron script attempts to re-prelink the system daily -- on
  16. # systems where users are adding applications, this might be reasonable
  17. # but for embedded, we should be re-running prelink -a after an update.
  18. #
  19. # Default is prelinking is enabled.
  20. #
  21. SUMMARY_${PN}-cron = "Cron scripts to control automatic prelinking"
  22. DESCRIPTION_${PN}-cron = "Cron scripts to control automatic prelinking. \
  23. See: ${sysconfdir}/cron.daily/prelink for configuration information."
  24. FILES_${PN}-cron = "${sysconfdir}/cron.daily ${sysconfdir}/default"
  25. PACKAGES =+ "${PN}-cron"
  26. SRC_URI = "git://git.yoctoproject.org/prelink-cross.git;branch=cross_prelink_staging \
  27. file://0001-Add-MIPS-gnu-hash-support.patch \
  28. file://prelink.conf \
  29. file://prelink.cron.daily \
  30. file://prelink.default \
  31. file://macros.prelink \
  32. "
  33. UPSTREAM_CHECK_COMMITS = "1"
  34. # error: error.h: No such file or directory
  35. COMPATIBLE_HOST_libc-musl = 'null'
  36. TARGET_OS_ORIG := "${TARGET_OS}"
  37. OVERRIDES_append = ":${TARGET_OS_ORIG}"
  38. S = "${WORKDIR}/git"
  39. inherit autotools
  40. BBCLASSEXTEND = "native"
  41. EXTRA_OECONF = "--disable-selinux --with-pkgversion=${PV}-${PR} \
  42. --with-bugurl=http://bugzilla.yoctoproject.org/"
  43. #
  44. # For target prelink we need to ensure paths match the lib path layout
  45. # including for any configured multilibs
  46. #
  47. python do_linkerpaths () {
  48. values = all_multilib_tune_list(["TUNE_ARCH", "baselib", "ABIEXTENSION"], d)
  49. arches = values["TUNE_ARCH"]
  50. baselibs = values["baselib"]
  51. abis = values["ABIEXTENSION"]
  52. def replace_lines(f, search, replacement, d, firstonly = False, secondonly = False):
  53. f = d.expand(f)
  54. if search == replacement:
  55. return
  56. bb.debug(2, "Replacing %s with %s in %s" % (search, replacement, f))
  57. with open(f, "r") as data:
  58. lines = data.readlines()
  59. with open(f, "w") as data:
  60. for line in lines:
  61. if not secondonly and not firstonly:
  62. line = line.replace(search, replacement)
  63. elif secondonly and search in line:
  64. secondonly = False
  65. elif firstonly and search and search in line:
  66. line = line.replace(search, replacement)
  67. search = None
  68. data.write(line)
  69. def replace_lines_rtld(f, search, replacement, section, d):
  70. f = d.expand(f)
  71. bb.debug(2, "Replacing %s with %s in %s" % (search, replacement, f))
  72. with open(f, "r") as data:
  73. lines = data.readlines()
  74. found = False
  75. found2 = False
  76. with open(f, "w") as data:
  77. for line in lines:
  78. if section in line:
  79. if section == "else" and "if" in line:
  80. found = False
  81. else:
  82. found = True
  83. if found and "dst_LIB =" in line:
  84. found2 = True
  85. elif "}" in line:
  86. found = False
  87. found2 = False
  88. if found2:
  89. line = line.replace(search, replacement)
  90. data.write(line)
  91. for i, arch in enumerate(arches):
  92. tune_baselib = baselibs[i]
  93. abi = abis[i]
  94. bits = 32
  95. if arch == "powerpc":
  96. replace_lines("${S}/src/arch-ppc.c", "/lib/ld.so.1", "/" + tune_baselib + "/ld.so.1", d)
  97. elif arch == "powerpc64":
  98. replace_lines("${S}/src/arch-ppc64.c", "/lib64/ld64.so.1", "/" + tune_baselib + "/ld64.so.1", d)
  99. bits = 64
  100. elif arch == "x86_64":
  101. if abi == "x32":
  102. replace_lines("${S}/src/arch-x86_64.c", "/libx32/ld-linux-x32.so.2", "/" + tune_baselib + "/ld-linux-x32.so.2", d)
  103. else:
  104. replace_lines("${S}/src/arch-x86_64.c", "/lib64/ld-linux-x86-64.so.2", "/" + tune_baselib + "/ld-linux-x86-64.so.2", d)
  105. bits = 64
  106. elif arch == "arm":
  107. replace_lines("${S}/src/arch-arm.c", "/lib/ld-linux.so.3", "/" + tune_baselib + "/ld-linux.so.3", d)
  108. replace_lines("${S}/src/arch-arm.c", "/lib/ld-linux-armhf.so.3", "/" + tune_baselib + "/ld-linux-armhf.so.3", d)
  109. elif arch == "mips" or arch == "mipsel":
  110. replace_lines("${S}/src/arch-mips.c", "/lib/ld.so.1", "/" + tune_baselib + "/ld.so.1", d, firstonly=True)
  111. replace_lines("${S}/src/arch-mips.c", "/lib32/ld.so.1", "/" + tune_baselib + "/ld.so.1", d)
  112. elif arch == "mips64" or arch == "mips64el":
  113. replace_lines("${S}/src/arch-mips.c", "/lib/ld.so.1", "/" + tune_baselib + "/ld.so.1", d, secondonly=True)
  114. replace_lines("${S}/src/arch-mips.c", "/lib64/ld.so.1", "/" + tune_baselib + "/ld.so.1", d)
  115. bits = 64
  116. elif arch.endswith("86"):
  117. replace_lines("${S}/src/arch-i386.c", "/lib/ld-linux.so.2", "/" + tune_baselib + "/ld-linux.so.2", d)
  118. if bits == 32 and tune_baselib != "lib":
  119. replace_lines_rtld("${S}/src/rtld/rtld.c", "lib", tune_baselib, "else", d)
  120. if bits == 64 and tune_baselib != "lib64":
  121. replace_lines_rtld("${S}/src/rtld/rtld.c", "lib64", tune_baselib, "use_64bit", d)
  122. }
  123. python () {
  124. overrides = d.getVar("OVERRIDES").split(":")
  125. if "class-target" in overrides:
  126. bb.build.addtask('do_linkerpaths', 'do_configure', 'do_patch', d)
  127. }
  128. do_configure_prepend () {
  129. # Disable documentation!
  130. echo "all:" > ${S}/doc/Makefile.am
  131. }
  132. do_install_append () {
  133. install -d ${D}${sysconfdir}/cron.daily ${D}${sysconfdir}/default ${D}${sysconfdir}/rpm
  134. install -m 0644 ${WORKDIR}/prelink.conf ${D}${sysconfdir}/prelink.conf
  135. install -m 0644 ${WORKDIR}/prelink.cron.daily ${D}${sysconfdir}/cron.daily/prelink
  136. install -m 0644 ${WORKDIR}/prelink.default ${D}${sysconfdir}/default/prelink
  137. install -m 0644 ${WORKDIR}/macros.prelink ${D}${sysconfdir}/rpm/macros.prelink
  138. }
  139. # If we ae doing a cross install, we want to avoid prelinking.
  140. # Prelinking during a cross install should be handled by the image-prelink
  141. # bbclass. If the user desires this to run on the target at first boot
  142. # they will need to create a custom boot script.
  143. pkg_postinst_prelink() {
  144. #!/bin/sh
  145. if [ "x$D" != "x" ]; then
  146. exit 0
  147. fi
  148. prelink -a
  149. }
  150. pkg_prerm_prelink() {
  151. #!/bin/sh
  152. if [ "x$D" != "x" ]; then
  153. exit 1
  154. fi
  155. prelink -au
  156. }