From 46950b42accabad1f112e3595bce61134c246594 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 12 Apr 2006 16:05:04 +0000 Subject: glibc: Add binary locale generation from OE. Adding ENABLE_BINARY_LOCALE_GENERATION = "1" to local.conf will enable the locale generation to be performed at build time using qemu which avoids length first boot times and OOM errors on the device. git-svn-id: https://svn.o-hand.com/repos/poky/trunk@345 311d38ba-8fff-0310-9ca6-ca027cbcb966 --- openembedded/packages/glibc/glibc-package.bbclass | 113 ++++++++++++++++++++- .../packages/glibc/glibc_2.3.5+cvs20050627.bb | 8 +- 2 files changed, 114 insertions(+), 7 deletions(-) (limited to 'openembedded/packages') diff --git a/openembedded/packages/glibc/glibc-package.bbclass b/openembedded/packages/glibc/glibc-package.bbclass index 9a91e3ab24..d6decfb709 100644 --- a/openembedded/packages/glibc/glibc-package.bbclass +++ b/openembedded/packages/glibc/glibc-package.bbclass @@ -14,11 +14,23 @@ python __anonymous () { bb.data.getVar('TARGET_OS', d, 1)) } +# Binary locales are generated at build time if ENABLE_BINARY_LOCALE_GENERATION +# is set. The idea is to avoid running localedef on the target (at first boot) +# to decrease initial boot time and avoid localedef being killed by the OOM +# killer which used to effectively break i18n on machines with < 128MB RAM. + +# default to disabled until qemu works for everyone +ENABLE_BINARY_LOCALE_GENERATION ?= "0" + +# BINARY_LOCALE_ARCHES is a space separated list of regular expressions +BINARY_LOCALE_ARCHES ?= "arm.*" + PACKAGES = "glibc catchsegv sln nscd ldd localedef glibc-utils glibc-dev glibc-doc glibc-locale libsegfault glibc-extra-nss glibc-thread-db glibc-pcprofile" +PACKAGES_DYNAMIC = "glibc-gconv-* glibc-charmap-* glibc-localedata-*" 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*" -FILES_${PN} = "${sysconfdir} ${libc_baselibs} /sbin/ldconfig ${libexecdir} ${datadir}/zoneinfo ${libdir}/locale" +FILES_${PN} = "${sysconfdir} ${libc_baselibs} /sbin/ldconfig ${libexecdir} ${datadir}/zoneinfo" FILES_ldd = "${bindir}/ldd" FILES_libsegfault = "/lib/libSegFault*" FILES_glibc-extra-nss = "/lib/libnss*" @@ -60,6 +72,11 @@ do_install() { install -m 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/ install -d ${D}${libdir}/locale make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED" + # get rid of some broken files... + for i in ${GLIBC_BROKEN_LOCALES}; do + grep -v $i ${WORKDIR}/SUPPORTED > ${WORKDIR}/SUPPORTED.tmp + mv ${WORKDIR}/SUPPORTED.tmp ${WORKDIR}/SUPPORTED + done rm -f ${D}/etc/rpc } @@ -95,7 +112,48 @@ mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/ rm -rf ${TMP_LOCALE} } -PACKAGES_DYNAMIC = "glibc-gconv-* glibc-charmap-* glibc-localedata-*" +python __anonymous () { + enabled = bb.data.getVar("ENABLE_BINARY_LOCALE_GENERATION", d, 1) + + if enabled and int(enabled): + import re + + target_arch = bb.data.getVar("TARGET_ARCH", d, 1) + binary_arches = bb.data.getVar("BINARY_LOCALE_ARCHES", d, 1) or "" + + for regexp in binary_arches.split(" "): + r = re.compile(regexp) + + if r.match(target_arch): + depends = bb.data.getVar("DEPENDS", d, 1) + depends = "%s qemu-native" % depends + bb.data.setVar("DEPENDS", depends, d) + bb.data.setVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", "1", d) + break +} + +do_prep_locale_tree() { + treedir=${WORKDIR}/locale-tree + rm -rf $treedir + mkdir -p $treedir/bin $treedir/lib $treedir/${datadir} $treedir/${libdir}/locale + cp -a ${D}${datadir}/i18n $treedir/${datadir}/i18n + # unzip to avoid parsing errors + for i in $treedir/${datadir}/i18n/charmaps/*gz; do + gunzip $i + done + cp -a ${STAGING_LIBDIR}/* $treedir/lib + if [ -f ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.* ]; then + cp -a ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.* $treedir/lib + fi + install -m 0755 ${D}${bindir}/localedef $treedir/bin +} + +do_collect_bins_from_locale_tree() { + treedir=${WORKDIR}/locale-tree + + mkdir -p ${D}${libdir} + cp -a $treedir/${libdir}/locale ${D}${libdir} +} python package_do_split_gconvs () { import os, re @@ -118,6 +176,7 @@ python package_do_split_gconvs () { gconv_libdir = os.path.join(libdir, "gconv") charmap_dir = os.path.join(datadir, "i18n", "charmaps") locales_dir = os.path.join(datadir, "i18n", "locales") + binary_locales_dir = os.path.join(libdir, "locale") 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') @@ -138,7 +197,12 @@ python package_do_split_gconvs () { if deps != []: bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d) - do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='glibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='') + use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1) + if use_bin: + 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') + else: + do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='glibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='') + bb.note("generation of binary locales disabled. this may break i18n!") bb.data.setVar('PACKAGES', bb.data.getVar('PACKAGES', d) + ' glibc-gconv', d) f = open(os.path.join(bb.data.getVar('WORKDIR', d, 1), "SUPPORTED"), "r") @@ -159,7 +223,7 @@ python package_do_split_gconvs () { encodings[locale] = [] encodings[locale].append(charset) - def output_locale(name, locale, encoding): + def output_locale_source(name, locale, encoding): pkgname = 'locale-base-' + legitimize_package_name(name) bb.data.setVar('RDEPENDS_%s' % pkgname, 'localedef glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d) @@ -173,6 +237,42 @@ python package_do_split_gconvs () { bb.data.setVar('pkg_postinst_%s' % pkgname, bb.data.getVar('locale_base_postinst', d, 1) % (locale, encoding, locale), d) bb.data.setVar('pkg_postrm_%s' % pkgname, bb.data.getVar('locale_base_postrm', d, 1) % (locale, encoding, locale), d) + def output_locale_binary(name, locale, encoding): + target_arch = bb.data.getVar("TARGET_ARCH", d, 1) + qemu = "qemu-%s" % target_arch + pkgname = 'locale-base-' + legitimize_package_name(name) + + bb.data.setVar('RDEPENDS_%s' % pkgname, 'glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d) + rprovides = 'virtual-locale-%s' % legitimize_package_name(name) + m = re.match("(.*)_(.*)", name) + if m: + rprovides += ' virtual-locale-%s' % m.group(1) + bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d) + bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d) + bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d) + + treedir = os.path.join(bb.data.getVar("WORKDIR", d, 1), "locale-tree") + path = bb.data.getVar("PATH", d, 1) + i18npath = os.path.join(treedir, datadir, "i18n") + + localedef_opts = "--force --old-style --no-archive --prefix=%s --inputfile=%s/i18n/locales/%s --charmap=%s %s" % (treedir, datadir, locale, encoding, locale) + cmd = "PATH=\"%s\" I18NPATH=\"%s\" %s -L %s %s/bin/localedef %s" % (path, i18npath, qemu, treedir, treedir, localedef_opts) + bb.note("generating locale %s (%s)" % (locale, encoding)) + if os.system(cmd): + raise bb.build.FuncFailed("localedef returned an error.") + + def output_locale(name, locale, encoding): + use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1) + if use_bin: + output_locale_binary(name, locale, encoding) + else: + output_locale_source(name, locale, encoding) + + use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1) + if use_bin: + bb.note("preparing tree for binary locale generation") + bb.build.exec_func("do_prep_locale_tree", d) + # Reshuffle names so that UTF-8 is preferred over other encodings for l in encodings.keys(): if len(encodings[l]) == 1: @@ -183,6 +283,11 @@ python package_do_split_gconvs () { encodings[l].remove("UTF-8") for e in encodings[l]: output_locale('%s-%s' % (l, e), l, e) + + use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1) + if use_bin: + bb.note("collecting binary locales from locale tree") + bb.build.exec_func("do_collect_bins_from_locale_tree", d) } # We want to do this indirection so that we can safely 'return' diff --git a/openembedded/packages/glibc/glibc_2.3.5+cvs20050627.bb b/openembedded/packages/glibc/glibc_2.3.5+cvs20050627.bb index e7adcd0a39..d1925902e4 100644 --- a/openembedded/packages/glibc/glibc_2.3.5+cvs20050627.bb +++ b/openembedded/packages/glibc/glibc_2.3.5+cvs20050627.bb @@ -7,11 +7,13 @@ MAINTAINER = "Phil Blundell " FILESDIR = "${@os.path.dirname(bb.data.getVar('FILE',d,1))}/glibc-cvs-2.3.5" SRCDATE = "20050627" -PR = "r1" +PR = "r3" GLIBC_ADDONS ?= "ports,linuxthreads" GLIBC_EXTRA_OECONF ?= "" +GLIBC_BROKEN_LOCALES = "sid_ET tr_TR mn_MN" + # # For now, we will skip building of a gcc package if it is a uclibc one # and our build is not a uclibc one, and we skip a glibc one if our build @@ -41,8 +43,8 @@ INHIBIT_DEFAULT_DEPS = "1" # \ # file://arm-ioperm.patch;patch=1;pnum=0 \ # file://ldd.patch;patch=1;pnum=0 \ -SRC_URI = "cvs://anoncvs@sources.redhat.com/cvs/glibc;module=libc \ - cvs://anoncvs@sources.redhat.com/cvs/glibc;module=ports \ +SRC_URI = "http://familiar.handhelds.org/source/v0.8.3/stash_libc_sources.redhat.com__20050627.tar.gz \ + http://familiar.handhelds.org/source/v0.8.3/stash_ports_sources.redhat.com__20050627.tar.gz \ file://arm-audit.patch;patch=1 \ file://arm-audit2.patch;patch=1 \ file://arm-no-hwcap.patch;patch=1 \ -- cgit v1.2.3