Merge branch 'prawn/reposyamllocal' into 'dev'

distro/repo_config: add support for repos.local.yml

See merge request kupfer/kupferbootstrap!62
This commit is contained in:
Prawn 2025-03-02 23:55:37 +00:00
commit 87fddda06e
4 changed files with 13 additions and 10 deletions

View file

@ -31,6 +31,7 @@ pytest:
- 'echo "kupfer ALL = (ALL) NOPASSWD: ALL" > /etc/sudoers.d/kupfer_all' - 'echo "kupfer ALL = (ALL) NOPASSWD: ALL" > /etc/sudoers.d/kupfer_all'
- useradd -m kupfer - useradd -m kupfer
- chmod 777 . - chmod 777 .
- usermod --unlock --expiredate="" nobody
script: script:
- script -e -c 'su kupfer -s /bin/bash -c "INTEGRATION_TESTS_USE_GLOBAL_CONFIG=TRUE KUPFERBOOTSTRAP_WRAPPED=DOCKER ./pytest.sh --junit-xml=pytest-report.xml --cov-report=xml:coverage.xml integration_tests.py"' - script -e -c 'su kupfer -s /bin/bash -c "INTEGRATION_TESTS_USE_GLOBAL_CONFIG=TRUE KUPFERBOOTSTRAP_WRAPPED=DOCKER ./pytest.sh --junit-xml=pytest-report.xml --cov-report=xml:coverage.xml integration_tests.py"'
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/' coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'

View file

@ -1,7 +1,7 @@
import atexit import atexit
import os import os
from typing import ClassVar, Optional from typing import ClassVar, Optional, cast
from config.state import config from config.state import config
from constants import Arch, BASE_PACKAGES from constants import Arch, BASE_PACKAGES
@ -20,15 +20,14 @@ class DeviceChroot(BuildChroot):
_copy_base: ClassVar[bool] = False _copy_base: ClassVar[bool] = False
def create_rootfs(self, reset, pacman_conf_target, active_previously): def create_rootfs(self, reset, pacman_conf_target, active_previously):
clss = BuildChroot if self.copy_base else BaseChroot
makedir(config.get_path('chroots')) makedir(config.get_path('chroots'))
root_makedir(self.get_path()) root_makedir(self.get_path())
if not self.copy_base: if not self.copy_base:
pacman_conf_target = os.path.join(get_temp_dir(register_cleanup=True), f'pacman-{self.name}.conf') pacman_conf_target = os.path.join(get_temp_dir(register_cleanup=True), f'pacman-{self.name}.conf')
self.write_pacman_conf(in_chroot=False, absolute_path=pacman_conf_target) self.write_pacman_conf(in_chroot=False, absolute_path=pacman_conf_target)
BaseChroot.create_rootfs(cast(BaseChroot, self), reset, pacman_conf_target, active_previously)
clss.create_rootfs(self, reset, pacman_conf_target, active_previously) else:
BuildChroot.create_rootfs(self, reset, pacman_conf_target, active_previously)
def mount_rootfs(self, source_path: str, fs_type: Optional[str] = None, options: list[str] = [], allow_overlay: bool = False): def mount_rootfs(self, source_path: str, fs_type: Optional[str] = None, options: list[str] = [], allow_overlay: bool = False):
if self.active: if self.active:

View file

@ -30,6 +30,7 @@ POST_INSTALL_CMDS = [
] ]
REPOS_CONFIG_FILE = "repos.yml" REPOS_CONFIG_FILE = "repos.yml"
REPOS_CONFIG_FILE_USER = "repos.local.yml"
REPOSITORIES = [ REPOSITORIES = [
'boot', 'boot',
@ -59,7 +60,6 @@ TargetArch: TypeAlias = Arch
ALARM_REPOS = { ALARM_REPOS = {
'core': 'http://mirror.archlinuxarm.org/$arch/$repo', 'core': 'http://mirror.archlinuxarm.org/$arch/$repo',
'extra': 'http://mirror.archlinuxarm.org/$arch/$repo', 'extra': 'http://mirror.archlinuxarm.org/$arch/$repo',
'community': 'http://mirror.archlinuxarm.org/$arch/$repo',
'alarm': 'http://mirror.archlinuxarm.org/$arch/$repo', 'alarm': 'http://mirror.archlinuxarm.org/$arch/$repo',
'aur': 'http://mirror.archlinuxarm.org/$arch/$repo', 'aur': 'http://mirror.archlinuxarm.org/$arch/$repo',
} }
@ -69,7 +69,6 @@ BASE_DISTROS: dict[DistroArch, dict[str, dict[str, str]]] = {
'repos': { 'repos': {
'core': 'https://geo.mirror.pkgbuild.com/$repo/os/$arch', 'core': 'https://geo.mirror.pkgbuild.com/$repo/os/$arch',
'extra': 'https://geo.mirror.pkgbuild.com/$repo/os/$arch', 'extra': 'https://geo.mirror.pkgbuild.com/$repo/os/$arch',
'community': 'https://geo.mirror.pkgbuild.com/$repo/os/$arch',
}, },
}, },
'aarch64': { 'aarch64': {

View file

@ -9,7 +9,7 @@ from copy import deepcopy
from typing import ClassVar, Optional, Mapping, Union from typing import ClassVar, Optional, Mapping, Union
from config.state import config 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 dictscheme import DictScheme, toml_inline_dicts, TomlPreserveInlineDictEncoder
from utils import sha256sum from utils import sha256sum
@ -134,9 +134,11 @@ def get_repo_config(
repo_config_file: Optional[str] = None, repo_config_file: Optional[str] = None,
) -> tuple[ReposConfigFile, bool]: ) -> tuple[ReposConfigFile, bool]:
global _current_config global _current_config
repo_config_file_default = os.path.join(config.get_path('pkgbuilds'), REPOS_CONFIG_FILE)
if repo_config_file is None: 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)
user_repo_config = os.path.join(config.get_path('pkgbuilds'), REPOS_CONFIG_FILE_USER)
if os.path.exists(user_repo_config):
repo_config_file_path = user_repo_config
else: else:
repo_config_file_path = repo_config_file repo_config_file_path = repo_config_file
config_exists = os.path.exists(repo_config_file_path) config_exists = os.path.exists(repo_config_file_path)
@ -150,6 +152,8 @@ def get_repo_config(
logging.warning(f"{repo_config_file_path} doesn't exist, using built-in repo config defaults") logging.warning(f"{repo_config_file_path} doesn't exist, using built-in repo config defaults")
_current_config = deepcopy(REPOS_CONFIG_DEFAULT) _current_config = deepcopy(REPOS_CONFIG_DEFAULT)
return _current_config, False return _current_config, False
if os.path.exists(user_repo_config):
repo_config_file_path = user_repo_config
changed = False changed = False
if (not _current_config) or (config_exists and _current_config._checksum != sha256sum(repo_config_file_path)): if (not _current_config) or (config_exists and _current_config._checksum != sha256sum(repo_config_file_path)):
if config_exists: if config_exists: