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))
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.
22 # default to disabled until qemu works for everyone
23 ENABLE_BINARY_LOCALE_GENERATION ?= "0"
25 # BINARY_LOCALE_ARCHES is a space separated list of regular expressions
26 BINARY_LOCALE_ARCHES ?= "arm.*"
28 PACKAGES = "glibc catchsegv sln nscd ldd localedef glibc-utils glibc-dev glibc-doc glibc-locale libsegfault glibc-extra-nss glibc-thread-db glibc-pcprofile"
30 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*"
32 FILES_${PN} = "${sysconfdir} ${libc_baselibs} /sbin/ldconfig ${libexecdir} ${datadir}/zoneinfo"
33 FILES_ldd = "${bindir}/ldd"
34 FILES_libsegfault = "/lib/libSegFault*"
35 FILES_glibc-extra-nss = "/lib/libnss*"
36 FILES_sln = "/sbin/sln"
37 FILES_glibc-dev_append = " ${libdir}/*.o ${bindir}/rpcgen"
38 FILES_nscd = "${sbindir}/nscd*"
39 FILES_glibc-utils = "${bindir} ${sbindir}"
40 FILES_glibc-gconv = "${libdir}/gconv"
41 FILES_catchsegv = "${bindir}/catchsegv"
42 RDEPENDS_catchsegv = "libsegfault"
43 FILES_glibc-pcprofile = "/lib/libpcprofile.so"
44 FILES_glibc-thread-db = "/lib/libthread_db*"
45 FILES_localedef = "${bindir}/localedef"
46 RPROVIDES_glibc-dev += "libc-dev"
48 DESCRIPTION_sln = "glibc: create symbolic links between files"
49 DESCRIPTION_nscd = "glibc: name service cache daemon for passwd, group, and hosts"
50 DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services"
51 DESCRIPTION_ldd = "glibc: print shared library dependencies"
52 DESCRIPTION_localedef = "glibc: compile locale definition files"
53 DESCRIPTION_glibc-utils = "glibc: misc utilities like iconf, local, gencat, tzselect, rpcinfo, ..."
55 def get_glibc_fpu_setting(bb, d):
56 if bb.data.getVar('TARGET_FPU', d, 1) in [ 'soft' ]:
60 EXTRA_OECONF += "${@get_glibc_fpu_setting(bb, d)}"
62 OVERRIDES_append = ":${TARGET_ARCH}-${TARGET_OS}"
63 EXTRA_OECONF_append_arm-linuxeabi = " --without-fp"
66 oe_runmake install_root=${D} install
67 for r in ${rpcsvc}; do
68 h=`echo $r|sed -e's,\.x$,.h,'`
69 install -m 0644 ${S}/sunrpc/rpcsvc/$h ${D}/${includedir}/rpcsvc/
71 install -m 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/
72 install -d ${D}${libdir}/locale
73 make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED"
74 # get rid of some broken files...
75 for i in ${GLIBC_BROKEN_LOCALES}; do
76 grep -v $i ${WORKDIR}/SUPPORTED > ${WORKDIR}/SUPPORTED.tmp
77 mv ${WORKDIR}/SUPPORTED.tmp ${WORKDIR}/SUPPORTED
82 TMP_LOCALE="/tmp/locale/${libdir}/locale"
84 locale_base_postinst() {
87 if [ "x$D" != "x" ]; then
92 mkdir -p ${TMP_LOCALE}
93 if [ -f ${libdir}/locale/locale-archive ]; then
94 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
96 localedef --inputfile=${datadir}/i18n/locales/%s --charmap=%s --prefix=/tmp/locale %s
97 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
101 locale_base_postrm() {
105 mkdir -p ${TMP_LOCALE}
106 if [ -f ${libdir}/locale/locale-archive ]; then
107 cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
109 localedef --delete-from-archive --inputfile=${datadir}/locales/%s --charmap=%s --prefix=/tmp/locale %s
110 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
114 python __anonymous () {
115 enabled = bb.data.getVar("ENABLE_BINARY_LOCALE_GENERATION", d, 1)
117 if enabled and int(enabled):
120 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
121 binary_arches = bb.data.getVar("BINARY_LOCALE_ARCHES", d, 1) or ""
123 for regexp in binary_arches.split(" "):
124 r = re.compile(regexp)
126 if r.match(target_arch):
127 depends = bb.data.getVar("DEPENDS", d, 1)
128 depends = "%s qemu-native" % depends
129 bb.data.setVar("DEPENDS", depends, d)
130 bb.data.setVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", "1", d)
134 do_prep_locale_tree() {
135 treedir=${WORKDIR}/locale-tree
137 mkdir -p $treedir/bin $treedir/lib $treedir/${datadir} $treedir/${libdir}/locale
138 cp -a ${D}${datadir}/i18n $treedir/${datadir}/i18n
139 # unzip to avoid parsing errors
140 for i in $treedir/${datadir}/i18n/charmaps/*gz; do
143 cp -a ${STAGING_LIBDIR}/* $treedir/lib
144 if [ -f ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.* ]; then
145 cp -a ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.* $treedir/lib
147 install -m 0755 ${D}${bindir}/localedef $treedir/bin
150 do_collect_bins_from_locale_tree() {
151 treedir=${WORKDIR}/locale-tree
153 mkdir -p ${D}${libdir}
154 cp -a $treedir/${libdir}/locale ${D}${libdir}
157 python package_do_split_gconvs () {
159 if (bb.data.getVar('PACKAGE_NO_GCONV', d, 1) == '1'):
160 bb.note("package requested not splitting gconvs")
163 if not bb.data.getVar('PACKAGES', d, 1):
166 libdir = bb.data.getVar('libdir', d, 1)
168 bb.error("libdir not defined")
170 datadir = bb.data.getVar('datadir', d, 1)
172 bb.error("datadir not defined")
175 gconv_libdir = os.path.join(libdir, "gconv")
176 charmap_dir = os.path.join(datadir, "i18n", "charmaps")
177 locales_dir = os.path.join(datadir, "i18n", "locales")
178 binary_locales_dir = os.path.join(libdir, "locale")
180 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 do_split_packages(d, charmap_dir, file_regex='^(.*)\.gz$', output_pattern='glibc-charmap-%s', description='character map for %s encoding', extra_depends='')
184 def calc_locale_deps(fn, pkg, file_regex, output_pattern, group):
187 c_re = re.compile('^copy "(.*)"')
188 i_re = re.compile('^include "(\w+)".*')
189 for l in f.readlines():
190 m = c_re.match(l) or i_re.match(l)
192 dp = legitimize_package_name('glibc-localedata-%s' % m.group(1))
197 bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
199 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
201 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 do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='glibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='')
204 bb.note("generation of binary locales disabled. this may break i18n!")
205 bb.data.setVar('PACKAGES', bb.data.getVar('PACKAGES', d) + ' glibc-gconv', d)
207 f = open(os.path.join(bb.data.getVar('WORKDIR', d, 1), "SUPPORTED"), "r")
208 supported = f.readlines()
211 dot_re = re.compile("(.*)\.(.*)")
213 # Collate the locales by base and encoding
217 (locale, charset) = l.split(" ")
218 m = dot_re.match(locale)
221 if not encodings.has_key(locale):
222 encodings[locale] = []
223 encodings[locale].append(charset)
225 def output_locale_source(name, locale, encoding):
226 pkgname = 'locale-base-' + legitimize_package_name(name)
228 bb.data.setVar('RDEPENDS_%s' % pkgname, 'localedef glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d)
229 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
230 m = re.match("(.*)_(.*)", name)
232 rprovides += ' virtual-locale-%s' % m.group(1)
233 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
234 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
235 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
236 bb.data.setVar('pkg_postinst_%s' % pkgname, bb.data.getVar('locale_base_postinst', d, 1) % (locale, encoding, locale), d)
237 bb.data.setVar('pkg_postrm_%s' % pkgname, bb.data.getVar('locale_base_postrm', d, 1) % (locale, encoding, locale), d)
239 def output_locale_binary(name, locale, encoding):
240 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
241 qemu = "qemu-%s" % target_arch
242 pkgname = 'locale-base-' + legitimize_package_name(name)
244 bb.data.setVar('RDEPENDS_%s' % pkgname, 'glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d)
245 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
246 m = re.match("(.*)_(.*)", name)
248 rprovides += ' virtual-locale-%s' % m.group(1)
249 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
250 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
251 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
253 treedir = os.path.join(bb.data.getVar("WORKDIR", d, 1), "locale-tree")
254 path = bb.data.getVar("PATH", d, 1)
255 i18npath = os.path.join(treedir, datadir, "i18n")
257 localedef_opts = "--force --old-style --no-archive --prefix=%s --inputfile=%s/i18n/locales/%s --charmap=%s %s" % (treedir, datadir, locale, encoding, locale)
258 cmd = "PATH=\"%s\" I18NPATH=\"%s\" %s -L %s %s/bin/localedef %s" % (path, i18npath, qemu, treedir, treedir, localedef_opts)
259 bb.note("generating locale %s (%s)" % (locale, encoding))
261 raise bb.build.FuncFailed("localedef returned an error.")
263 def output_locale(name, locale, encoding):
264 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
266 output_locale_binary(name, locale, encoding)
268 output_locale_source(name, locale, encoding)
270 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
272 bb.note("preparing tree for binary locale generation")
273 bb.build.exec_func("do_prep_locale_tree", d)
275 # Reshuffle names so that UTF-8 is preferred over other encodings
276 for l in encodings.keys():
277 if len(encodings[l]) == 1:
278 output_locale(l, l, encodings[l][0])
280 if "UTF-8" in encodings[l]:
281 output_locale(l, l, "UTF-8")
282 encodings[l].remove("UTF-8")
283 for e in encodings[l]:
284 output_locale('%s-%s' % (l, e), l, e)
286 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
288 bb.note("collecting binary locales from locale tree")
289 bb.build.exec_func("do_collect_bins_from_locale_tree", d)
292 # We want to do this indirection so that we can safely 'return'
293 # from the called function even though we're prepending
294 python populate_packages_prepend () {
295 if bb.data.getVar('DEBIAN_NAMES', d, 1):
296 bb.data.setVar('PKG_glibc', 'libc6', d)
297 bb.data.setVar('PKG_glibc-dev', 'libc6-dev', d)
298 bb.build.exec_func('package_do_split_gconvs', d)