diff options
Diffstat (limited to 'openembedded/packages/glibc/glibc-package.bbclass')
| -rw-r--r-- | openembedded/packages/glibc/glibc-package.bbclass | 193 |
1 files changed, 193 insertions, 0 deletions
diff --git a/openembedded/packages/glibc/glibc-package.bbclass b/openembedded/packages/glibc/glibc-package.bbclass new file mode 100644 index 0000000000..053794ed7f --- /dev/null +++ b/openembedded/packages/glibc/glibc-package.bbclass | |||
| @@ -0,0 +1,193 @@ | |||
| 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 | |||
| 9 | python __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 | PACKAGES = "glibc catchsegv sln nscd ldd localedef glibc-utils glibc-dev glibc-doc glibc-locale libsegfault glibc-extra-nss glibc-thread-db glibc-pcprofile" | ||
| 18 | |||
| 19 | 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*" | ||
| 20 | |||
| 21 | FILES_${PN} = "${sysconfdir} ${libc_baselibs} /sbin/ldconfig ${libexecdir} ${datadir}/zoneinfo ${libdir}/locale" | ||
| 22 | FILES_ldd = "${bindir}/ldd" | ||
| 23 | FILES_libsegfault = "/lib/libSegFault*" | ||
| 24 | FILES_glibc-extra-nss = "/lib/libnss*" | ||
| 25 | FILES_sln = "/sbin/sln" | ||
| 26 | FILES_glibc-dev_append = " ${libdir}/*.o ${bindir}/rpcgen" | ||
| 27 | FILES_nscd = "${sbindir}/nscd*" | ||
| 28 | FILES_glibc-utils = "${bindir} ${sbindir}" | ||
| 29 | FILES_glibc-gconv = "${libdir}/gconv" | ||
| 30 | FILES_catchsegv = "${bindir}/catchsegv" | ||
| 31 | RDEPENDS_catchsegv = "libsegfault" | ||
| 32 | FILES_glibc-pcprofile = "/lib/libpcprofile.so" | ||
| 33 | FILES_glibc-thread-db = "/lib/libthread_db*" | ||
| 34 | FILES_localedef = "${bindir}/localedef" | ||
| 35 | RPROVIDES_glibc-dev += "libc-dev" | ||
| 36 | |||
| 37 | DESCRIPTION_sln = "glibc: create symbolic links between files" | ||
| 38 | DESCRIPTION_nscd = "glibc: name service cache daemon for passwd, group, and hosts" | ||
| 39 | DESCRIPTION_glibc-extra-nss = "glibc: nis, nisplus and hesiod search services" | ||
| 40 | DESCRIPTION_ldd = "glibc: print shared library dependencies" | ||
| 41 | DESCRIPTION_localedef = "glibc: compile locale definition files" | ||
| 42 | DESCRIPTION_glibc-utils = "glibc: misc utilities like iconf, local, gencat, tzselect, rpcinfo, ..." | ||
| 43 | |||
| 44 | def get_glibc_fpu_setting(bb, d): | ||
| 45 | if bb.data.getVar('TARGET_FPU', d, 1) in [ 'soft' ]: | ||
| 46 | return "--without-fp" | ||
| 47 | return "" | ||
| 48 | |||
| 49 | EXTRA_OECONF += "${@get_glibc_fpu_setting(bb, d)}" | ||
| 50 | |||
| 51 | OVERRIDES_append = ":${TARGET_ARCH}-${TARGET_OS}" | ||
| 52 | EXTRA_OECONF_append_arm-linuxeabi = " --without-fp" | ||
| 53 | |||
| 54 | do_install() { | ||
| 55 | oe_runmake install_root=${D} install | ||
| 56 | for r in ${rpcsvc}; do | ||
| 57 | h=`echo $r|sed -e's,\.x$,.h,'` | ||
| 58 | install -m 0644 ${S}/sunrpc/rpcsvc/$h ${D}/${includedir}/rpcsvc/ | ||
| 59 | done | ||
| 60 | install -m 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/ | ||
| 61 | install -d ${D}${libdir}/locale | ||
| 62 | make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED" | ||
| 63 | rm -f ${D}/etc/rpc | ||
| 64 | } | ||
| 65 | |||
| 66 | TMP_LOCALE="/tmp/locale/${libdir}/locale" | ||
| 67 | |||
| 68 | locale_base_postinst() { | ||
| 69 | #!/bin/sh | ||
| 70 | |||
| 71 | if [ "x$D" != "x" ]; then | ||
| 72 | exit 1 | ||
| 73 | fi | ||
| 74 | |||
| 75 | rm -rf ${TMP_LOCALE} | ||
| 76 | mkdir -p ${TMP_LOCALE} | ||
| 77 | if [ -f ${libdir}/locale/locale-archive ]; then | ||
| 78 | cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/ | ||
| 79 | fi | ||
| 80 | localedef --inputfile=${datadir}/i18n/locales/%s --charmap=%s --prefix=/tmp/locale %s | ||
| 81 | mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/ | ||
| 82 | rm -rf ${TMP_LOCALE} | ||
| 83 | } | ||
| 84 | |||
| 85 | locale_base_postrm() { | ||
| 86 | #!/bin/sh | ||
| 87 | |||
| 88 | rm -rf ${TMP_LOCALE} | ||
| 89 | mkdir -p ${TMP_LOCALE} | ||
| 90 | if [ -f ${libdir}/locale/locale-archive ]; then | ||
| 91 | cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/ | ||
| 92 | fi | ||
| 93 | localedef --delete-from-archive --inputfile=${datadir}/locales/%s --charmap=%s --prefix=/tmp/locale %s | ||
| 94 | mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/ | ||
| 95 | rm -rf ${TMP_LOCALE} | ||
| 96 | } | ||
| 97 | |||
| 98 | python package_do_split_gconvs () { | ||
| 99 | import os, re | ||
| 100 | if (bb.data.getVar('PACKAGE_NO_GCONV', d, 1) == '1'): | ||
| 101 | bb.note("package requested not splitting gconvs") | ||
| 102 | return | ||
| 103 | |||
| 104 | if not bb.data.getVar('PACKAGES', d, 1): | ||
| 105 | return | ||
| 106 | |||
| 107 | libdir = bb.data.getVar('libdir', d, 1) | ||
| 108 | if not libdir: | ||
| 109 | bb.error("libdir not defined") | ||
| 110 | return | ||
| 111 | datadir = bb.data.getVar('datadir', d, 1) | ||
| 112 | if not datadir: | ||
| 113 | bb.error("datadir not defined") | ||
| 114 | return | ||
| 115 | |||
| 116 | gconv_libdir = os.path.join(libdir, "gconv") | ||
| 117 | charmap_dir = os.path.join(datadir, "i18n", "charmaps") | ||
| 118 | locales_dir = os.path.join(datadir, "i18n", "locales") | ||
| 119 | |||
| 120 | 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') | ||
| 121 | |||
| 122 | do_split_packages(d, charmap_dir, file_regex='^(.*)\.gz$', output_pattern='glibc-charmap-%s', description='character map for %s encoding', extra_depends='') | ||
| 123 | |||
| 124 | def calc_locale_deps(fn, pkg, file_regex, output_pattern, group): | ||
| 125 | deps = [] | ||
| 126 | f = open(fn, "r") | ||
| 127 | c_re = re.compile('^copy "(.*)"') | ||
| 128 | i_re = re.compile('^include "(\w+)".*') | ||
| 129 | for l in f.readlines(): | ||
| 130 | m = c_re.match(l) or i_re.match(l) | ||
| 131 | if m: | ||
| 132 | dp = legitimize_package_name('glibc-localedata-%s' % m.group(1)) | ||
| 133 | if not dp in deps: | ||
| 134 | deps.append(dp) | ||
| 135 | f.close() | ||
| 136 | if deps != []: | ||
| 137 | bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d) | ||
| 138 | |||
| 139 | do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='glibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='') | ||
| 140 | bb.data.setVar('PACKAGES', bb.data.getVar('PACKAGES', d) + ' glibc-gconv', d) | ||
| 141 | |||
| 142 | f = open(os.path.join(bb.data.getVar('WORKDIR', d, 1), "SUPPORTED"), "r") | ||
| 143 | supported = f.readlines() | ||
| 144 | f.close() | ||
| 145 | |||
| 146 | dot_re = re.compile("(.*)\.(.*)") | ||
| 147 | |||
| 148 | # Collate the locales by base and encoding | ||
| 149 | encodings = {} | ||
| 150 | for l in supported: | ||
| 151 | l = l[:-1] | ||
| 152 | (locale, charset) = l.split(" ") | ||
| 153 | m = dot_re.match(locale) | ||
| 154 | if m: | ||
| 155 | locale = m.group(1) | ||
| 156 | if not encodings.has_key(locale): | ||
| 157 | encodings[locale] = [] | ||
| 158 | encodings[locale].append(charset) | ||
| 159 | |||
| 160 | def output_locale(name, locale, encoding): | ||
| 161 | pkgname = 'locale-base-' + legitimize_package_name(name) | ||
| 162 | |||
| 163 | bb.data.setVar('RDEPENDS_%s' % pkgname, 'localedef glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d) | ||
| 164 | rprovides = 'virtual-locale-%s' % legitimize_package_name(name) | ||
| 165 | m = re.match("(.*)_(.*)", name) | ||
| 166 | if m: | ||
| 167 | rprovides += ' virtual-locale-%s' % m.group(1) | ||
| 168 | bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d) | ||
| 169 | bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d) | ||
| 170 | bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d) | ||
| 171 | bb.data.setVar('pkg_postinst_%s' % pkgname, bb.data.getVar('locale_base_postinst', d, 1) % (locale, encoding, locale), d) | ||
| 172 | bb.data.setVar('pkg_postrm_%s' % pkgname, bb.data.getVar('locale_base_postrm', d, 1) % (locale, encoding, locale), d) | ||
| 173 | |||
| 174 | # Reshuffle names so that UTF-8 is preferred over other encodings | ||
| 175 | for l in encodings.keys(): | ||
| 176 | if len(encodings[l]) == 1: | ||
| 177 | output_locale(l, l, encodings[l][0]) | ||
| 178 | else: | ||
| 179 | if "UTF-8" in encodings[l]: | ||
| 180 | output_locale(l, l, "UTF-8") | ||
| 181 | encodings[l].remove("UTF-8") | ||
| 182 | for e in encodings[l]: | ||
| 183 | output_locale('%s-%s' % (l, e), l, e) | ||
| 184 | } | ||
| 185 | |||
| 186 | # We want to do this indirection so that we can safely 'return' | ||
| 187 | # from the called function even though we're prepending | ||
| 188 | python populate_packages_prepend () { | ||
| 189 | if bb.data.getVar('DEBIAN_NAMES', d, 1): | ||
| 190 | bb.data.setVar('PKG_glibc', 'libc6', d) | ||
| 191 | bb.data.setVar('PKG_glibc-dev', 'libc6-dev', d) | ||
| 192 | bb.build.exec_func('package_do_split_gconvs', d) | ||
| 193 | } | ||
