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