stages: add org.osbuild.pacman.mirrorlist.conf
Stage for configuring the pacman mirrorlist file.
This commit is contained in:
parent
11f8eef5b5
commit
b7fe5c724f
1 changed files with 47 additions and 0 deletions
47
stages/org.osbuild.pacman.mirrorlist.conf
Executable file
47
stages/org.osbuild.pacman.mirrorlist.conf
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/python3
|
||||
"""
|
||||
configure pacman's mirrorlist
|
||||
"""
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"filename": {
|
||||
"type": "string",
|
||||
"default": "/etc/pacman.d/mirrorlist"
|
||||
},
|
||||
"mirrors": {
|
||||
"type": "array",
|
||||
"description": "Mirror locations for pacman",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"examples": ["https://archlinux.org/$repo/os/$arch"]
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
filename = options.get("filename", "/etc/pacman.d/mirrorlist").lstrip("/")
|
||||
mirrors = options.get("mirrors", [])
|
||||
filepath = pathlib.Path(filename)
|
||||
|
||||
os.makedirs(os.path.join(tree, *filepath.parts[:-1]), exist_ok=True)
|
||||
mirrorpath = os.path.join(tree, *filepath.parts)
|
||||
with open(mirrorpath, "w", encoding="utf-8") as cfgfile:
|
||||
cfgfile.write("\n".join(f"Server = {m}\n" for m in mirrors))
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
Loading…
Add table
Add a link
Reference in a new issue