stages: add the ability to configure pacman repos
Without configured repositories the generated pacman.conf isn't super useful. Pacman supports two different ways to configure a repository either with a Server = line or sourced from pacman's mirrorlist.
This commit is contained in:
parent
20231c8918
commit
25d43dd82e
1 changed files with 45 additions and 0 deletions
|
|
@ -15,6 +15,37 @@ SCHEMA = """
|
|||
"type": "string",
|
||||
"description": "pacman architecture",
|
||||
"default": "x86_64"
|
||||
},
|
||||
"repositories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"oneOf": [
|
||||
{ "required": ["name", "server"] },
|
||||
{ "required": ["name", "include"] }
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"siglevels": {
|
||||
"type": "array",
|
||||
"minLength": 1,
|
||||
"maxLength": 2,
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": ["Required", "Optional", "Never", "TrustAll", "TrustedOnly"]
|
||||
}
|
||||
},
|
||||
"server": {
|
||||
"type": "string"
|
||||
},
|
||||
"include": {
|
||||
"type": "string",
|
||||
"default": "/etc/pacman.d/mirrorlist"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
|
@ -22,12 +53,26 @@ SCHEMA = """
|
|||
|
||||
def main(tree, options):
|
||||
arch = options.get("architecture", "x86_64")
|
||||
repositories = options.get("repositories", [])
|
||||
cfg = f"""
|
||||
[options]
|
||||
Architecture = {arch}
|
||||
SigLevel = Required DatabaseOptional
|
||||
LocalFileSigLevel = Optional
|
||||
"""
|
||||
for repo in repositories:
|
||||
entry = f"[{repo['name']}]\n"
|
||||
siglevels = repo.get('siglevels', [])
|
||||
include = repo.get('include', '/etc/pacman.d/mirrorlist')
|
||||
if siglevels:
|
||||
siglevelstr = ' '.join(siglevels)
|
||||
entry += f"SigLevel = {siglevelstr}\n"
|
||||
if 'server' in repo:
|
||||
entry += f"Server = {repo['server']}\n"
|
||||
if 'include' in repo:
|
||||
entry += f"Include = {include}\n"
|
||||
cfg += entry + "\n"
|
||||
|
||||
os.makedirs(os.path.join(tree, "etc"), exist_ok=True)
|
||||
cfgpath = os.path.join(tree, "etc", "pacman.conf")
|
||||
with open(cfgpath, "w", encoding="utf-8") as cfgfile:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue