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"
39RDEPENDS_${PN}-dev = "linux-libc-headers-dev"
40FILES_${PN}-staticdev += "${libdir}/*.a ${base_libdir}/*.a"
41FILES_nscd = "${sbindir}/nscd* ${sysconfdir}/init.d/nscd ${systemd_unitdir}/system/nscd* ${sysconfdir}/tmpfiles.d/nscd.conf \
42              ${sysconfdir}/nscd.conf ${sysconfdir}/default/volatiles/98_nscd ${localstatedir}/db/nscd"
43FILES_${PN}-mtrace = "${bindir}/mtrace"
44FILES_tzcode = "${bindir}/tzselect ${sbindir}/zic ${sbindir}/zdump"
45FILES_${PN}-utils = "${bindir}/* ${sbindir}/*"
46FILES_catchsegv = "${bindir}/catchsegv"
47RDEPENDS_catchsegv = "libsegfault"
48FILES_${PN}-pcprofile = "${base_libdir}/libpcprofile.so"
49FILES_glibc-thread-db = "${base_libdir}/libthread_db.so.* ${base_libdir}/libthread_db-*.so"
50RPROVIDES_${PN}-dev += "libc-dev"
51RPROVIDES_${PN}-staticdev += "libc-staticdev"
52
53SUMMARY_sln = "The static ln"
54DESCRIPTION_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."
55SUMMARY_nscd = "Name service cache daemon"
56DESCRIPTION_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."
57SUMMARY_glibc-extra-nss = "hesiod, NIS and NIS+ nss libraries"
58DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services."
59SUMMARY_ldd = "print shared library dependencies"
60DESCRIPTION_ldd = "${bindir}/ldd prints shared library dependencies for each program or shared library specified on the command line."
61SUMMARY_${PN}-utils = "Miscellaneous utilities provided by glibc"
62DESCRIPTION_${PN}-utils = "Miscellaneous utilities including getconf, iconv, locale, gencat, ..."
63DESCRIPTION_libsotruss = "Library to support sotruss which traces calls through PLTs"
64DESCRIPTION_tzcode = "tzcode, timezone zoneinfo utils -- zic, zdump, tzselect"
65
66inherit libc-common multilib_header
67
68do_install_append () {
69	rm -f ${D}${sysconfdir}/localtime
70
71	# remove empty glibc dir
72	if [ -d ${D}${libexecdir} ]; then
73		rmdir --ignore-fail-on-non-empty ${D}${libexecdir}
74	fi
75
76	oe_multilib_header bits/syscall.h bits/long-double.h bits/floatn.h
77
78	if [ -f ${D}${bindir}/mtrace ]; then
79		sed -i -e '1s,#!.*perl,#! ${USRBINPATH}/env perl,' -e '2s,exec.*perl,exec ${USRBINPATH}/env perl,' ${D}${bindir}/mtrace
80	fi
81	# Info dir listing isn't interesting at this point so remove it if it exists.
82	if [ -e "${D}${infodir}/dir" ]; then
83		rm -f ${D}${infodir}/dir
84	fi
85
86	if ! ${@bb.utils.contains('DISTRO_FEATURES', 'ldconfig', 'true', 'false', d)}; then
87		# The distro doesn't want these files so let's not install them
88		rm -f ${D}${sysconfdir}/ld.so.conf
89		rm -f ${D}${base_sbindir}/ldconfig
90		# This directory will be empty now so remove it too.
91		rmdir ${D}${sysconfdir}
92	fi
93
94	install -d ${D}${sysconfdir}/init.d
95	install -d ${D}${localstatedir}/db/nscd
96	install -m 0755 ${S}/nscd/nscd.init ${D}${sysconfdir}/init.d/nscd
97	install -m 0755 ${S}/nscd/nscd.conf ${D}${sysconfdir}/nscd.conf
98	install -m 0755 ${WORKDIR}/makedbs.sh ${D}${localstatedir}/db
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	fi
110
111	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
112		install -d ${D}${sysconfdir}/default/volatiles
113		echo "d root root 0755 /var/run/nscd none" \
114			> ${D}${sysconfdir}/default/volatiles/98_nscd
115	fi
116
117	# The dynamic loader will have been installed into
118	# ${base_libdir}. However, if that isn't going to end up being
119	# available in the ABI-mandated location, then a symlink must
120        # be created.
121
122	if [ -n "${ARCH_DYNAMIC_LOADER}" -a ! -e "${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then
123		install -d ${D}${root_prefix}/lib
124		ln -s ${@oe.path.relative('${root_prefix}/lib', '${base_libdir}')}/${ARCH_DYNAMIC_LOADER} \
125				${D}${root_prefix}/lib/${ARCH_DYNAMIC_LOADER}
126	fi
127}
128
129do_install_append_aarch64 () {
130	do_install_armmultilib
131}
132
133do_install_append_arm () {
134	do_install_armmultilib
135}
136
137do_install_append_armeb () {
138	do_install_armmultilib
139}
140
141do_install_armmultilib () {
142	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
143	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
144	oe_multilib_header bits/shm.h bits/sigstack.h bits/stat.h bits/statfs.h bits/typesizes.h
145	oe_multilib_header bits/procfs-id.h bits/procfs.h bits/shmlba.h
146
147	oe_multilib_header fpu_control.h gnu/lib-names.h gnu/stubs.h ieee754.h
148
149	oe_multilib_header sys/elf.h sys/procfs.h sys/ptrace.h sys/ucontext.h sys/user.h
150}
151
152
153LOCALESTASH = "${WORKDIR}/stashed-locale"
154bashscripts = "mtrace sotruss xtrace"
155
156do_stash_locale () {
157	dest=${LOCALESTASH}
158	install -d $dest${base_libdir} $dest${bindir} $dest${libdir} $dest${datadir}
159	# Hide away the locale data from the deployment
160	if [ -e ${D}${bindir}/localedef ]; then
161		cp -a ${D}${bindir}/localedef $dest${bindir}
162	fi
163	if [ -e ${D}${libdir}/gconv ]; then
164		cp -a ${D}${libdir}/gconv $dest${libdir}
165	fi
166	if [ -e ${D}${datadir}/i18n ]; then
167		cp -a  ${D}${datadir}/i18n $dest${datadir}
168	fi
169
170	# Make a copy of all the libraries into the locale stash
171	cp -fpPR ${D}${libdir}/* $dest${libdir}
172	if [ "${base_libdir}" != "${libdir}" ]; then
173		cp -fpPR ${D}${base_libdir}/* $dest${base_libdir}
174	fi
175	if [ -e ${D}${exec_prefix}/lib ]; then
176		if [ ${exec_prefix}/lib != ${base_libdir} ] && [ ${exec_prefix}/lib != ${libdir} ]; then
177			cp -fpPR ${D}${exec_prefix}/lib $dest${exec_prefix}
178		fi
179	fi
180
181	cp -fpPR ${D}${datadir}/* $dest${datadir}
182	rm -rf ${D}${datadir}/locale/
183	cp -fpPR ${WORKDIR}/SUPPORTED $dest
184
185	target=$dest/scripts
186	mkdir -p $target
187	for i in ${bashscripts}; do
188		if [ -f ${D}${bindir}/$i ]; then
189			cp ${D}${bindir}/$i $target/
190		fi
191	done
192}
193
194addtask do_stash_locale after do_install before do_populate_sysroot do_package
195do_stash_locale[dirs] = "${B}"
196do_stash_locale[cleandirs] = "${LOCALESTASH}"
197SSTATETASKS += "do_stash_locale"
198do_stash_locale[sstate-inputdirs] = "${LOCALESTASH}"
199do_stash_locale[sstate-outputdirs] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
200do_stash_locale[sstate-fixmedir] = "${COMPONENTS_DIR}/${PACKAGE_ARCH}/glibc-stash-locale"
201
202python do_stash_locale_setscene () {
203    sstate_setscene(d)
204}
205addtask do_stash_locale_setscene
206
207PACKAGE_PREPROCESS_FUNCS += "stash_locale_package_cleanup"
208SYSROOT_PREPROCESS_FUNCS += "stash_locale_sysroot_cleanup"
209stash_locale_cleanup () {
210	cleanupdir=$1
211	# Remove all files which do_stash_locale() copies
212	for i in ${bashscripts}; do
213		rm -f $cleanupdir${bindir}/$i
214	done
215	rm -f $cleanupdir${bindir}/localedef
216	rm -rf $cleanupdir${datadir}/i18n
217	rm -rf $cleanupdir${libdir}/gconv
218	rm -rf $cleanupdir${localedir}
219	rm -rf $cleanupdir${datadir}/locale
220	if [ "${libdir}" != "${exec_prefix}/lib" ] && [ "${root_prefix}/lib" != "${exec_prefix}/lib" ]; then
221		if [ -d "$cleanupdir${exec_prefix}/lib" ]; then
222			if [ -z "${ARCH_DYNAMIC_LOADER}" -o \
223			     ! -e "$cleanupdir${exec_prefix}/lib/${ARCH_DYNAMIC_LOADER}" ]; then
224				# error out if directory isn't empty
225				# this dir should only contain locale dir
226				# which has been deleted in the previous step
227				rmdir $cleanupdir${exec_prefix}/lib
228			fi
229		fi
230	fi
231}
232
233stash_locale_sysroot_cleanup() {
234	stash_locale_cleanup ${SYSROOT_DESTDIR}
235}
236stash_locale_package_cleanup() {
237	stash_locale_cleanup ${PKGD}
238}
239
240pkg_postinst_nscd () {
241	if [ -z "$D" ]; then
242		if command -v systemd-tmpfiles >/dev/null; then
243			systemd-tmpfiles --create ${sysconfdir}/tmpfiles.d/nscd.conf
244		elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
245			${sysconfdir}/init.d/populate-volatile.sh update
246		fi
247	fi
248}
249CONFFILES_nscd="${sysconfdir}/nscd.conf"
250
251SYSTEMD_PACKAGES = "nscd"
252SYSTEMD_SERVICE_nscd = "nscd.service"
253