1INHIBIT_SYSROOT_STRIP = "1"
2
3PACKAGES = "${PN}-dbg catchsegv sln nscd ldd tzcode glibc-thread-db ${PN}-pic libcidn libmemusage libnss-db libsegfault ${PN}-pcprofile libsotruss ${PN} ${PN}-utils glibc-extra-nss ${PN}-dev ${PN}-staticdev ${PN}-doc"
4
5# The ld.so in this glibc supports the GNU_HASH
6RPROVIDES_${PN} = "eglibc rtld(GNU_HASH)"
7RPROVIDES_${PN}-utils = "eglibc-utils"
8RPROVIDES_${PN}-mtrace = "eglibc-mtrace libc-mtrace"
9RPROVIDES_${PN}-pic = "eglibc-pic"
10RPROVIDES_${PN}-dev = "eglibc-dev libc6-dev virtual-libc-dev"
11RPROVIDES_${PN}-staticdev = "eglibc-staticdev"
12RPROVIDES_${PN}-doc = "eglibc-doc"
13RPROVIDES_glibc-extra-nss = "eglibc-extra-nss"
14RPROVIDES_glibc-thread-db = "eglibc-thread-db"
15RPROVIDES_${PN}-pcprofile = "eglibc-pcprofile"
16RPROVIDES_${PN}-dbg = "eglibc-dbg"
17libc_baselibs = "${base_libdir}/libc.so.* ${base_libdir}/libc-*.so ${base_libdir}/libm*.so.* ${base_libdir}/libm-*.so ${base_libdir}/libmvec-*.so ${base_libdir}/ld*.so.* ${base_libdir}/ld-*.so ${base_libdir}/libpthread*.so.* ${base_libdir}/libpthread-*.so ${base_libdir}/libresolv*.so.* ${base_libdir}/libresolv-*.so ${base_libdir}/librt*.so.* ${base_libdir}/librt-*.so ${base_libdir}/libutil*.so.* ${base_libdir}/libutil-*.so ${base_libdir}/libnsl*.so.* ${base_libdir}/libnsl-*.so ${base_libdir}/libnss_files*.so.* ${base_libdir}/libnss_files-*.so ${base_libdir}/libnss_compat*.so.* ${base_libdir}/libnss_compat-*.so ${base_libdir}/libnss_dns*.so.* ${base_libdir}/libnss_dns-*.so ${base_libdir}/libdl*.so.* ${base_libdir}/libdl-*.so ${base_libdir}/libanl*.so.* ${base_libdir}/libanl-*.so ${base_libdir}/libBrokenLocale*.so.* ${base_libdir}/libBrokenLocale-*.so"
18ARCH_DYNAMIC_LOADER = ""
19# The aarch64 ABI says the dynamic linker -must- be
20# /lib/ld-linux-aarch64{,_be}.so.1. With usrmerge, that may mean that
21# we need to install it in /usr/lib.
22ARCH_DYNAMIC_LOADER_aarch64 = "ld-linux-${TARGET_ARCH}.so.1"
23libc_baselibs_append = " ${@oe.utils.conditional('ARCH_DYNAMIC_LOADER', '', '', '${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}', d)}"
24INSANE_SKIP_${PN}_append_aarch64 = " libdir"
25
26FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${base_sbindir}/ldconfig ${sysconfdir}/ld.so.conf"
27FILES_ldd = "${bindir}/ldd"
28FILES_libsegfault = "${base_libdir}/libSegFault*"
29FILES_libcidn = "${base_libdir}/libcidn-*.so ${base_libdir}/libcidn.so.*"
30FILES_libmemusage = "${base_libdir}/libmemusage.so"
31FILES_libnss-db = "${base_libdir}/libnss_db.so.* ${base_libdir}/libnss_db-*.so ${localstatedir}/db/Makefile ${localstatedir}/db/makedbs.sh"
32RDEPENDS_libnss-db = "${PN}-utils"
33FILES_glibc-extra-nss = "${base_libdir}/libnss_*-*.so ${base_libdir}/libnss_*.so.*"
34FILES_sln = "${base_sbindir}/sln"
35FILES_${PN}-pic = "${libdir}/*_pic.a ${libdir}/*_pic.map ${libdir}/libc_pic/*.o"
36FILES_libsotruss = "${libdir}/audit/sotruss-lib.so"
37FILES_SOLIBSDEV = "${libdir}/lib*${SOLIBSDEV}"
38FILES_${PN}-dev += "${libdir}/*_nonshared.a ${base_libdir}/*_nonshared.a ${base_libdir}/*.o ${datadir}/aclocal"
39FILES_${PN}-staticdev += "${libdir}/*.a ${base_libdir}/*.a"
40FILES_nscd = "${sbindir}/nscd* ${sysconfdir}/init.d/nscd ${systemd_unitdir}/system/nscd* ${sysconfdir}/tmpfiles.d/nscd.conf \
41              ${sysconfdir}/nscd.conf ${sysconfdir}/default/volatiles/98_nscd ${localstatedir}/db/nscd"
42FILES_${PN}-mtrace = "${bindir}/mtrace"
43FILES_tzcode = "${bindir}/tzselect ${sbindir}/zic ${sbindir}/zdump"
44FILES_${PN}-utils = "${bindir}/* ${sbindir}/*"
45FILES_catchsegv = "${bindir}/catchsegv"
46RDEPENDS_catchsegv = "libsegfault"
47FILES_${PN}-pcprofile = "${base_libdir}/libpcprofile.so"
48FILES_glibc-thread-db = "${base_libdir}/libthread_db.so.* ${base_libdir}/libthread_db-*.so"
49RPROVIDES_${PN}-dev += "libc-dev"
50RPROVIDES_${PN}-staticdev += "libc-staticdev"
51
52SUMMARY_sln = "The static ln"
53DESCRIPTION_sln = "Similar to the 'ln' utility, but statically linked.  sln is useful to make symbolic links to dynamic libraries if the dynamic linking system, for some reason, is not functional."
54SUMMARY_nscd = "Name service cache daemon"
55DESCRIPTION_nscd = "nscd, name service cache daemon, caches name service lookups for the passwd, group and hosts information.  It can damatically improvide performance with remote, such as NIS or NIS+, name services."
56SUMMARY_glibc-extra-nss = "hesiod, NIS and NIS+ nss libraries"
57DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services."
58SUMMARY_ldd = "print shared library dependencies"
59DESCRIPTION_ldd = "${bindir}/ldd prints shared library dependencies for each program or shared library specified on the command line."
60SUMMARY_${PN}-utils = "Miscellaneous utilities provided by glibc"
61DESCRIPTION_${PN}-utils = "Miscellaneous utilities including getconf, iconv, locale, gencat, ..."
62DESCRIPTION_libsotruss = "Library to support sotruss which traces calls through PLTs"
63DESCRIPTION_tzcode = "tzcode, timezone zoneinfo utils -- zic, zdump, tzselect"
64
65inherit libc-common multilib_header
66
67do_install_append () {
68	rm -f ${D}${sysconfdir}/localtime
69
70	# remove empty glibc dir
71	if [ -d ${D}${libexecdir} ]; then
72		rmdir --ignore-fail-on-non-empty ${D}${libexecdir}
73	fi
74
75	oe_multilib_header bits/syscall.h bits/long-double.h bits/floatn.h
76
77	if [ -f ${D}${bindir}/mtrace ]; then
78		sed -i -e '1s,#!.*perl,#! ${USRBINPATH}/env perl,' -e '2s,exec.*perl,exec ${USRBINPATH}/env perl,' ${D}${bindir}/mtrace
79	fi
80	# Info dir listing isn't interesting at this point so remove it if it exists.
81	if [ -e "${D}${infodir}/dir" ]; then
82		rm -f ${D}${infodir}/dir
83	fi
84
85	if ! ${@bb.utils.contains('DISTRO_FEATURES', 'ldconfig', 'true', 'false', d)}; then
86		# The distro doesn't want these files so let's not install them
87		rm -f ${D}${sysconfdir}/ld.so.conf
88		rm -f ${D}${base_sbindir}/ldconfig
89		# This directory will be empty now so remove it too.
90		# But check whether it exists first, since it won't for glibc-initial.
91		if [ -d ${D}${sysconfdir} ]; then
92			rmdir ${D}${sysconfdir}
93		fi
94	fi
95
96	if echo ${PN}|grep -q "glibc-initial"; then
97		return
98	fi
99
100	install -d ${D}${sysconfdir}/init.d
101	install -d ${D}${localstatedir}/db/nscd
102	install -m 0755 ${S}/nscd/nscd.init ${D}${sysconfdir}/init.d/nscd
103	install -m 0755 ${S}/nscd/nscd.conf ${D}${sysconfdir}/nscd.conf
104	install -m 0755 ${WORKDIR}/makedbs.sh ${D}${localstatedir}/db
105	sed -i "s%daemon%start-stop-daemon --start --exec%g" ${D}${sysconfdir}/init.d/nscd
106	sed -i "s|\(enable-cache\t\+netgroup\t\+\)yes|\1no|" ${D}${sysconfdir}/nscd.conf
107
108	install -d ${D}${systemd_unitdir}/system
109	install -m 0644 ${S}/nscd/nscd.service ${D}${systemd_unitdir}/system/
110
111	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
112		install -d ${D}${sysconfdir}/tmpfiles.d
113		echo "d /run/nscd 755 root root -" \
114			> ${D}${sysconfdir}/tmpfiles.d/nscd.conf
115	fi
116
117	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
118		install -d ${D}${sysconfdir}/default/volatiles
119		echo "d root root 0755 /var/run/nscd none" \
120			> ${D}${sysconfdir}/default/volatiles/98_nscd
121	fi
122
123	# The dynamic loader will have been installed into
124	# ${base_libdir}. However, if that isn't going to end up being
125	# available in the ABI-mandated location, then a symlink must
126        # be created.
127
128	if [ -n "${ARCH_DYNAMIC_LOADER}" -a ! -e "${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then
129		install -d ${D}${root_prefix}/lib
130		ln -s ${@oe.path.relative('${root_prefix}/lib', '${base_libdir}')}/${ARCH_DYNAMIC_LOADER} \
131				${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}
132	fi
133}
134
135do_install_append_aarch64 () {
136	do_install_armmultilib
137}
138
139do_install_append_arm () {
140	do_install_armmultilib
141}
142
143do_install_append_armeb () {
144	do_install_armmultilib
145}
146
147do_install_armmultilib () {
148	oe_multilib_header bits/endian.h bits/fcntl.h bits/fenv.h bits/fp-fast.h bits/hwcap.h bits/ipc.h bits/link.h bits/wordsize.h
149	oe_multilib_header bits/local_lim.h bits/mman.h bits/msq.h bits/pthreadtypes.h bits/pthreadtypes-arch.h  bits/sem.h  bits/semaphore.h bits/setjmp.h
150	oe_multilib_header bits/shm.h bits/sigstack.h bits/stat.h bits/statfs.h bits/typesizes.h
151	oe_multilib_header bits/procfs-id.h bits/procfs.h bits/shmlba.h
152
153	oe_multilib_header fpu_control.h gnu/lib-names.h gnu/stubs.h ieee754.h
154
155	oe_multilib_header sys/elf.h sys/procfs.h sys/ptrace.h sys/ucontext.h sys/user.h
156}
157
158
159LOCALESTASH = "${WORKDIR}/stashed-locale"
160bashscripts = "mtrace sotruss xtrace"
161
162do_stash_locale () {
163	dest=${LOCALESTASH}
164	install -d ${dest}${base_libdir} ${dest}${bindir} ${dest}${libdir} ${dest}${datadir}
165	if [ "${base_libdir}" != "${libdir}" ]; then
166		cp -fpPR ${D}${base_libdir}/* ${dest}${base_libdir}
167	fi
168	if [ -e ${D}${bindir}/localedef ]; then
169		mv -f ${D}${bindir}/localedef ${dest}${bindir}
170	fi
171	if [ -e ${D}${libdir}/gconv ]; then
172		mv -f ${D}${libdir}/gconv ${dest}${libdir}
173	fi
174	if [ -e ${D}${exec_prefix}/lib ]; then
175		cp -fpPR ${D}${exec_prefix}/lib ${dest}${exec_prefix}
176	fi
177	if [ -e ${D}${datadir}/i18n ]; then
178		mv ${D}${datadir}/i18n ${dest}${datadir}
179	fi
180	cp -fpPR ${D}${datadir}/* ${dest}${datadir}
181	rm -rf ${D}${datadir}/locale/
182	cp -fpPR ${WORKDIR}/SUPPORTED ${dest}
183
184	target=${dest}/scripts
185	mkdir -p $target
186	for i in ${bashscripts}; do
187		if [ -f ${D}${bindir}/$i ]; then
188			cp ${D}${bindir}/$i $target/
189		fi
190	done
191}
192
193addtask do_stash_locale after do_install before do_populate_sysroot do_package
194do_stash_locale[dirs] = "${B}"
195do_stash_locale[cleandirs] = "${LOCALESTASH}"
196SSTATETASKS += "do_stash_locale"
197do_stash_locale[sstate-inputdirs] = "${LOCALESTASH}"
198do_stash_locale[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
199do_stash_locale[sstate-fixmedir] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
200
201python do_stash_locale_setscene () {
202    sstate_setscene(d)
203}
204addtask do_stash_locale_setscene
205
206do_poststash_install_cleanup () {
207	# Remove all files which do_stash_locale would remove (mv)
208	# since that task could have come from sstate and not get run.
209	for i in ${bashscripts}; do
210	    rm -f ${D}${bindir}/$i
211	done
212	rm -f ${D}${bindir}/localedef
213	rm -rf ${D}${datadir}/i18n
214	rm -rf ${D}${libdir}/gconv
215	rm -rf ${D}/${localedir}
216	rm -rf ${D}${datadir}/locale
217	if [ "${libdir}" != "${exec_prefix}/lib" ]; then
218	    if [ -d "${D}${exec_prefix}/lib" ]; then
219		if [ -z "${ARCH_DYNAMIC_LOADER}" -o \
220		     ! -e "${D}${exec_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then
221			# error out if directory isn't empty
222			# this dir should only contain locale dir
223			# which has been deleted in the previous step
224			rmdir ${D}${exec_prefix}/lib
225		fi
226	    fi
227	fi
228}
229addtask do_poststash_install_cleanup after do_stash_locale do_install before do_populate_sysroot do_package
230
231pkg_postinst_nscd () {
232	if [ -z "$D" ]; then
233		if command -v systemd-tmpfiles >/dev/null; then
234			systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/nscd.conf
235		elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
236			${sysconfdir}/init.d/populate-volatile.sh update
237		fi
238	fi
239}
240CONFFILES_nscd="${sysconfdir}/nscd.conf"
241
242SYSTEMD_PACKAGES = "nscd"
243SYSTEMD_SERVICE_nscd = "nscd.service"
244