diff --git a/pmb/config/pmaports.py b/pmb/config/pmaports.py index 702b574b..fb1a1a7c 100644 --- a/pmb/config/pmaports.py +++ b/pmb/config/pmaports.py @@ -216,9 +216,6 @@ def switch_to_channel_branch(args: PmbArgs, channel_new): " fix what git complained about, then try again: " f"{args.aports}") - # Invalidate all caches - pmb.helpers.other.init_cache() - # Verify pmaports.cfg on new branch read_config(args) return True diff --git a/pmb/helpers/args.py b/pmb/helpers/args.py index eed45e7e..f1e09e66 100644 --- a/pmb/helpers/args.py +++ b/pmb/helpers/args.py @@ -113,7 +113,6 @@ def init(args: PmbArgs): fix_mirrors_postmarketos(args) pmb.config.merge_with_args(args) replace_placeholders(args) - pmb.helpers.other.init_cache() # Initialize logs (we could raise errors below) pmb.helpers.logging.init(args) diff --git a/pmb/helpers/other.py b/pmb/helpers/other.py index 3e3b9547..e59d5108 100644 --- a/pmb/helpers/other.py +++ b/pmb/helpers/other.py @@ -10,6 +10,7 @@ import pmb.config.init from pmb.core.types import PmbArgs import pmb.helpers.pmaports import pmb.helpers.run +from typing import Dict, Any def folder_size(args: PmbArgs, path: Path): @@ -97,7 +98,7 @@ def migrate_work_folder(args: PmbArgs): logging.info("* Building chroots have a different username (#709)") logging.info("Migration will do the following:") logging.info("* Zap your chroots") - logging.info("* Adjust '" + pmb.config.work / "config_abuild/abuild.conf'") + logging.info(f"* Adjust '{pmb.config.work / 'config_abuild/abuild.conf'}'") if not pmb.helpers.cli.confirm(args): raise RuntimeError("Aborted.") @@ -117,8 +118,7 @@ def migrate_work_folder(args: PmbArgs): logging.info("Changelog:") logging.info("* Fix: cache_distfiles was writable for everyone") logging.info("Migration will do the following:") - logging.info("* Fix permissions of '" + pmb.config.work + - "/cache_distfiles'") + logging.info(f"* Fix permissions of '{pmb.config.work / 'cache_distfiles'}'") if not pmb.helpers.cli.confirm(args): raise RuntimeError("Aborted.") @@ -155,7 +155,7 @@ def migrate_work_folder(args: PmbArgs): logging.info(" 'git' instead of using it from an Alpine chroot") logging.info("Migration will do the following:") logging.info("* Check if 'git' is installed") - logging.info("* Change ownership to your user: " + path) + logging.info(f"* Change ownership to your user: {path}") if not pmb.helpers.cli.confirm(args): raise RuntimeError("Aborted.") @@ -236,8 +236,8 @@ def migrate_work_folder(args: PmbArgs): if current != required: raise RuntimeError("Sorry, we can't migrate that automatically. Please" " run 'pmbootstrap shutdown', then delete your" - " current work folder manually ('sudo rm -rf " + - pmb.config.work + "') and start over with 'pmbootstrap" + " current work folder manually ('sudo rm -rf " + f"{pmb.config.work}') and start over with 'pmbootstrap" " init'. All your binary packages and caches will" " be lost.") @@ -281,22 +281,17 @@ def lookup(key): pmb.helpers.other.cache["mycache"][key] = ret return ret """ -cache = None - - -def init_cache(): - global cache - """Add a caching dict (caches parsing of files etc. for the current session).""" - repo_update = {"404": [], "offline_msg_shown": False} - cache = {"apkindex": {}, - "apkbuild": {}, - "apk_min_version_checked": [], - "apk_repository_list_updated": [], - "built": {}, - "find_aport": {}, - "pmb.helpers.package.depends_recurse": {}, - "pmb.helpers.package.get": {}, - "pmb.helpers.repo.update": repo_update, - "pmb.helpers.git.parse_channels_cfg": {}, - "pmb.config.pmaports.read_config": None, - "pmb.config.pmaports.read_config_repos": None} +cache: Dict[str, Any] = { + "apkindex": {}, + "apkbuild": {}, + "apk_min_version_checked": [], + "apk_repository_list_updated": [], + "built": {}, + "find_aport": {}, + "pmb.helpers.package.depends_recurse": {}, + "pmb.helpers.package.get": {}, + "pmb.helpers.repo.update": {"404": [], "offline_msg_shown": False}, + "pmb.helpers.git.parse_channels_cfg": {}, + "pmb.config.pmaports.read_config": None, + "pmb.config.pmaports.read_config_repos": None, +} diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index ab9f5744..b2345e54 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -593,7 +593,6 @@ def package_completer(prefix, action, parser=None, parsed_args=None): args = parsed_args pmb.config.merge_with_args(args) pmb.helpers.args.replace_placeholders(args) - pmb.helpers.other.init_cache() packages = set( package for package in pmb.helpers.pmaports.get_list(args) if package.startswith(prefix))