diff options
Diffstat (limited to 'meta/classes/package_ipk.bbclass')
-rw-r--r-- | meta/classes/package_ipk.bbclass | 282 |
1 files changed, 0 insertions, 282 deletions
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass deleted file mode 100644 index 600b3ac90c..0000000000 --- a/meta/classes/package_ipk.bbclass +++ /dev/null | |||
@@ -1,282 +0,0 @@ | |||
1 | inherit package | ||
2 | |||
3 | IMAGE_PKGTYPE ?= "ipk" | ||
4 | |||
5 | IPKGCONF_TARGET = "${WORKDIR}/opkg.conf" | ||
6 | IPKGCONF_SDK = "${WORKDIR}/opkg-sdk.conf" | ||
7 | IPKGCONF_SDK_TARGET = "${WORKDIR}/opkg-sdk-target.conf" | ||
8 | |||
9 | PKGWRITEDIRIPK = "${WORKDIR}/deploy-ipks" | ||
10 | |||
11 | # Program to be used to build opkg packages | ||
12 | OPKGBUILDCMD ??= 'opkg-build -Z xz -a "${XZ_DEFAULTS}"' | ||
13 | |||
14 | OPKG_ARGS += "--force_postinstall --prefer-arch-to-version" | ||
15 | OPKG_ARGS += "${@['', '--no-install-recommends'][d.getVar("NO_RECOMMENDATIONS") == "1"]}" | ||
16 | OPKG_ARGS += "${@['', '--add-exclude ' + ' --add-exclude '.join((d.getVar('PACKAGE_EXCLUDE') or "").split())][(d.getVar("PACKAGE_EXCLUDE") or "").strip() != ""]}" | ||
17 | |||
18 | OPKGLIBDIR ??= "${localstatedir}/lib" | ||
19 | |||
20 | python do_package_ipk () { | ||
21 | workdir = d.getVar('WORKDIR') | ||
22 | outdir = d.getVar('PKGWRITEDIRIPK') | ||
23 | tmpdir = d.getVar('TMPDIR') | ||
24 | pkgdest = d.getVar('PKGDEST') | ||
25 | if not workdir or not outdir or not tmpdir: | ||
26 | bb.error("Variables incorrectly set, unable to package") | ||
27 | return | ||
28 | |||
29 | packages = d.getVar('PACKAGES') | ||
30 | if not packages or packages == '': | ||
31 | bb.debug(1, "No packages; nothing to do") | ||
32 | return | ||
33 | |||
34 | # We're about to add new packages so the index needs to be checked | ||
35 | # so remove the appropriate stamp file. | ||
36 | if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK): | ||
37 | os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN")) | ||
38 | |||
39 | oe.utils.multiprocess_launch(ipk_write_pkg, packages.split(), d, extraargs=(d,)) | ||
40 | } | ||
41 | do_package_ipk[vardeps] += "ipk_write_pkg" | ||
42 | do_package_ipk[vardepsexclude] = "BB_NUMBER_THREADS" | ||
43 | |||
44 | def ipk_write_pkg(pkg, d): | ||
45 | import re, copy | ||
46 | import subprocess | ||
47 | import textwrap | ||
48 | import collections | ||
49 | import glob | ||
50 | |||
51 | def cleanupcontrol(root): | ||
52 | for p in ['CONTROL', 'DEBIAN']: | ||
53 | p = os.path.join(root, p) | ||
54 | if os.path.exists(p): | ||
55 | bb.utils.prunedir(p) | ||
56 | |||
57 | outdir = d.getVar('PKGWRITEDIRIPK') | ||
58 | pkgdest = d.getVar('PKGDEST') | ||
59 | recipesource = os.path.basename(d.getVar('FILE')) | ||
60 | |||
61 | localdata = bb.data.createCopy(d) | ||
62 | root = "%s/%s" % (pkgdest, pkg) | ||
63 | |||
64 | lf = bb.utils.lockfile(root + ".lock") | ||
65 | try: | ||
66 | localdata.setVar('ROOT', '') | ||
67 | localdata.setVar('ROOT_%s' % pkg, root) | ||
68 | pkgname = localdata.getVar('PKG_%s' % pkg) | ||
69 | if not pkgname: | ||
70 | pkgname = pkg | ||
71 | localdata.setVar('PKG', pkgname) | ||
72 | |||
73 | localdata.setVar('OVERRIDES', d.getVar("OVERRIDES", False) + ":" + pkg) | ||
74 | |||
75 | basedir = os.path.join(os.path.dirname(root)) | ||
76 | arch = localdata.getVar('PACKAGE_ARCH') | ||
77 | |||
78 | if localdata.getVar('IPK_HIERARCHICAL_FEED', False) == "1": | ||
79 | # Spread packages across subdirectories so each isn't too crowded | ||
80 | if pkgname.startswith('lib'): | ||
81 | pkg_prefix = 'lib' + pkgname[3] | ||
82 | else: | ||
83 | pkg_prefix = pkgname[0] | ||
84 | |||
85 | # Keep -dbg, -dev, -doc, -staticdev, -locale and -locale-* packages | ||
86 | # together. These package suffixes are taken from the definitions of | ||
87 | # PACKAGES and PACKAGES_DYNAMIC in meta/conf/bitbake.conf | ||
88 | if pkgname[-4:] in ('-dbg', '-dev', '-doc'): | ||
89 | pkg_subdir = pkgname[:-4] | ||
90 | elif pkgname.endswith('-staticdev'): | ||
91 | pkg_subdir = pkgname[:-10] | ||
92 | elif pkgname.endswith('-locale'): | ||
93 | pkg_subdir = pkgname[:-7] | ||
94 | elif '-locale-' in pkgname: | ||
95 | pkg_subdir = pkgname[:pkgname.find('-locale-')] | ||
96 | else: | ||
97 | pkg_subdir = pkgname | ||
98 | |||
99 | pkgoutdir = "%s/%s/%s/%s" % (outdir, arch, pkg_prefix, pkg_subdir) | ||
100 | else: | ||
101 | pkgoutdir = "%s/%s" % (outdir, arch) | ||
102 | |||
103 | bb.utils.mkdirhier(pkgoutdir) | ||
104 | os.chdir(root) | ||
105 | cleanupcontrol(root) | ||
106 | g = glob.glob('*') | ||
107 | if not g and localdata.getVar('ALLOW_EMPTY', False) != "1": | ||
108 | bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV'), localdata.getVar('PKGR'))) | ||
109 | return | ||
110 | |||
111 | controldir = os.path.join(root, 'CONTROL') | ||
112 | bb.utils.mkdirhier(controldir) | ||
113 | ctrlfile = open(os.path.join(controldir, 'control'), 'w') | ||
114 | |||
115 | fields = [] | ||
116 | pe = d.getVar('PKGE') | ||
117 | if pe and int(pe) > 0: | ||
118 | fields.append(["Version: %s:%s-%s\n", ['PKGE', 'PKGV', 'PKGR']]) | ||
119 | else: | ||
120 | fields.append(["Version: %s-%s\n", ['PKGV', 'PKGR']]) | ||
121 | fields.append(["Description: %s\n", ['DESCRIPTION']]) | ||
122 | fields.append(["Section: %s\n", ['SECTION']]) | ||
123 | fields.append(["Priority: %s\n", ['PRIORITY']]) | ||
124 | fields.append(["Maintainer: %s\n", ['MAINTAINER']]) | ||
125 | fields.append(["License: %s\n", ['LICENSE']]) | ||
126 | fields.append(["Architecture: %s\n", ['PACKAGE_ARCH']]) | ||
127 | fields.append(["OE: %s\n", ['PN']]) | ||
128 | if d.getVar('HOMEPAGE'): | ||
129 | fields.append(["Homepage: %s\n", ['HOMEPAGE']]) | ||
130 | |||
131 | def pullData(l, d): | ||
132 | l2 = [] | ||
133 | for i in l: | ||
134 | l2.append(d.getVar(i)) | ||
135 | return l2 | ||
136 | |||
137 | ctrlfile.write("Package: %s\n" % pkgname) | ||
138 | # check for required fields | ||
139 | for (c, fs) in fields: | ||
140 | for f in fs: | ||
141 | if localdata.getVar(f, False) is None: | ||
142 | raise KeyError(f) | ||
143 | # Special behavior for description... | ||
144 | if 'DESCRIPTION' in fs: | ||
145 | summary = localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or "." | ||
146 | ctrlfile.write('Description: %s\n' % summary) | ||
147 | description = localdata.getVar('DESCRIPTION') or "." | ||
148 | description = textwrap.dedent(description).strip() | ||
149 | if '\\n' in description: | ||
150 | # Manually indent: multiline description includes a leading space | ||
151 | for t in description.split('\\n'): | ||
152 | ctrlfile.write(' %s\n' % (t.strip() or ' .')) | ||
153 | else: | ||
154 | # Auto indent | ||
155 | ctrlfile.write('%s\n' % textwrap.fill(description, width=74, initial_indent=' ', subsequent_indent=' ')) | ||
156 | else: | ||
157 | ctrlfile.write(c % tuple(pullData(fs, localdata))) | ||
158 | |||
159 | custom_fields_chunk = get_package_additional_metadata("ipk", localdata) | ||
160 | if custom_fields_chunk is not None: | ||
161 | ctrlfile.write(custom_fields_chunk) | ||
162 | ctrlfile.write("\n") | ||
163 | |||
164 | mapping_rename_hook(localdata) | ||
165 | |||
166 | def debian_cmp_remap(var): | ||
167 | # In debian '>' and '<' do not mean what it appears they mean | ||
168 | # '<' = less or equal | ||
169 | # '>' = greater or equal | ||
170 | # adjust these to the '<<' and '>>' equivalents | ||
171 | # | ||
172 | for dep in var: | ||
173 | for i, v in enumerate(var[dep]): | ||
174 | if (v or "").startswith("< "): | ||
175 | var[dep][i] = var[dep][i].replace("< ", "<< ") | ||
176 | elif (v or "").startswith("> "): | ||
177 | var[dep][i] = var[dep][i].replace("> ", ">> ") | ||
178 | |||
179 | rdepends = bb.utils.explode_dep_versions2(localdata.getVar("RDEPENDS") or "") | ||
180 | debian_cmp_remap(rdepends) | ||
181 | rrecommends = bb.utils.explode_dep_versions2(localdata.getVar("RRECOMMENDS") or "") | ||
182 | debian_cmp_remap(rrecommends) | ||
183 | rsuggests = bb.utils.explode_dep_versions2(localdata.getVar("RSUGGESTS") or "") | ||
184 | debian_cmp_remap(rsuggests) | ||
185 | # Deliberately drop version information here, not wanted/supported by ipk | ||
186 | rprovides = dict.fromkeys(bb.utils.explode_dep_versions2(localdata.getVar("RPROVIDES") or ""), []) | ||
187 | rprovides = collections.OrderedDict(sorted(rprovides.items(), key=lambda x: x[0])) | ||
188 | debian_cmp_remap(rprovides) | ||
189 | rreplaces = bb.utils.explode_dep_versions2(localdata.getVar("RREPLACES") or "") | ||
190 | debian_cmp_remap(rreplaces) | ||
191 | rconflicts = bb.utils.explode_dep_versions2(localdata.getVar("RCONFLICTS") or "") | ||
192 | debian_cmp_remap(rconflicts) | ||
193 | |||
194 | if rdepends: | ||
195 | ctrlfile.write("Depends: %s\n" % bb.utils.join_deps(rdepends)) | ||
196 | if rsuggests: | ||
197 | ctrlfile.write("Suggests: %s\n" % bb.utils.join_deps(rsuggests)) | ||
198 | if rrecommends: | ||
199 | ctrlfile.write("Recommends: %s\n" % bb.utils.join_deps(rrecommends)) | ||
200 | if rprovides: | ||
201 | ctrlfile.write("Provides: %s\n" % bb.utils.join_deps(rprovides)) | ||
202 | if rreplaces: | ||
203 | ctrlfile.write("Replaces: %s\n" % bb.utils.join_deps(rreplaces)) | ||
204 | if rconflicts: | ||
205 | ctrlfile.write("Conflicts: %s\n" % bb.utils.join_deps(rconflicts)) | ||
206 | ctrlfile.write("Source: %s\n" % recipesource) | ||
207 | ctrlfile.close() | ||
208 | |||
209 | for script in ["preinst", "postinst", "prerm", "postrm"]: | ||
210 | scriptvar = localdata.getVar('pkg_%s' % script) | ||
211 | if not scriptvar: | ||
212 | continue | ||
213 | scriptfile = open(os.path.join(controldir, script), 'w') | ||
214 | scriptfile.write(scriptvar) | ||
215 | scriptfile.close() | ||
216 | os.chmod(os.path.join(controldir, script), 0o755) | ||
217 | |||
218 | conffiles_str = ' '.join(get_conffiles(pkg, d)) | ||
219 | if conffiles_str: | ||
220 | conffiles = open(os.path.join(controldir, 'conffiles'), 'w') | ||
221 | for f in conffiles_str.split(): | ||
222 | if os.path.exists(oe.path.join(root, f)): | ||
223 | conffiles.write('%s\n' % f) | ||
224 | conffiles.close() | ||
225 | |||
226 | os.chdir(basedir) | ||
227 | subprocess.check_output("PATH=\"%s\" %s %s %s" % (localdata.getVar("PATH"), | ||
228 | d.getVar("OPKGBUILDCMD"), pkg, pkgoutdir), | ||
229 | stderr=subprocess.STDOUT, | ||
230 | shell=True) | ||
231 | |||
232 | if d.getVar('IPK_SIGN_PACKAGES') == '1': | ||
233 | ipkver = "%s-%s" % (d.getVar('PKGV'), d.getVar('PKGR')) | ||
234 | ipk_to_sign = "%s/%s_%s_%s.ipk" % (pkgoutdir, pkgname, ipkver, d.getVar('PACKAGE_ARCH')) | ||
235 | sign_ipk(d, ipk_to_sign) | ||
236 | |||
237 | finally: | ||
238 | cleanupcontrol(root) | ||
239 | bb.utils.unlockfile(lf) | ||
240 | |||
241 | # Have to list any variables referenced as X_<pkg> that aren't in pkgdata here | ||
242 | IPKEXTRAVARS = "PRIORITY MAINTAINER PACKAGE_ARCH HOMEPAGE PACKAGE_ADD_METADATA_IPK" | ||
243 | ipk_write_pkg[vardeps] += "${@gen_packagevar(d, 'IPKEXTRAVARS')}" | ||
244 | |||
245 | # Otherwise allarch packages may change depending on override configuration | ||
246 | ipk_write_pkg[vardepsexclude] = "OVERRIDES" | ||
247 | |||
248 | |||
249 | SSTATETASKS += "do_package_write_ipk" | ||
250 | do_package_write_ipk[sstate-inputdirs] = "${PKGWRITEDIRIPK}" | ||
251 | do_package_write_ipk[sstate-outputdirs] = "${DEPLOY_DIR_IPK}" | ||
252 | |||
253 | python do_package_write_ipk_setscene () { | ||
254 | tmpdir = d.getVar('TMPDIR') | ||
255 | |||
256 | if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK): | ||
257 | os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN")) | ||
258 | |||
259 | sstate_setscene(d) | ||
260 | } | ||
261 | addtask do_package_write_ipk_setscene | ||
262 | |||
263 | python () { | ||
264 | if d.getVar('PACKAGES') != '': | ||
265 | deps = ' opkg-utils-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot xz-native:do_populate_sysroot' | ||
266 | d.appendVarFlag('do_package_write_ipk', 'depends', deps) | ||
267 | d.setVarFlag('do_package_write_ipk', 'fakeroot', "1") | ||
268 | } | ||
269 | |||
270 | python do_package_write_ipk () { | ||
271 | bb.build.exec_func("read_subpackage_metadata", d) | ||
272 | bb.build.exec_func("do_package_ipk", d) | ||
273 | } | ||
274 | do_package_write_ipk[dirs] = "${PKGWRITEDIRIPK}" | ||
275 | do_package_write_ipk[cleandirs] = "${PKGWRITEDIRIPK}" | ||
276 | do_package_write_ipk[depends] += "${@oe.utils.build_depends_string(d.getVar('PACKAGE_WRITE_DEPS'), 'do_populate_sysroot')}" | ||
277 | addtask package_write_ipk after do_packagedata do_package | ||
278 | |||
279 | PACKAGEINDEXDEPS += "opkg-utils-native:do_populate_sysroot" | ||
280 | PACKAGEINDEXDEPS += "opkg-native:do_populate_sysroot" | ||
281 | |||
282 | do_build[recrdeptask] += "do_package_write_ipk" | ||