Add distros.get_base_distros()

This commit is contained in:
InsanePrawn 2021-09-22 02:32:03 +02:00
parent fef0f07297
commit d08e25fe1b
5 changed files with 33 additions and 8 deletions

View file

@ -28,6 +28,6 @@ RUN pip install -r requirements.txt
COPY . . COPY . .
RUN python -c "import constants; repos='\n'.join(['\n'.join([f'[{repo}]', f'Server = file:///prebuilts/\$repo', '']) for repo in constants.REPOSITORIES]); print(repos)" | tee /etc/pacman.d/kupfer-local RUN python -c "import constants; repos='\n'.join(['\n'.join(['', f'[{repo}]', f'Server = file:///prebuilts/\$repo']) for repo in constants.REPOSITORIES]); print(repos)" | tee -a /etc/pacman.conf
WORKDIR /src WORKDIR /src

View file

@ -7,7 +7,6 @@ import click
CONFIG_DEFAULT_PATH = os.path.join(appdirs.user_config_dir('kupfer'), 'kupferbootstrap.toml') CONFIG_DEFAULT_PATH = os.path.join(appdirs.user_config_dir('kupfer'), 'kupferbootstrap.toml')
PROFILE_DEFAULTS = { PROFILE_DEFAULTS = {
'device': '', 'device': '',
'flavour': '', 'flavour': '',
@ -41,6 +40,7 @@ CONFIG_RUNTIME_DEFAULTS = {
'arch': None, 'arch': None,
} }
def sanitize_config(conf: dict, warn_missing_defaultprofile=True) -> dict: def sanitize_config(conf: dict, warn_missing_defaultprofile=True) -> dict:
"""checks the input config dict for unknown keys and returns only the known parts""" """checks the input config dict for unknown keys and returns only the known parts"""
return merge_configs(conf_new=conf, conf_base={}, warn_missing_defaultprofile=warn_missing_defaultprofile) return merge_configs(conf_new=conf, conf_base={}, warn_missing_defaultprofile=warn_missing_defaultprofile)

View file

@ -47,8 +47,21 @@ ARCHES = [
'aarch64', 'aarch64',
] ]
BASE_DISTROS: { BASE_DISTROS = {
'x86_64': { 'x86_64': {
'': '', 'repos': {
'core': 'http://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch',
'extra': 'http://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch',
'community': 'http://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch',
},
},
'aarch64': {
'repos': {
'core': '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',
'aur': 'http://mirror.archlinuxarm.org/$arch/$repo',
}
}, },
} }

View file

@ -32,7 +32,6 @@ class Repo:
name: str name: str
url_template: str url_template: str
resolved_url: str resolved_url: str
repo_name: str
arch: str arch: str
packages: dict[str, PackageInfo] packages: dict[str, PackageInfo]
options: dict[str, str] options: dict[str, str]
@ -43,11 +42,10 @@ class Repo:
self.remote = not self.resolved_url.startswith('file://') self.remote = not self.resolved_url.startswith('file://')
# TODO # TODO
def __init__(self, name: str, url_template: str, arch: str, repo_name: str, options={}, scan=True): def __init__(self, name: str, url_template: str, arch: str, options={}, scan=True):
self.name = name self.name = name
self.url_template = url_template self.url_template = url_template
self.arch = arch self.arch = arch
self.repo_name = repo_name
self.options = deepcopy(options) self.options = deepcopy(options)
if scan: if scan:
self.scan() self.scan()
@ -86,3 +84,17 @@ class Distro:
assert (repo.packages is not None) assert (repo.packages is not None)
for package in repo.packages: for package in repo.packages:
results[package.name] = package results[package.name] = package
_base_distros: dict[str, Distro] = None
def get_base_distros() -> dict[str, Distro]:
global _base_distros
if not _base_distros:
_distros: dict[str, Distro] = {}
for arch, distro_conf in BASE_DISTROS.items():
repos = {name: RepoInfo(url_template=url) for name, url in distro_conf['repos'].items()}
_distros[arch] = Distro(arch=arch, repo_infos=repos, scan=False)
_base_distros = _distros
return _base_distros

View file

@ -354,7 +354,7 @@ def setup_dependencies_and_sources(package: Package, chroot: str, repo_dir: str
makepkg_setup_args = [ makepkg_setup_args = [
'--nobuild', '--nobuild',
'--holdver', '--holdver',
'--nodeps' '--nodeps',
] ]
if (package.mode == 'cross' and enable_crosscompile): if (package.mode == 'cross' and enable_crosscompile):
logging.info('Setting up dependencies for cross-compilation') logging.info('Setting up dependencies for cross-compilation')