summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/eglibc/eglibc-package.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-08-27 15:14:24 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-27 15:29:45 +0100
commit29d6678fd546377459ef75cf54abeef5b969b5cf (patch)
tree8edd65790e37a00d01c3f203f773fe4b5012db18 /meta/recipes-core/eglibc/eglibc-package.bbclass
parentda49de6885ee1bc424e70bc02f21f6ab920efb55 (diff)
downloadpoky-29d6678fd546377459ef75cf54abeef5b969b5cf.tar.gz
Major layout change to the packages directory
Having one monolithic packages directory makes it hard to find things and is generally overwhelming. This commit splits it into several logical sections roughly based on function, recipes.txt gives more information about the classifications used. The opportunity is also used to switch from "packages" to "recipes" as used in OpenEmbedded as the term "packages" can be confusing to people and has many different meanings. Not all recipes have been classified yet, this is just a first pass at separating things out. Some packages are moved to meta-extras as they're no longer actively used or maintained. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/recipes-core/eglibc/eglibc-package.bbclass')
-rw-r--r--meta/recipes-core/eglibc/eglibc-package.bbclass381
1 files changed, 381 insertions, 0 deletions
diff --git a/meta/recipes-core/eglibc/eglibc-package.bbclass b/meta/recipes-core/eglibc/eglibc-package.bbclass
new file mode 100644
index 0000000000..4e286afa80
--- /dev/null
+++ b/meta/recipes-core/eglibc/eglibc-package.bbclass
@@ -0,0 +1,381 @@
1#
2# For now, we will skip building of a gcc package if it is a uclibc one
3# and our build is not a uclibc one, and we skip a eglibc one if our build
4# is a uclibc build.
5#
6# See the note in gcc/gcc_3.4.0.oe
7#
8
9inherit qemu
10
11python __anonymous () {
12 import bb, re
13 uc_os = (re.match('.*uclibc*', bb.data.getVar('TARGET_OS', d, 1)) != None)
14 if uc_os:
15 raise bb.parse.SkipPackage("incompatible with target %s" %
16 bb.data.getVar('TARGET_OS', d, 1))
17}
18
19
20# Binary locales are generated at build time if ENABLE_BINARY_LOCALE_GENERATION
21# is set. The idea is to avoid running localedef on the target (at first boot)
22# to decrease initial boot time and avoid localedef being killed by the OOM
23# killer which used to effectively break i18n on machines with < 128MB RAM.
24
25# default to disabled until qemu works for everyone
26ENABLE_BINARY_LOCALE_GENERATION ?= "0"
27
28# BINARY_LOCALE_ARCHES is a space separated list of regular expressions
29BINARY_LOCALE_ARCHES ?= "arm.* i[3-6]86 x86_64 powerpc"
30
31# Set this to zero if you don't want ldconfig in the output package
32USE_LDCONFIG ?= "1"
33
34PACKAGES = "eglibc-dbg eglibc catchsegv sln nscd ldd localedef eglibc-utils eglibc-pic eglibc-dev eglibc-doc eglibc-locale libcidn libmemusage libsegfault eglibc-extra-nss eglibc-thread-db eglibc-pcprofile"
35PACKAGES_DYNAMIC = "glibc-gconv-* glibc-charmap-* glibc-localedata-* glibc-binary-localedata-* eglibc-gconv-* eglibc-charmap-* eglibc-localedata-* eglibc-binary-localedata-* locale-base-*"
36
37RPROVIDES_eglibc = "glibc"
38RPROVIDES_eglibc-utils = "glibc-utils"
39RPROVIDES_eglibc-pic = "glibc-pic"
40RPROVIDES_eglibc-dev = "glibc-dev"
41RPROVIDES_eglibc-doc = "glibc-doc"
42RPROVIDES_eglibc-locale = "glibc-locale"
43RPROVIDES_eglibc-extra-nss = "glibc-extra-nss"
44RPROVIDES_eglibc-thread-db = "glibc-thread-db"
45RPROVIDES_eglibc-pcprofile = "glibc-pcprofile"
46RPROVIDES_eglibc-dbg = "glibc-dbg"
47libc_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}/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"
48
49FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${@base_conditional('USE_LDCONFIG', '1', '${base_sbindir}/ldconfig', '', d)}"
50FILES_ldd = "${bindir}/ldd"
51FILES_libsegfault = "${base_libdir}/libSegFault*"
52FILES_libcidn = "${base_libdir}/libcidn*.so"
53FILES_libmemusage = "${base_libdir}/libmemusage.so"
54FILES_eglibc-extra-nss = "${base_libdir}/libnss*"
55FILES_sln = "/sbin/sln"
56FILES_eglibc-pic = "${libdir}/*_pic.a ${libdir}/*_pic.map ${libdir}/libc_pic/"
57FILES_eglibc-dev_append += "${bindir}/rpcgen ${libdir}/*.a \
58 ${base_libdir}/*.a ${base_libdir}/*.o ${datadir}/aclocal"
59FILES_nscd = "${sbindir}/nscd*"
60FILES_eglibc-utils = "${bindir}/* ${sbindir}/*"
61FILES_eglibc-gconv = "${libdir}/gconv/*"
62FILES_${PN}-dbg += "${libexecdir}/*/.debug ${libdir}/gconv/.debug"
63FILES_catchsegv = "${bindir}/catchsegv"
64RDEPENDS_catchsegv = "libsegfault"
65FILES_eglibc-pcprofile = "${base_libdir}/libpcprofile.so"
66FILES_eglibc-thread-db = "${base_libdir}/libthread_db*"
67FILES_localedef = "${bindir}/localedef"
68RPROVIDES_eglibc-dev += "libc-dev"
69
70DESCRIPTION_sln = "eglibc: create symbolic links between files"
71DESCRIPTION_nscd = "eglibc: name service cache daemon for passwd, group, and hosts"
72DESCRIPTION_eglibc-extra-nss = "eglibc: nis, nisplus and hesiod search services"
73DESCRIPTION_ldd = "eglibc: print shared library dependencies"
74DESCRIPTION_localedef = "eglibc: compile locale definition files"
75DESCRIPTION_eglibc-utils = "eglibc: misc utilities like iconf, local, gencat, tzselect, rpcinfo, ..."
76
77def get_eglibc_fpu_setting(bb, d):
78 if bb.data.getVar('TARGET_FPU', d, 1) in [ 'soft' ]:
79 return "--without-fp"
80 return ""
81
82EXTRA_OECONF += "${@get_eglibc_fpu_setting(bb, d)}"
83
84OVERRIDES_append = ":${TARGET_ARCH}-${TARGET_OS}"
85
86do_configure_prepend() {
87 sed -e "s#@BASH@#/bin/sh#" -i ${S}/elf/ldd.bash.in
88}
89
90do_install() {
91 oe_runmake install_root=${D} install
92 for r in ${rpcsvc}; do
93 h=`echo $r|sed -e's,\.x$,.h,'`
94 install -m 0644 ${S}/sunrpc/rpcsvc/$h ${D}/${includedir}/rpcsvc/
95 done
96 install -m 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/
97 install -d ${D}${libdir}/locale
98 make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED"
99 # get rid of some broken files...
100 for i in ${GLIBC_BROKEN_LOCALES}; do
101 grep -v $i ${WORKDIR}/SUPPORTED > ${WORKDIR}/SUPPORTED.tmp
102 mv ${WORKDIR}/SUPPORTED.tmp ${WORKDIR}/SUPPORTED
103 done
104 rm -f ${D}/etc/rpc
105 rm -rf ${D}${datadir}/zoneinfo
106 rm -rf ${D}${libexecdir}/getconf
107}
108
109TMP_LOCALE="/tmp/locale${libdir}/locale"
110
111locale_base_postinst() {
112#!/bin/sh
113
114if [ "x$D" != "x" ]; then
115 exit 1
116fi
117
118rm -rf ${TMP_LOCALE}
119mkdir -p ${TMP_LOCALE}
120if [ -f ${libdir}/locale/locale-archive ]; then
121 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
122fi
123localedef --inputfile=${datadir}/i18n/locales/%s --charmap=%s --prefix=/tmp/locale %s
124mkdir -p ${libdir}/locale/
125mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
126rm -rf ${TMP_LOCALE}
127}
128
129locale_base_postrm() {
130#!/bin/sh
131
132rm -rf ${TMP_LOCALE}
133mkdir -p ${TMP_LOCALE}
134if [ -f ${libdir}/locale/locale-archive ]; then
135 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
136fi
137localedef --delete-from-archive --inputfile=${datadir}/locales/%s --charmap=%s --prefix=/tmp/locale %s
138mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
139rm -rf ${TMP_LOCALE}
140}
141
142python __anonymous () {
143 enabled = bb.data.getVar("ENABLE_BINARY_LOCALE_GENERATION", d, 1)
144
145 if enabled and int(enabled):
146 import re
147
148 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
149 binary_arches = bb.data.getVar("BINARY_LOCALE_ARCHES", d, 1) or ""
150
151 for regexp in binary_arches.split(" "):
152 r = re.compile(regexp)
153
154 if r.match(target_arch):
155 depends = bb.data.getVar("DEPENDS", d, 1)
156 depends = "%s qemu-native" % depends
157 bb.data.setVar("DEPENDS", depends, d)
158 bb.data.setVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", "1", d)
159 break
160}
161
162do_prep_locale_tree() {
163 treedir=${WORKDIR}/locale-tree
164 rm -rf $treedir
165 mkdir -p $treedir/bin $treedir/lib $treedir/${datadir} $treedir/${libdir}/locale
166 cp -pPR ${PKGD}${datadir}/i18n $treedir/${datadir}/i18n
167 # unzip to avoid parsing errors
168 for i in $treedir/${datadir}/i18n/charmaps/*gz; do
169 gunzip $i
170 done
171 ls -d ${PKGD}${base_libdir}/* | xargs -iBLAH cp -pPR BLAH $treedir/lib
172 if [ -f ${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/lib/libgcc_s.* ]; then
173 cp -pPR ${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/lib/libgcc_s.* $treedir/lib
174 fi
175 install -m 0755 ${PKGD}${bindir}/localedef $treedir/bin
176}
177
178do_collect_bins_from_locale_tree() {
179 treedir=${WORKDIR}/locale-tree
180
181 mkdir -p ${PKGD}${libdir}
182 cp -pPR $treedir/${libdir}/locale ${PKGD}${libdir}
183}
184
185python package_do_split_gconvs () {
186 import os, re
187 if (bb.data.getVar('PACKAGE_NO_GCONV', d, 1) == '1'):
188 bb.note("package requested not splitting gconvs")
189 return
190
191 if not bb.data.getVar('PACKAGES', d, 1):
192 return
193
194 libdir = bb.data.getVar('libdir', d, 1)
195 if not libdir:
196 bb.error("libdir not defined")
197 return
198 datadir = bb.data.getVar('datadir', d, 1)
199 if not datadir:
200 bb.error("datadir not defined")
201 return
202
203 gconv_libdir = base_path_join(libdir, "gconv")
204 charmap_dir = base_path_join(datadir, "i18n", "charmaps")
205 locales_dir = base_path_join(datadir, "i18n", "locales")
206 binary_locales_dir = base_path_join(libdir, "locale")
207
208 def calc_gconv_deps(fn, pkg, file_regex, output_pattern, group):
209 deps = []
210 f = open(fn, "r")
211 c_re = re.compile('^copy "(.*)"')
212 i_re = re.compile('^include "(\w+)".*')
213 for l in f.readlines():
214 m = c_re.match(l) or i_re.match(l)
215 if m:
216 dp = legitimize_package_name('eglibc-gconv-%s' % m.group(1))
217 if not dp in deps:
218 deps.append(dp)
219 f.close()
220 if deps != []:
221 bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
222 bb.data.setVar('RPROVIDES_%s' % pkg, pkg.replace('eglibc', 'glibc'), d)
223
224 do_split_packages(d, gconv_libdir, file_regex='^(.*)\.so$', output_pattern='eglibc-gconv-%s', description='gconv module for character set %s', hook=calc_gconv_deps, extra_depends='eglibc-gconv')
225
226 def calc_charmap_deps(fn, pkg, file_regex, output_pattern, group):
227 deps = []
228 f = open(fn, "r")
229 c_re = re.compile('^copy "(.*)"')
230 i_re = re.compile('^include "(\w+)".*')
231 for l in f.readlines():
232 m = c_re.match(l) or i_re.match(l)
233 if m:
234 dp = legitimize_package_name('eglibc-charmap-%s' % m.group(1))
235 if not dp in deps:
236 deps.append(dp)
237 f.close()
238 if deps != []:
239 bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
240 bb.data.setVar('RPROVIDES_%s' % pkg, pkg.replace('eglibc', 'glibc'), d)
241
242 do_split_packages(d, charmap_dir, file_regex='^(.*)\.gz$', output_pattern='eglibc-charmap-%s', description='character map for %s encoding', hook=calc_charmap_deps, extra_depends='')
243
244 def calc_locale_deps(fn, pkg, file_regex, output_pattern, group):
245 deps = []
246 f = open(fn, "r")
247 c_re = re.compile('^copy "(.*)"')
248 i_re = re.compile('^include "(\w+)".*')
249 for l in f.readlines():
250 m = c_re.match(l) or i_re.match(l)
251 if m:
252 dp = legitimize_package_name('eglibc-localedata-%s' % m.group(1))
253 if not dp in deps:
254 deps.append(dp)
255 f.close()
256 if deps != []:
257 bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
258 bb.data.setVar('RPROVIDES_%s' % pkg, pkg.replace('eglibc', 'glibc'), d)
259
260 do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='eglibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='')
261 bb.data.setVar('PACKAGES', bb.data.getVar('PACKAGES', d) + ' eglibc-gconv', d)
262
263 supported = bb.data.getVar('GLIBC_GENERATE_LOCALES', d, 1)
264 if not supported or supported == "all":
265 f = open(base_path_join(bb.data.getVar('WORKDIR', d, 1), "SUPPORTED"), "r")
266 supported = f.readlines()
267 f.close()
268 else:
269 supported = supported.split()
270 supported = map(lambda s:s.replace(".", " ") + "\n", supported)
271
272 dot_re = re.compile("(.*)\.(.*)")
273
274 # Collate the locales by base and encoding
275 encodings = {}
276 for l in supported:
277 l = l[:-1]
278 (locale, charset) = l.split(" ")
279 m = dot_re.match(locale)
280 if m:
281 locale = m.group(1)
282 if not encodings.has_key(locale):
283 encodings[locale] = []
284 encodings[locale].append(charset)
285
286 def output_locale_source(name, locale, encoding):
287 pkgname = 'locale-base-' + legitimize_package_name(name)
288
289 bb.data.setVar('RDEPENDS_%s' % pkgname, 'localedef eglibc-localedata-%s eglibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d)
290 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
291 m = re.match("(.*)_(.*)", name)
292 if m:
293 rprovides += ' virtual-locale-%s' % m.group(1)
294 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
295 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
296 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
297 bb.data.setVar('pkg_postinst_%s' % pkgname, bb.data.getVar('locale_base_postinst', d, 1) % (locale, encoding, locale), d)
298 bb.data.setVar('pkg_postrm_%s' % pkgname, bb.data.getVar('locale_base_postrm', d, 1) % (locale, encoding, locale), d)
299
300 def output_locale_binary(name, locale, encoding):
301 qemu = qemu_target_binary(d) + " -s 1048576"
302 kernel_ver = bb.data.getVar("OLDEST_KERNEL", d, 1)
303 if kernel_ver:
304 qemu += " -r %s" % (kernel_ver)
305 pkgname = 'locale-base-' + legitimize_package_name(name)
306 m = re.match("(.*)\.(.*)", name)
307 if m:
308 eglibc_name = "%s.%s" % (m.group(1), m.group(2).lower().replace("-",""))
309 else:
310 eglibc_name = name
311 bb.data.setVar('RDEPENDS_%s' % pkgname, legitimize_package_name('eglibc-binary-localedata-%s' % eglibc_name), d)
312 bb.data.setVar('RPROVIDES_%s' % pkgname, 'glibc-binary-localedata-%s' % eglibc_name, d)
313 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
314 m = re.match("(.*)_(.*)", name)
315 if m:
316 rprovides += ' virtual-locale-%s' % m.group(1)
317 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
318 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
319 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
320
321 treedir = base_path_join(bb.data.getVar("WORKDIR", d, 1), "locale-tree")
322 ldlibdir = "%s/lib" % treedir
323 path = bb.data.getVar("PATH", d, 1)
324 i18npath = base_path_join(treedir, datadir, "i18n")
325
326 localedef_opts = "--force --old-style --no-archive --prefix=%s --inputfile=%s/i18n/locales/%s --charmap=%s %s" % (treedir, datadir, locale, encoding, name)
327 cmd = "PATH=\"%s\" I18NPATH=\"%s\" %s -L %s -E LD_LIBRARY_PATH=%s %s/bin/localedef %s" % (path, i18npath, qemu, treedir, ldlibdir, treedir, localedef_opts)
328 bb.note("generating locale %s (%s)" % (locale, encoding))
329 if os.system(cmd):
330 raise bb.build.FuncFailed("localedef returned an error (command was %s)." % cmd)
331
332 def output_locale(name, locale, encoding):
333 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
334 if use_bin:
335 output_locale_binary(name, locale, encoding)
336 else:
337 output_locale_source(name, locale, encoding)
338
339 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
340 if use_bin:
341 bb.note("preparing tree for binary locale generation")
342 bb.build.exec_func("do_prep_locale_tree", d)
343
344 # Reshuffle names so that UTF-8 is preferred over other encodings
345 non_utf8 = []
346 for l in encodings.keys():
347 if len(encodings[l]) == 1:
348 output_locale(l, l, encodings[l][0])
349 if encodings[l][0] != "UTF-8":
350 non_utf8.append(l)
351 else:
352 if "UTF-8" in encodings[l]:
353 output_locale(l, l, "UTF-8")
354 encodings[l].remove("UTF-8")
355 else:
356 non_utf8.append(l)
357 for e in encodings[l]:
358 output_locale('%s.%s' % (l, e), l, e)
359
360 if non_utf8 != []:
361 bb.note("the following locales are supported only in legacy encodings:")
362 bb.note(" " + " ".join(non_utf8))
363
364 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
365 if use_bin:
366 bb.note("collecting binary locales from locale tree")
367 bb.build.exec_func("do_collect_bins_from_locale_tree", d)
368 do_split_packages(d, binary_locales_dir, file_regex='(.*)', output_pattern='eglibc-binary-localedata-%s', description='binary locale definition for %s', extra_depends='', allow_dirs=True)
369 else:
370 bb.note("generation of binary locales disabled. this may break i18n!")
371
372}
373
374# We want to do this indirection so that we can safely 'return'
375# from the called function even though we're prepending
376python populate_packages_prepend () {
377 if bb.data.getVar('DEBIAN_NAMES', d, 1):
378 bb.data.setVar('PKG_eglibc', 'libc6', d)
379 bb.data.setVar('PKG_eglibc-dev', 'libc6-dev', d)
380 bb.build.exec_func('package_do_split_gconvs', d)
381}