summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/package_manager/ipk/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/package_manager/ipk/__init__.py')
-rw-r--r--meta/lib/oe/package_manager/ipk/__init__.py89
1 files changed, 2 insertions, 87 deletions
diff --git a/meta/lib/oe/package_manager/ipk/__init__.py b/meta/lib/oe/package_manager/ipk/__init__.py
index 8cc9953a02..3d998e52ff 100644
--- a/meta/lib/oe/package_manager/ipk/__init__.py
+++ b/meta/lib/oe/package_manager/ipk/__init__.py
@@ -8,6 +8,7 @@ import re
8import shutil 8import shutil
9import subprocess 9import subprocess
10from oe.package_manager import * 10from oe.package_manager import *
11from oe.package_manager.common_deb_ipk import OpkgDpkgPM
11 12
12class OpkgIndexer(Indexer): 13class OpkgIndexer(Indexer):
13 def write_index(self): 14 def write_index(self):
@@ -90,76 +91,6 @@ class PMPkgsList(PkgsList):
90 return opkg_query(cmd_output) 91 return opkg_query(cmd_output)
91 92
92 93
93
94class OpkgDpkgPM(PackageManager):
95 def __init__(self, d, target_rootfs):
96 """
97 This is an abstract class. Do not instantiate this directly.
98 """
99 super(OpkgDpkgPM, self).__init__(d, target_rootfs)
100
101 def package_info(self, pkg, cmd):
102 """
103 Returns a dictionary with the package info.
104
105 This method extracts the common parts for Opkg and Dpkg
106 """
107
108 proc = subprocess.run(cmd, capture_output=True, encoding="utf-8", shell=True)
109 if proc.returncode:
110 bb.fatal("Unable to list available packages. Command '%s' "
111 "returned %d:\n%s" % (cmd, proc.returncode, proc.stderr))
112 elif proc.stderr:
113 bb.note("Command '%s' returned stderr: %s" % (cmd, proc.stderr))
114
115 return opkg_query(proc.stdout)
116
117 def extract(self, pkg, pkg_info):
118 """
119 Returns the path to a tmpdir where resides the contents of a package.
120
121 Deleting the tmpdir is responsability of the caller.
122
123 This method extracts the common parts for Opkg and Dpkg
124 """
125
126 ar_cmd = bb.utils.which(os.getenv("PATH"), "ar")
127 tar_cmd = bb.utils.which(os.getenv("PATH"), "tar")
128 pkg_path = pkg_info[pkg]["filepath"]
129
130 if not os.path.isfile(pkg_path):
131 bb.fatal("Unable to extract package for '%s'."
132 "File %s doesn't exists" % (pkg, pkg_path))
133
134 tmp_dir = tempfile.mkdtemp()
135 current_dir = os.getcwd()
136 os.chdir(tmp_dir)
137 data_tar = 'data.tar.zst'
138
139 try:
140 cmd = [ar_cmd, 'x', pkg_path]
141 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
142 cmd = [tar_cmd, 'xf', data_tar]
143 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
144 except subprocess.CalledProcessError as e:
145 bb.utils.remove(tmp_dir, recurse=True)
146 bb.fatal("Unable to extract %s package. Command '%s' "
147 "returned %d:\n%s" % (pkg_path, ' '.join(cmd), e.returncode, e.output.decode("utf-8")))
148 except OSError as e:
149 bb.utils.remove(tmp_dir, recurse=True)
150 bb.fatal("Unable to extract %s package. Command '%s' "
151 "returned %d:\n%s at %s" % (pkg_path, ' '.join(cmd), e.errno, e.strerror, e.filename))
152
153 bb.note("Extracted %s to %s" % (pkg_path, tmp_dir))
154 bb.utils.remove(os.path.join(tmp_dir, "debian-binary"))
155 bb.utils.remove(os.path.join(tmp_dir, "control.tar.gz"))
156 os.chdir(current_dir)
157
158 return tmp_dir
159
160 def _handle_intercept_failure(self, registered_pkgs):
161 self.mark_packages("unpacked", registered_pkgs.split())
162
163class OpkgPM(OpkgDpkgPM): 94class OpkgPM(OpkgDpkgPM):
164 def __init__(self, d, target_rootfs, config_file, archs, task_name='target', ipk_repo_workdir="oe-rootfs-repo", filterbydependencies=True, prepare_index=True): 95 def __init__(self, d, target_rootfs, config_file, archs, task_name='target', ipk_repo_workdir="oe-rootfs-repo", filterbydependencies=True, prepare_index=True):
165 super(OpkgPM, self).__init__(d, target_rootfs) 96 super(OpkgPM, self).__init__(d, target_rootfs)
@@ -485,7 +416,7 @@ class OpkgPM(OpkgDpkgPM):
485 Returns a dictionary with the package info. 416 Returns a dictionary with the package info.
486 """ 417 """
487 cmd = "%s %s info %s" % (self.opkg_cmd, self.opkg_args, pkg) 418 cmd = "%s %s info %s" % (self.opkg_cmd, self.opkg_args, pkg)
488 pkg_info = super(OpkgPM, self).package_info(pkg, cmd) 419 pkg_info = self._common_package_info(cmd)
489 420
490 pkg_arch = pkg_info[pkg]["arch"] 421 pkg_arch = pkg_info[pkg]["arch"]
491 pkg_filename = pkg_info[pkg]["filename"] 422 pkg_filename = pkg_info[pkg]["filename"]
@@ -493,19 +424,3 @@ class OpkgPM(OpkgDpkgPM):
493 os.path.join(self.deploy_dir, pkg_arch, pkg_filename) 424 os.path.join(self.deploy_dir, pkg_arch, pkg_filename)
494 425
495 return pkg_info 426 return pkg_info
496
497 def extract(self, pkg):
498 """
499 Returns the path to a tmpdir where resides the contents of a package.
500
501 Deleting the tmpdir is responsability of the caller.
502 """
503 pkg_info = self.package_info(pkg)
504 if not pkg_info:
505 bb.fatal("Unable to get information for package '%s' while "
506 "trying to extract the package." % pkg)
507
508 tmp_dir = super(OpkgPM, self).extract(pkg, pkg_info)
509 bb.utils.remove(os.path.join(tmp_dir, "data.tar.zst"))
510
511 return tmp_dir