1 # Debian package renaming only occurs when a package is built
2 # We therefore have to make sure we build all runtime packages
3 # before building the current package to make the packages runtime
6 # Custom library package names can be defined setting
7 # DEBIANNAME_ + pkgname to the desired name.
9 # Better expressed as ensure all RDEPENDS package before we package
10 # This means we can't have circular RDEPENDS/RRECOMMENDS
11 do_package_write_ipk[rdeptask] = "do_package"
12 do_package_write_deb[rdeptask] = "do_package"
13 do_package_write_tar[rdeptask] = "do_package"
14 do_package_write_rpm[rdeptask] = "do_package"
16 python debian_package_name_hook () {
17 import glob, copy, stat, errno, re
19 pkgdest = bb.data.getVar('PKGDEST', d, 1)
20 packages = bb.data.getVar('PACKAGES', d, 1)
23 s = s.lower().replace('_', '-')
24 m = re.match("^(.*)(.)\.so\.(.*)$", s)
27 if m.group(2) in '0123456789':
28 bin = '%s%s-%s' % (m.group(1), m.group(2), m.group(3))
30 bin = m.group(1) + m.group(2) + m.group(3)
31 dev = m.group(1) + m.group(2)
37 except (os.error, AttributeError):
39 return (s[stat.ST_MODE] & stat.S_IEXEC)
41 def auto_libname(packages, orig_pkg):
42 bin_re = re.compile(".*/s?bin$")
43 lib_re = re.compile(".*/lib$")
44 so_re = re.compile("lib.*\.so")
48 pkg_dir = os.path.join(pkgdest, orig_pkg)
49 for root, dirs, files in os.walk(pkg_dir):
50 if bin_re.match(root) and files:
52 if lib_re.match(root) and files:
56 fp = os.path.join(root, f)
57 cmd = "PATH=" + bb.data.getVar('PATH', d, 1) + " " + (bb.data.getVar('TARGET_PREFIX', d, 1) or "") + "objdump -p " + fp + " 2>/dev/null"
59 lines = fd.readlines()
62 m = re.match("\s+SONAME\s+([^\s]*)", l)
63 if m and not m.group(1) in sonames:
64 sonames.append(m.group(1))
66 bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames))
70 elif len(sonames) > 1:
71 lead = bb.data.getVar('LEAD_SONAME', d, 1)
78 if len(filtered) == 1:
80 elif len(filtered) > 1:
81 bb.note("Multiple matches (%s) for LEAD_SONAME '%s'" % (", ".join(filtered), lead))
83 bb.note("Multiple libraries (%s) found, but LEAD_SONAME '%s' doesn't match any of them" % (", ".join(sonames), lead))
85 bb.note("Multiple libraries (%s) found and LEAD_SONAME not defined" % ", ".join(sonames))
87 if has_libs and not has_bins and soname:
88 soname_result = socrunch(soname)
90 (pkgname, devname) = soname_result
91 for pkg in packages.split():
92 if (bb.data.getVar('PKG_' + pkg, d) or bb.data.getVar('DEBIAN_NOAUTONAME_' + pkg, d)):
94 debian_pn = bb.data.getVar('DEBIANNAME_' + pkg, d)
100 newpkg = pkg.replace(orig_pkg, devname, 1)
102 bb.data.setVar('PKG_' + pkg, newpkg, d)
104 for pkg in (bb.data.getVar('AUTO_LIBNAME_PKGS', d, 1) or "").split():
105 auto_libname(packages, pkg)
108 EXPORT_FUNCTIONS package_name_hook