def determine_pkg_availability(rhel_repos_content, installed_pkgs): """Compare list of the installed packages to the packages in RHEL repos (as stored in dark matrix-generated static data) to get a dictionary determining the availability of each installed package. """ pkgs = {} pkgs["removed"] = [] pkgs["kept"] = [] pkgs["moved"] = utils.DictWListValues() for installed_pkg in installed_pkgs: if installed_pkg in rhel_repos_content["removed"]: pkgs["removed"].append(installed_pkg) if installed_pkg in rhel_repos_content["kept"]: pkgs["kept"].append(installed_pkg) for moved_to in rhel_repos_content["moved"].keys(): if installed_pkg in rhel_repos_content["moved"][moved_to]: pkgs["moved"][moved_to].append(installed_pkg) return pkgs
def read_repo_files(repo_data_files): """Read content of the single RHEL variant-related dark matrix-generated static repository files which hold information about moved, removed and kept packages. """ rhel_repos_content = {} rhel_repos_content["removed"] = [] rhel_repos_content["kept"] = [] rhel_repos_content["moved"] = utils.DictWListValues() for repo_file in repo_data_files: if "_kept" in repo_file: # The repository names on the original system do not # match those on RHEL, except the base repo (that has no suffix, # like -optional). Therefore all kept packages are put into just # one list, basically representing just the RHEL base repo. The # list will serve just to complete the picture, which packages are # available in RHEL repos. # TODO: This may not be true -> implement logic to cope with repos # different from base repo in which the packages are 'kept' for pkg in utils.get_file_content(repo_file, True): rhel_repos_content["kept"].append(pkg.split(' kept')[0]) if "_removed" in repo_file: # Put all removed packages into one list, no matter in which repo # they are missing. This list will be used to determine which # packages are not available in the RHEL repos. for pkg in utils.get_file_content(repo_file, True): rhel_repos_content["removed"].append(pkg.split(' removed')[0]) if "_moved" in repo_file: # The moved packages are stored into separate dictionaries to # distinguish in which repository is each 'moved' package # available. moved_to = repo_file.rsplit('moved_', 1)[1] for pkg in utils.get_file_content(repo_file, True): rhel_repos_content["moved"][moved_to].append( pkg.split(' moved')[0]) return rhel_repos_content