diff options
| -rw-r--r-- | meta/lib/oe/rootfs.py | 211 |
1 files changed, 205 insertions, 6 deletions
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py index 659a44d1b2..75fba3911d 100644 --- a/meta/lib/oe/rootfs.py +++ b/meta/lib/oe/rootfs.py | |||
| @@ -217,11 +217,157 @@ class Rootfs(object): | |||
| 217 | 217 | ||
| 218 | 218 | ||
| 219 | class RpmRootfs(Rootfs): | 219 | class RpmRootfs(Rootfs): |
| 220 | def __init__(self, manifest): | 220 | def __init__(self, d, manifest_dir): |
| 221 | super(RpmRootfs, self).__init__(manifest) | 221 | super(RpmRootfs, self).__init__(d) |
| 222 | """ | 222 | |
| 223 | TBD | 223 | self.manifest = RpmManifest(d, manifest_dir) |
| 224 | """ | 224 | |
| 225 | package_archs = { | ||
| 226 | 'default': [], | ||
| 227 | } | ||
| 228 | target_os = { | ||
| 229 | 'default': "", | ||
| 230 | } | ||
| 231 | package_archs['default'] = self.d.getVar("PACKAGE_ARCHS", True).split() | ||
| 232 | # arch order is reversed. This ensures the -best- match is | ||
| 233 | # listed first! | ||
| 234 | package_archs['default'].reverse() | ||
| 235 | target_os['default'] = self.d.getVar("TARGET_OS", True).strip() | ||
| 236 | multilibs = self.d.getVar('MULTILIBS', True) or "" | ||
| 237 | for ext in multilibs.split(): | ||
| 238 | eext = ext.split(':') | ||
| 239 | if len(eext) > 1 and eext[0] == 'multilib': | ||
| 240 | localdata = bb.data.createCopy(self.d) | ||
| 241 | default_tune_key = "DEFAULTTUNE_virtclass-multilib-" + eext[1] | ||
| 242 | default_tune = localdata.getVar(default_tune_key, False) | ||
| 243 | if default_tune: | ||
| 244 | localdata.setVar("DEFAULTTUNE", default_tune) | ||
| 245 | bb.data.update_data(localdata) | ||
| 246 | package_archs[eext[1]] = localdata.getVar('PACKAGE_ARCHS', | ||
| 247 | True).split() | ||
| 248 | package_archs[eext[1]].reverse() | ||
| 249 | target_os[eext[1]] = localdata.getVar("TARGET_OS", | ||
| 250 | True).strip() | ||
| 251 | |||
| 252 | self.pm = RpmPM(d, | ||
| 253 | d.getVar('IMAGE_ROOTFS', True), | ||
| 254 | package_archs, | ||
| 255 | target_os, | ||
| 256 | self.d.getVar('TARGET_VENDOR', True) | ||
| 257 | ) | ||
| 258 | |||
| 259 | self.inc_rpm_image_gen = self.d.getVar('INC_RPM_IMAGE_GEN', True) | ||
| 260 | if self.inc_rpm_image_gen != "1": | ||
| 261 | bb.utils.remove(self.image_rootfs, True) | ||
| 262 | else: | ||
| 263 | self.pm.recovery_packaging_data() | ||
| 264 | bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS', True), True) | ||
| 265 | |||
| 266 | self.pm.create_configs() | ||
| 267 | |||
| 268 | ''' | ||
| 269 | While rpm incremental image generation is enabled, it will remove the | ||
| 270 | unneeded pkgs by comparing the new install solution manifest and the | ||
| 271 | old installed manifest. | ||
| 272 | ''' | ||
| 273 | def _create_incremental(self, pkgs_initial_install): | ||
| 274 | if self.inc_rpm_image_gen == "1": | ||
| 275 | |||
| 276 | pkgs_to_install = list() | ||
| 277 | for pkg_type in pkgs_initial_install: | ||
| 278 | pkgs_to_install += pkgs_initial_install[pkg_type] | ||
| 279 | |||
| 280 | installed_manifest = self.pm.load_old_install_solution() | ||
| 281 | solution_manifest = self.pm.dump_install_solution(pkgs_to_install) | ||
| 282 | |||
| 283 | pkg_to_remove = list() | ||
| 284 | for pkg in installed_manifest: | ||
| 285 | if pkg not in solution_manifest: | ||
| 286 | pkg_to_remove.append(pkg) | ||
| 287 | |||
| 288 | self.pm.update() | ||
| 289 | |||
| 290 | bb.note('incremental update -- upgrade packages in place ') | ||
| 291 | self.pm.upgrade() | ||
| 292 | if pkg_to_remove != []: | ||
| 293 | bb.note('incremental removed: %s' % ' '.join(pkg_to_remove)) | ||
| 294 | self.pm.remove(pkg_to_remove) | ||
| 295 | |||
| 296 | def _create(self): | ||
| 297 | pkgs_to_install = self.manifest.parse_initial_manifest() | ||
| 298 | |||
| 299 | # update PM index files | ||
| 300 | self.pm.write_index() | ||
| 301 | |||
| 302 | self.pm.dump_all_available_pkgs() | ||
| 303 | |||
| 304 | if self.inc_rpm_image_gen == "1": | ||
| 305 | self._create_incremental(pkgs_to_install) | ||
| 306 | |||
| 307 | self.pm.update() | ||
| 308 | |||
| 309 | for pkg_type in self.install_order: | ||
| 310 | if pkg_type in pkgs_to_install: | ||
| 311 | self.pm.install(pkgs_to_install[pkg_type], | ||
| 312 | [False, True][pkg_type == "aop"]) | ||
| 313 | |||
| 314 | self.pm.install_complementary() | ||
| 315 | |||
| 316 | self._log_check() | ||
| 317 | |||
| 318 | if self.inc_rpm_image_gen == "1": | ||
| 319 | self.pm.backup_packaging_data() | ||
| 320 | |||
| 321 | self.pm.rpm_setup_smart_target_config() | ||
| 322 | |||
| 323 | def _get_delayed_postinsts(self): | ||
| 324 | postinst_dir = self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/rpm-postinsts") | ||
| 325 | if os.path.isdir(postinst_dir): | ||
| 326 | files = os.listdir(postinst_dir) | ||
| 327 | for f in files: | ||
| 328 | bb.note('Delayed package scriptlet: %s' % f) | ||
| 329 | return files | ||
| 330 | |||
| 331 | return None | ||
| 332 | |||
| 333 | def _save_postinsts(self): | ||
| 334 | # this is just a stub. For RPM, the failed postinstalls are | ||
| 335 | # already saved in /etc/rpm-postinsts | ||
| 336 | pass | ||
| 337 | |||
| 338 | def _log_check(self): | ||
| 339 | r = re.compile('(unpacking of archive failed|Cannot find package|exit 1|ERR|Fail)') | ||
| 340 | log_path = self.d.expand("${T}/log.do_rootfs") | ||
| 341 | with open(log_path, 'r') as log: | ||
| 342 | found_error = 0 | ||
| 343 | message = "\n" | ||
| 344 | for line in log.read().split('\n'): | ||
| 345 | if 'log_check' in line: | ||
| 346 | continue | ||
| 347 | |||
| 348 | m = r.search(line) | ||
| 349 | if m: | ||
| 350 | found_error = 1 | ||
| 351 | bb.warn('log_check: There were error messages in the logfile') | ||
| 352 | bb.warn('log_check: Matched keyword: [%s]\n\n' % m.group()) | ||
| 353 | |||
| 354 | if found_error >= 1 and found_error <= 5: | ||
| 355 | message += line + '\n' | ||
| 356 | found_error += 1 | ||
| 357 | |||
| 358 | if found_error == 6: | ||
| 359 | bb.fatal(message) | ||
| 360 | |||
| 361 | def _insert_feed_uris(self): | ||
| 362 | pass | ||
| 363 | |||
| 364 | def _handle_intercept_failure(self, registered_pkgs): | ||
| 365 | rpm_postinsts_dir = self.image_rootfs + self.d.expand('${sysconfdir}/rpm-postinsts/') | ||
| 366 | bb.utils.mkdirhier(rpm_postinsts_dir) | ||
| 367 | |||
| 368 | # Save the package postinstalls in /etc/rpm-postinsts | ||
| 369 | for pkg in registered_pkgs: | ||
| 370 | self.pm.save_rpmpostinist(pkg) | ||
| 225 | 371 | ||
| 226 | 372 | ||
| 227 | class DpkgRootfs(Rootfs): | 373 | class DpkgRootfs(Rootfs): |
| @@ -447,7 +593,7 @@ def create_rootfs(d, manifest_dir=None): | |||
| 447 | 593 | ||
| 448 | img_type = d.getVar('IMAGE_PKGTYPE', True) | 594 | img_type = d.getVar('IMAGE_PKGTYPE', True) |
| 449 | if img_type == "rpm": | 595 | if img_type == "rpm": |
| 450 | bb.fatal("RPM backend was not implemented yet...") | 596 | RpmRootfs(d, manifest_dir).create() |
| 451 | elif img_type == "ipk": | 597 | elif img_type == "ipk": |
| 452 | OpkgRootfs(d, manifest_dir).create() | 598 | OpkgRootfs(d, manifest_dir).create() |
| 453 | elif img_type == "deb": | 599 | elif img_type == "deb": |
| @@ -456,6 +602,59 @@ def create_rootfs(d, manifest_dir=None): | |||
| 456 | os.environ.clear() | 602 | os.environ.clear() |
| 457 | os.environ.update(env_bkp) | 603 | os.environ.update(env_bkp) |
| 458 | 604 | ||
| 605 | |||
| 606 | def list_installed_packages(d, format=None, rootfs_dir=None): | ||
| 607 | if not rootfs_dir: | ||
| 608 | rootfs_dir = d.getVar('IMAGE_ROOTFS', True) | ||
| 609 | |||
| 610 | img_type = d.getVar('IMAGE_PKGTYPE', True) | ||
| 611 | if img_type == "rpm": | ||
| 612 | package_archs = { | ||
| 613 | 'default': [], | ||
| 614 | } | ||
| 615 | target_os = { | ||
| 616 | 'default': "", | ||
| 617 | } | ||
| 618 | package_archs['default'] = d.getVar("PACKAGE_ARCHS", True).split() | ||
| 619 | # arch order is reversed. This ensures the -best- match is | ||
| 620 | # listed first! | ||
| 621 | package_archs['default'].reverse() | ||
| 622 | target_os['default'] = d.getVar("TARGET_OS", True).strip() | ||
| 623 | multilibs = d.getVar('MULTILIBS', True) or "" | ||
| 624 | for ext in multilibs.split(): | ||
| 625 | eext = ext.split(':') | ||
| 626 | if len(eext) > 1 and eext[0] == 'multilib': | ||
| 627 | localdata = bb.data.createCopy(d) | ||
| 628 | default_tune_key = "DEFAULTTUNE_virtclass-multilib-" + eext[1] | ||
| 629 | default_tune = localdata.getVar(default_tune_key, False) | ||
| 630 | if default_tune: | ||
| 631 | localdata.setVar("DEFAULTTUNE", default_tune) | ||
| 632 | bb.data.update_data(localdata) | ||
| 633 | package_archs[eext[1]] = localdata.getVar('PACKAGE_ARCHS', | ||
| 634 | True).split() | ||
| 635 | package_archs[eext[1]].reverse() | ||
| 636 | target_os[eext[1]] = localdata.getVar("TARGET_OS", | ||
| 637 | True).strip() | ||
| 638 | |||
| 639 | return RpmPM(d, | ||
| 640 | rootfs_dir, | ||
| 641 | package_archs, | ||
| 642 | target_os, | ||
| 643 | d.getVar('TARGET_VENDOR', True) | ||
| 644 | ).list_installed(format) | ||
| 645 | elif img_type == "ipk": | ||
| 646 | return OpkgPM(d, | ||
| 647 | rootfs_dir, | ||
| 648 | d.getVar("IPKGCONF_TARGET", True), | ||
| 649 | d.getVar("ALL_MULTILIB_PACKAGE_ARCHS", True) | ||
| 650 | ).list_installed(format) | ||
| 651 | elif img_type == "deb": | ||
| 652 | return DpkgPM(d, | ||
| 653 | rootfs_dir, | ||
| 654 | d.getVar('PACKAGE_ARCHS', True), | ||
| 655 | d.getVar('DPKG_ARCH', True) | ||
| 656 | ).list_installed(format) | ||
| 657 | |||
| 459 | if __name__ == "__main__": | 658 | if __name__ == "__main__": |
| 460 | """ | 659 | """ |
| 461 | We should be able to run this as a standalone script, from outside bitbake | 660 | We should be able to run this as a standalone script, from outside bitbake |
