diff options
Diffstat (limited to 'meta/classes/debian.bbclass')
-rw-r--r-- | meta/classes/debian.bbclass | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/meta/classes/debian.bbclass b/meta/classes/debian.bbclass deleted file mode 100644 index 6f8a599ccb..0000000000 --- a/meta/classes/debian.bbclass +++ /dev/null | |||
@@ -1,146 +0,0 @@ | |||
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 | ||
4 | # depends are correct | ||
5 | # | ||
6 | # Custom library package names can be defined setting | ||
7 | # DEBIANNAME_ + pkgname to the desired name. | ||
8 | # | ||
9 | # Better expressed as ensure all RDEPENDS package before we package | ||
10 | # This means we can't have circular RDEPENDS/RRECOMMENDS | ||
11 | |||
12 | AUTO_LIBNAME_PKGS = "${PACKAGES}" | ||
13 | |||
14 | inherit package | ||
15 | |||
16 | DEBIANRDEP = "do_packagedata" | ||
17 | do_package_write_ipk[rdeptask] = "${DEBIANRDEP}" | ||
18 | do_package_write_deb[rdeptask] = "${DEBIANRDEP}" | ||
19 | do_package_write_tar[rdeptask] = "${DEBIANRDEP}" | ||
20 | do_package_write_rpm[rdeptask] = "${DEBIANRDEP}" | ||
21 | |||
22 | python () { | ||
23 | if not d.getVar("PACKAGES"): | ||
24 | d.setVar("DEBIANRDEP", "") | ||
25 | } | ||
26 | |||
27 | python debian_package_name_hook () { | ||
28 | import glob, copy, stat, errno, re, pathlib, subprocess | ||
29 | |||
30 | pkgdest = d.getVar("PKGDEST") | ||
31 | packages = d.getVar('PACKAGES') | ||
32 | so_re = re.compile(r"lib.*\.so") | ||
33 | |||
34 | def socrunch(s): | ||
35 | s = s.lower().replace('_', '-') | ||
36 | m = re.match(r"^(.*)(.)\.so\.(.*)$", s) | ||
37 | if m is None: | ||
38 | return None | ||
39 | if m.group(2) in '0123456789': | ||
40 | bin = '%s%s-%s' % (m.group(1), m.group(2), m.group(3)) | ||
41 | else: | ||
42 | bin = m.group(1) + m.group(2) + m.group(3) | ||
43 | dev = m.group(1) + m.group(2) | ||
44 | return (bin, dev) | ||
45 | |||
46 | def isexec(path): | ||
47 | try: | ||
48 | s = os.stat(path) | ||
49 | except (os.error, AttributeError): | ||
50 | return 0 | ||
51 | return (s[stat.ST_MODE] & stat.S_IEXEC) | ||
52 | |||
53 | def add_rprovides(pkg, d): | ||
54 | newpkg = d.getVar('PKG_' + pkg) | ||
55 | if newpkg and newpkg != pkg: | ||
56 | provs = (d.getVar('RPROVIDES_' + pkg) or "").split() | ||
57 | if pkg not in provs: | ||
58 | d.appendVar('RPROVIDES_' + pkg, " " + pkg + " (=" + d.getVar("PKGV") + ")") | ||
59 | |||
60 | def auto_libname(packages, orig_pkg): | ||
61 | p = lambda var: pathlib.PurePath(d.getVar(var)) | ||
62 | libdirs = (p("base_libdir"), p("libdir")) | ||
63 | bindirs = (p("base_bindir"), p("base_sbindir"), p("bindir"), p("sbindir")) | ||
64 | |||
65 | sonames = [] | ||
66 | has_bins = 0 | ||
67 | has_libs = 0 | ||
68 | for f in pkgfiles[orig_pkg]: | ||
69 | # This is .../packages-split/orig_pkg/ | ||
70 | pkgpath = pathlib.PurePath(pkgdest, orig_pkg) | ||
71 | # Strip pkgpath off the full path to a file in the package, re-root | ||
72 | # so it is absolute, and then get the parent directory of the file. | ||
73 | path = pathlib.PurePath("/") / (pathlib.PurePath(f).relative_to(pkgpath).parent) | ||
74 | if path in bindirs: | ||
75 | has_bins = 1 | ||
76 | if path in libdirs: | ||
77 | has_libs = 1 | ||
78 | if so_re.match(os.path.basename(f)): | ||
79 | try: | ||
80 | cmd = [d.expand("${TARGET_PREFIX}objdump"), "-p", f] | ||
81 | output = subprocess.check_output(cmd).decode("utf-8") | ||
82 | for m in re.finditer(r"\s+SONAME\s+([^\s]+)", output): | ||
83 | if m.group(1) not in sonames: | ||
84 | sonames.append(m.group(1)) | ||
85 | except subprocess.CalledProcessError: | ||
86 | pass | ||
87 | bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames)) | ||
88 | soname = None | ||
89 | if len(sonames) == 1: | ||
90 | soname = sonames[0] | ||
91 | elif len(sonames) > 1: | ||
92 | lead = d.getVar('LEAD_SONAME') | ||
93 | if lead: | ||
94 | r = re.compile(lead) | ||
95 | filtered = [] | ||
96 | for s in sonames: | ||
97 | if r.match(s): | ||
98 | filtered.append(s) | ||
99 | if len(filtered) == 1: | ||
100 | soname = filtered[0] | ||
101 | elif len(filtered) > 1: | ||
102 | bb.note("Multiple matches (%s) for LEAD_SONAME '%s'" % (", ".join(filtered), lead)) | ||
103 | else: | ||
104 | bb.note("Multiple libraries (%s) found, but LEAD_SONAME '%s' doesn't match any of them" % (", ".join(sonames), lead)) | ||
105 | else: | ||
106 | bb.note("Multiple libraries (%s) found and LEAD_SONAME not defined" % ", ".join(sonames)) | ||
107 | |||
108 | if has_libs and not has_bins and soname: | ||
109 | soname_result = socrunch(soname) | ||
110 | if soname_result: | ||
111 | (pkgname, devname) = soname_result | ||
112 | for pkg in packages.split(): | ||
113 | if (d.getVar('PKG_' + pkg, False) or d.getVar('DEBIAN_NOAUTONAME_' + pkg, False)): | ||
114 | add_rprovides(pkg, d) | ||
115 | continue | ||
116 | debian_pn = d.getVar('DEBIANNAME_' + pkg, False) | ||
117 | if debian_pn: | ||
118 | newpkg = debian_pn | ||
119 | elif pkg == orig_pkg: | ||
120 | newpkg = pkgname | ||
121 | else: | ||
122 | newpkg = pkg.replace(orig_pkg, devname, 1) | ||
123 | mlpre=d.getVar('MLPREFIX') | ||
124 | if mlpre: | ||
125 | if not newpkg.find(mlpre) == 0: | ||
126 | newpkg = mlpre + newpkg | ||
127 | if newpkg != pkg: | ||
128 | bb.note("debian: renaming %s to %s" % (pkg, newpkg)) | ||
129 | d.setVar('PKG_' + pkg, newpkg) | ||
130 | add_rprovides(pkg, d) | ||
131 | else: | ||
132 | add_rprovides(orig_pkg, d) | ||
133 | |||
134 | # reversed sort is needed when some package is substring of another | ||
135 | # ie in ncurses we get without reverse sort: | ||
136 | # DEBUG: LIBNAMES: pkgname libtic5 devname libtic pkg ncurses-libtic orig_pkg ncurses-libtic debian_pn None newpkg libtic5 | ||
137 | # and later | ||
138 | # DEBUG: LIBNAMES: pkgname libtic5 devname libtic pkg ncurses-libticw orig_pkg ncurses-libtic debian_pn None newpkg libticw | ||
139 | # so we need to handle ncurses-libticw->libticw5 before ncurses-libtic->libtic5 | ||
140 | for pkg in sorted((d.getVar('AUTO_LIBNAME_PKGS') or "").split(), reverse=True): | ||
141 | auto_libname(packages, pkg) | ||
142 | } | ||
143 | |||
144 | EXPORT_FUNCTIONS package_name_hook | ||
145 | |||
146 | DEBIAN_NAMES = "1" | ||