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
6 # See the note in gcc/gcc_3.4.0.oe
9 python __anonymous () {
11 uc_os = (re.match('.*uclibc*', bb.data.getVar('TARGET_OS', d, 1)) != None)
13 raise bb.parse.SkipPackage("incompatible with target %s" %
14 bb.data.getVar('TARGET_OS', d, 1))
18 # Binary locales are generated at build time if ENABLE_BINARY_LOCALE_GENERATION
19 # is set. The idea is to avoid running localedef on the target (at first boot)
20 # to decrease initial boot time and avoid localedef being killed by the OOM
21 # killer which used to effectively break i18n on machines with < 128MB RAM.
23 # default to disabled until qemu works for everyone
24 ENABLE_BINARY_LOCALE_GENERATION ?= "0"
26 # BINARY_LOCALE_ARCHES is a space separated list of regular expressions
27 BINARY_LOCALE_ARCHES ?= "arm.* i[3-6]86 x86_64 powerpc"
29 # Set this to zero if you don't want ldconfig in the output package
32 PACKAGES = "glibc-dbg glibc catchsegv sln nscd ldd localedef glibc-utils glibc-dev glibc-doc glibc-locale libsegfault glibc-extra-nss glibc-thread-db glibc-pcprofile"
33 PACKAGES_DYNAMIC = "glibc-gconv-* glibc-charmap-* glibc-localedata-* locale-base-* glibc-binary-localedata-*"
35 libc_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*"
37 FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${datadir}/zoneinfo ${@base_conditional('USE_LDCONFIG', '1', '/sbin/ldconfig', '', d)}"
38 FILES_ldd = "${bindir}/ldd"
39 FILES_libsegfault = "/lib/libSegFault*"
40 FILES_glibc-extra-nss = "/lib/libnss*"
41 FILES_sln = "/sbin/sln"
42 FILES_glibc-dev_append = " ${libdir}/*.o ${bindir}/rpcgen"
43 FILES_nscd = "${sbindir}/nscd*"
44 FILES_glibc-utils = "${bindir}/* ${sbindir}/*"
45 FILES_glibc-gconv = "${libdir}/gconv/*"
46 FILES_${PN}-dbg += " ${libdir}/gconv/.debug ${libexecdir}/*/.debug"
47 FILES_catchsegv = "${bindir}/catchsegv"
48 RDEPENDS_catchsegv = "libsegfault"
49 FILES_glibc-pcprofile = "/lib/libpcprofile.so"
50 FILES_glibc-thread-db = "/lib/libthread_db*"
51 FILES_localedef = "${bindir}/localedef"
52 RPROVIDES_glibc-dev += "libc-dev"
54 DESCRIPTION_sln = "glibc: create symbolic links between files"
55 DESCRIPTION_nscd = "glibc: name service cache daemon for passwd, group, and hosts"
56 DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services"
57 DESCRIPTION_ldd = "glibc: print shared library dependencies"
58 DESCRIPTION_localedef = "glibc: compile locale definition files"
59 DESCRIPTION_glibc-utils = "glibc: misc utilities like iconf, local, gencat, tzselect, rpcinfo, ..."
61 def get_glibc_fpu_setting(bb, d):
62 if bb.data.getVar('TARGET_FPU', d, 1) in [ 'soft' ]:
66 EXTRA_OECONF += "${@get_glibc_fpu_setting(bb, d)}"
68 OVERRIDES_append = ":${TARGET_ARCH}-${TARGET_OS}"
71 oe_runmake install_root=${D} install
72 for r in ${rpcsvc}; do
73 h=`echo $r|sed -e's,\.x$,.h,'`
74 install -m 0644 ${S}/sunrpc/rpcsvc/$h ${D}/${includedir}/rpcsvc/
76 install -d ${D}${libdir}/locale
77 make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED"
78 # get rid of some broken files...
79 for i in ${GLIBC_BROKEN_LOCALES}; do
80 grep -v $i ${WORKDIR}/SUPPORTED > ${WORKDIR}/SUPPORTED.tmp
81 mv ${WORKDIR}/SUPPORTED.tmp ${WORKDIR}/SUPPORTED
86 TMP_LOCALE="/tmp/locale${libdir}/locale"
88 locale_base_postinst() {
91 if [ "x$D" != "x" ]; then
96 mkdir -p ${TMP_LOCALE}
97 if [ -f ${libdir}/locale/locale-archive ]; then
98 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
100 localedef --inputfile=${datadir}/i18n/locales/%s --charmap=%s --prefix=/tmp/locale %s
101 mkdir -p ${libdir}/locale/
102 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
106 locale_base_postrm() {
110 mkdir -p ${TMP_LOCALE}
111 if [ -f ${libdir}/locale/locale-archive ]; then
112 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
114 localedef --delete-from-archive --inputfile=${datadir}/locales/%s --charmap=%s --prefix=/tmp/locale %s
115 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
119 python __anonymous () {
120 enabled = bb.data.getVar("ENABLE_BINARY_LOCALE_GENERATION", d, 1)
122 if enabled and int(enabled):
125 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
126 binary_arches = bb.data.getVar("BINARY_LOCALE_ARCHES", d, 1) or ""
128 for regexp in binary_arches.split(" "):
129 r = re.compile(regexp)
131 if r.match(target_arch):
132 depends = bb.data.getVar("DEPENDS", d, 1)
133 depends = "%s qemu-native" % depends
134 bb.data.setVar("DEPENDS", depends, d)
135 bb.data.setVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", "1", d)
139 do_prep_locale_tree() {
140 treedir=${WORKDIR}/locale-tree
142 mkdir -p $treedir/bin $treedir/lib $treedir/${datadir} $treedir/${libdir}/locale
143 cp -pPR ${D}${datadir}/i18n $treedir/${datadir}/i18n
144 # unzip to avoid parsing errors
145 for i in $treedir/${datadir}/i18n/charmaps/*gz; do
148 ls ${D}/lib/* | xargs -iBLAH cp -pPR BLAH $treedir/lib
149 if [ -f ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.so ]; then
150 cp -pPR ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.so $treedir/lib
152 if [ -f ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.so.* ]; then
153 cp -pPR ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.so.* $treedir/lib
155 install -m 0755 ${D}${bindir}/localedef $treedir/bin
158 do_collect_bins_from_locale_tree() {
159 treedir=${WORKDIR}/locale-tree
161 mkdir -p ${D}${libdir}
162 cp -pPR $treedir/${libdir}/locale ${D}${libdir}
165 python package_do_split_gconvs () {
167 if (bb.data.getVar('PACKAGE_NO_GCONV', d, 1) == '1'):
168 bb.note("package requested not splitting gconvs")
171 if not bb.data.getVar('PACKAGES', d, 1):
174 libdir = bb.data.getVar('libdir', d, 1)
176 bb.error("libdir not defined")
178 datadir = bb.data.getVar('datadir', d, 1)
180 bb.error("datadir not defined")
183 gconv_libdir = base_path_join(libdir, "gconv")
184 charmap_dir = base_path_join(datadir, "i18n", "charmaps")
185 locales_dir = base_path_join(datadir, "i18n", "locales")
186 binary_locales_dir = base_path_join(libdir, "locale")
188 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')
190 do_split_packages(d, charmap_dir, file_regex='^(.*)\.gz$', output_pattern='glibc-charmap-%s', description='character map for %s encoding', extra_depends='')
192 def calc_locale_deps(fn, pkg, file_regex, output_pattern, group):
195 c_re = re.compile('^copy "(.*)"')
196 i_re = re.compile('^include "(\w+)".*')
197 for l in f.readlines():
198 m = c_re.match(l) or i_re.match(l)
200 dp = legitimize_package_name('glibc-localedata-%s' % m.group(1))
205 bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
207 do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='glibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='')
208 bb.data.setVar('PACKAGES', bb.data.getVar('PACKAGES', d) + ' glibc-gconv', d)
210 supported = bb.data.getVar('GLIBC_GENERATE_LOCALES', d, 1)
211 if not supported or supported == "all":
212 f = open(base_path_join(bb.data.getVar('WORKDIR', d, 1), "SUPPORTED"), "r")
213 supported = f.readlines()
216 supported = supported.split()
217 supported = map(lambda s:s.replace(".", " ") + "\n", supported)
219 dot_re = re.compile("(.*)\.(.*)")
221 # Collate the locales by base and encoding
222 utf8_only = int(bb.data.getVar('LOCALE_UTF8_ONLY', d, 1) or 0)
226 (locale, charset) = l.split(" ")
227 if utf8_only and charset != 'UTF-8':
229 m = dot_re.match(locale)
232 if not encodings.has_key(locale):
233 encodings[locale] = []
234 encodings[locale].append(charset)
236 def output_locale_source(name, locale, encoding):
237 pkgname = 'locale-base-' + legitimize_package_name(name)
239 bb.data.setVar('RDEPENDS_%s' % pkgname, 'localedef glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d)
240 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
241 m = re.match("(.*)_(.*)", name)
243 rprovides += ' virtual-locale-%s' % m.group(1)
244 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
245 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
246 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
247 bb.data.setVar('pkg_postinst_%s' % pkgname, bb.data.getVar('locale_base_postinst', d, 1) % (locale, encoding, locale), d)
248 bb.data.setVar('pkg_postrm_%s' % pkgname, bb.data.getVar('locale_base_postrm', d, 1) % (locale, encoding, locale), d)
250 def output_locale_binary(name, locale, encoding):
251 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
252 if target_arch in ("i486", "i586", "i686"):
254 elif target_arch == "powerpc":
257 kernel_ver = bb.data.getVar("OLDEST_KERNEL", d, 1)
258 if kernel_ver is None:
259 qemu = "qemu-%s -s 1048576" % target_arch
261 qemu = "qemu-%s -s 1048576 -r %s" % (target_arch, kernel_ver)
262 pkgname = 'locale-base-' + legitimize_package_name(name)
263 m = re.match("(.*)\.(.*)", name)
265 glibc_name = "%s.%s" % (m.group(1), m.group(2).lower().replace("-",""))
268 bb.data.setVar('RDEPENDS_%s' % pkgname, legitimize_package_name('glibc-binary-localedata-%s' % glibc_name), d)
269 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
270 m = re.match("(.*)_(.*)", name)
272 rprovides += ' virtual-locale-%s' % m.group(1)
273 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
274 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
275 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
277 treedir = base_path_join(bb.data.getVar("WORKDIR", d, 1), "locale-tree")
278 ldlibdir = "%s/lib" % treedir
279 path = bb.data.getVar("PATH", d, 1)
280 i18npath = base_path_join(treedir, datadir, "i18n")
282 localedef_opts = "--force --old-style --no-archive --prefix=%s --inputfile=%s/i18n/locales/%s --charmap=%s %s" % (treedir, datadir, locale, encoding, name)
284 qemu_options = bb.data.getVar("QEMU_OPTIONS_%s" % bb.data.getVar('PACKAGE_ARCH', d, 1), d, 1)
286 qemu_options = bb.data.getVar('QEMU_OPTIONS', d, 1)
288 cmd = "PATH=\"%s\" I18NPATH=\"%s\" %s -L %s -E LD_LIBRARY_PATH=%s %s %s/bin/localedef %s" % (path, i18npath, qemu, treedir, ldlibdir, qemu_options, treedir, localedef_opts)
289 bb.note("generating locale %s (%s)" % (locale, encoding))
291 raise bb.build.FuncFailed("localedef returned an error (command was %s)." % cmd)
293 def output_locale(name, locale, encoding):
294 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
296 output_locale_binary(name, locale, encoding)
298 output_locale_source(name, locale, encoding)
300 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
302 bb.note("preparing tree for binary locale generation")
303 bb.build.exec_func("do_prep_locale_tree", d)
305 # Reshuffle names so that UTF-8 is preferred over other encodings
307 for l in encodings.keys():
308 if len(encodings[l]) == 1:
309 output_locale(l, l, encodings[l][0])
310 if encodings[l][0] != "UTF-8":
313 if "UTF-8" in encodings[l]:
314 output_locale(l, l, "UTF-8")
315 encodings[l].remove("UTF-8")
318 for e in encodings[l]:
319 output_locale('%s.%s' % (l, e), l, e)
322 bb.note("the following locales are supported only in legacy encodings:")
323 bb.note(" " + " ".join(non_utf8))
325 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
327 bb.note("collecting binary locales from locale tree")
328 bb.build.exec_func("do_collect_bins_from_locale_tree", d)
329 do_split_packages(d, binary_locales_dir, file_regex='(.*)', output_pattern='glibc-binary-localedata-%s', description='binary locale definition for %s', extra_depends='', allow_dirs=True)
331 bb.note("generation of binary locales disabled. this may break i18n!")
335 # We want to do this indirection so that we can safely 'return'
336 # from the called function even though we're prepending
337 python populate_packages_prepend () {
338 if bb.data.getVar('DEBIAN_NAMES', d, 1):
339 bb.data.setVar('PKG_glibc', 'libc6', d)
340 bb.data.setVar('PKG_glibc-dev', 'libc6-dev', d)
341 bb.build.exec_func('package_do_split_gconvs', d)