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 INSANE_SKIP_glibc-dbg = True
37 libc_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"
39 FILES_${PN} = "${libc_baselibs} ${libexecdir}/* ${datadir}/zoneinfo ${@base_conditional('USE_LDCONFIG', '1', '${base_sbindir}/ldconfig', '', d)}"
40 FILES_ldd = "${bindir}/ldd"
41 FILES_libsegfault = "${base_libdir}/libSegFault*"
42 FILES_glibc-extra-nss = "${base_libdir}/libnss*"
43 FILES_sln = "${base_sbindir}/sln"
44 FILES_glibc-dev_append = " ${libdir}/*.o ${bindir}/rpcgen"
45 FILES_nscd = "${sbindir}/nscd* ${sysconfdir}/nscd* ${sysconfdir}/init.d/nscd*"
46 FILES_glibc-utils = "${bindir}/* ${sbindir}/*"
47 FILES_glibc-gconv = "${libdir}/gconv/*"
48 FILES_${PN}-dbg += " ${libdir}/gconv/.debug ${libexecdir}/*/.debug"
49 FILES_catchsegv = "${bindir}/catchsegv"
50 RDEPENDS_catchsegv = "libsegfault"
51 FILES_glibc-pcprofile = "${base_libdir}/libpcprofile.so"
52 FILES_glibc-thread-db = "${base_libdir}/libthread_db*"
53 FILES_localedef = "${bindir}/localedef"
54 RPROVIDES_glibc-dev += "libc-dev"
56 DESCRIPTION_sln = "glibc: create symbolic links between files"
57 DESCRIPTION_nscd = "glibc: name service cache daemon for passwd, group, and hosts"
58 DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services"
59 DESCRIPTION_ldd = "glibc: print shared library dependencies"
60 DESCRIPTION_localedef = "glibc: compile locale definition files"
61 DESCRIPTION_glibc-utils = "glibc: misc utilities like iconf, local, gencat, tzselect, rpcinfo, ..."
63 INITSCRIPT_NAME = "nscd"
64 INITSCRIPT_PACKAGES = "nscd"
65 INITSCRIPT_PARAMS = "start 40 S . stop 40 0 6 1 ."
68 def get_glibc_fpu_setting(bb, d):
69 if bb.data.getVar('TARGET_FPU', d, 1) in [ 'soft' ]:
73 EXTRA_OECONF += "${@get_glibc_fpu_setting(bb, d)}"
74 EXTRA_OEMAKE += "rootsbindir=${base_sbindir}"
76 OVERRIDES_append = ":${TARGET_ARCH}-${TARGET_OS}"
79 oe_runmake install_root=${D} install
80 for r in ${rpcsvc}; do
81 h=`echo $r|sed -e's,\.x$,.h,'`
82 install -m 0644 ${S}/sunrpc/rpcsvc/$h ${D}/${includedir}/rpcsvc/
84 install -d ${D}${libdir}/locale
85 make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED"
86 # get rid of some broken files...
87 for i in ${GLIBC_BROKEN_LOCALES}; do
88 grep -v $i ${WORKDIR}/SUPPORTED > ${WORKDIR}/SUPPORTED.tmp
89 mv ${WORKDIR}/SUPPORTED.tmp ${WORKDIR}/SUPPORTED
91 rm -f ${D}{sysconfdir}/rpc
92 install -d ${D}${sysconfdir}/init.d
93 install -m 0644 ${S}/nscd/nscd.conf ${D}${sysconfdir}/
94 install ${S}/nscd/nscd.init ${D}${sysconfdir}/init.d/nscd
97 TMP_LOCALE="/tmp/locale${libdir}/locale"
99 locale_base_postinst() {
102 if [ "x$D" != "x" ]; then
107 mkdir -p ${TMP_LOCALE}
108 if [ -f ${libdir}/locale/locale-archive ]; then
109 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
111 localedef --inputfile=${datadir}/i18n/locales/%s --charmap=%s --prefix=/tmp/locale %s
112 mkdir -p ${libdir}/locale/
113 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
117 locale_base_postrm() {
121 mkdir -p ${TMP_LOCALE}
122 if [ -f ${libdir}/locale/locale-archive ]; then
123 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
125 localedef --delete-from-archive --inputfile=${datadir}/locales/%s --charmap=%s --prefix=/tmp/locale %s
126 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
130 python __anonymous () {
131 enabled = bb.data.getVar("ENABLE_BINARY_LOCALE_GENERATION", d, 1)
133 if enabled and int(enabled):
136 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
137 binary_arches = bb.data.getVar("BINARY_LOCALE_ARCHES", d, 1) or ""
139 for regexp in binary_arches.split(" "):
140 r = re.compile(regexp)
142 if r.match(target_arch):
143 depends = bb.data.getVar("DEPENDS", d, 1)
144 depends = "%s qemu-native" % depends
145 bb.data.setVar("DEPENDS", depends, d)
146 bb.data.setVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", "1", d)
150 do_prep_locale_tree() {
151 treedir=${WORKDIR}/locale-tree
153 mkdir -p $treedir/bin $treedir/lib $treedir/${datadir} $treedir/${libdir}/locale
154 cp -pPR ${D}${datadir}/i18n $treedir/${datadir}/i18n
155 # unzip to avoid parsing errors
156 for i in $treedir/${datadir}/i18n/charmaps/*gz; do
159 ls -d ${D}${base_libdir}/* | xargs -iBLAH cp -pPR BLAH $treedir/lib
160 if [ -f ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.so ]; then
161 cp -pPR ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.so $treedir/lib
163 if [ -f ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.so.* ]; then
164 cp -pPR ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.so.* $treedir/lib
166 install -m 0755 ${D}${bindir}/localedef $treedir/bin
169 do_collect_bins_from_locale_tree() {
170 treedir=${WORKDIR}/locale-tree
172 mkdir -p ${D}${libdir}
173 cp -pPR $treedir/${libdir}/locale ${D}${libdir}
176 python package_do_split_gconvs () {
178 if (bb.data.getVar('PACKAGE_NO_GCONV', d, 1) == '1'):
179 bb.note("package requested not splitting gconvs")
182 if not bb.data.getVar('PACKAGES', d, 1):
185 libdir = bb.data.getVar('libdir', d, 1)
187 bb.error("libdir not defined")
189 datadir = bb.data.getVar('datadir', d, 1)
191 bb.error("datadir not defined")
194 gconv_libdir = base_path_join(libdir, "gconv")
195 charmap_dir = base_path_join(datadir, "i18n", "charmaps")
196 locales_dir = base_path_join(datadir, "i18n", "locales")
197 binary_locales_dir = base_path_join(libdir, "locale")
199 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')
201 do_split_packages(d, charmap_dir, file_regex='^(.*)\.gz$', output_pattern='glibc-charmap-%s', description='character map for %s encoding', extra_depends='')
203 def calc_locale_deps(fn, pkg, file_regex, output_pattern, group):
206 c_re = re.compile('^copy "(.*)"')
207 i_re = re.compile('^include "(\w+)".*')
208 for l in f.readlines():
209 m = c_re.match(l) or i_re.match(l)
211 dp = legitimize_package_name('glibc-localedata-%s' % m.group(1))
216 bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
218 do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='glibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='')
219 bb.data.setVar('PACKAGES', bb.data.getVar('PACKAGES', d) + ' glibc-gconv', d)
221 supported = bb.data.getVar('GLIBC_GENERATE_LOCALES', d, 1)
222 if not supported or supported == "all":
223 f = open(base_path_join(bb.data.getVar('WORKDIR', d, 1), "SUPPORTED"), "r")
224 supported = f.readlines()
227 supported = supported.split()
228 supported = map(lambda s:s.replace(".", " ") + "\n", supported)
230 dot_re = re.compile("(.*)\.(.*)")
232 # Collate the locales by base and encoding
233 utf8_only = int(bb.data.getVar('LOCALE_UTF8_ONLY', d, 1) or 0)
237 (locale, charset) = l.split(" ")
238 if utf8_only and charset != 'UTF-8':
240 m = dot_re.match(locale)
243 if not encodings.has_key(locale):
244 encodings[locale] = []
245 encodings[locale].append(charset)
247 def output_locale_source(name, locale, encoding):
248 pkgname = 'locale-base-' + legitimize_package_name(name)
250 bb.data.setVar('RDEPENDS_%s' % pkgname, 'localedef glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d)
251 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
252 m = re.match("(.*)_(.*)", name)
254 rprovides += ' virtual-locale-%s' % m.group(1)
255 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
256 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
257 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
258 bb.data.setVar('pkg_postinst_%s' % pkgname, bb.data.getVar('locale_base_postinst', d, 1) % (locale, encoding, locale), d)
259 bb.data.setVar('pkg_postrm_%s' % pkgname, bb.data.getVar('locale_base_postrm', d, 1) % (locale, encoding, locale), d)
261 def output_locale_binary(name, locale, encoding):
262 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
263 if target_arch in ("i486", "i586", "i686"):
265 elif target_arch == "powerpc":
268 # This is a hack till linux-libc-headers gets patched for the missing arm syscalls and all arm device kernels as well
269 if bb.data.getVar("DISTRO_NAME", d, 1) == "Angstrom":
270 kernel_ver = "2.6.24"
271 elif bb.data.getVar("DISTRO_NAME", d, 1) == "KaeilOS":
272 kernel_ver = "2.6.24"
274 kernel_ver = bb.data.getVar("OLDEST_KERNEL", d, 1)
276 if kernel_ver is None:
277 qemu = "qemu-%s -s 1048576" % target_arch
279 qemu = "qemu-%s -s 1048576 -r %s" % (target_arch, kernel_ver)
280 pkgname = 'locale-base-' + legitimize_package_name(name)
281 m = re.match("(.*)\.(.*)", name)
283 glibc_name = "%s.%s" % (m.group(1), m.group(2).lower().replace("-",""))
286 bb.data.setVar('RDEPENDS_%s' % pkgname, legitimize_package_name('glibc-binary-localedata-%s' % glibc_name), d)
287 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
288 m = re.match("(.*)_(.*)", name)
290 rprovides += ' virtual-locale-%s' % m.group(1)
291 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
292 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
293 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
295 treedir = base_path_join(bb.data.getVar("WORKDIR", d, 1), "locale-tree")
296 ldlibdir = "%s/lib" % treedir
297 path = bb.data.getVar("PATH", d, 1)
298 i18npath = base_path_join(treedir, datadir, "i18n")
300 localedef_opts = "--force --old-style --no-archive --prefix=%s --inputfile=%s/i18n/locales/%s --charmap=%s %s" % (treedir, datadir, locale, encoding, name)
302 qemu_options = bb.data.getVar("QEMU_OPTIONS_%s" % bb.data.getVar('PACKAGE_ARCH', d, 1), d, 1)
304 qemu_options = bb.data.getVar('QEMU_OPTIONS', d, 1)
306 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)
307 bb.note("generating locale %s (%s)" % (locale, encoding))
309 raise bb.build.FuncFailed("localedef returned an error (command was %s)." % cmd)
311 def output_locale(name, locale, encoding):
312 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
314 output_locale_binary(name, locale, encoding)
316 output_locale_source(name, locale, encoding)
318 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
320 bb.note("preparing tree for binary locale generation")
321 bb.build.exec_func("do_prep_locale_tree", d)
323 # Reshuffle names so that UTF-8 is preferred over other encodings
325 for l in encodings.keys():
326 if len(encodings[l]) == 1:
327 output_locale(l, l, encodings[l][0])
328 if encodings[l][0] != "UTF-8":
331 if "UTF-8" in encodings[l]:
332 output_locale(l, l, "UTF-8")
333 encodings[l].remove("UTF-8")
336 for e in encodings[l]:
337 output_locale('%s.%s' % (l, e), l, e)
340 bb.note("the following locales are supported only in legacy encodings:")
341 bb.note(" " + " ".join(non_utf8))
343 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
345 bb.note("collecting binary locales from locale tree")
346 bb.build.exec_func("do_collect_bins_from_locale_tree", d)
347 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)
349 bb.note("generation of binary locales disabled. this may break i18n!")
353 # We want to do this indirection so that we can safely 'return'
354 # from the called function even though we're prepending
355 python populate_packages_prepend () {
356 if bb.data.getVar('DEBIAN_NAMES', d, 1):
357 bb.data.setVar('PKG_glibc', 'libc6', d)
358 bb.data.setVar('PKG_glibc-dev', 'libc6-dev', d)
359 bb.build.exec_func('package_do_split_gconvs', d)