Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | from abc import ABCMeta, abstractmethod |
| 2 | from oe.utils import execute_pre_post_process |
| 3 | from oe.package_manager import * |
| 4 | from oe.manifest import * |
| 5 | import oe.path |
| 6 | import filecmp |
| 7 | import shutil |
| 8 | import os |
| 9 | import subprocess |
| 10 | import re |
| 11 | |
| 12 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 13 | class Rootfs(object, metaclass=ABCMeta): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14 | """ |
| 15 | This is an abstract class. Do not instantiate this directly. |
| 16 | """ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 18 | def __init__(self, d, progress_reporter=None, logcatcher=None): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | self.d = d |
| 20 | self.pm = None |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 21 | self.image_rootfs = self.d.getVar('IMAGE_ROOTFS') |
| 22 | self.deploydir = self.d.getVar('IMGDEPLOYDIR') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 23 | self.progress_reporter = progress_reporter |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 24 | self.logcatcher = logcatcher |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | |
| 26 | self.install_order = Manifest.INSTALL_ORDER |
| 27 | |
| 28 | @abstractmethod |
| 29 | def _create(self): |
| 30 | pass |
| 31 | |
| 32 | @abstractmethod |
| 33 | def _get_delayed_postinsts(self): |
| 34 | pass |
| 35 | |
| 36 | @abstractmethod |
| 37 | def _save_postinsts(self): |
| 38 | pass |
| 39 | |
| 40 | @abstractmethod |
| 41 | def _log_check(self): |
| 42 | pass |
| 43 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 44 | def _log_check_common(self, type, match): |
| 45 | # Ignore any lines containing log_check to avoid recursion, and ignore |
| 46 | # lines beginning with a + since sh -x may emit code which isn't |
| 47 | # actually executed, but may contain error messages |
| 48 | excludes = [ 'log_check', r'^\+' ] |
| 49 | if hasattr(self, 'log_check_expected_regexes'): |
| 50 | excludes.extend(self.log_check_expected_regexes) |
| 51 | excludes = [re.compile(x) for x in excludes] |
| 52 | r = re.compile(match) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 | log_path = self.d.expand("${T}/log.do_rootfs") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 54 | messages = [] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | with open(log_path, 'r') as log: |
| 56 | for line in log: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 57 | if self.logcatcher and self.logcatcher.contains(line.rstrip()): |
| 58 | continue |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 59 | for ee in excludes: |
| 60 | m = ee.search(line) |
| 61 | if m: |
| 62 | break |
| 63 | if m: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | continue |
| 65 | |
| 66 | m = r.search(line) |
| 67 | if m: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 68 | messages.append('[log_check] %s' % line) |
| 69 | if messages: |
| 70 | if len(messages) == 1: |
| 71 | msg = '1 %s message' % type |
| 72 | else: |
| 73 | msg = '%d %s messages' % (len(messages), type) |
| 74 | msg = '[log_check] %s: found %s in the logfile:\n%s' % \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | (self.d.getVar('PN'), msg, ''.join(messages)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 76 | if type == 'error': |
| 77 | bb.fatal(msg) |
| 78 | else: |
| 79 | bb.warn(msg) |
| 80 | |
| 81 | def _log_check_warn(self): |
| 82 | self._log_check_common('warning', '^(warn|Warn|WARNING:)') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 83 | |
| 84 | def _log_check_error(self): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 85 | self._log_check_common('error', self.log_check_regex) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | |
| 87 | def _insert_feed_uris(self): |
| 88 | if bb.utils.contains("IMAGE_FEATURES", "package-management", |
| 89 | True, False, self.d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 90 | self.pm.insert_feeds_uris(self.d.getVar('PACKAGE_FEED_URIS') or "", |
| 91 | self.d.getVar('PACKAGE_FEED_BASE_PATHS') or "", |
| 92 | self.d.getVar('PACKAGE_FEED_ARCHS')) |
| 93 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 94 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | """ |
| 96 | The _cleanup() method should be used to clean-up stuff that we don't really |
| 97 | want to end up on target. For example, in the case of RPM, the DB locks. |
| 98 | The method is called, once, at the end of create() method. |
| 99 | """ |
| 100 | @abstractmethod |
| 101 | def _cleanup(self): |
| 102 | pass |
| 103 | |
| 104 | def _setup_dbg_rootfs(self, dirs): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 105 | gen_debugfs = self.d.getVar('IMAGE_GEN_DEBUGFS') or '0' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 106 | if gen_debugfs != '1': |
| 107 | return |
| 108 | |
| 109 | bb.note(" Renaming the original rootfs...") |
| 110 | try: |
| 111 | shutil.rmtree(self.image_rootfs + '-orig') |
| 112 | except: |
| 113 | pass |
| 114 | os.rename(self.image_rootfs, self.image_rootfs + '-orig') |
| 115 | |
| 116 | bb.note(" Creating debug rootfs...") |
| 117 | bb.utils.mkdirhier(self.image_rootfs) |
| 118 | |
| 119 | bb.note(" Copying back package database...") |
| 120 | for dir in dirs: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 121 | if not os.path.isdir(self.image_rootfs + '-orig' + dir): |
| 122 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | bb.utils.mkdirhier(self.image_rootfs + os.path.dirname(dir)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 124 | shutil.copytree(self.image_rootfs + '-orig' + dir, self.image_rootfs + dir, symlinks=True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 125 | |
| 126 | cpath = oe.cachedpath.CachedPath() |
| 127 | # Copy files located in /usr/lib/debug or /usr/src/debug |
| 128 | for dir in ["/usr/lib/debug", "/usr/src/debug"]: |
| 129 | src = self.image_rootfs + '-orig' + dir |
| 130 | if cpath.exists(src): |
| 131 | dst = self.image_rootfs + dir |
| 132 | bb.utils.mkdirhier(os.path.dirname(dst)) |
| 133 | shutil.copytree(src, dst) |
| 134 | |
| 135 | # Copy files with suffix '.debug' or located in '.debug' dir. |
| 136 | for root, dirs, files in cpath.walk(self.image_rootfs + '-orig'): |
| 137 | relative_dir = root[len(self.image_rootfs + '-orig'):] |
| 138 | for f in files: |
| 139 | if f.endswith('.debug') or '/.debug' in relative_dir: |
| 140 | bb.utils.mkdirhier(self.image_rootfs + relative_dir) |
| 141 | shutil.copy(os.path.join(root, f), |
| 142 | self.image_rootfs + relative_dir) |
| 143 | |
| 144 | bb.note(" Install complementary '*-dbg' packages...") |
| 145 | self.pm.install_complementary('*-dbg') |
| 146 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 147 | if self.d.getVar('PACKAGE_DEBUG_SPLIT_STYLE') == 'debug-with-srcpkg': |
| 148 | bb.note(" Install complementary '*-src' packages...") |
| 149 | self.pm.install_complementary('*-src') |
| 150 | |
| 151 | """ |
| 152 | Install additional debug packages. Possibility to install additional packages, |
| 153 | which are not automatically installed as complementary package of |
| 154 | standard one, e.g. debug package of static libraries. |
| 155 | """ |
| 156 | extra_debug_pkgs = self.d.getVar('IMAGE_INSTALL_DEBUGFS') |
| 157 | if extra_debug_pkgs: |
| 158 | bb.note(" Install extra debug packages...") |
| 159 | self.pm.install(extra_debug_pkgs.split(), True) |
| 160 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 161 | bb.note(" Rename debug rootfs...") |
| 162 | try: |
| 163 | shutil.rmtree(self.image_rootfs + '-dbg') |
| 164 | except: |
| 165 | pass |
| 166 | os.rename(self.image_rootfs, self.image_rootfs + '-dbg') |
| 167 | |
| 168 | bb.note(" Restoreing original rootfs...") |
| 169 | os.rename(self.image_rootfs + '-orig', self.image_rootfs) |
| 170 | |
| 171 | def _exec_shell_cmd(self, cmd): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 172 | fakerootcmd = self.d.getVar('FAKEROOT') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 173 | if fakerootcmd is not None: |
| 174 | exec_cmd = [fakerootcmd, cmd] |
| 175 | else: |
| 176 | exec_cmd = cmd |
| 177 | |
| 178 | try: |
| 179 | subprocess.check_output(exec_cmd, stderr=subprocess.STDOUT) |
| 180 | except subprocess.CalledProcessError as e: |
| 181 | return("Command '%s' returned %d:\n%s" % (e.cmd, e.returncode, e.output)) |
| 182 | |
| 183 | return None |
| 184 | |
| 185 | def create(self): |
| 186 | bb.note("###### Generate rootfs #######") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 187 | pre_process_cmds = self.d.getVar("ROOTFS_PREPROCESS_COMMAND") |
| 188 | post_process_cmds = self.d.getVar("ROOTFS_POSTPROCESS_COMMAND") |
| 189 | rootfs_post_install_cmds = self.d.getVar('ROOTFS_POSTINSTALL_COMMAND') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 190 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 191 | bb.utils.mkdirhier(self.image_rootfs) |
| 192 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 193 | bb.utils.mkdirhier(self.deploydir) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 194 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 195 | execute_pre_post_process(self.d, pre_process_cmds) |
| 196 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 197 | if self.progress_reporter: |
| 198 | self.progress_reporter.next_stage() |
| 199 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 200 | # call the package manager dependent create method |
| 201 | self._create() |
| 202 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 203 | sysconfdir = self.image_rootfs + self.d.getVar('sysconfdir') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 204 | bb.utils.mkdirhier(sysconfdir) |
| 205 | with open(sysconfdir + "/version", "w+") as ver: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 206 | ver.write(self.d.getVar('BUILDNAME') + "\n") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 207 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 208 | execute_pre_post_process(self.d, rootfs_post_install_cmds) |
| 209 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 210 | self.pm.run_intercepts() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 211 | |
| 212 | execute_pre_post_process(self.d, post_process_cmds) |
| 213 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 214 | if self.progress_reporter: |
| 215 | self.progress_reporter.next_stage() |
| 216 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 217 | if bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", |
| 218 | True, False, self.d): |
| 219 | delayed_postinsts = self._get_delayed_postinsts() |
| 220 | if delayed_postinsts is not None: |
| 221 | bb.fatal("The following packages could not be configured " |
| 222 | "offline and rootfs is read-only: %s" % |
| 223 | delayed_postinsts) |
| 224 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 225 | if self.d.getVar('USE_DEVFS') != "1": |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 226 | self._create_devfs() |
| 227 | |
| 228 | self._uninstall_unneeded() |
| 229 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 230 | if self.progress_reporter: |
| 231 | self.progress_reporter.next_stage() |
| 232 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 233 | self._insert_feed_uris() |
| 234 | |
| 235 | self._run_ldconfig() |
| 236 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 237 | if self.d.getVar('USE_DEPMOD') != "0": |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 238 | self._generate_kernel_module_deps() |
| 239 | |
| 240 | self._cleanup() |
| 241 | self._log_check() |
| 242 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 243 | if self.progress_reporter: |
| 244 | self.progress_reporter.next_stage() |
| 245 | |
| 246 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 247 | def _uninstall_unneeded(self): |
| 248 | # Remove unneeded init script symlinks |
| 249 | delayed_postinsts = self._get_delayed_postinsts() |
| 250 | if delayed_postinsts is None: |
| 251 | if os.path.exists(self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts")): |
| 252 | self._exec_shell_cmd(["update-rc.d", "-f", "-r", |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 253 | self.d.getVar('IMAGE_ROOTFS'), |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 254 | "run-postinsts", "remove"]) |
| 255 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 256 | image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 257 | True, False, self.d) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 258 | image_rorfs_force = self.d.getVar('FORCE_RO_REMOVE') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 259 | |
| 260 | if image_rorfs or image_rorfs_force == "1": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 261 | # Remove components that we don't need if it's a read-only rootfs |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 262 | unneeded_pkgs = self.d.getVar("ROOTFS_RO_UNNEEDED").split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 263 | pkgs_installed = image_list_installed_packages(self.d) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 264 | # Make sure update-alternatives is removed last. This is |
| 265 | # because its database has to available while uninstalling |
| 266 | # other packages, allowing alternative symlinks of packages |
| 267 | # to be uninstalled or to be managed correctly otherwise. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 268 | provider = self.d.getVar("VIRTUAL-RUNTIME_update-alternatives") |
| 269 | pkgs_to_remove = sorted([pkg for pkg in pkgs_installed if pkg in unneeded_pkgs], key=lambda x: x == provider) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 270 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 271 | # update-alternatives provider is removed in its own remove() |
| 272 | # call because all package managers do not guarantee the packages |
| 273 | # are removed in the order they given in the list (which is |
| 274 | # passed to the command line). The sorting done earlier is |
| 275 | # utilized to implement the 2-stage removal. |
| 276 | if len(pkgs_to_remove) > 1: |
| 277 | self.pm.remove(pkgs_to_remove[:-1], False) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 278 | if len(pkgs_to_remove) > 0: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 279 | self.pm.remove([pkgs_to_remove[-1]], False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 280 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 281 | if delayed_postinsts: |
| 282 | self._save_postinsts() |
| 283 | if image_rorfs: |
| 284 | bb.warn("There are post install scripts " |
| 285 | "in a read-only rootfs") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 286 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 287 | post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 288 | execute_pre_post_process(self.d, post_uninstall_cmds) |
| 289 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 290 | runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management", |
| 291 | True, False, self.d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 292 | if not runtime_pkgmanage: |
| 293 | # Remove the package manager data files |
| 294 | self.pm.remove_packaging_data() |
| 295 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 296 | def _run_ldconfig(self): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 297 | if self.d.getVar('LDCONFIGDEPEND'): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 298 | bb.note("Executing: ldconfig -r" + self.image_rootfs + "-c new -v") |
| 299 | self._exec_shell_cmd(['ldconfig', '-r', self.image_rootfs, '-c', |
| 300 | 'new', '-v']) |
| 301 | |
| 302 | def _check_for_kernel_modules(self, modules_dir): |
| 303 | for root, dirs, files in os.walk(modules_dir, topdown=True): |
| 304 | for name in files: |
| 305 | found_ko = name.endswith(".ko") |
| 306 | if found_ko: |
| 307 | return found_ko |
| 308 | return False |
| 309 | |
| 310 | def _generate_kernel_module_deps(self): |
| 311 | modules_dir = os.path.join(self.image_rootfs, 'lib', 'modules') |
| 312 | # if we don't have any modules don't bother to do the depmod |
| 313 | if not self._check_for_kernel_modules(modules_dir): |
| 314 | bb.note("No Kernel Modules found, not running depmod") |
| 315 | return |
| 316 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 317 | kernel_abi_ver_file = oe.path.join(self.d.getVar('PKGDATA_DIR'), "kernel-depmod", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 318 | 'kernel-abiversion') |
| 319 | if not os.path.exists(kernel_abi_ver_file): |
| 320 | bb.fatal("No kernel-abiversion file found (%s), cannot run depmod, aborting" % kernel_abi_ver_file) |
| 321 | |
| 322 | kernel_ver = open(kernel_abi_ver_file).read().strip(' \n') |
| 323 | versioned_modules_dir = os.path.join(self.image_rootfs, modules_dir, kernel_ver) |
| 324 | |
| 325 | bb.utils.mkdirhier(versioned_modules_dir) |
| 326 | |
| 327 | self._exec_shell_cmd(['depmodwrapper', '-a', '-b', self.image_rootfs, kernel_ver]) |
| 328 | |
| 329 | """ |
| 330 | Create devfs: |
| 331 | * IMAGE_DEVICE_TABLE is the old name to an absolute path to a device table file |
| 332 | * IMAGE_DEVICE_TABLES is a new name for a file, or list of files, seached |
| 333 | for in the BBPATH |
| 334 | If neither are specified then the default name of files/device_table-minimal.txt |
| 335 | is searched for in the BBPATH (same as the old version.) |
| 336 | """ |
| 337 | def _create_devfs(self): |
| 338 | devtable_list = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 339 | devtable = self.d.getVar('IMAGE_DEVICE_TABLE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 340 | if devtable is not None: |
| 341 | devtable_list.append(devtable) |
| 342 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 343 | devtables = self.d.getVar('IMAGE_DEVICE_TABLES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 344 | if devtables is None: |
| 345 | devtables = 'files/device_table-minimal.txt' |
| 346 | for devtable in devtables.split(): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 347 | devtable_list.append("%s" % bb.utils.which(self.d.getVar('BBPATH'), devtable)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 348 | |
| 349 | for devtable in devtable_list: |
| 350 | self._exec_shell_cmd(["makedevs", "-r", |
| 351 | self.image_rootfs, "-D", devtable]) |
| 352 | |
| 353 | |
| 354 | class RpmRootfs(Rootfs): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 355 | def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None): |
| 356 | super(RpmRootfs, self).__init__(d, progress_reporter, logcatcher) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 357 | self.log_check_regex = r'(unpacking of archive failed|Cannot find package'\ |
| 358 | r'|exit 1|ERROR: |Error: |Error |ERROR '\ |
| 359 | r'|Failed |Failed: |Failed$|Failed\(\d+\):)' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 360 | self.manifest = RpmManifest(d, manifest_dir) |
| 361 | |
| 362 | self.pm = RpmPM(d, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 363 | d.getVar('IMAGE_ROOTFS'), |
| 364 | self.d.getVar('TARGET_VENDOR') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 365 | ) |
| 366 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 367 | self.inc_rpm_image_gen = self.d.getVar('INC_RPM_IMAGE_GEN') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 368 | if self.inc_rpm_image_gen != "1": |
| 369 | bb.utils.remove(self.image_rootfs, True) |
| 370 | else: |
| 371 | self.pm.recovery_packaging_data() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 372 | bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS'), True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 373 | |
| 374 | self.pm.create_configs() |
| 375 | |
| 376 | ''' |
| 377 | While rpm incremental image generation is enabled, it will remove the |
| 378 | unneeded pkgs by comparing the new install solution manifest and the |
| 379 | old installed manifest. |
| 380 | ''' |
| 381 | def _create_incremental(self, pkgs_initial_install): |
| 382 | if self.inc_rpm_image_gen == "1": |
| 383 | |
| 384 | pkgs_to_install = list() |
| 385 | for pkg_type in pkgs_initial_install: |
| 386 | pkgs_to_install += pkgs_initial_install[pkg_type] |
| 387 | |
| 388 | installed_manifest = self.pm.load_old_install_solution() |
| 389 | solution_manifest = self.pm.dump_install_solution(pkgs_to_install) |
| 390 | |
| 391 | pkg_to_remove = list() |
| 392 | for pkg in installed_manifest: |
| 393 | if pkg not in solution_manifest: |
| 394 | pkg_to_remove.append(pkg) |
| 395 | |
| 396 | self.pm.update() |
| 397 | |
| 398 | bb.note('incremental update -- upgrade packages in place ') |
| 399 | self.pm.upgrade() |
| 400 | if pkg_to_remove != []: |
| 401 | bb.note('incremental removed: %s' % ' '.join(pkg_to_remove)) |
| 402 | self.pm.remove(pkg_to_remove) |
| 403 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 404 | self.pm.autoremove() |
| 405 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 406 | def _create(self): |
| 407 | pkgs_to_install = self.manifest.parse_initial_manifest() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 408 | rpm_pre_process_cmds = self.d.getVar('RPM_PREPROCESS_COMMANDS') |
| 409 | rpm_post_process_cmds = self.d.getVar('RPM_POSTPROCESS_COMMANDS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 410 | |
| 411 | # update PM index files |
| 412 | self.pm.write_index() |
| 413 | |
| 414 | execute_pre_post_process(self.d, rpm_pre_process_cmds) |
| 415 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 416 | if self.progress_reporter: |
| 417 | self.progress_reporter.next_stage() |
| 418 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 419 | if self.inc_rpm_image_gen == "1": |
| 420 | self._create_incremental(pkgs_to_install) |
| 421 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 422 | if self.progress_reporter: |
| 423 | self.progress_reporter.next_stage() |
| 424 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 425 | self.pm.update() |
| 426 | |
| 427 | pkgs = [] |
| 428 | pkgs_attempt = [] |
| 429 | for pkg_type in pkgs_to_install: |
| 430 | if pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY: |
| 431 | pkgs_attempt += pkgs_to_install[pkg_type] |
| 432 | else: |
| 433 | pkgs += pkgs_to_install[pkg_type] |
| 434 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 435 | if self.progress_reporter: |
| 436 | self.progress_reporter.next_stage() |
| 437 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 438 | self.pm.install(pkgs) |
| 439 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 440 | if self.progress_reporter: |
| 441 | self.progress_reporter.next_stage() |
| 442 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 443 | self.pm.install(pkgs_attempt, True) |
| 444 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 445 | if self.progress_reporter: |
| 446 | self.progress_reporter.next_stage() |
| 447 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 448 | self.pm.install_complementary() |
| 449 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 450 | if self.progress_reporter: |
| 451 | self.progress_reporter.next_stage() |
| 452 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 453 | self._setup_dbg_rootfs(['/etc', '/var/lib/rpm', '/var/cache/dnf', '/var/lib/dnf']) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 454 | |
| 455 | execute_pre_post_process(self.d, rpm_post_process_cmds) |
| 456 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 457 | if self.inc_rpm_image_gen == "1": |
| 458 | self.pm.backup_packaging_data() |
| 459 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 460 | if self.progress_reporter: |
| 461 | self.progress_reporter.next_stage() |
| 462 | |
| 463 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 464 | @staticmethod |
| 465 | def _depends_list(): |
| 466 | return ['DEPLOY_DIR_RPM', 'INC_RPM_IMAGE_GEN', 'RPM_PREPROCESS_COMMANDS', |
| 467 | 'RPM_POSTPROCESS_COMMANDS', 'RPM_PREFER_ELF_ARCH'] |
| 468 | |
| 469 | def _get_delayed_postinsts(self): |
| 470 | postinst_dir = self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts") |
| 471 | if os.path.isdir(postinst_dir): |
| 472 | files = os.listdir(postinst_dir) |
| 473 | for f in files: |
| 474 | bb.note('Delayed package scriptlet: %s' % f) |
| 475 | return files |
| 476 | |
| 477 | return None |
| 478 | |
| 479 | def _save_postinsts(self): |
| 480 | # this is just a stub. For RPM, the failed postinstalls are |
| 481 | # already saved in /etc/rpm-postinsts |
| 482 | pass |
| 483 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 484 | def _log_check(self): |
| 485 | self._log_check_warn() |
| 486 | self._log_check_error() |
| 487 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 488 | def _cleanup(self): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 489 | if bb.utils.contains("IMAGE_FEATURES", "package-management", True, False, self.d): |
| 490 | self.pm._invoke_dnf(["clean", "all"]) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 491 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 492 | |
| 493 | class DpkgOpkgRootfs(Rootfs): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 494 | def __init__(self, d, progress_reporter=None, logcatcher=None): |
| 495 | super(DpkgOpkgRootfs, self).__init__(d, progress_reporter, logcatcher) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 496 | |
| 497 | def _get_pkgs_postinsts(self, status_file): |
| 498 | def _get_pkg_depends_list(pkg_depends): |
| 499 | pkg_depends_list = [] |
| 500 | # filter version requirements like libc (>= 1.1) |
| 501 | for dep in pkg_depends.split(', '): |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 502 | m_dep = re.match(r"^(.*) \(.*\)$", dep) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 503 | if m_dep: |
| 504 | dep = m_dep.group(1) |
| 505 | pkg_depends_list.append(dep) |
| 506 | |
| 507 | return pkg_depends_list |
| 508 | |
| 509 | pkgs = {} |
| 510 | pkg_name = "" |
| 511 | pkg_status_match = False |
| 512 | pkg_depends = "" |
| 513 | |
| 514 | with open(status_file) as status: |
| 515 | data = status.read() |
| 516 | status.close() |
| 517 | for line in data.split('\n'): |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 518 | m_pkg = re.match(r"^Package: (.*)", line) |
| 519 | m_status = re.match(r"^Status:.*unpacked", line) |
| 520 | m_depends = re.match(r"^Depends: (.*)", line) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 521 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 522 | #Only one of m_pkg, m_status or m_depends is not None at time |
| 523 | #If m_pkg is not None, we started a new package |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 524 | if m_pkg is not None: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 525 | #Get Package name |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 526 | pkg_name = m_pkg.group(1) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 527 | #Make sure we reset other variables |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 528 | pkg_status_match = False |
| 529 | pkg_depends = "" |
| 530 | elif m_status is not None: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 531 | #New status matched |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 532 | pkg_status_match = True |
| 533 | elif m_depends is not None: |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 534 | #New depends macthed |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 535 | pkg_depends = m_depends.group(1) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 536 | else: |
| 537 | pass |
| 538 | |
| 539 | #Now check if we can process package depends and postinst |
| 540 | if "" != pkg_name and pkg_status_match: |
| 541 | pkgs[pkg_name] = _get_pkg_depends_list(pkg_depends) |
| 542 | else: |
| 543 | #Not enough information |
| 544 | pass |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 545 | |
| 546 | # remove package dependencies not in postinsts |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 547 | pkg_names = list(pkgs.keys()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 548 | for pkg_name in pkg_names: |
| 549 | deps = pkgs[pkg_name][:] |
| 550 | |
| 551 | for d in deps: |
| 552 | if d not in pkg_names: |
| 553 | pkgs[pkg_name].remove(d) |
| 554 | |
| 555 | return pkgs |
| 556 | |
| 557 | def _get_delayed_postinsts_common(self, status_file): |
| 558 | def _dep_resolve(graph, node, resolved, seen): |
| 559 | seen.append(node) |
| 560 | |
| 561 | for edge in graph[node]: |
| 562 | if edge not in resolved: |
| 563 | if edge in seen: |
| 564 | raise RuntimeError("Packages %s and %s have " \ |
| 565 | "a circular dependency in postinsts scripts." \ |
| 566 | % (node, edge)) |
| 567 | _dep_resolve(graph, edge, resolved, seen) |
| 568 | |
| 569 | resolved.append(node) |
| 570 | |
| 571 | pkg_list = [] |
| 572 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 573 | pkgs = None |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 574 | if not self.d.getVar('PACKAGE_INSTALL').strip(): |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 575 | bb.note("Building empty image") |
| 576 | else: |
| 577 | pkgs = self._get_pkgs_postinsts(status_file) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 578 | if pkgs: |
| 579 | root = "__packagegroup_postinst__" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 580 | pkgs[root] = list(pkgs.keys()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 581 | _dep_resolve(pkgs, root, pkg_list, []) |
| 582 | pkg_list.remove(root) |
| 583 | |
| 584 | if len(pkg_list) == 0: |
| 585 | return None |
| 586 | |
| 587 | return pkg_list |
| 588 | |
| 589 | def _save_postinsts_common(self, dst_postinst_dir, src_postinst_dir): |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 590 | if bb.utils.contains("IMAGE_FEATURES", "package-management", |
| 591 | True, False, self.d): |
| 592 | return |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 593 | num = 0 |
| 594 | for p in self._get_delayed_postinsts(): |
| 595 | bb.utils.mkdirhier(dst_postinst_dir) |
| 596 | |
| 597 | if os.path.exists(os.path.join(src_postinst_dir, p + ".postinst")): |
| 598 | shutil.copy(os.path.join(src_postinst_dir, p + ".postinst"), |
| 599 | os.path.join(dst_postinst_dir, "%03d-%s" % (num, p))) |
| 600 | |
| 601 | num += 1 |
| 602 | |
| 603 | class DpkgRootfs(DpkgOpkgRootfs): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 604 | def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None): |
| 605 | super(DpkgRootfs, self).__init__(d, progress_reporter, logcatcher) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 606 | self.log_check_regex = '^E:' |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 607 | self.log_check_expected_regexes = \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 608 | [ |
| 609 | "^E: Unmet dependencies." |
| 610 | ] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 611 | |
| 612 | bb.utils.remove(self.image_rootfs, True) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 613 | bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS'), True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 614 | self.manifest = DpkgManifest(d, manifest_dir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 615 | self.pm = DpkgPM(d, d.getVar('IMAGE_ROOTFS'), |
| 616 | d.getVar('PACKAGE_ARCHS'), |
| 617 | d.getVar('DPKG_ARCH')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 618 | |
| 619 | |
| 620 | def _create(self): |
| 621 | pkgs_to_install = self.manifest.parse_initial_manifest() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 622 | deb_pre_process_cmds = self.d.getVar('DEB_PREPROCESS_COMMANDS') |
| 623 | deb_post_process_cmds = self.d.getVar('DEB_POSTPROCESS_COMMANDS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 624 | |
| 625 | alt_dir = self.d.expand("${IMAGE_ROOTFS}/var/lib/dpkg/alternatives") |
| 626 | bb.utils.mkdirhier(alt_dir) |
| 627 | |
| 628 | # update PM index files |
| 629 | self.pm.write_index() |
| 630 | |
| 631 | execute_pre_post_process(self.d, deb_pre_process_cmds) |
| 632 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 633 | if self.progress_reporter: |
| 634 | self.progress_reporter.next_stage() |
| 635 | # Don't support incremental, so skip that |
| 636 | self.progress_reporter.next_stage() |
| 637 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 638 | self.pm.update() |
| 639 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 640 | if self.progress_reporter: |
| 641 | self.progress_reporter.next_stage() |
| 642 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 643 | for pkg_type in self.install_order: |
| 644 | if pkg_type in pkgs_to_install: |
| 645 | self.pm.install(pkgs_to_install[pkg_type], |
| 646 | [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) |
| 647 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 648 | if self.progress_reporter: |
| 649 | # Don't support attemptonly, so skip that |
| 650 | self.progress_reporter.next_stage() |
| 651 | self.progress_reporter.next_stage() |
| 652 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 653 | self.pm.install_complementary() |
| 654 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 655 | if self.progress_reporter: |
| 656 | self.progress_reporter.next_stage() |
| 657 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 658 | self._setup_dbg_rootfs(['/var/lib/dpkg']) |
| 659 | |
| 660 | self.pm.fix_broken_dependencies() |
| 661 | |
| 662 | self.pm.mark_packages("installed") |
| 663 | |
| 664 | self.pm.run_pre_post_installs() |
| 665 | |
| 666 | execute_pre_post_process(self.d, deb_post_process_cmds) |
| 667 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 668 | if self.progress_reporter: |
| 669 | self.progress_reporter.next_stage() |
| 670 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 671 | @staticmethod |
| 672 | def _depends_list(): |
| 673 | return ['DEPLOY_DIR_DEB', 'DEB_SDK_ARCH', 'APTCONF_TARGET', 'APT_ARGS', 'DPKG_ARCH', 'DEB_PREPROCESS_COMMANDS', 'DEB_POSTPROCESS_COMMANDS'] |
| 674 | |
| 675 | def _get_delayed_postinsts(self): |
| 676 | status_file = self.image_rootfs + "/var/lib/dpkg/status" |
| 677 | return self._get_delayed_postinsts_common(status_file) |
| 678 | |
| 679 | def _save_postinsts(self): |
| 680 | dst_postinst_dir = self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/deb-postinsts") |
| 681 | src_postinst_dir = self.d.expand("${IMAGE_ROOTFS}/var/lib/dpkg/info") |
| 682 | return self._save_postinsts_common(dst_postinst_dir, src_postinst_dir) |
| 683 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 684 | def _log_check(self): |
| 685 | self._log_check_warn() |
| 686 | self._log_check_error() |
| 687 | |
| 688 | def _cleanup(self): |
| 689 | pass |
| 690 | |
| 691 | |
| 692 | class OpkgRootfs(DpkgOpkgRootfs): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 693 | def __init__(self, d, manifest_dir, progress_reporter=None, logcatcher=None): |
| 694 | super(OpkgRootfs, self).__init__(d, progress_reporter, logcatcher) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 695 | self.log_check_regex = '(exit 1|Collected errors)' |
| 696 | |
| 697 | self.manifest = OpkgManifest(d, manifest_dir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 698 | self.opkg_conf = self.d.getVar("IPKGCONF_TARGET") |
| 699 | self.pkg_archs = self.d.getVar("ALL_MULTILIB_PACKAGE_ARCHS") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 700 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 701 | self.inc_opkg_image_gen = self.d.getVar('INC_IPK_IMAGE_GEN') or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 702 | if self._remove_old_rootfs(): |
| 703 | bb.utils.remove(self.image_rootfs, True) |
| 704 | self.pm = OpkgPM(d, |
| 705 | self.image_rootfs, |
| 706 | self.opkg_conf, |
| 707 | self.pkg_archs) |
| 708 | else: |
| 709 | self.pm = OpkgPM(d, |
| 710 | self.image_rootfs, |
| 711 | self.opkg_conf, |
| 712 | self.pkg_archs) |
| 713 | self.pm.recover_packaging_data() |
| 714 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 715 | bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS'), True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 716 | |
| 717 | def _prelink_file(self, root_dir, filename): |
| 718 | bb.note('prelink %s in %s' % (filename, root_dir)) |
| 719 | prelink_cfg = oe.path.join(root_dir, |
| 720 | self.d.expand('${sysconfdir}/prelink.conf')) |
| 721 | if not os.path.exists(prelink_cfg): |
| 722 | shutil.copy(self.d.expand('${STAGING_DIR_NATIVE}${sysconfdir_native}/prelink.conf'), |
| 723 | prelink_cfg) |
| 724 | |
| 725 | cmd_prelink = self.d.expand('${STAGING_DIR_NATIVE}${sbindir_native}/prelink') |
| 726 | self._exec_shell_cmd([cmd_prelink, |
| 727 | '--root', |
| 728 | root_dir, |
| 729 | '-amR', |
| 730 | '-N', |
| 731 | '-c', |
| 732 | self.d.expand('${sysconfdir}/prelink.conf')]) |
| 733 | |
| 734 | ''' |
| 735 | Compare two files with the same key twice to see if they are equal. |
| 736 | If they are not equal, it means they are duplicated and come from |
| 737 | different packages. |
| 738 | 1st: Comapre them directly; |
| 739 | 2nd: While incremental image creation is enabled, one of the |
| 740 | files could be probaly prelinked in the previous image |
| 741 | creation and the file has been changed, so we need to |
| 742 | prelink the other one and compare them. |
| 743 | ''' |
| 744 | def _file_equal(self, key, f1, f2): |
| 745 | |
| 746 | # Both of them are not prelinked |
| 747 | if filecmp.cmp(f1, f2): |
| 748 | return True |
| 749 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 750 | if bb.data.inherits_class('image-prelink', self.d): |
| 751 | if self.image_rootfs not in f1: |
| 752 | self._prelink_file(f1.replace(key, ''), f1) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 753 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 754 | if self.image_rootfs not in f2: |
| 755 | self._prelink_file(f2.replace(key, ''), f2) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 756 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 757 | # Both of them are prelinked |
| 758 | if filecmp.cmp(f1, f2): |
| 759 | return True |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 760 | |
| 761 | # Not equal |
| 762 | return False |
| 763 | |
| 764 | """ |
| 765 | This function was reused from the old implementation. |
| 766 | See commit: "image.bbclass: Added variables for multilib support." by |
| 767 | Lianhao Lu. |
| 768 | """ |
| 769 | def _multilib_sanity_test(self, dirs): |
| 770 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 771 | allow_replace = self.d.getVar("MULTILIBRE_ALLOW_REP") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 772 | if allow_replace is None: |
| 773 | allow_replace = "" |
| 774 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 775 | allow_rep = re.compile(re.sub(r"\|$", r"", allow_replace)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 776 | error_prompt = "Multilib check error:" |
| 777 | |
| 778 | files = {} |
| 779 | for dir in dirs: |
| 780 | for root, subfolders, subfiles in os.walk(dir): |
| 781 | for file in subfiles: |
| 782 | item = os.path.join(root, file) |
| 783 | key = str(os.path.join("/", os.path.relpath(item, dir))) |
| 784 | |
| 785 | valid = True |
| 786 | if key in files: |
| 787 | #check whether the file is allow to replace |
| 788 | if allow_rep.match(key): |
| 789 | valid = True |
| 790 | else: |
| 791 | if os.path.exists(files[key]) and \ |
| 792 | os.path.exists(item) and \ |
| 793 | not self._file_equal(key, files[key], item): |
| 794 | valid = False |
| 795 | bb.fatal("%s duplicate files %s %s is not the same\n" % |
| 796 | (error_prompt, item, files[key])) |
| 797 | |
| 798 | #pass the check, add to list |
| 799 | if valid: |
| 800 | files[key] = item |
| 801 | |
| 802 | def _multilib_test_install(self, pkgs): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 803 | ml_temp = self.d.getVar("MULTILIB_TEMP_ROOTFS") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 804 | bb.utils.mkdirhier(ml_temp) |
| 805 | |
| 806 | dirs = [self.image_rootfs] |
| 807 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 808 | for variant in self.d.getVar("MULTILIB_VARIANTS").split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 809 | ml_target_rootfs = os.path.join(ml_temp, variant) |
| 810 | |
| 811 | bb.utils.remove(ml_target_rootfs, True) |
| 812 | |
| 813 | ml_opkg_conf = os.path.join(ml_temp, |
| 814 | variant + "-" + os.path.basename(self.opkg_conf)) |
| 815 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 816 | ml_pm = OpkgPM(self.d, ml_target_rootfs, ml_opkg_conf, self.pkg_archs, prepare_index=False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 817 | |
| 818 | ml_pm.update() |
| 819 | ml_pm.install(pkgs) |
| 820 | |
| 821 | dirs.append(ml_target_rootfs) |
| 822 | |
| 823 | self._multilib_sanity_test(dirs) |
| 824 | |
| 825 | ''' |
| 826 | While ipk incremental image generation is enabled, it will remove the |
| 827 | unneeded pkgs by comparing the old full manifest in previous existing |
| 828 | image and the new full manifest in the current image. |
| 829 | ''' |
| 830 | def _remove_extra_packages(self, pkgs_initial_install): |
| 831 | if self.inc_opkg_image_gen == "1": |
| 832 | # Parse full manifest in previous existing image creation session |
| 833 | old_full_manifest = self.manifest.parse_full_manifest() |
| 834 | |
| 835 | # Create full manifest for the current image session, the old one |
| 836 | # will be replaced by the new one. |
| 837 | self.manifest.create_full(self.pm) |
| 838 | |
| 839 | # Parse full manifest in current image creation session |
| 840 | new_full_manifest = self.manifest.parse_full_manifest() |
| 841 | |
| 842 | pkg_to_remove = list() |
| 843 | for pkg in old_full_manifest: |
| 844 | if pkg not in new_full_manifest: |
| 845 | pkg_to_remove.append(pkg) |
| 846 | |
| 847 | if pkg_to_remove != []: |
| 848 | bb.note('decremental removed: %s' % ' '.join(pkg_to_remove)) |
| 849 | self.pm.remove(pkg_to_remove) |
| 850 | |
| 851 | ''' |
| 852 | Compare with previous existing image creation, if some conditions |
| 853 | triggered, the previous old image should be removed. |
| 854 | The conditions include any of 'PACKAGE_EXCLUDE, NO_RECOMMENDATIONS |
| 855 | and BAD_RECOMMENDATIONS' has been changed. |
| 856 | ''' |
| 857 | def _remove_old_rootfs(self): |
| 858 | if self.inc_opkg_image_gen != "1": |
| 859 | return True |
| 860 | |
| 861 | vars_list_file = self.d.expand('${T}/vars_list') |
| 862 | |
| 863 | old_vars_list = "" |
| 864 | if os.path.exists(vars_list_file): |
| 865 | old_vars_list = open(vars_list_file, 'r+').read() |
| 866 | |
| 867 | new_vars_list = '%s:%s:%s\n' % \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 868 | ((self.d.getVar('BAD_RECOMMENDATIONS') or '').strip(), |
| 869 | (self.d.getVar('NO_RECOMMENDATIONS') or '').strip(), |
| 870 | (self.d.getVar('PACKAGE_EXCLUDE') or '').strip()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 871 | open(vars_list_file, 'w+').write(new_vars_list) |
| 872 | |
| 873 | if old_vars_list != new_vars_list: |
| 874 | return True |
| 875 | |
| 876 | return False |
| 877 | |
| 878 | def _create(self): |
| 879 | pkgs_to_install = self.manifest.parse_initial_manifest() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 880 | opkg_pre_process_cmds = self.d.getVar('OPKG_PREPROCESS_COMMANDS') |
| 881 | opkg_post_process_cmds = self.d.getVar('OPKG_POSTPROCESS_COMMANDS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 882 | |
Brad Bishop | 004d499 | 2018-10-02 23:54:45 +0200 | [diff] [blame] | 883 | # update PM index files |
| 884 | self.pm.write_index() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 885 | |
| 886 | execute_pre_post_process(self.d, opkg_pre_process_cmds) |
| 887 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 888 | if self.progress_reporter: |
| 889 | self.progress_reporter.next_stage() |
| 890 | # Steps are a bit different in order, skip next |
| 891 | self.progress_reporter.next_stage() |
| 892 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 893 | self.pm.update() |
| 894 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 895 | if self.progress_reporter: |
| 896 | self.progress_reporter.next_stage() |
| 897 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 898 | if self.inc_opkg_image_gen == "1": |
| 899 | self._remove_extra_packages(pkgs_to_install) |
| 900 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 901 | if self.progress_reporter: |
| 902 | self.progress_reporter.next_stage() |
| 903 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 904 | for pkg_type in self.install_order: |
| 905 | if pkg_type in pkgs_to_install: |
| 906 | # For multilib, we perform a sanity test before final install |
| 907 | # If sanity test fails, it will automatically do a bb.fatal() |
| 908 | # and the installation will stop |
| 909 | if pkg_type == Manifest.PKG_TYPE_MULTILIB: |
| 910 | self._multilib_test_install(pkgs_to_install[pkg_type]) |
| 911 | |
| 912 | self.pm.install(pkgs_to_install[pkg_type], |
| 913 | [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) |
| 914 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 915 | if self.progress_reporter: |
| 916 | self.progress_reporter.next_stage() |
| 917 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 918 | self.pm.install_complementary() |
| 919 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 920 | if self.progress_reporter: |
| 921 | self.progress_reporter.next_stage() |
| 922 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 923 | opkg_lib_dir = self.d.getVar('OPKGLIBDIR') |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 924 | opkg_dir = os.path.join(opkg_lib_dir, 'opkg') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 925 | self._setup_dbg_rootfs([opkg_dir]) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 926 | |
| 927 | execute_pre_post_process(self.d, opkg_post_process_cmds) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 928 | |
| 929 | if self.inc_opkg_image_gen == "1": |
| 930 | self.pm.backup_packaging_data() |
| 931 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 932 | if self.progress_reporter: |
| 933 | self.progress_reporter.next_stage() |
| 934 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 935 | @staticmethod |
| 936 | def _depends_list(): |
| 937 | return ['IPKGCONF_SDK', 'IPK_FEED_URIS', 'DEPLOY_DIR_IPK', 'IPKGCONF_TARGET', 'INC_IPK_IMAGE_GEN', 'OPKG_ARGS', 'OPKGLIBDIR', 'OPKG_PREPROCESS_COMMANDS', 'OPKG_POSTPROCESS_COMMANDS', 'OPKGLIBDIR'] |
| 938 | |
| 939 | def _get_delayed_postinsts(self): |
| 940 | status_file = os.path.join(self.image_rootfs, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 941 | self.d.getVar('OPKGLIBDIR').strip('/'), |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 942 | "opkg", "status") |
| 943 | return self._get_delayed_postinsts_common(status_file) |
| 944 | |
| 945 | def _save_postinsts(self): |
| 946 | dst_postinst_dir = self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts") |
| 947 | src_postinst_dir = self.d.expand("${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/info") |
| 948 | return self._save_postinsts_common(dst_postinst_dir, src_postinst_dir) |
| 949 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 950 | def _log_check(self): |
| 951 | self._log_check_warn() |
| 952 | self._log_check_error() |
| 953 | |
| 954 | def _cleanup(self): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 955 | self.pm.remove_lists() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 956 | |
| 957 | def get_class_for_type(imgtype): |
| 958 | return {"rpm": RpmRootfs, |
| 959 | "ipk": OpkgRootfs, |
| 960 | "deb": DpkgRootfs}[imgtype] |
| 961 | |
| 962 | def variable_depends(d, manifest_dir=None): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 963 | img_type = d.getVar('IMAGE_PKGTYPE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 964 | cls = get_class_for_type(img_type) |
| 965 | return cls._depends_list() |
| 966 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 967 | def create_rootfs(d, manifest_dir=None, progress_reporter=None, logcatcher=None): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 968 | env_bkp = os.environ.copy() |
| 969 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 970 | img_type = d.getVar('IMAGE_PKGTYPE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 971 | if img_type == "rpm": |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 972 | RpmRootfs(d, manifest_dir, progress_reporter, logcatcher).create() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 973 | elif img_type == "ipk": |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 974 | OpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 975 | elif img_type == "deb": |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 976 | DpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 977 | |
| 978 | os.environ.clear() |
| 979 | os.environ.update(env_bkp) |
| 980 | |
| 981 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 982 | def image_list_installed_packages(d, rootfs_dir=None): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 983 | if not rootfs_dir: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 984 | rootfs_dir = d.getVar('IMAGE_ROOTFS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 985 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 986 | img_type = d.getVar('IMAGE_PKGTYPE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 987 | if img_type == "rpm": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 988 | return RpmPkgsList(d, rootfs_dir).list_pkgs() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 989 | elif img_type == "ipk": |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 990 | return OpkgPkgsList(d, rootfs_dir, d.getVar("IPKGCONF_TARGET")).list_pkgs() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 991 | elif img_type == "deb": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 992 | return DpkgPkgsList(d, rootfs_dir).list_pkgs() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 993 | |
| 994 | if __name__ == "__main__": |
| 995 | """ |
| 996 | We should be able to run this as a standalone script, from outside bitbake |
| 997 | environment. |
| 998 | """ |
| 999 | """ |
| 1000 | TBD |
| 1001 | """ |