summaryrefslogtreecommitdiffstats
path: root/meta/packages/glibc/glibc-package.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
committerRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
commitb2f192faabe412adce79534e22efe9fb69ee40e2 (patch)
tree7076c49d4286f8a1733650bd8fbc7161af200d57 /meta/packages/glibc/glibc-package.bbclass
parent2cf0eadf9f730027833af802d7e6c90b44248f80 (diff)
downloadpoky-b2f192faabe412adce79534e22efe9fb69ee40e2.tar.gz
Rename /openembedded/ -> /meta/
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@530 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/glibc/glibc-package.bbclass')
-rw-r--r--meta/packages/glibc/glibc-package.bbclass300
1 files changed, 300 insertions, 0 deletions
diff --git a/meta/packages/glibc/glibc-package.bbclass b/meta/packages/glibc/glibc-package.bbclass
new file mode 100644
index 0000000000..d6decfb709
--- /dev/null
+++ b/meta/packages/glibc/glibc-package.bbclass
@@ -0,0 +1,300 @@
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 glibc one if our build
4# is a uclibc build.
5#
6# See the note in gcc/gcc_3.4.0.oe
7#
8
9python __anonymous () {
10 import bb, re
11 uc_os = (re.match('.*uclibc$', bb.data.getVar('TARGET_OS', d, 1)) != None)
12 if uc_os:
13 raise bb.parse.SkipPackage("incompatible with target %s" %
14 bb.data.getVar('TARGET_OS', d, 1))
15}
16
17# Binary locales are generated at build time if ENABLE_BINARY_LOCALE_GENERATION
18# is set. The idea is to avoid running localedef on the target (at first boot)
19# to decrease initial boot time and avoid localedef being killed by the OOM
20# killer which used to effectively break i18n on machines with < 128MB RAM.
21
22# default to disabled until qemu works for everyone
23ENABLE_BINARY_LOCALE_GENERATION ?= "0"
24
25# BINARY_LOCALE_ARCHES is a space separated list of regular expressions
26BINARY_LOCALE_ARCHES ?= "arm.*"
27
28PACKAGES = "glibc catchsegv sln nscd ldd localedef glibc-utils glibc-dev glibc-doc glibc-locale libsegfault glibc-extra-nss glibc-thread-db glibc-pcprofile"
29PACKAGES_DYNAMIC = "glibc-gconv-* glibc-charmap-* glibc-localedata-*"
30
31libc_baselibs = "/lib/libc* /lib/libm* /lib/ld* /lib/libpthread* /lib/libresolv* /lib/librt* /lib/libutil* /lib/libnsl* /lib/libnss_files* /lib/libnss_compat* /lib/libnss_dns* /lib/libdl* /lib/libanl* /lib/libBrokenLocale*"
32
33FILES_${PN} = "${sysconfdir} ${libc_baselibs} /sbin/ldconfig ${libexecdir} ${datadir}/zoneinfo"
34FILES_ldd = "${bindir}/ldd"
35FILES_libsegfault = "/lib/libSegFault*"
36FILES_glibc-extra-nss = "/lib/libnss*"
37FILES_sln = "/sbin/sln"
38FILES_glibc-dev_append = " ${libdir}/*.o ${bindir}/rpcgen"
39FILES_nscd = "${sbindir}/nscd*"
40FILES_glibc-utils = "${bindir} ${sbindir}"
41FILES_glibc-gconv = "${libdir}/gconv"
42FILES_catchsegv = "${bindir}/catchsegv"
43RDEPENDS_catchsegv = "libsegfault"
44FILES_glibc-pcprofile = "/lib/libpcprofile.so"
45FILES_glibc-thread-db = "/lib/libthread_db*"
46FILES_localedef = "${bindir}/localedef"
47RPROVIDES_glibc-dev += "libc-dev"
48
49DESCRIPTION_sln = "glibc: create symbolic links between files"
50DESCRIPTION_nscd = "glibc: name service cache daemon for passwd, group, and hosts"
51DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services"
52DESCRIPTION_ldd = "glibc: print shared library dependencies"
53DESCRIPTION_localedef = "glibc: compile locale definition files"
54DESCRIPTION_glibc-utils = "glibc: misc utilities like iconf, local, gencat, tzselect, rpcinfo, ..."
55
56def get_glibc_fpu_setting(bb, d):
57 if bb.data.getVar('TARGET_FPU', d, 1) in [ 'soft' ]:
58 return "--without-fp"
59 return ""
60
61EXTRA_OECONF += "${@get_glibc_fpu_setting(bb, d)}"
62
63OVERRIDES_append = ":${TARGET_ARCH}-${TARGET_OS}"
64EXTRA_OECONF_append_arm-linuxeabi = " --without-fp"
65
66do_install() {
67 oe_runmake install_root=${D} install
68 for r in ${rpcsvc}; do
69 h=`echo $r|sed -e's,\.x$,.h,'`
70 install -m 0644 ${S}/sunrpc/rpcsvc/$h ${D}/${includedir}/rpcsvc/
71 done
72 install -m 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/
73 install -d ${D}${libdir}/locale
74 make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED"
75 # get rid of some broken files...
76 for i in ${GLIBC_BROKEN_LOCALES}; do
77 grep -v $i ${WORKDIR}/SUPPORTED > ${WORKDIR}/SUPPORTED.tmp
78 mv ${WORKDIR}/SUPPORTED.tmp ${WORKDIR}/SUPPORTED
79 done
80 rm -f ${D}/etc/rpc
81}
82
83TMP_LOCALE="/tmp/locale/${libdir}/locale"
84
85locale_base_postinst() {
86#!/bin/sh
87
88if [ "x$D" != "x" ]; then
89 exit 1
90fi
91
92rm -rf ${TMP_LOCALE}
93mkdir -p ${TMP_LOCALE}
94if [ -f ${libdir}/locale/locale-archive ]; then
95 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
96fi
97localedef --inputfile=${datadir}/i18n/locales/%s --charmap=%s --prefix=/tmp/locale %s
98mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
99rm -rf ${TMP_LOCALE}
100}
101
102locale_base_postrm() {
103#!/bin/sh
104
105rm -rf ${TMP_LOCALE}
106mkdir -p ${TMP_LOCALE}
107if [ -f ${libdir}/locale/locale-archive ]; then
108 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
109fi
110localedef --delete-from-archive --inputfile=${datadir}/locales/%s --charmap=%s --prefix=/tmp/locale %s
111mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
112rm -rf ${TMP_LOCALE}
113}
114
115python __anonymous () {
116 enabled = bb.data.getVar("ENABLE_BINARY_LOCALE_GENERATION", d, 1)
117
118 if enabled and int(enabled):
119 import re
120
121 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
122 binary_arches = bb.data.getVar("BINARY_LOCALE_ARCHES", d, 1) or ""
123
124 for regexp in binary_arches.split(" "):
125 r = re.compile(regexp)
126
127 if r.match(target_arch):
128 depends = bb.data.getVar("DEPENDS", d, 1)
129 depends = "%s qemu-native" % depends
130 bb.data.setVar("DEPENDS", depends, d)
131 bb.data.setVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", "1", d)
132 break
133}
134
135do_prep_locale_tree() {
136 treedir=${WORKDIR}/locale-tree
137 rm -rf $treedir
138 mkdir -p $treedir/bin $treedir/lib $treedir/${datadir} $treedir/${libdir}/locale
139 cp -a ${D}${datadir}/i18n $treedir/${datadir}/i18n
140 # unzip to avoid parsing errors
141 for i in $treedir/${datadir}/i18n/charmaps/*gz; do
142 gunzip $i
143 done
144 cp -a ${STAGING_LIBDIR}/* $treedir/lib
145 if [ -f ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.* ]; then
146 cp -a ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.* $treedir/lib
147 fi
148 install -m 0755 ${D}${bindir}/localedef $treedir/bin
149}
150
151do_collect_bins_from_locale_tree() {
152 treedir=${WORKDIR}/locale-tree
153
154 mkdir -p ${D}${libdir}
155 cp -a $treedir/${libdir}/locale ${D}${libdir}
156}
157
158python package_do_split_gconvs () {
159 import os, re
160 if (bb.data.getVar('PACKAGE_NO_GCONV', d, 1) == '1'):
161 bb.note("package requested not splitting gconvs")
162 return
163
164 if not bb.data.getVar('PACKAGES', d, 1):
165 return
166
167 libdir = bb.data.getVar('libdir', d, 1)
168 if not libdir:
169 bb.error("libdir not defined")
170 return
171 datadir = bb.data.getVar('datadir', d, 1)
172 if not datadir:
173 bb.error("datadir not defined")
174 return
175
176 gconv_libdir = os.path.join(libdir, "gconv")
177 charmap_dir = os.path.join(datadir, "i18n", "charmaps")
178 locales_dir = os.path.join(datadir, "i18n", "locales")
179 binary_locales_dir = os.path.join(libdir, "locale")
180
181 do_split_packages(d, gconv_libdir, file_regex='^(.*)\.so$', output_pattern='glibc-gconv-%s', description='gconv module for character set %s', extra_depends='glibc-gconv')
182
183 do_split_packages(d, charmap_dir, file_regex='^(.*)\.gz$', output_pattern='glibc-charmap-%s', description='character map for %s encoding', extra_depends='')
184
185 def calc_locale_deps(fn, pkg, file_regex, output_pattern, group):
186 deps = []
187 f = open(fn, "r")
188 c_re = re.compile('^copy "(.*)"')
189 i_re = re.compile('^include "(\w+)".*')
190 for l in f.readlines():
191 m = c_re.match(l) or i_re.match(l)
192 if m:
193 dp = legitimize_package_name('glibc-localedata-%s' % m.group(1))
194 if not dp in deps:
195 deps.append(dp)
196 f.close()
197 if deps != []:
198 bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
199
200 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
201 if use_bin:
202 do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='glibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='', aux_files_pattern_verbatim=binary_locales_dir + '/%s')
203 else:
204 do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='glibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='')
205 bb.note("generation of binary locales disabled. this may break i18n!")
206 bb.data.setVar('PACKAGES', bb.data.getVar('PACKAGES', d) + ' glibc-gconv', d)
207
208 f = open(os.path.join(bb.data.getVar('WORKDIR', d, 1), "SUPPORTED"), "r")
209 supported = f.readlines()
210 f.close()
211
212 dot_re = re.compile("(.*)\.(.*)")
213
214 # Collate the locales by base and encoding
215 encodings = {}
216 for l in supported:
217 l = l[:-1]
218 (locale, charset) = l.split(" ")
219 m = dot_re.match(locale)
220 if m:
221 locale = m.group(1)
222 if not encodings.has_key(locale):
223 encodings[locale] = []
224 encodings[locale].append(charset)
225
226 def output_locale_source(name, locale, encoding):
227 pkgname = 'locale-base-' + legitimize_package_name(name)
228
229 bb.data.setVar('RDEPENDS_%s' % pkgname, 'localedef glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d)
230 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
231 m = re.match("(.*)_(.*)", name)
232 if m:
233 rprovides += ' virtual-locale-%s' % m.group(1)
234 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
235 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
236 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
237 bb.data.setVar('pkg_postinst_%s' % pkgname, bb.data.getVar('locale_base_postinst', d, 1) % (locale, encoding, locale), d)
238 bb.data.setVar('pkg_postrm_%s' % pkgname, bb.data.getVar('locale_base_postrm', d, 1) % (locale, encoding, locale), d)
239
240 def output_locale_binary(name, locale, encoding):
241 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
242 qemu = "qemu-%s" % target_arch
243 pkgname = 'locale-base-' + legitimize_package_name(name)
244
245 bb.data.setVar('RDEPENDS_%s' % pkgname, 'glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d)
246 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
247 m = re.match("(.*)_(.*)", name)
248 if m:
249 rprovides += ' virtual-locale-%s' % m.group(1)
250 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
251 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
252 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
253
254 treedir = os.path.join(bb.data.getVar("WORKDIR", d, 1), "locale-tree")
255 path = bb.data.getVar("PATH", d, 1)
256 i18npath = os.path.join(treedir, datadir, "i18n")
257
258 localedef_opts = "--force --old-style --no-archive --prefix=%s --inputfile=%s/i18n/locales/%s --charmap=%s %s" % (treedir, datadir, locale, encoding, locale)
259 cmd = "PATH=\"%s\" I18NPATH=\"%s\" %s -L %s %s/bin/localedef %s" % (path, i18npath, qemu, treedir, treedir, localedef_opts)
260 bb.note("generating locale %s (%s)" % (locale, encoding))
261 if os.system(cmd):
262 raise bb.build.FuncFailed("localedef returned an error.")
263
264 def output_locale(name, locale, encoding):
265 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
266 if use_bin:
267 output_locale_binary(name, locale, encoding)
268 else:
269 output_locale_source(name, locale, encoding)
270
271 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
272 if use_bin:
273 bb.note("preparing tree for binary locale generation")
274 bb.build.exec_func("do_prep_locale_tree", d)
275
276 # Reshuffle names so that UTF-8 is preferred over other encodings
277 for l in encodings.keys():
278 if len(encodings[l]) == 1:
279 output_locale(l, l, encodings[l][0])
280 else:
281 if "UTF-8" in encodings[l]:
282 output_locale(l, l, "UTF-8")
283 encodings[l].remove("UTF-8")
284 for e in encodings[l]:
285 output_locale('%s-%s' % (l, e), l, e)
286
287 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
288 if use_bin:
289 bb.note("collecting binary locales from locale tree")
290 bb.build.exec_func("do_collect_bins_from_locale_tree", d)
291}
292
293# We want to do this indirection so that we can safely 'return'
294# from the called function even though we're prepending
295python populate_packages_prepend () {
296 if bb.data.getVar('DEBIAN_NAMES', d, 1):
297 bb.data.setVar('PKG_glibc', 'libc6', d)
298 bb.data.setVar('PKG_glibc-dev', 'libc6-dev', d)
299 bb.build.exec_func('package_do_split_gconvs', d)
300}