forked from Mirror/pmbootstrap
core: move Config type (MR 2252)
Keeping the Config class in types seemed kinda weird and was just done as a workaround to some cyclical imports. But now things are more in shape let's move it to core. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
b43724fee4
commit
450bc6873d
12 changed files with 55 additions and 48 deletions
|
@ -16,7 +16,7 @@ from .helpers import frontend
|
||||||
from .helpers import logging
|
from .helpers import logging
|
||||||
from .helpers import mount
|
from .helpers import mount
|
||||||
from .helpers import other
|
from .helpers import other
|
||||||
from .core import Chroot, get_context
|
from .core import Chroot, get_context, Config
|
||||||
from .commands import run_command
|
from .commands import run_command
|
||||||
|
|
||||||
# pmbootstrap version
|
# pmbootstrap version
|
||||||
|
|
|
@ -9,7 +9,7 @@ import glob
|
||||||
import pmb.config.pmaports
|
import pmb.config.pmaports
|
||||||
import pmb.helpers.repo
|
import pmb.helpers.repo
|
||||||
import pmb.build
|
import pmb.build
|
||||||
from pmb.types import Config
|
from pmb.core import Config
|
||||||
from pmb.core import get_context
|
from pmb.core import get_context
|
||||||
|
|
||||||
from pmb import commands
|
from pmb import commands
|
||||||
|
|
|
@ -14,7 +14,8 @@ from typing import Any, List, Optional
|
||||||
import pmb.aportgen
|
import pmb.aportgen
|
||||||
import pmb.config
|
import pmb.config
|
||||||
import pmb.config.pmaports
|
import pmb.config.pmaports
|
||||||
from pmb.types import Config, PmbArgs
|
from pmb.core import Config
|
||||||
|
from pmb.types import PmbArgs
|
||||||
import pmb.helpers.cli
|
import pmb.helpers.cli
|
||||||
import pmb.helpers.devices
|
import pmb.helpers.devices
|
||||||
import pmb.helpers.git
|
import pmb.helpers.git
|
||||||
|
|
|
@ -7,8 +7,7 @@ import configparser
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import pmb.config
|
import pmb.config
|
||||||
from pmb.types import Config
|
from pmb.core import Config
|
||||||
from pmb.types import PmbArgs
|
|
||||||
|
|
||||||
|
|
||||||
def sanity_check(cfg: Config, key, allowed, path: Optional[Path] = None):
|
def sanity_check(cfg: Config, key, allowed, path: Optional[Path] = None):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright 2024 Oliver Smith
|
# Copyright 2024 Oliver Smith
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
from pmb.types import Config
|
from pmb.core import Config
|
||||||
import pmb.helpers.ui
|
import pmb.helpers.ui
|
||||||
import pmb.config.pmaports
|
import pmb.config.pmaports
|
||||||
|
|
||||||
|
|
39
pmb/core/config.py
Normal file
39
pmb/core/config.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
import multiprocessing
|
||||||
|
from typing import List, Dict
|
||||||
|
from pathlib import Path
|
||||||
|
import os
|
||||||
|
|
||||||
|
class Config():
|
||||||
|
aports: List[Path] = [Path(os.path.expanduser("~") +
|
||||||
|
"/.local/var/pmbootstrap/cache_git/pmaports")]
|
||||||
|
boot_size: int = 256
|
||||||
|
build_default_device_arch: bool = False
|
||||||
|
build_pkgs_on_install: bool = True
|
||||||
|
ccache_size: str = "5G" # yeahhhh this one has a suffix
|
||||||
|
device: str = "qemu-amd64"
|
||||||
|
extra_packages: str = "none"
|
||||||
|
extra_space: int = 0
|
||||||
|
hostname: str = ""
|
||||||
|
is_default_channel: bool = True
|
||||||
|
jobs: str = str(multiprocessing.cpu_count() + 1)
|
||||||
|
kernel: str = "stable"
|
||||||
|
keymap: str = ""
|
||||||
|
locale: str = "en_US.UTF-8"
|
||||||
|
# NOTE: mirrors use http by default to leverage caching
|
||||||
|
mirror_alpine: str = "http://dl-cdn.alpinelinux.org/alpine/"
|
||||||
|
# NOTE: mirrors_postmarketos variable type is supposed to be
|
||||||
|
# comma-separated string, not a python list or any other type!
|
||||||
|
mirrors_postmarketos: List[str] = ["http://mirror.postmarketos.org/postmarketos/"]
|
||||||
|
qemu_redir_stdio: bool = False
|
||||||
|
ssh_key_glob: str = "~/.ssh/id_*.pub"
|
||||||
|
ssh_keys: bool = False
|
||||||
|
sudo_timer: bool = False
|
||||||
|
systemd: str = "default"
|
||||||
|
timezone: str = "GMT"
|
||||||
|
ui: str = "console"
|
||||||
|
ui_extras: bool = False
|
||||||
|
user: str = "user"
|
||||||
|
work: Path = Path(os.path.expanduser("~") + "/.local/var/pmbootstrap")
|
||||||
|
|
||||||
|
providers: Dict[str, str] = { }
|
|
@ -16,7 +16,8 @@ import pmb.chroot.initfs
|
||||||
import pmb.chroot.other
|
import pmb.chroot.other
|
||||||
import pmb.ci
|
import pmb.ci
|
||||||
import pmb.config
|
import pmb.config
|
||||||
from pmb.types import Config, PathString, PmbArgs
|
from pmb.core import Config
|
||||||
|
from pmb.types import PmbArgs
|
||||||
import pmb.export
|
import pmb.export
|
||||||
import pmb.flasher
|
import pmb.flasher
|
||||||
import pmb.helpers.aportupgrade
|
import pmb.helpers.aportupgrade
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
import pmb.config
|
import pmb.config
|
||||||
import pmb.config.workdir
|
import pmb.config.workdir
|
||||||
import pmb.helpers.git
|
import pmb.helpers.git
|
||||||
from pmb.types import Config, PmbArgs
|
from pmb.core import Config
|
||||||
|
from pmb.types import PmbArgs
|
||||||
from pmb.core import get_context
|
from pmb.core import get_context
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ import pmb.chroot.initfs
|
||||||
import pmb.config
|
import pmb.config
|
||||||
import pmb.config.pmaports
|
import pmb.config.pmaports
|
||||||
from pmb.parse.deviceinfo import Deviceinfo
|
from pmb.parse.deviceinfo import Deviceinfo
|
||||||
from pmb.types import Config, PartitionLayout, PmbArgs
|
from pmb.core import Config
|
||||||
|
from pmb.types import PartitionLayout, PmbArgs
|
||||||
import pmb.helpers.devices
|
import pmb.helpers.devices
|
||||||
from pmb.helpers.mount import mount_device_rootfs
|
from pmb.helpers.mount import mount_device_rootfs
|
||||||
import pmb.helpers.run
|
import pmb.helpers.run
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
from typing import List
|
from typing import List
|
||||||
from pmb.helpers import logging
|
from pmb.helpers import logging
|
||||||
|
|
||||||
from pmb.types import Config
|
from pmb.core import Config
|
||||||
import pmb.helpers.pmaports
|
import pmb.helpers.pmaports
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,9 @@ import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pmb.types import Config, PmbArgs
|
from pmb.core.arch import Arch
|
||||||
|
from pmb.core import Config
|
||||||
|
from pmb.types import PmbArgs
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import argcomplete # type:ignore[import-untyped]
|
import argcomplete # type:ignore[import-untyped]
|
||||||
|
|
37
pmb/types.py
37
pmb/types.py
|
@ -2,8 +2,6 @@
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
import multiprocessing
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Optional, Tuple, TypedDict, Union
|
from typing import Dict, List, Optional, Tuple, TypedDict, Union
|
||||||
|
|
||||||
|
@ -154,38 +152,3 @@ class PmbArgs(Namespace):
|
||||||
xauth: str
|
xauth: str
|
||||||
zap: str
|
zap: str
|
||||||
|
|
||||||
|
|
||||||
class Config():
|
|
||||||
aports: List[Path] = [Path(os.path.expanduser("~") +
|
|
||||||
"/.local/var/pmbootstrap/cache_git/pmaports")]
|
|
||||||
boot_size: int = 256
|
|
||||||
build_default_device_arch: bool = False
|
|
||||||
build_pkgs_on_install: bool = True
|
|
||||||
ccache_size: str = "5G" # yeahhhh this one has a suffix
|
|
||||||
device: str = "qemu-amd64"
|
|
||||||
extra_packages: str = "none"
|
|
||||||
extra_space: int = 0
|
|
||||||
hostname: str = ""
|
|
||||||
is_default_channel: bool = True
|
|
||||||
jobs: str = str(multiprocessing.cpu_count() + 1)
|
|
||||||
kernel: str = "stable"
|
|
||||||
keymap: str = ""
|
|
||||||
locale: str = "en_US.UTF-8"
|
|
||||||
# NOTE: mirrors use http by default to leverage caching
|
|
||||||
mirror_alpine: str = "http://dl-cdn.alpinelinux.org/alpine/"
|
|
||||||
# NOTE: mirrors_postmarketos variable type is supposed to be
|
|
||||||
# comma-separated string, not a python list or any other type!
|
|
||||||
mirrors_postmarketos: List[str] = ["http://mirror.postmarketos.org/postmarketos/"]
|
|
||||||
qemu_redir_stdio: bool = False
|
|
||||||
ssh_key_glob: str = "~/.ssh/id_*.pub"
|
|
||||||
ssh_keys: bool = False
|
|
||||||
sudo_timer: bool = False
|
|
||||||
systemd: str = "default"
|
|
||||||
timezone: str = "GMT"
|
|
||||||
ui: str = "console"
|
|
||||||
ui_extras: bool = False
|
|
||||||
user: str = "user"
|
|
||||||
work: Path = Path(os.path.expanduser("~") + "/.local/var/pmbootstrap")
|
|
||||||
|
|
||||||
providers: Dict[str, str] = { }
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue