distro: add Distro.{scan,is_scanned}()
This commit is contained in:
parent
bcf7450235
commit
1a58b136e3
1 changed files with 13 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
from typing import Optional, Mapping
|
||||
|
||||
from constants import ARCHES, BASE_DISTROS, REPOSITORIES, KUPFER_HTTPS, CHROOT_PATHS
|
||||
from constants import Arch, ARCHES, BASE_DISTROS, REPOSITORIES, KUPFER_HTTPS, CHROOT_PATHS
|
||||
from generator import generate_pacman_conf_body
|
||||
from config import config
|
||||
|
||||
|
@ -12,7 +12,7 @@ class Distro:
|
|||
repos: Mapping[str, Repo]
|
||||
arch: str
|
||||
|
||||
def __init__(self, arch: str, repo_infos: dict[str, RepoInfo], scan=False):
|
||||
def __init__(self, arch: Arch, repo_infos: dict[str, RepoInfo], scan=False):
|
||||
assert (arch in ARCHES)
|
||||
self.arch = arch
|
||||
self.repos = dict[str, Repo]()
|
||||
|
@ -41,6 +41,17 @@ class Distro:
|
|||
body = generate_pacman_conf_body(self.arch, check_space=check_space)
|
||||
return body + self.repos_config_snippet(extra_repos)
|
||||
|
||||
def scan(self, lazy=True):
|
||||
for repo in self.repos.values():
|
||||
if not (lazy and repo.scanned):
|
||||
repo.scan()
|
||||
|
||||
def is_scanned(self):
|
||||
for repo in self.repos.values():
|
||||
if not repo.scanned:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def get_base_distro(arch: str) -> Distro:
|
||||
repos = {name: RepoInfo(url_template=url) for name, url in BASE_DISTROS[arch]['repos'].items()}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue