1INHIBIT_SYSROOT_STRIP = "1"
2
3PACKAGES = "${PN}-dbg catchsegv sln nscd ldd tzcode glibc-thread-db ${PN}-pic libcidn libmemusage 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}/libcrypt*.so.* ${base_libdir}/libcrypt-*.so ${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"
18libc_baselibs_append_aarch64 = " /lib/ld-linux-aarch64*.so.1"
19INSANE_SKIP_${PN}_append_aarch64 = " libdir"
20
21FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${base_sbindir}/ldconfig ${sysconfdir}/ld.so.conf"
22FILES_ldd = "${bindir}/ldd"
23FILES_libsegfault = "${base_libdir}/libSegFault*"
24FILES_libcidn = "${base_libdir}/libcidn-*.so ${base_libdir}/libcidn.so.*"
25FILES_libmemusage = "${base_libdir}/libmemusage.so"
26FILES_glibc-extra-nss = "${base_libdir}/libnss_*-*.so ${base_libdir}/libnss_*.so.*"
27FILES_sln = "${base_sbindir}/sln"
28FILES_${PN}-pic = "${libdir}/*_pic.a ${libdir}/*_pic.map ${libdir}/libc_pic/*.o"
29FILES_libsotruss = "${libdir}/audit/sotruss-lib.so"
30FILES_SOLIBSDEV = "${libdir}/lib*${SOLIBSDEV}"
31FILES_${PN}-dev += "${bindir}/rpcgen ${libdir}/*_nonshared.a ${base_libdir}/*_nonshared.a ${base_libdir}/*.o ${datadir}/aclocal"
32FILES_${PN}-staticdev += "${libdir}/*.a ${base_libdir}/*.a"
33FILES_nscd = "${sbindir}/nscd* ${sysconfdir}/init.d/nscd ${systemd_unitdir}/system/nscd* ${sysconfdir}/tmpfiles.d/nscd.conf \
34              ${sysconfdir}/nscd.conf ${sysconfdir}/default/volatiles/98_nscd ${localstatedir}/db/nscd"
35FILES_${PN}-mtrace = "${bindir}/mtrace"
36FILES_tzcode = "${bindir}/tzselect ${sbindir}/zic ${sbindir}/zdump"
37FILES_${PN}-utils = "${bindir}/* ${sbindir}/*"
38FILES_catchsegv = "${bindir}/catchsegv"
39RDEPENDS_catchsegv = "libsegfault"
40FILES_${PN}-pcprofile = "${base_libdir}/libpcprofile.so"
41FILES_glibc-thread-db = "${base_libdir}/libthread_db.so.* ${base_libdir}/libthread_db-*.so"
42RPROVIDES_${PN}-dev += "libc-dev"
43RPROVIDES_${PN}-staticdev += "libc-staticdev"
44
45SUMMARY_sln = "The static ln"
46DESCRIPTION_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."
47SUMMARY_nscd = "Name service cache daemon"
48DESCRIPTION_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."
49SUMMARY_glibc-extra-nss = "hesiod, NIS and NIS+ nss libraries"
50DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services."
51SUMMARY_ldd = "print shared library dependencies"
52DESCRIPTION_ldd = "${bindir}/ldd prints shared library dependencies for each program or shared library specified on the command line."
53SUMMARY_${PN}-utils = "Miscellaneous utilities provided by glibc"
54DESCRIPTION_${PN}-utils = "Miscellaneous utilities including getconf, iconv, locale, gencat, rpcgen, ..."
55DESCRIPTION_libsotruss = "Library to support sotruss which traces calls through PLTs"
56DESCRIPTION_tzcode = "tzcode, timezone zoneinfo utils -- zic, zdump, tzselect"
57
58inherit libc-common multilib_header
59
60do_install_append () {
61	rm -f ${D}${sysconfdir}/localtime
62	rm -rf ${D}${localstatedir}
63
64	# remove empty glibc dir
65	if [ -d ${D}${libexecdir} ]; then
66		rmdir --ignore-fail-on-non-empty ${D}${libexecdir}
67	fi
68
69	oe_multilib_header bits/syscall.h bits/long-double.h bits/floatn.h
70
71	if [ -f ${D}${bindir}/mtrace ]; then
72		sed -i -e '1s,#!.*perl,#! ${USRBINPATH}/env perl,' -e '2s,exec.*perl,exec ${USRBINPATH}/env perl,' ${D}${bindir}/mtrace
73	fi
74	rm -rf ${D}${includedir}/rpcsvc/rquota*
75	# Info dir listing isn't interesting at this point so remove it if it exists.
76	if [ -e "${D}${infodir}/dir" ]; then
77		rm -f ${D}${infodir}/dir
78	fi
79
80	if ! ${@bb.utils.contains('DISTRO_FEATURES', 'ldconfig', 'true', 'false', d)}; then
81		# The distro doesn't want these files so let's not install them
82		rm -f ${D}${sysconfdir}/ld.so.conf
83		rm -f ${D}${base_sbindir}/ldconfig
84		# This directory will be empty now so remove it too.
85		# But check whether it exists first, since it won't for glibc-initial.
86		if [ -d ${D}${sysconfdir} ]; then
87			rmdir ${D}${sysconfdir}
88		fi
89	fi
90
91	if echo ${PN}|grep -q "glibc-initial"; then
92		return
93	fi
94
95	install -d ${D}${sysconfdir}/init.d
96	install -d ${D}${localstatedir}/db/nscd
97	install -m 0755 ${S}/nscd/nscd.init ${D}${sysconfdir}/init.d/nscd
98	install -m 0755 ${S}/nscd/nscd.conf ${D}${sysconfdir}/nscd.conf
99	sed -i "s%daemon%start-stop-daemon --start --exec%g" ${D}${sysconfdir}/init.d/nscd
100	sed -i "s|\(enable-cache\t\+netgroup\t\+\)yes|\1no|" ${D}${sysconfdir}/nscd.conf
101
102	install -d ${D}${systemd_unitdir}/system
103	install -m 0644 ${S}/nscd/nscd.service ${D}${systemd_unitdir}/system/
104
105	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
106		install -d ${D}${sysconfdir}/tmpfiles.d
107		echo "d /run/nscd 755 root root -" \
108			> ${D}${sysconfdir}/tmpfiles.d/nscd.conf
109	else
110		install -d ${D}${sysconfdir}/default/volatiles
111		echo "d root root 0755 /var/run/nscd none" \
112			> ${D}${sysconfdir}/default/volatiles/98_nscd
113	fi
114}
115
116do_install_append_aarch64 () {
117	if [ "${base_libdir}" != "${nonarch_base_libdir}" ]; then
118		# The aarch64 ABI says the dynamic linker -must- be /lib/ld-linux-aarch64[_be].so.1
119		install -d ${D}${nonarch_base_libdir}
120		if [ -e ${D}${base_libdir}/ld-linux-aarch64.so.1 ]; then
121			ln -s ${@oe.path.relative('${nonarch_base_libdir}', '${base_libdir}')}/ld-linux-aarch64.so.1 \
122				${D}${nonarch_base_libdir}/ld-linux-aarch64.so.1
123		elif [ -e ${D}${base_libdir}/ld-linux-aarch64_be.so.1 ]; then
124			ln -s ${@oe.path.relative('${nonarch_base_libdir}', '${base_libdir}')}/ld-linux-aarch64_be.so.1 \
125				${D}${nonarch_base_libdir}/ld-linux-aarch64_be.so.1
126		fi
127	fi
128	do_install_armmultilib
129}
130
131do_install_append_arm () {
132	do_install_armmultilib
133}
134
135do_install_append_armeb () {
136	do_install_armmultilib
137}
138
139do_install_armmultilib () {
140	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
141	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
142	oe_multilib_header bits/shm.h bits/sigstack.h bits/stat.h bits/statfs.h bits/typesizes.h
143
144	oe_multilib_header fpu_control.h gnu/lib-names.h gnu/stubs.h ieee754.h
145
146	oe_multilib_header sys/elf.h sys/procfs.h sys/ptrace.h sys/ucontext.h sys/user.h
147}
148
149
150LOCALESTASH = "${WORKDIR}/stashed-locale"
151bashscripts = "mtrace sotruss xtrace"
152
153do_stash_locale () {
154	dest=${LOCALESTASH}
155	install -d ${dest}${base_libdir} ${dest}${bindir} ${dest}${libdir} ${dest}${datadir}
156	if [ "${base_libdir}" != "${libdir}" ]; then
157		cp -fpPR ${D}${base_libdir}/* ${dest}${base_libdir}
158	fi
159	if [ -e ${D}${bindir}/localedef ]; then
160		mv -f ${D}${bindir}/localedef ${dest}${bindir}
161	fi
162	if [ -e ${D}${libdir}/gconv ]; then
163		mv -f ${D}${libdir}/gconv ${dest}${libdir}
164	fi
165	if [ -e ${D}${exec_prefix}/lib ]; then
166		cp -fpPR ${D}${exec_prefix}/lib ${dest}${exec_prefix}
167	fi
168	if [ -e ${D}${datadir}/i18n ]; then
169		mv ${D}${datadir}/i18n ${dest}${datadir}
170	fi
171	cp -fpPR ${D}${datadir}/* ${dest}${datadir}
172	rm -rf ${D}${datadir}/locale/
173	cp -fpPR ${WORKDIR}/SUPPORTED ${dest}
174
175	target=${dest}/scripts
176	mkdir -p $target
177	for i in ${bashscripts}; do
178		if [ -f ${D}${bindir}/$i ]; then
179			cp ${D}${bindir}/$i $target/
180		fi
181	done
182}
183
184addtask do_stash_locale after do_install before do_populate_sysroot do_package
185do_stash_locale[dirs] = "${B}"
186do_stash_locale[cleandirs] = "${LOCALESTASH}"
187SSTATETASKS += "do_stash_locale"
188do_stash_locale[sstate-inputdirs] = "${LOCALESTASH}"
189do_stash_locale[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
190do_stash_locale[sstate-fixmedir] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
191
192python do_stash_locale_setscene () {
193    sstate_setscene(d)
194}
195addtask do_stash_locale_setscene
196
197do_poststash_install_cleanup () {
198	# Remove all files which do_stash_locale would remove (mv)
199	# since that task could have come from sstate and not get run.
200	for i in ${bashscripts}; do
201	    rm -f ${D}${bindir}/$i
202	done
203	rm -f ${D}${bindir}/localedef
204	rm -rf ${D}${datadir}/i18n
205	rm -rf ${D}${libdir}/gconv
206	rm -rf ${D}/${localedir}
207	rm -rf ${D}${datadir}/locale
208	if [ "${libdir}" != "${exec_prefix}/lib" ]; then
209		if [ -d ${D}${exec_prefix}/lib/locale ] ; then
210			rm -rf ${D}${exec_prefix}/lib/locale
211			# error out if directory isn't empty
212			rm -f ${D}${exec_prefix}/lib
213		fi
214	fi
215}
216addtask do_poststash_install_cleanup after do_stash_locale do_install before do_populate_sysroot do_package
217
218pkg_postinst_nscd () {
219	if [ -z "$D" ]; then
220		if command -v systemd-tmpfiles >/dev/null; then
221			systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/nscd.conf
222		elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
223			${sysconfdir}/init.d/populate-volatile.sh update
224		fi
225	fi
226}
227CONFFILES_nscd="${sysconfdir}/nscd.conf"
228
229SYSTEMD_PACKAGES = "nscd"
230SYSTEMD_SERVICE_nscd = "nscd.service"
231