diff options
| author | Richard Purdie <richard@openedhand.com> | 2005-08-31 10:45:47 +0000 |
|---|---|---|
| committer | Richard Purdie <richard@openedhand.com> | 2005-08-31 10:45:47 +0000 |
| commit | 4b46c1f6e891b1ddd5968536440b888661fade3e (patch) | |
| tree | e0ba2c1f56f61b868bf746da5c4feabb25b800b2 /openembedded/classes/debian.bbclass | |
| download | poky-4b46c1f6e891b1ddd5968536440b888661fade3e.tar.gz | |
Initial population
git-svn-id: https://svn.o-hand.com/repos/poky@1 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'openembedded/classes/debian.bbclass')
| -rw-r--r-- | openembedded/classes/debian.bbclass | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/openembedded/classes/debian.bbclass b/openembedded/classes/debian.bbclass new file mode 100644 index 0000000000..d66c1fc763 --- /dev/null +++ b/openembedded/classes/debian.bbclass | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | python debian_package_name_hook () { | ||
| 2 | import glob, copy, stat, errno, re | ||
| 3 | |||
| 4 | workdir = bb.data.getVar('WORKDIR', d, 1) | ||
| 5 | packages = bb.data.getVar('PACKAGES', d, 1) | ||
| 6 | |||
| 7 | def socrunch(s): | ||
| 8 | s = s.lower().replace('_', '-') | ||
| 9 | m = re.match("^(.*)(.)\.so\.(.*)$", s) | ||
| 10 | if m is None: | ||
| 11 | return None | ||
| 12 | if m.group(2) in '0123456789': | ||
| 13 | bin = '%s%s-%s' % (m.group(1), m.group(2), m.group(3)) | ||
| 14 | else: | ||
| 15 | bin = m.group(1) + m.group(2) + m.group(3) | ||
| 16 | dev = m.group(1) + m.group(2) | ||
| 17 | return (bin, dev) | ||
| 18 | |||
| 19 | def isexec(path): | ||
| 20 | try: | ||
| 21 | s = os.stat(path) | ||
| 22 | except (os.error, AttributeError): | ||
| 23 | return 0 | ||
| 24 | return (s[stat.ST_MODE] & stat.S_IEXEC) | ||
| 25 | |||
| 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") | ||
| 30 | sonames = [] | ||
| 31 | has_bins = 0 | ||
| 32 | has_libs = 0 | ||
| 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: | ||
| 36 | has_bins = 1 | ||
| 37 | if lib_re.match(root) and files: | ||
| 38 | has_libs = 1 | ||
| 39 | for f in files: | ||
| 40 | if so_re.match(f): | ||
| 41 | fp = os.path.join(root, f) | ||
| 42 | cmd = (bb.data.getVar('BUILD_PREFIX', d, 1) or "") + "objdump -p " + fp + " 2>/dev/null" | ||
| 43 | fd = os.popen(cmd) | ||
| 44 | lines = fd.readlines() | ||
| 45 | fd.close() | ||
| 46 | for l in lines: | ||
| 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)) | ||
| 50 | |||
| 51 | bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames)) | ||
| 52 | soname = None | ||
| 53 | if len(sonames) == 1: | ||
| 54 | soname = sonames[0] | ||
| 55 | elif len(sonames) > 1: | ||
| 56 | lead = bb.data.getVar('LEAD_SONAME', d, 1) | ||
| 57 | if lead: | ||
| 58 | r = re.compile(lead) | ||
| 59 | filtered = [] | ||
| 60 | for s in sonames: | ||
| 61 | if r.match(s): | ||
| 62 | filtered.append(s) | ||
| 63 | if len(filtered) == 1: | ||
| 64 | soname = filtered[0] | ||
| 65 | elif len(filtered) > 1: | ||
| 66 | bb.note("Multiple matches (%s) for LEAD_SONAME '%s'" % (", ".join(filtered), lead)) | ||
| 67 | else: | ||
| 68 | bb.note("Multiple libraries (%s) found, but LEAD_SONAME '%s' doesn't match any of them" % (", ".join(sonames), lead)) | ||
| 69 | else: | ||
| 70 | bb.note("Multiple libraries (%s) found and LEAD_SONAME not defined" % ", ".join(sonames)) | ||
| 71 | |||
| 72 | if has_libs and not has_bins and soname: | ||
| 73 | soname_result = socrunch(soname) | ||
| 74 | if soname_result: | ||
| 75 | (pkgname, devname) = soname_result | ||
| 76 | for pkg in packages.split(): | ||
| 77 | if (bb.data.getVar('PKG_' + pkg, d)): | ||
| 78 | continue | ||
| 79 | if pkg == orig_pkg: | ||
| 80 | newpkg = pkgname | ||
| 81 | else: | ||
| 82 | newpkg = pkg.replace(orig_pkg, devname, 1) | ||
| 83 | if newpkg != pkg: | ||
| 84 | bb.data.setVar('PKG_' + pkg, newpkg, d) | ||
| 85 | |||
| 86 | for pkg in (bb.data.getVar('AUTO_LIBNAME_PKGS', d, 1) or "").split(): | ||
| 87 | auto_libname(packages, pkg) | ||
| 88 | } | ||
| 89 | |||
| 90 | EXPORT_FUNCTIONS package_name_hook | ||
| 91 | |||
| 92 | DEBIAN_NAMES = 1 | ||
| 93 | |||
