summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/package_manager/ipk
diff options
context:
space:
mode:
authorPhilip Lorenz <philip.lorenz@bmw.de>2024-05-16 09:24:38 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-05-28 09:38:23 +0100
commitf7e9eb03d2d9b69514a902692e5539a1b7661c1f (patch)
treef47ee9cc8bb803040c0eb9218f75f6c2043089dd /meta/lib/oe/package_manager/ipk
parentb2a59134dcbf0a8fffa76076bc578ecd5791c968 (diff)
downloadpoky-f7e9eb03d2d9b69514a902692e5539a1b7661c1f.tar.gz
package_manager: Move OpkgDpkgPM into common module
The OpkgDpkgPM class was introduced to share common functionality between the Opkg and Debian package manager implementations. However, for unknown reasons , the refactoring done in 5bc67f55028407de78ac09f97f9a47b165ae8760 duplicated the common class into the deb and ipk modules. Undo this part of the change by moving the common base class into a newly created module. The two variants did not diverge a lot (next to the payload name generalization, the Debian variant missed 17e2eaed036e1da8e7cb42cb3de51b9523ba54ec) and as such no regressions should be expected. (From OE-Core rev: c7830c5879f6fa68fa9f47ee59b7bf7f2d276c81) Signed-off-by: Philip Lorenz <philip.lorenz@bmw.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/package_manager/ipk')
-rw-r--r--meta/lib/oe/package_manager/ipk/__init__.py78
1 files changed, 1 insertions, 77 deletions
diff --git a/meta/lib/oe/package_manager/ipk/__init__.py b/meta/lib/oe/package_manager/ipk/__init__.py
index 47e72cc7a6..23536294b0 100644
--- a/meta/lib/oe/package_manager/ipk/__init__.py
+++ b/meta/lib/oe/package_manager/ipk/__init__.py
@@ -4,11 +4,11 @@
4# SPDX-License-Identifier: GPL-2.0-only 4# SPDX-License-Identifier: GPL-2.0-only
5# 5#
6 6
7import glob
8import re 7import re
9import shutil 8import shutil
10import subprocess 9import subprocess
11from oe.package_manager import * 10from oe.package_manager import *
11from oe.package_manager.common_deb_ipk import OpkgDpkgPM
12 12
13class OpkgIndexer(Indexer): 13class OpkgIndexer(Indexer):
14 def write_index(self): 14 def write_index(self):
@@ -91,82 +91,6 @@ class PMPkgsList(PkgsList):
91 return opkg_query(cmd_output) 91 return opkg_query(cmd_output)
92 92
93 93
94
95class OpkgDpkgPM(PackageManager):
96 def __init__(self, d, target_rootfs):
97 """
98 This is an abstract class. Do not instantiate this directly.
99 """
100 super(OpkgDpkgPM, self).__init__(d, target_rootfs)
101
102 def package_info(self, pkg, cmd):
103 """
104 Returns a dictionary with the package info.
105
106 This method extracts the common parts for Opkg and Dpkg
107 """
108
109 proc = subprocess.run(cmd, capture_output=True, encoding="utf-8", shell=True)
110 if proc.returncode:
111 bb.fatal("Unable to list available packages. Command '%s' "
112 "returned %d:\n%s" % (cmd, proc.returncode, proc.stderr))
113 elif proc.stderr:
114 bb.note("Command '%s' returned stderr: %s" % (cmd, proc.stderr))
115
116 return opkg_query(proc.stdout)
117
118 def extract(self, pkg, pkg_info):
119 """
120 Returns the path to a tmpdir where resides the contents of a package.
121
122 Deleting the tmpdir is responsability of the caller.
123
124 This method extracts the common parts for Opkg and Dpkg
125 """
126
127 ar_cmd = bb.utils.which(os.getenv("PATH"), "ar")
128 tar_cmd = bb.utils.which(os.getenv("PATH"), "tar")
129 pkg_path = pkg_info[pkg]["filepath"]
130
131 if not os.path.isfile(pkg_path):
132 bb.fatal("Unable to extract package for '%s'."
133 "File %s doesn't exists" % (pkg, pkg_path))
134
135 tmp_dir = tempfile.mkdtemp()
136 current_dir = os.getcwd()
137 os.chdir(tmp_dir)
138
139 try:
140 cmd = [ar_cmd, 'x', pkg_path]
141 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
142 data_tar = glob.glob("data.tar.*")
143 if len(data_tar) != 1:
144 bb.fatal("Unable to extract %s package. Failed to identify "
145 "data tarball (found tarballs '%s').",
146 pkg_path, data_tar)
147 data_tar = data_tar[0]
148 cmd = [tar_cmd, 'xf', data_tar]
149 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
150 except subprocess.CalledProcessError as e:
151 bb.utils.remove(tmp_dir, recurse=True)
152 bb.fatal("Unable to extract %s package. Command '%s' "
153 "returned %d:\n%s" % (pkg_path, ' '.join(cmd), e.returncode, e.output.decode("utf-8")))
154 except OSError as e:
155 bb.utils.remove(tmp_dir, recurse=True)
156 bb.fatal("Unable to extract %s package. Command '%s' "
157 "returned %d:\n%s at %s" % (pkg_path, ' '.join(cmd), e.errno, e.strerror, e.filename))
158
159 bb.note("Extracted %s to %s" % (pkg_path, tmp_dir))
160 bb.utils.remove(os.path.join(tmp_dir, "debian-binary"))
161 bb.utils.remove(os.path.join(tmp_dir, "control.tar.gz"))
162 bb.utils.remove(os.path.join(tmp_dir, data_tar))
163 os.chdir(current_dir)
164
165 return tmp_dir
166
167 def _handle_intercept_failure(self, registered_pkgs):
168 self.mark_packages("unpacked", registered_pkgs.split())
169
170class OpkgPM(OpkgDpkgPM): 94class OpkgPM(OpkgDpkgPM):
171 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):
172 super(OpkgPM, self).__init__(d, target_rootfs) 96 super(OpkgPM, self).__init__(d, target_rootfs)