From a17ae67600f94d70d58dfb4d41d2a5a8a5798227 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Sun, 2 Mar 2025 13:39:01 +0100 Subject: [PATCH] distro/repo_config: add support for repos.local.yml --- constants.py | 1 + distro/repo_config.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/constants.py b/constants.py index 2ddd686..564f1fb 100644 --- a/constants.py +++ b/constants.py @@ -30,6 +30,7 @@ POST_INSTALL_CMDS = [ ] REPOS_CONFIG_FILE = "repos.yml" +REPOS_CONFIG_FILE_USER = "repos.local.yml" REPOSITORIES = [ 'boot', diff --git a/distro/repo_config.py b/distro/repo_config.py index 5f32d2b..88092af 100644 --- a/distro/repo_config.py +++ b/distro/repo_config.py @@ -9,7 +9,7 @@ from copy import deepcopy from typing import ClassVar, Optional, Mapping, Union from config.state import config -from constants import Arch, BASE_DISTROS, KUPFER_HTTPS, REPOS_CONFIG_FILE, REPOSITORIES +from constants import Arch, BASE_DISTROS, KUPFER_HTTPS, REPOS_CONFIG_FILE, REPOS_CONFIG_FILE_USER, REPOSITORIES from dictscheme import DictScheme, toml_inline_dicts, TomlPreserveInlineDictEncoder from utils import sha256sum @@ -134,9 +134,11 @@ def get_repo_config( repo_config_file: Optional[str] = None, ) -> tuple[ReposConfigFile, bool]: global _current_config - repo_config_file_default = os.path.join(config.get_path('pkgbuilds'), REPOS_CONFIG_FILE) + user_repo_config = os.path.join(config.get_path('pkgbuilds'), REPOS_CONFIG_FILE_USER) if repo_config_file is None: - repo_config_file_path = repo_config_file_default + repo_config_file_path = os.path.join(config.get_path('pkgbuilds'), REPOS_CONFIG_FILE) + if os.path.exists(user_repo_config): + repo_config_file_path = user_repo_config else: repo_config_file_path = repo_config_file config_exists = os.path.exists(repo_config_file_path) @@ -150,6 +152,9 @@ def get_repo_config( logging.warning(f"{repo_config_file_path} doesn't exist, using built-in repo config defaults") _current_config = deepcopy(REPOS_CONFIG_DEFAULT) return _current_config, False + if os.path.exists(user_repo_config): + repo_config_file_path = user_repo_config + config_exists = True changed = False if (not _current_config) or (config_exists and _current_config._checksum != sha256sum(repo_config_file_path)): if config_exists: