def kernel_version_list(self): # Find all installed rpms that provide 'kernel' # If a PackagePayload is in use, rpm needs to be available try: import rpm except ImportError: raise PayloadError( "failed to import rpm-python, cannot determine kernel versions" ) files = [] ts = rpm.TransactionSet(conf.target.system_root) mi = ts.dbMatch('providename', 'kernel') for hdr in mi: unicode_fnames = (decode_bytes(f) for f in hdr.filenames) # Find all /boot/vmlinuz- files and strip off vmlinuz- files.extend((f.split("/")[-1][8:] for f in unicode_fnames if fnmatch(f, "/boot/vmlinuz-*") or fnmatch( f, "/boot/efi/EFI/%s/vmlinuz-*" % conf.bootloader.efi_dir))) return sorted(files, key=functools.cmp_to_key(payload_utils.version_cmp))
def selected_groups_IDs(self): """ Return list of selected group IDs. :return: List of selected group IDs. :raise PayloadError: If translation is not supported by payload. """ # pylint: disable=try-except-raise try: ret = [] for grp in self.selected_groups(): ret.append(self.group_id(grp)) return ret # Translation feature is not implemented for this payload. except NotImplementedError: raise PayloadError(("Can't translate group names to group ID - " "Group translation is not implemented for %s payload." % self)) except PayloadError as ex: raise PayloadError("Can't translate group names to group ID - {}".format(ex))