summaryrefslogtreecommitdiffstats
path: root/meta/classes/debian.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/debian.bbclass')
-rw-r--r--meta/classes/debian.bbclass184
1 files changed, 92 insertions, 92 deletions
diff --git a/meta/classes/debian.bbclass b/meta/classes/debian.bbclass
index bb4ae11eca..2484003e37 100644
--- a/meta/classes/debian.bbclass
+++ b/meta/classes/debian.bbclass
@@ -20,105 +20,105 @@ python () {
20} 20}
21 21
22python debian_package_name_hook () { 22python debian_package_name_hook () {
23 import glob, copy, stat, errno, re 23 import glob, copy, stat, errno, re
24 24
25 pkgdest = d.getVar('PKGDEST', True) 25 pkgdest = d.getVar('PKGDEST', True)
26 packages = d.getVar('PACKAGES', True) 26 packages = d.getVar('PACKAGES', True)
27 bin_re = re.compile(".*/s?" + os.path.basename(d.getVar("bindir", True)) + "$") 27 bin_re = re.compile(".*/s?" + os.path.basename(d.getVar("bindir", True)) + "$")
28 lib_re = re.compile(".*/" + os.path.basename(d.getVar("libdir", True)) + "$") 28 lib_re = re.compile(".*/" + os.path.basename(d.getVar("libdir", True)) + "$")
29 so_re = re.compile("lib.*\.so") 29 so_re = re.compile("lib.*\.so")
30 30
31 def socrunch(s): 31 def socrunch(s):
32 s = s.lower().replace('_', '-') 32 s = s.lower().replace('_', '-')
33 m = re.match("^(.*)(.)\.so\.(.*)$", s) 33 m = re.match("^(.*)(.)\.so\.(.*)$", s)
34 if m is None: 34 if m is None:
35 return None 35 return None
36 if m.group(2) in '0123456789': 36 if m.group(2) in '0123456789':
37 bin = '%s%s-%s' % (m.group(1), m.group(2), m.group(3)) 37 bin = '%s%s-%s' % (m.group(1), m.group(2), m.group(3))
38 else: 38 else:
39 bin = m.group(1) + m.group(2) + m.group(3) 39 bin = m.group(1) + m.group(2) + m.group(3)
40 dev = m.group(1) + m.group(2) 40 dev = m.group(1) + m.group(2)
41 return (bin, dev) 41 return (bin, dev)
42 42
43 def isexec(path): 43 def isexec(path):
44 try: 44 try:
45 s = os.stat(path) 45 s = os.stat(path)
46 except (os.error, AttributeError): 46 except (os.error, AttributeError):
47 return 0 47 return 0
48 return (s[stat.ST_MODE] & stat.S_IEXEC) 48 return (s[stat.ST_MODE] & stat.S_IEXEC)
49 49
50 def auto_libname(packages, orig_pkg): 50 def auto_libname(packages, orig_pkg):
51 sonames = [] 51 sonames = []
52 has_bins = 0 52 has_bins = 0
53 has_libs = 0 53 has_libs = 0
54 pkg_dir = os.path.join(pkgdest, orig_pkg) 54 pkg_dir = os.path.join(pkgdest, orig_pkg)
55 for root, dirs, files in os.walk(pkg_dir): 55 for root, dirs, files in os.walk(pkg_dir):
56 if bin_re.match(root) and files: 56 if bin_re.match(root) and files:
57 has_bins = 1 57 has_bins = 1
58 if lib_re.match(root) and files: 58 if lib_re.match(root) and files:
59 has_libs = 1 59 has_libs = 1
60 for f in files: 60 for f in files:
61 if so_re.match(f): 61 if so_re.match(f):
62 fp = os.path.join(root, f) 62 fp = os.path.join(root, f)
63 cmd = (d.getVar('TARGET_PREFIX', True) or "") + "objdump -p " + fp + " 2>/dev/null" 63 cmd = (d.getVar('TARGET_PREFIX', True) or "") + "objdump -p " + fp + " 2>/dev/null"
64 fd = os.popen(cmd) 64 fd = os.popen(cmd)
65 lines = fd.readlines() 65 lines = fd.readlines()
66 fd.close() 66 fd.close()
67 for l in lines: 67 for l in lines:
68 m = re.match("\s+SONAME\s+([^\s]*)", l) 68 m = re.match("\s+SONAME\s+([^\s]*)", l)
69 if m and not m.group(1) in sonames: 69 if m and not m.group(1) in sonames:
70 sonames.append(m.group(1)) 70 sonames.append(m.group(1))
71 71
72 bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames)) 72 bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames))
73 soname = None 73 soname = None
74 if len(sonames) == 1: 74 if len(sonames) == 1:
75 soname = sonames[0] 75 soname = sonames[0]
76 elif len(sonames) > 1: 76 elif len(sonames) > 1:
77 lead = d.getVar('LEAD_SONAME', True) 77 lead = d.getVar('LEAD_SONAME', True)
78 if lead: 78 if lead:
79 r = re.compile(lead) 79 r = re.compile(lead)
80 filtered = [] 80 filtered = []
81 for s in sonames: 81 for s in sonames:
82 if r.match(s): 82 if r.match(s):
83 filtered.append(s) 83 filtered.append(s)
84 if len(filtered) == 1: 84 if len(filtered) == 1:
85 soname = filtered[0] 85 soname = filtered[0]
86 elif len(filtered) > 1: 86 elif len(filtered) > 1:
87 bb.note("Multiple matches (%s) for LEAD_SONAME '%s'" % (", ".join(filtered), lead)) 87 bb.note("Multiple matches (%s) for LEAD_SONAME '%s'" % (", ".join(filtered), lead))
88 else: 88 else:
89 bb.note("Multiple libraries (%s) found, but LEAD_SONAME '%s' doesn't match any of them" % (", ".join(sonames), lead)) 89 bb.note("Multiple libraries (%s) found, but LEAD_SONAME '%s' doesn't match any of them" % (", ".join(sonames), lead))
90 else: 90 else:
91 bb.note("Multiple libraries (%s) found and LEAD_SONAME not defined" % ", ".join(sonames)) 91 bb.note("Multiple libraries (%s) found and LEAD_SONAME not defined" % ", ".join(sonames))
92 92
93 if has_libs and not has_bins and soname: 93 if has_libs and not has_bins and soname:
94 soname_result = socrunch(soname) 94 soname_result = socrunch(soname)
95 if soname_result: 95 if soname_result:
96 (pkgname, devname) = soname_result 96 (pkgname, devname) = soname_result
97 for pkg in packages.split(): 97 for pkg in packages.split():
98 if (d.getVar('PKG_' + pkg) or d.getVar('DEBIAN_NOAUTONAME_' + pkg)): 98 if (d.getVar('PKG_' + pkg) or d.getVar('DEBIAN_NOAUTONAME_' + pkg)):
99 continue 99 continue
100 debian_pn = d.getVar('DEBIANNAME_' + pkg) 100 debian_pn = d.getVar('DEBIANNAME_' + pkg)
101 if debian_pn: 101 if debian_pn:
102 newpkg = debian_pn 102 newpkg = debian_pn
103 elif pkg == orig_pkg: 103 elif pkg == orig_pkg:
104 newpkg = pkgname 104 newpkg = pkgname
105 else: 105 else:
106 newpkg = pkg.replace(orig_pkg, devname, 1) 106 newpkg = pkg.replace(orig_pkg, devname, 1)
107 mlpre=d.getVar('MLPREFIX', True) 107 mlpre=d.getVar('MLPREFIX', True)
108 if mlpre: 108 if mlpre:
109 if not newpkg.find(mlpre) == 0: 109 if not newpkg.find(mlpre) == 0:
110 newpkg = mlpre + newpkg 110 newpkg = mlpre + newpkg
111 if newpkg != pkg: 111 if newpkg != pkg:
112 d.setVar('PKG_' + pkg, newpkg) 112 d.setVar('PKG_' + pkg, newpkg)
113 113
114 # reversed sort is needed when some package is substring of another 114 # reversed sort is needed when some package is substring of another
115 # ie in ncurses we get without reverse sort: 115 # ie in ncurses we get without reverse sort:
116 # DEBUG: LIBNAMES: pkgname libtic5 devname libtic pkg ncurses-libtic orig_pkg ncurses-libtic debian_pn None newpkg libtic5 116 # DEBUG: LIBNAMES: pkgname libtic5 devname libtic pkg ncurses-libtic orig_pkg ncurses-libtic debian_pn None newpkg libtic5
117 # and later 117 # and later
118 # DEBUG: LIBNAMES: pkgname libtic5 devname libtic pkg ncurses-libticw orig_pkg ncurses-libtic debian_pn None newpkg libticw 118 # DEBUG: LIBNAMES: pkgname libtic5 devname libtic pkg ncurses-libticw orig_pkg ncurses-libtic debian_pn None newpkg libticw
119 # so we need to handle ncurses-libticw->libticw5 before ncurses-libtic->libtic5 119 # so we need to handle ncurses-libticw->libticw5 before ncurses-libtic->libtic5
120 for pkg in sorted((d.getVar('AUTO_LIBNAME_PKGS', True) or "").split(), reverse=True): 120 for pkg in sorted((d.getVar('AUTO_LIBNAME_PKGS', True) or "").split(), reverse=True):
121 auto_libname(packages, pkg) 121 auto_libname(packages, pkg)
122} 122}
123 123
124EXPORT_FUNCTIONS package_name_hook 124EXPORT_FUNCTIONS package_name_hook