Merge oe-devel@oe-devel.bkbits.net:packages
[vuplus_openembedded] / glibc / glibc-package.oeclass
1 do_install() {
2         oe_runmake install_root=${D} install
3         for r in ${rpcsvc}; do
4                 h=`echo $r|sed -e's,\.x$,.h,'`
5                 install -m 0644 ${S}/sunrpc/rpcsvc/$h ${D}/${includedir}/rpcsvc/
6         done
7         install -m 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/
8         install -d ${D}${libdir}/locale
9         make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED"
10         rm -f ${D}/etc/rpc
11 }
12
13 TMP_LOCALE="/tmp/locale/${libdir}/locale"
14
15 locale_base_postinst() {
16 #!/bin/sh
17
18 if [ "x$D" != "x" ]; then
19   exit 1
20 fi
21
22 rm -rf ${TMP_LOCALE}
23 mkdir -p ${TMP_LOCALE}
24 if [ -f ${libdir}/locale/locale-archive ]; then
25         cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
26 fi
27 localedef --inputfile=${datadir}/i18n/locales/%s --charmap=%s --prefix=/tmp/locale %s
28 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
29 rm -rf ${TMP_LOCALE}
30 }
31
32 locale_base_postrm() {
33 #!/bin/sh
34
35 rm -rf ${TMP_LOCALE}
36 mkdir -p ${TMP_LOCALE}
37 if [ -f ${libdir}/locale/locale-archive ]; then
38         cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
39 fi
40 localedef --delete-from-archive --inputfile=${datadir}/locales/%s --charmap=%s --prefix=/tmp/locale %s
41 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
42 rm -rf ${TMP_LOCALE}
43 }
44
45 python package_do_split_gconvs () {
46         import os, re
47         if (oe.data.getVar('PACKAGE_NO_GCONV', d, 1) == '1'):
48                 oe.note("package requested not splitting gconvs")
49                 return
50
51         if not oe.data.getVar('PACKAGES', d, 1):
52                 return
53
54         libdir = oe.data.getVar('libdir', d, 1)
55         if not libdir:
56                 oe.error("libdir not defined")
57                 return
58         datadir = oe.data.getVar('datadir', d, 1)
59         if not datadir:
60                 oe.error("datadir not defined")
61                 return
62
63         gconv_libdir = os.path.join(libdir, "gconv")
64         charmap_dir = os.path.join(datadir, "i18n", "charmaps")
65         locales_dir = os.path.join(datadir, "i18n", "locales")
66
67         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')
68
69         do_split_packages(d, charmap_dir, file_regex='^(.*)\.gz$', output_pattern='glibc-charmap-%s', description='character map for %s encoding', extra_depends='')
70
71         def calc_locale_deps(fn, pkg, file_regex, output_pattern, group):
72                 deps = []
73                 f = open(fn, "r")
74                 c_re = re.compile('^copy "(.*)"')
75                 i_re = re.compile('^include "(\w+)".*')
76                 for l in f.readlines():
77                         m = c_re.match(l) or i_re.match(l)
78                         if m:
79                                 dp = legitimize_package_name('glibc-localedata-%s' % m.group(1))
80                                 if not dp in deps:
81                                         deps.append(dp)
82                 f.close()
83                 if deps != []:
84                         oe.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
85
86         do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='glibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='')
87         oe.data.setVar('PACKAGES', oe.data.getVar('PACKAGES', d) + ' glibc-gconv', d)
88
89         f = open(os.path.join(oe.data.getVar('WORKDIR', d, 1), "SUPPORTED"), "r")
90         supported = f.readlines()
91         f.close()
92
93         dot_re = re.compile("(.*)\.(.*)")
94
95         # Collate the locales by base and encoding
96         encodings = {}
97         for l in supported:
98                 l = l[:-1]
99                 (locale, charset) = l.split(" ")
100                 m = dot_re.match(locale)
101                 if m:
102                         locale = m.group(1)
103                 if not encodings.has_key(locale):
104                         encodings[locale] = []
105                 encodings[locale].append(charset)
106
107         def output_locale(name, locale, encoding):
108                 pkgname = 'locale-base-' + legitimize_package_name(name)
109
110                 oe.data.setVar('RDEPENDS_%s' % pkgname, 'localedef glibc-localedata-%s glibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d)
111                 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
112                 m = re.match("(.*)_(.*)", name)
113                 if m:
114                         rprovides += ' virtual-locale-%s' % m.group(1)
115                 oe.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
116                 oe.data.setVar('PACKAGES', '%s %s' % (pkgname, oe.data.getVar('PACKAGES', d, 1)), d)
117                 oe.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
118                 oe.data.setVar('pkg_postinst_%s' % pkgname, oe.data.getVar('locale_base_postinst', d, 1) % (locale, encoding, locale), d)
119                 oe.data.setVar('pkg_postrm_%s' % pkgname, oe.data.getVar('locale_base_postrm', d, 1) % (locale, encoding, locale), d)
120
121         # Reshuffle names so that UTF-8 is preferred over other encodings
122         for l in encodings.keys():
123                 if len(encodings[l]) == 1:
124                         output_locale(l, l, encodings[l][0])
125                 else:
126                         if "UTF-8" in encodings[l]:
127                                 output_locale(l, l, "UTF-8")
128                                 encodings[l].remove("UTF-8")
129                         for e in encodings[l]:
130                                 output_locale('%s-%s' % (l, e), l, e)                   
131 }
132
133 # We want to do this indirection so that we can safely 'return'
134 # from the called function even though we're prepending
135 python populate_packages_prepend () {
136         if oe.data.getVar('DEBIAN_NAMES', d, 1):
137                 oe.data.setVar('PKG_glibc', 'libc6', d)
138                 oe.data.setVar('PKG_glibc-dev', 'libc6-dev', d)
139         oe.build.exec_func('package_do_split_gconvs', d)
140 }