summaryrefslogtreecommitdiffstats
path: root/meta/classes/debian.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
committerRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
commitb2f192faabe412adce79534e22efe9fb69ee40e2 (patch)
tree7076c49d4286f8a1733650bd8fbc7161af200d57 /meta/classes/debian.bbclass
parent2cf0eadf9f730027833af802d7e6c90b44248f80 (diff)
downloadpoky-b2f192faabe412adce79534e22efe9fb69ee40e2.tar.gz
Rename /openembedded/ -> /meta/
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@530 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes/debian.bbclass')
-rw-r--r--meta/classes/debian.bbclass101
1 files changed, 101 insertions, 0 deletions
diff --git a/meta/classes/debian.bbclass b/meta/classes/debian.bbclass
new file mode 100644
index 0000000000..5688dad93b
--- /dev/null
+++ b/meta/classes/debian.bbclass
@@ -0,0 +1,101 @@
1STAGING_PKGMAPS_DIR = "${STAGING_DIR}/pkgmaps/debian"
2
3# Debain package renaming only occurs when a package is built
4# We therefore have to make sure we build all runtime packages
5# before building the current package to make the packages runtime
6# depends are correct
7BUILD_ALL_DEPS = "1"
8
9python debian_package_name_hook () {
10 import glob, copy, stat, errno, re
11
12 workdir = bb.data.getVar('WORKDIR', d, 1)
13 packages = bb.data.getVar('PACKAGES', d, 1)
14
15 def socrunch(s):
16 s = s.lower().replace('_', '-')
17 m = re.match("^(.*)(.)\.so\.(.*)$", s)
18 if m is None:
19 return None
20 if m.group(2) in '0123456789':
21 bin = '%s%s-%s' % (m.group(1), m.group(2), m.group(3))
22 else:
23 bin = m.group(1) + m.group(2) + m.group(3)
24 dev = m.group(1) + m.group(2)
25 return (bin, dev)
26
27 def isexec(path):
28 try:
29 s = os.stat(path)
30 except (os.error, AttributeError):
31 return 0
32 return (s[stat.ST_MODE] & stat.S_IEXEC)
33
34 def auto_libname(packages, orig_pkg):
35 bin_re = re.compile(".*/s?bin$")
36 lib_re = re.compile(".*/lib$")
37 so_re = re.compile("lib.*\.so")
38 sonames = []
39 has_bins = 0
40 has_libs = 0
41 pkg_dir = os.path.join(workdir, "install", orig_pkg)
42 for root, dirs, files in os.walk(pkg_dir):
43 if bin_re.match(root) and files:
44 has_bins = 1
45 if lib_re.match(root) and files:
46 has_libs = 1
47 for f in files:
48 if so_re.match(f):
49 fp = os.path.join(root, f)
50 cmd = (bb.data.getVar('BUILD_PREFIX', d, 1) or "") + "objdump -p " + fp + " 2>/dev/null"
51 fd = os.popen(cmd)
52 lines = fd.readlines()
53 fd.close()
54 for l in lines:
55 m = re.match("\s+SONAME\s+([^\s]*)", l)
56 if m and not m.group(1) in sonames:
57 sonames.append(m.group(1))
58
59 bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames))
60 soname = None
61 if len(sonames) == 1:
62 soname = sonames[0]
63 elif len(sonames) > 1:
64 lead = bb.data.getVar('LEAD_SONAME', d, 1)
65 if lead:
66 r = re.compile(lead)
67 filtered = []
68 for s in sonames:
69 if r.match(s):
70 filtered.append(s)
71 if len(filtered) == 1:
72 soname = filtered[0]
73 elif len(filtered) > 1:
74 bb.note("Multiple matches (%s) for LEAD_SONAME '%s'" % (", ".join(filtered), lead))
75 else:
76 bb.note("Multiple libraries (%s) found, but LEAD_SONAME '%s' doesn't match any of them" % (", ".join(sonames), lead))
77 else:
78 bb.note("Multiple libraries (%s) found and LEAD_SONAME not defined" % ", ".join(sonames))
79
80 if has_libs and not has_bins and soname:
81 soname_result = socrunch(soname)
82 if soname_result:
83 (pkgname, devname) = soname_result
84 for pkg in packages.split():
85 if (bb.data.getVar('PKG_' + pkg, d) or bb.data.getVar('DEBIAN_NOAUTONAME_' + pkg, d)):
86 continue
87 if pkg == orig_pkg:
88 newpkg = pkgname
89 else:
90 newpkg = pkg.replace(orig_pkg, devname, 1)
91 if newpkg != pkg:
92 bb.data.setVar('PKG_' + pkg, newpkg, d)
93
94 for pkg in (bb.data.getVar('AUTO_LIBNAME_PKGS', d, 1) or "").split():
95 auto_libname(packages, pkg)
96}
97
98EXPORT_FUNCTIONS package_name_hook
99
100DEBIAN_NAMES = 1
101