1 python debian_package_name_hook () {
2 import glob, copy, stat, errno, re
4 workdir = bb.data.getVar('WORKDIR', d, 1)
5 packages = bb.data.getVar('PACKAGES', d, 1)
8 s = s.lower().replace('_', '-')
9 m = re.match("^(.*)(.)\.so\.(.*)$", s)
12 if m.group(2) in '0123456789':
13 bin = '%s%s-%s' % (m.group(1), m.group(2), m.group(3))
15 bin = m.group(1) + m.group(2) + m.group(3)
16 dev = m.group(1) + m.group(2)
22 except (os.error, AttributeError):
24 return (s[stat.ST_MODE] & stat.S_IEXEC)
26 def auto_libname(packages, orig_pkg):
27 bin_re = re.compile(".*/s?bin$")
28 lib_re = re.compile(".*/lib$")
29 so_re = re.compile("lib.*\.so")
33 pkg_dir = os.path.join(workdir, "install", orig_pkg)
34 for root, dirs, files in os.walk(pkg_dir):
35 if bin_re.match(root) and files:
37 if lib_re.match(root) and files:
41 fp = os.path.join(root, f)
42 cmd = (bb.data.getVar('BUILD_PREFIX', d, 1) or "") + "objdump -p " + fp + " 2>/dev/null"
44 lines = fd.readlines()
47 m = re.match("\s+SONAME\s+([^\s]*)", l)
48 if m and not m.group(1) in sonames:
49 sonames.append(m.group(1))
51 bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames))
55 elif len(sonames) > 1:
56 lead = bb.data.getVar('LEAD_SONAME', d, 1)
63 if len(filtered) == 1:
65 elif len(filtered) > 1:
66 bb.note("Multiple matches (%s) for LEAD_SONAME '%s'" % (", ".join(filtered), lead))
68 bb.note("Multiple libraries (%s) found, but LEAD_SONAME '%s' doesn't match any of them" % (", ".join(sonames), lead))
70 bb.note("Multiple libraries (%s) found and LEAD_SONAME not defined" % ", ".join(sonames))
72 if has_libs and not has_bins and soname:
73 soname_result = socrunch(soname)
75 (pkgname, devname) = soname_result
76 for pkg in packages.split():
77 if (bb.data.getVar('PKG_' + pkg, d)):
82 newpkg = pkg.replace(orig_pkg, devname, 1)
84 bb.data.setVar('PKG_' + pkg, newpkg, d)
86 for pkg in (bb.data.getVar('AUTO_LIBNAME_PKGS', d, 1) or "").split():
87 auto_libname(packages, pkg)
90 EXPORT_FUNCTIONS package_name_hook