def is_valid_install_disk(tree_dir): """Is the disk a valid installation repository? Success criteria: - Disk must be already mounted at tree_dir. - A .discinfo file exists. - Third line of .discinfo equals current architecture. :param str tree_dir: Where the disk is mounted. :rtype: bool """ try: with open(join_paths(tree_dir, ".discinfo"), "r") as f: f.readline() # throw away timestamp f.readline() # throw away description arch = f.readline().strip() if arch == get_arch(): return True except OSError: pass return False
def verify_opal_compatibility(storage, constraints, report_error, report_warning): """ Verify the OPAL compatibility. :param storage: a storage to check :param constraints: a dictionary of constraints :param report_error: a function for error reporting :param report_warning: a function for warning reporting """ if arch.get_arch() == "ppc64le" and arch.is_powernv(): # Check the kernel version. version = _get_opal_firmware_kernel_version() if _check_opal_firmware_kernel_version(version, "5.10"): return # Is /boot on XFS? dev = storage.mountpoints.get("/boot") or storage.mountpoints.get("/") if dev and dev.format and dev.format.type == "xfs": report_warning(_( "Your firmware doesn't support XFS file system features " "on the /boot file system. The system will not be bootable. " "Please, upgrade the firmware or change the file system type." ))
def _find_first_iso_image(path, mount_path="/mnt/install/cdimage"): """Find the first iso image in path. :param str path: path to the directory with iso image(s); this also supports pointing to a specific .iso image :param str mount_path: path for mounting the ISO when checking it is valid FIXME once payloads are modularized: - mount_path should lose the legacy default :return: basename of the image - file name without path :rtype: str or None """ try: os.stat(path) except OSError: return None arch = get_arch() discinfo_path = os.path.join(mount_path, ".discinfo") if os.path.isfile(path) and path.endswith(".iso"): files = [os.path.basename(path)] path = os.path.dirname(path) else: files = os.listdir(path) for fn in files: what = os.path.join(path, fn) log.debug("Checking %s", what) if not _is_iso_image(what): continue log.debug("Mounting %s on %s", what, mount_path) try: blivet.util.mount(what, mount_path, fstype="iso9660", options="ro") except OSError: continue if not os.access(discinfo_path, os.R_OK): blivet.util.umount(mount_path) continue log.debug("Reading .discinfo") disc_info = DiscInfo() # TODO replace next 2 blocks with: # pyanaconda.modules.payloads.source.utils.is_valid_install_disk try: disc_info.load(discinfo_path) disc_arch = disc_info.arch except Exception as ex: # pylint: disable=broad-except log.warning(".discinfo file can't be loaded: %s", ex) continue log.debug("discArch = %s", disc_arch) if disc_arch != arch: log.warning( "Architectures mismatch in find_first_iso_image: %s != %s", disc_arch, arch) blivet.util.umount(mount_path) continue # If there's no repodata, there's no point in trying to # install from it. if not _check_repodata(mount_path): log.warning("%s doesn't have a valid repodata, skipping", what) blivet.util.umount(mount_path) continue # warn user if images appears to be wrong size if os.stat(what)[stat.ST_SIZE] % 2048: log.warning( "The ISO image %s has a size which is not " "a multiple of 2048 bytes. This may mean it " "was corrupted on transfer to this computer.", what) blivet.util.umount(mount_path) continue log.info("Found disc at %s", fn) blivet.util.umount(mount_path) return fn return None
class FakeEddEntry(edd.EddEntry): def __init__(self, sysfspath, **kw): edd.EddEntry.__init__(self, sysfspath) for (name, value) in kw.items(): self.__dict__[name] = value def load(self): pass def __repr__(self): return "<FakeEddEntry%s>" % (self._fmt(' ', ''),) @unittest.skipUnless(arch.get_arch() in ['x86', 'x86_64'], reason='incompatible arch') class EddTestCase(unittest.TestCase): def __init__(self, *args, **kwds): super(EddTestCase, self).__init__(*args, **kwds) self._edd_logger = None # these don't follow PEP8 because unittest.TestCase expects them this way self.maxDiff = None self.longMessage = True def setUp(self): super(EddTestCase, self).setUp() if 'WORKSPACE' in os.environ.keys(): ws = os.environ['WORKSPACE']