blob: b96ea0bad4664837a5712f4fc753ca249bf3954d [file] [log] [blame]
Andrew Geissler635e0e42020-08-21 15:58:33 -05001#
2# SPDX-License-Identifier: GPL-2.0-only
3#
4
5import re
6import subprocess
7from oe.package_manager import *
8
9class DpkgIndexer(Indexer):
10 def _create_configs(self):
11 bb.utils.mkdirhier(self.apt_conf_dir)
12 bb.utils.mkdirhier(os.path.join(self.apt_conf_dir, "lists", "partial"))
13 bb.utils.mkdirhier(os.path.join(self.apt_conf_dir, "apt.conf.d"))
14 bb.utils.mkdirhier(os.path.join(self.apt_conf_dir, "preferences.d"))
15
16 with open(os.path.join(self.apt_conf_dir, "preferences"),
17 "w") as prefs_file:
18 pass
19 with open(os.path.join(self.apt_conf_dir, "sources.list"),
20 "w+") as sources_file:
21 pass
22
23 with open(self.apt_conf_file, "w") as apt_conf:
24 with open(os.path.join(self.d.expand("${STAGING_ETCDIR_NATIVE}"),
25 "apt", "apt.conf.sample")) as apt_conf_sample:
26 for line in apt_conf_sample.read().split("\n"):
27 line = re.sub(r"#ROOTFS#", "/dev/null", line)
28 line = re.sub(r"#APTCONF#", self.apt_conf_dir, line)
29 apt_conf.write(line + "\n")
30
31 def write_index(self):
32 self.apt_conf_dir = os.path.join(self.d.expand("${APTCONF_TARGET}"),
33 "apt-ftparchive")
34 self.apt_conf_file = os.path.join(self.apt_conf_dir, "apt.conf")
35 self._create_configs()
36
37 os.environ['APT_CONFIG'] = self.apt_conf_file
38
39 pkg_archs = self.d.getVar('PACKAGE_ARCHS')
40 if pkg_archs is not None:
41 arch_list = pkg_archs.split()
42 sdk_pkg_archs = self.d.getVar('SDK_PACKAGE_ARCHS')
43 if sdk_pkg_archs is not None:
44 for a in sdk_pkg_archs.split():
45 if a not in pkg_archs:
46 arch_list.append(a)
47
48 all_mlb_pkg_arch_list = (self.d.getVar('ALL_MULTILIB_PACKAGE_ARCHS') or "").split()
49 arch_list.extend(arch for arch in all_mlb_pkg_arch_list if arch not in arch_list)
50
51 apt_ftparchive = bb.utils.which(os.getenv('PATH'), "apt-ftparchive")
52 gzip = bb.utils.which(os.getenv('PATH'), "gzip")
53
54 index_cmds = []
55 deb_dirs_found = False
Patrick Williamsde0582f2022-04-08 10:23:27 -050056 index_sign_files = set()
Andrew Geissler635e0e42020-08-21 15:58:33 -050057 for arch in arch_list:
58 arch_dir = os.path.join(self.deploy_dir, arch)
59 if not os.path.isdir(arch_dir):
60 continue
61
62 cmd = "cd %s; PSEUDO_UNLOAD=1 %s packages . > Packages;" % (arch_dir, apt_ftparchive)
63
64 cmd += "%s -fcn Packages > Packages.gz;" % gzip
65
Patrick Williamsde0582f2022-04-08 10:23:27 -050066 release_file = os.path.join(arch_dir, "Release")
67 index_sign_files.add(release_file)
68
69 with open(release_file, "w+") as release:
Andrew Geissler635e0e42020-08-21 15:58:33 -050070 release.write("Label: %s\n" % arch)
71
72 cmd += "PSEUDO_UNLOAD=1 %s release . >> Release" % apt_ftparchive
73
74 index_cmds.append(cmd)
75
76 deb_dirs_found = True
77
78 if not deb_dirs_found:
79 bb.note("There are no packages in %s" % self.deploy_dir)
80 return
81
82 oe.utils.multiprocess_launch(create_index, index_cmds, self.d)
Patrick Williamsde0582f2022-04-08 10:23:27 -050083 if self.d.getVar('PACKAGE_FEED_SIGN', True) == '1':
84 signer = get_signer(self.d, self.d.getVar('PACKAGE_FEED_GPG_BACKEND', True))
85 else:
86 signer = None
87 if signer:
88 for f in index_sign_files:
89 signer.detach_sign(f,
90 self.d.getVar('PACKAGE_FEED_GPG_NAME', True),
91 self.d.getVar('PACKAGE_FEED_GPG_PASSPHRASE_FILE', True),
92 output_suffix="gpg",
93 use_sha256=True)
Andrew Geissler635e0e42020-08-21 15:58:33 -050094
Andrew Geissler6ce62a22020-11-30 19:58:47 -060095class PMPkgsList(PkgsList):
Andrew Geissler635e0e42020-08-21 15:58:33 -050096
97 def list_pkgs(self):
98 cmd = [bb.utils.which(os.getenv('PATH'), "dpkg-query"),
99 "--admindir=%s/var/lib/dpkg" % self.rootfs_dir,
100 "-W"]
101
102 cmd.append("-f=Package: ${Package}\nArchitecture: ${PackageArch}\nVersion: ${Version}\nFile: ${Package}_${Version}_${Architecture}.deb\nDepends: ${Depends}\nRecommends: ${Recommends}\nProvides: ${Provides}\n\n")
103
104 try:
105 cmd_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode("utf-8")
106 except subprocess.CalledProcessError as e:
107 bb.fatal("Cannot get the installed packages list. Command '%s' "
108 "returned %d:\n%s" % (' '.join(cmd), e.returncode, e.output.decode("utf-8")))
109
110 return opkg_query(cmd_output)
111
112class OpkgDpkgPM(PackageManager):
113 def __init__(self, d, target_rootfs):
114 """
115 This is an abstract class. Do not instantiate this directly.
116 """
117 super(OpkgDpkgPM, self).__init__(d, target_rootfs)
118
119 def package_info(self, pkg, cmd):
120 """
121 Returns a dictionary with the package info.
122
123 This method extracts the common parts for Opkg and Dpkg
124 """
125
126 try:
127 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
128 except subprocess.CalledProcessError as e:
129 bb.fatal("Unable to list available packages. Command '%s' "
130 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
131 return opkg_query(output)
132
133 def extract(self, pkg, pkg_info):
134 """
135 Returns the path to a tmpdir where resides the contents of a package.
136
137 Deleting the tmpdir is responsability of the caller.
138
139 This method extracts the common parts for Opkg and Dpkg
140 """
141
142 ar_cmd = bb.utils.which(os.getenv("PATH"), "ar")
143 tar_cmd = bb.utils.which(os.getenv("PATH"), "tar")
144 pkg_path = pkg_info[pkg]["filepath"]
145
146 if not os.path.isfile(pkg_path):
147 bb.fatal("Unable to extract package for '%s'."
148 "File %s doesn't exists" % (pkg, pkg_path))
149
150 tmp_dir = tempfile.mkdtemp()
151 current_dir = os.getcwd()
152 os.chdir(tmp_dir)
153 data_tar = 'data.tar.xz'
154
155 try:
156 cmd = [ar_cmd, 'x', pkg_path]
157 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
158 cmd = [tar_cmd, 'xf', data_tar]
159 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
160 except subprocess.CalledProcessError as e:
161 bb.utils.remove(tmp_dir, recurse=True)
162 bb.fatal("Unable to extract %s package. Command '%s' "
163 "returned %d:\n%s" % (pkg_path, ' '.join(cmd), e.returncode, e.output.decode("utf-8")))
164 except OSError as e:
165 bb.utils.remove(tmp_dir, recurse=True)
166 bb.fatal("Unable to extract %s package. Command '%s' "
167 "returned %d:\n%s at %s" % (pkg_path, ' '.join(cmd), e.errno, e.strerror, e.filename))
168
169 bb.note("Extracted %s to %s" % (pkg_path, tmp_dir))
170 bb.utils.remove(os.path.join(tmp_dir, "debian-binary"))
171 bb.utils.remove(os.path.join(tmp_dir, "control.tar.gz"))
172 os.chdir(current_dir)
173
174 return tmp_dir
175
176 def _handle_intercept_failure(self, registered_pkgs):
177 self.mark_packages("unpacked", registered_pkgs.split())
178
179class DpkgPM(OpkgDpkgPM):
180 def __init__(self, d, target_rootfs, archs, base_archs, apt_conf_dir=None, deb_repo_workdir="oe-rootfs-repo", filterbydependencies=True):
181 super(DpkgPM, self).__init__(d, target_rootfs)
182 self.deploy_dir = oe.path.join(self.d.getVar('WORKDIR'), deb_repo_workdir)
183
184 create_packages_dir(self.d, self.deploy_dir, d.getVar("DEPLOY_DIR_DEB"), "package_write_deb", filterbydependencies)
185
186 if apt_conf_dir is None:
187 self.apt_conf_dir = self.d.expand("${APTCONF_TARGET}/apt")
188 else:
189 self.apt_conf_dir = apt_conf_dir
190 self.apt_conf_file = os.path.join(self.apt_conf_dir, "apt.conf")
191 self.apt_get_cmd = bb.utils.which(os.getenv('PATH'), "apt-get")
192 self.apt_cache_cmd = bb.utils.which(os.getenv('PATH'), "apt-cache")
193
194 self.apt_args = d.getVar("APT_ARGS")
195
196 self.all_arch_list = archs.split()
197 all_mlb_pkg_arch_list = (self.d.getVar('ALL_MULTILIB_PACKAGE_ARCHS') or "").split()
198 self.all_arch_list.extend(arch for arch in all_mlb_pkg_arch_list if arch not in self.all_arch_list)
199
200 self._create_configs(archs, base_archs)
201
202 self.indexer = DpkgIndexer(self.d, self.deploy_dir)
203
204 def mark_packages(self, status_tag, packages=None):
205 """
206 This function will change a package's status in /var/lib/dpkg/status file.
207 If 'packages' is None then the new_status will be applied to all
208 packages
209 """
210 status_file = self.target_rootfs + "/var/lib/dpkg/status"
211
212 with open(status_file, "r") as sf:
213 with open(status_file + ".tmp", "w+") as tmp_sf:
214 if packages is None:
215 tmp_sf.write(re.sub(r"Package: (.*?)\n((?:[^\n]+\n)*?)Status: (.*)(?:unpacked|installed)",
216 r"Package: \1\n\2Status: \3%s" % status_tag,
217 sf.read()))
218 else:
219 if type(packages).__name__ != "list":
220 raise TypeError("'packages' should be a list object")
221
222 status = sf.read()
223 for pkg in packages:
224 status = re.sub(r"Package: %s\n((?:[^\n]+\n)*?)Status: (.*)(?:unpacked|installed)" % pkg,
225 r"Package: %s\n\1Status: \2%s" % (pkg, status_tag),
226 status)
227
228 tmp_sf.write(status)
229
Andrew Geisslerc926e172021-05-07 16:11:35 -0500230 bb.utils.rename(status_file + ".tmp", status_file)
Andrew Geissler635e0e42020-08-21 15:58:33 -0500231
232 def run_pre_post_installs(self, package_name=None):
233 """
234 Run the pre/post installs for package "package_name". If package_name is
235 None, then run all pre/post install scriptlets.
236 """
237 info_dir = self.target_rootfs + "/var/lib/dpkg/info"
238 ControlScript = collections.namedtuple("ControlScript", ["suffix", "name", "argument"])
239 control_scripts = [
240 ControlScript(".preinst", "Preinstall", "install"),
241 ControlScript(".postinst", "Postinstall", "configure")]
242 status_file = self.target_rootfs + "/var/lib/dpkg/status"
243 installed_pkgs = []
244
245 with open(status_file, "r") as status:
246 for line in status.read().split('\n'):
247 m = re.match(r"^Package: (.*)", line)
248 if m is not None:
249 installed_pkgs.append(m.group(1))
250
251 if package_name is not None and not package_name in installed_pkgs:
252 return
253
254 os.environ['D'] = self.target_rootfs
255 os.environ['OFFLINE_ROOT'] = self.target_rootfs
256 os.environ['IPKG_OFFLINE_ROOT'] = self.target_rootfs
257 os.environ['OPKG_OFFLINE_ROOT'] = self.target_rootfs
258 os.environ['INTERCEPT_DIR'] = self.intercepts_dir
259 os.environ['NATIVE_ROOT'] = self.d.getVar('STAGING_DIR_NATIVE')
260
261 for pkg_name in installed_pkgs:
262 for control_script in control_scripts:
263 p_full = os.path.join(info_dir, pkg_name + control_script.suffix)
264 if os.path.exists(p_full):
265 try:
266 bb.note("Executing %s for package: %s ..." %
267 (control_script.name.lower(), pkg_name))
268 output = subprocess.check_output([p_full, control_script.argument],
269 stderr=subprocess.STDOUT).decode("utf-8")
270 bb.note(output)
271 except subprocess.CalledProcessError as e:
272 bb.warn("%s for package %s failed with %d:\n%s" %
273 (control_script.name, pkg_name, e.returncode,
274 e.output.decode("utf-8")))
275 failed_postinsts_abort([pkg_name], self.d.expand("${T}/log.do_${BB_CURRENTTASK}"))
276
277 def update(self):
278 os.environ['APT_CONFIG'] = self.apt_conf_file
279
280 self.deploy_dir_lock()
281
282 cmd = "%s update" % self.apt_get_cmd
283
284 try:
285 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
286 except subprocess.CalledProcessError as e:
287 bb.fatal("Unable to update the package index files. Command '%s' "
288 "returned %d:\n%s" % (e.cmd, e.returncode, e.output.decode("utf-8")))
289
290 self.deploy_dir_unlock()
291
Andrew Geissler615f2f12022-07-15 14:00:58 -0500292 def install(self, pkgs, attempt_only=False, hard_depends_only=False):
Andrew Geissler635e0e42020-08-21 15:58:33 -0500293 if attempt_only and len(pkgs) == 0:
294 return
295
296 os.environ['APT_CONFIG'] = self.apt_conf_file
297
Andrew Geissler615f2f12022-07-15 14:00:58 -0500298 extra_args = ""
299 if hard_depends_only:
300 extra_args = "--no-install-recommends"
301
302 cmd = "%s %s install --allow-downgrades --allow-remove-essential --allow-change-held-packages --allow-unauthenticated --no-remove %s %s" % \
303 (self.apt_get_cmd, self.apt_args, extra_args, ' '.join(pkgs))
Andrew Geissler635e0e42020-08-21 15:58:33 -0500304
305 try:
306 bb.note("Installing the following packages: %s" % ' '.join(pkgs))
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600307 output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
308 bb.note(output.decode("utf-8"))
Andrew Geissler635e0e42020-08-21 15:58:33 -0500309 except subprocess.CalledProcessError as e:
310 (bb.fatal, bb.warn)[attempt_only]("Unable to install packages. "
311 "Command '%s' returned %d:\n%s" %
312 (cmd, e.returncode, e.output.decode("utf-8")))
313
314 # rename *.dpkg-new files/dirs
315 for root, dirs, files in os.walk(self.target_rootfs):
316 for dir in dirs:
317 new_dir = re.sub(r"\.dpkg-new", "", dir)
318 if dir != new_dir:
Andrew Geisslerc926e172021-05-07 16:11:35 -0500319 bb.utils.rename(os.path.join(root, dir),
Andrew Geissler635e0e42020-08-21 15:58:33 -0500320 os.path.join(root, new_dir))
321
322 for file in files:
323 new_file = re.sub(r"\.dpkg-new", "", file)
324 if file != new_file:
Andrew Geisslerc926e172021-05-07 16:11:35 -0500325 bb.utils.rename(os.path.join(root, file),
Andrew Geissler635e0e42020-08-21 15:58:33 -0500326 os.path.join(root, new_file))
327
328
329 def remove(self, pkgs, with_dependencies=True):
330 if not pkgs:
331 return
332
Andrew Geissler9b4d8b02021-02-19 12:26:16 -0600333 os.environ['D'] = self.target_rootfs
334 os.environ['OFFLINE_ROOT'] = self.target_rootfs
335 os.environ['IPKG_OFFLINE_ROOT'] = self.target_rootfs
336 os.environ['OPKG_OFFLINE_ROOT'] = self.target_rootfs
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600337 os.environ['INTERCEPT_DIR'] = self.intercepts_dir
338
Andrew Geissler635e0e42020-08-21 15:58:33 -0500339 if with_dependencies:
340 os.environ['APT_CONFIG'] = self.apt_conf_file
341 cmd = "%s purge %s" % (self.apt_get_cmd, ' '.join(pkgs))
342 else:
343 cmd = "%s --admindir=%s/var/lib/dpkg --instdir=%s" \
344 " -P --force-depends %s" % \
345 (bb.utils.which(os.getenv('PATH'), "dpkg"),
346 self.target_rootfs, self.target_rootfs, ' '.join(pkgs))
347
348 try:
349 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
350 except subprocess.CalledProcessError as e:
351 bb.fatal("Unable to remove packages. Command '%s' "
352 "returned %d:\n%s" % (e.cmd, e.returncode, e.output.decode("utf-8")))
353
354 def write_index(self):
355 self.deploy_dir_lock()
356
357 result = self.indexer.write_index()
358
359 self.deploy_dir_unlock()
360
361 if result is not None:
362 bb.fatal(result)
363
364 def insert_feeds_uris(self, feed_uris, feed_base_paths, feed_archs):
365 if feed_uris == "":
366 return
367
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600368
Andrew Geissler635e0e42020-08-21 15:58:33 -0500369 sources_conf = os.path.join("%s/etc/apt/sources.list"
370 % self.target_rootfs)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600371 if not os.path.exists(os.path.dirname(sources_conf)):
372 return
373
Andrew Geissler635e0e42020-08-21 15:58:33 -0500374 arch_list = []
375
376 if feed_archs is None:
377 for arch in self.all_arch_list:
378 if not os.path.exists(os.path.join(self.deploy_dir, arch)):
379 continue
380 arch_list.append(arch)
381 else:
382 arch_list = feed_archs.split()
383
384 feed_uris = self.construct_uris(feed_uris.split(), feed_base_paths.split())
385
386 with open(sources_conf, "w+") as sources_file:
387 for uri in feed_uris:
388 if arch_list:
389 for arch in arch_list:
390 bb.note('Adding dpkg channel at (%s)' % uri)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600391 sources_file.write("deb [trusted=yes] %s/%s ./\n" %
Andrew Geissler635e0e42020-08-21 15:58:33 -0500392 (uri, arch))
393 else:
394 bb.note('Adding dpkg channel at (%s)' % uri)
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600395 sources_file.write("deb [trusted=yes] %s ./\n" % uri)
Andrew Geissler635e0e42020-08-21 15:58:33 -0500396
397 def _create_configs(self, archs, base_archs):
398 base_archs = re.sub(r"_", r"-", base_archs)
399
400 if os.path.exists(self.apt_conf_dir):
401 bb.utils.remove(self.apt_conf_dir, True)
402
403 bb.utils.mkdirhier(self.apt_conf_dir)
404 bb.utils.mkdirhier(self.apt_conf_dir + "/lists/partial/")
405 bb.utils.mkdirhier(self.apt_conf_dir + "/apt.conf.d/")
406 bb.utils.mkdirhier(self.apt_conf_dir + "/preferences.d/")
407
408 arch_list = []
409 for arch in self.all_arch_list:
410 if not os.path.exists(os.path.join(self.deploy_dir, arch)):
411 continue
412 arch_list.append(arch)
413
414 with open(os.path.join(self.apt_conf_dir, "preferences"), "w+") as prefs_file:
415 priority = 801
416 for arch in arch_list:
417 prefs_file.write(
418 "Package: *\n"
419 "Pin: release l=%s\n"
420 "Pin-Priority: %d\n\n" % (arch, priority))
421
422 priority += 5
423
424 pkg_exclude = self.d.getVar('PACKAGE_EXCLUDE') or ""
425 for pkg in pkg_exclude.split():
426 prefs_file.write(
427 "Package: %s\n"
428 "Pin: release *\n"
429 "Pin-Priority: -1\n\n" % pkg)
430
431 arch_list.reverse()
432
433 with open(os.path.join(self.apt_conf_dir, "sources.list"), "w+") as sources_file:
434 for arch in arch_list:
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600435 sources_file.write("deb [trusted=yes] file:%s/ ./\n" %
Andrew Geissler635e0e42020-08-21 15:58:33 -0500436 os.path.join(self.deploy_dir, arch))
437
438 base_arch_list = base_archs.split()
439 multilib_variants = self.d.getVar("MULTILIB_VARIANTS");
440 for variant in multilib_variants.split():
441 localdata = bb.data.createCopy(self.d)
Patrick Williams213cb262021-08-07 19:21:33 -0500442 variant_tune = localdata.getVar("DEFAULTTUNE:virtclass-multilib-" + variant, False)
Andrew Geissler635e0e42020-08-21 15:58:33 -0500443 orig_arch = localdata.getVar("DPKG_ARCH")
444 localdata.setVar("DEFAULTTUNE", variant_tune)
445 variant_arch = localdata.getVar("DPKG_ARCH")
446 if variant_arch not in base_arch_list:
447 base_arch_list.append(variant_arch)
448
449 with open(self.apt_conf_file, "w+") as apt_conf:
450 with open(self.d.expand("${STAGING_ETCDIR_NATIVE}/apt/apt.conf.sample")) as apt_conf_sample:
451 for line in apt_conf_sample.read().split("\n"):
452 match_arch = re.match(r" Architecture \".*\";$", line)
453 architectures = ""
454 if match_arch:
455 for base_arch in base_arch_list:
456 architectures += "\"%s\";" % base_arch
457 apt_conf.write(" Architectures {%s};\n" % architectures);
458 apt_conf.write(" Architecture \"%s\";\n" % base_archs)
459 else:
460 line = re.sub(r"#ROOTFS#", self.target_rootfs, line)
461 line = re.sub(r"#APTCONF#", self.apt_conf_dir, line)
462 apt_conf.write(line + "\n")
463
464 target_dpkg_dir = "%s/var/lib/dpkg" % self.target_rootfs
465 bb.utils.mkdirhier(os.path.join(target_dpkg_dir, "info"))
466
467 bb.utils.mkdirhier(os.path.join(target_dpkg_dir, "updates"))
468
469 if not os.path.exists(os.path.join(target_dpkg_dir, "status")):
470 open(os.path.join(target_dpkg_dir, "status"), "w+").close()
471 if not os.path.exists(os.path.join(target_dpkg_dir, "available")):
472 open(os.path.join(target_dpkg_dir, "available"), "w+").close()
473
474 def remove_packaging_data(self):
475 bb.utils.remove(self.target_rootfs + self.d.getVar('opkglibdir'), True)
476 bb.utils.remove(self.target_rootfs + "/var/lib/dpkg/", True)
477
478 def fix_broken_dependencies(self):
479 os.environ['APT_CONFIG'] = self.apt_conf_file
480
481 cmd = "%s %s --allow-unauthenticated -f install" % (self.apt_get_cmd, self.apt_args)
482
483 try:
484 subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
485 except subprocess.CalledProcessError as e:
486 bb.fatal("Cannot fix broken dependencies. Command '%s' "
487 "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))
488
489 def list_installed(self):
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600490 return PMPkgsList(self.d, self.target_rootfs).list_pkgs()
Andrew Geissler635e0e42020-08-21 15:58:33 -0500491
492 def package_info(self, pkg):
493 """
494 Returns a dictionary with the package info.
495 """
496 cmd = "%s show %s" % (self.apt_cache_cmd, pkg)
497 pkg_info = super(DpkgPM, self).package_info(pkg, cmd)
498
499 pkg_arch = pkg_info[pkg]["pkgarch"]
500 pkg_filename = pkg_info[pkg]["filename"]
501 pkg_info[pkg]["filepath"] = \
502 os.path.join(self.deploy_dir, pkg_arch, pkg_filename)
503
504 return pkg_info
505
506 def extract(self, pkg):
507 """
508 Returns the path to a tmpdir where resides the contents of a package.
509
510 Deleting the tmpdir is responsability of the caller.
511 """
512 pkg_info = self.package_info(pkg)
513 if not pkg_info:
514 bb.fatal("Unable to get information for package '%s' while "
515 "trying to extract the package." % pkg)
516
517 tmp_dir = super(DpkgPM, self).extract(pkg, pkg_info)
518 bb.utils.remove(os.path.join(tmp_dir, "data.tar.xz"))
519
520 return tmp_dir