mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-12 19:09:56 +03:00
Ruff: fix typing.Xxx
is deprecated, use xxx
instead (MR 2327)
This commit is contained in:
parent
61cb4f4abb
commit
18fa4e58a3
47 changed files with 137 additions and 147 deletions
|
@ -6,7 +6,7 @@
|
|||
import sys
|
||||
import os
|
||||
import datetime
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
|
||||
sys.path.insert(0, os.path.abspath("..")) # Allow modules to be found
|
||||
|
@ -47,7 +47,7 @@ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|||
html_theme = "sphinx_rtd_theme"
|
||||
html_favicon = "https://wiki.postmarketos.org/favicon.ico"
|
||||
|
||||
html_theme_options: Dict[str, Any] = {
|
||||
html_theme_options: dict[str, Any] = {
|
||||
"style_nav_header_background": "008b69",
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# Copyright 2023 Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from typing import List
|
||||
from pmb.core.context import get_context
|
||||
from pmb.parse.deviceinfo import Deviceinfo
|
||||
import pmb.helpers.run
|
||||
|
@ -8,7 +7,7 @@ import pmb.aportgen.core
|
|||
import pmb.parse.apkindex
|
||||
|
||||
|
||||
def generate_apkbuild(pkgname: str, deviceinfo: Deviceinfo, patches: List[str]):
|
||||
def generate_apkbuild(pkgname: str, deviceinfo: Deviceinfo, patches: list[str]):
|
||||
device = "-".join(pkgname.split("-")[1:])
|
||||
carch = deviceinfo.arch.kernel()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright 2023 Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import datetime
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, TypedDict
|
||||
from typing import Any, Callable, Optional, TypedDict
|
||||
from pmb.build.other import BuildStatus
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.core.context import Context
|
||||
|
@ -149,7 +149,7 @@ def finish(apkbuild, channel, arch, output: Path, chroot: Chroot, strict=False):
|
|||
logging.info(f"@YELLOW@=>@END@ @BLUE@{channel}/{apkbuild['pkgname']}@END@: Done!")
|
||||
|
||||
|
||||
_package_cache: Dict[str, List[str]] = {}
|
||||
_package_cache: dict[str, list[str]] = {}
|
||||
|
||||
|
||||
def is_cached_or_cache(arch: Arch, pkgname: str) -> bool:
|
||||
|
@ -192,10 +192,10 @@ class BuildQueueItem(TypedDict):
|
|||
name: str
|
||||
arch: Arch # Arch to build for
|
||||
aports: str
|
||||
apkbuild: Dict[str, Any]
|
||||
apkbuild: dict[str, Any]
|
||||
output_path: Path
|
||||
channel: str
|
||||
depends: List[str]
|
||||
depends: list[str]
|
||||
cross: str
|
||||
chroot: Chroot
|
||||
|
||||
|
@ -208,7 +208,7 @@ def process_package(
|
|||
arch: Optional[Arch],
|
||||
fallback_arch: Arch,
|
||||
force: bool,
|
||||
) -> List[str]:
|
||||
) -> list[str]:
|
||||
# Only build when APKBUILD exists
|
||||
base_aports, base_apkbuild = get_apkbuild(pkgname)
|
||||
if not base_apkbuild:
|
||||
|
@ -306,14 +306,14 @@ def process_package(
|
|||
|
||||
def packages(
|
||||
context: Context,
|
||||
pkgnames: List[str],
|
||||
pkgnames: list[str],
|
||||
arch: Optional[Arch] = None,
|
||||
force=False,
|
||||
strict=False,
|
||||
src=None,
|
||||
bootstrap_stage=BootstrapStage.NONE,
|
||||
log_callback: Optional[Callable] = None,
|
||||
) -> List[str]:
|
||||
) -> list[str]:
|
||||
"""
|
||||
Build a package and its dependencies with Alpine Linux' abuild.
|
||||
|
||||
|
@ -331,14 +331,14 @@ def packages(
|
|||
"""
|
||||
global _package_cache
|
||||
|
||||
build_queue: List[BuildQueueItem] = []
|
||||
built_packages: Set[str] = set()
|
||||
build_queue: list[BuildQueueItem] = []
|
||||
built_packages: set[str] = set()
|
||||
|
||||
# Add a package to the build queue, fetch it's dependency, and
|
||||
# add record build helpers to installed (e.g. sccache)
|
||||
def queue_build(
|
||||
aports: Path, apkbuild: Dict[str, Any], depends: List[str], cross: Optional[str] = None
|
||||
) -> List[str]:
|
||||
aports: Path, apkbuild: dict[str, Any], depends: list[str], cross: Optional[str] = None
|
||||
) -> list[str]:
|
||||
# Skip if already queued
|
||||
name = apkbuild["pkgname"]
|
||||
if any(item["name"] == name for item in build_queue):
|
||||
|
@ -389,7 +389,7 @@ def packages(
|
|||
|
||||
# Process the packages we've been asked to build, queuing up any
|
||||
# dependencies that need building as well as the package itself
|
||||
all_dependencies: List[str] = []
|
||||
all_dependencies: list[str] = []
|
||||
for pkgname in pkgnames:
|
||||
all_dependencies += process_package(
|
||||
context, queue_build, pkgname, arch, fallback_arch, force
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
from pathlib import Path
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.helpers import logging
|
||||
from typing import Any, Dict, Optional, Union
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
import pmb.config
|
||||
import pmb.chroot.apk
|
||||
|
@ -38,7 +38,7 @@ def arch_from_deviceinfo(pkgname, aport: Path) -> Optional[Arch]:
|
|||
|
||||
|
||||
@Cache("package")
|
||||
def arch(package: Union[str, Dict[str, Any]]):
|
||||
def arch(package: Union[str, dict[str, Any]]):
|
||||
"""
|
||||
Find a good default in case the user did not specify for which architecture
|
||||
a package should be built.
|
||||
|
@ -83,7 +83,7 @@ def arch(package: Union[str, Dict[str, Any]]):
|
|||
return Arch.native()
|
||||
|
||||
|
||||
def chroot(apkbuild: Dict[str, str], arch: Arch) -> Chroot:
|
||||
def chroot(apkbuild: dict[str, str], arch: Arch) -> Chroot:
|
||||
if arch == Arch.native():
|
||||
return Chroot.native()
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import enum
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
from pmb.core.pkgrepo import pkgrepo_paths
|
||||
import pmb.helpers.run
|
||||
import pmb.chroot
|
||||
|
@ -115,12 +114,12 @@ def override_source(apkbuild, pkgver, src, chroot: Chroot = Chroot.native()):
|
|||
pmb.chroot.user(["mv", append_path + "_", apkbuild_path], chroot)
|
||||
|
||||
|
||||
def mount_pmaports(chroot: Chroot = Chroot.native()) -> Dict[str, Path]:
|
||||
def mount_pmaports(chroot: Chroot = Chroot.native()) -> dict[str, Path]:
|
||||
"""
|
||||
Mount pmaports.git in chroot.
|
||||
|
||||
:param chroot: chroot to target
|
||||
:returns: Dictionary mapping pkgrepo name to dest path
|
||||
:returns: dictionary mapping pkgrepo name to dest path
|
||||
"""
|
||||
dest_paths = {}
|
||||
for repo in pkgrepo_paths(skip_extras=True):
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# Copyright 2023 Robert Yang
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from typing import List
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.core.context import Context
|
||||
from pmb.helpers import logging
|
||||
|
@ -187,7 +186,7 @@ def run_abuild(context: Context, pkgname: str, arch: Arch, apkbuild_path: Path,
|
|||
pmb.chroot.root(["ln", "-s", "/mnt/linux", build_path / "src"])
|
||||
pmb.chroot.root(["ln", "-s", kbuild_out_source, build_path / "src" / kbuild_out])
|
||||
|
||||
cmd: List[PathString] = ["cp", apkbuild_path, chroot / build_path / "APKBUILD"]
|
||||
cmd: list[PathString] = ["cp", apkbuild_path, chroot / build_path / "APKBUILD"]
|
||||
pmb.helpers.run.root(cmd)
|
||||
|
||||
# Create the apk package
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# Copyright 2023 Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from typing import List
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.core.context import Context
|
||||
from pmb.helpers import logging
|
||||
|
@ -16,7 +15,7 @@ from pmb.core import Chroot
|
|||
from pmb.core.context import get_context
|
||||
|
||||
|
||||
def init_abuild_minimal(chroot: Chroot = Chroot.native(), additional_pkgs: List[str] = []):
|
||||
def init_abuild_minimal(chroot: Chroot = Chroot.native(), additional_pkgs: list[str] = []):
|
||||
"""Initialize a minimal chroot with abuild where one can do 'abuild checksum'."""
|
||||
marker = chroot / "tmp/pmb_chroot_abuild_init_done"
|
||||
if os.path.exists(marker):
|
||||
|
|
|
@ -4,7 +4,7 @@ import os
|
|||
from pmb.core.context import get_context
|
||||
from pmb.helpers import logging
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
|
||||
import pmb.build
|
||||
import pmb.build.autodetect
|
||||
|
@ -50,7 +50,7 @@ def get_arch(apkbuild):
|
|||
return apkbuild["arch"][0]
|
||||
|
||||
|
||||
def get_outputdir(pkgname: str, apkbuild: Dict[str, Any]) -> Path:
|
||||
def get_outputdir(pkgname: str, apkbuild: dict[str, Any]) -> Path:
|
||||
"""Get the folder for the kernel compilation output.
|
||||
|
||||
For most APKBUILDs, this is $builddir. But some older ones still use
|
||||
|
|
|
@ -6,7 +6,6 @@ import os
|
|||
from pathlib import Path
|
||||
import shlex
|
||||
import datetime
|
||||
from typing import List
|
||||
|
||||
import pmb.chroot
|
||||
import pmb.config.pmaports
|
||||
|
@ -138,7 +137,7 @@ def index_repo(arch=None):
|
|||
"""
|
||||
pmb.build.init()
|
||||
|
||||
paths: List[Path] = []
|
||||
paths: list[Path] = []
|
||||
|
||||
for channel in pmb.config.pmaports.all_channels():
|
||||
pkgdir: Path = get_context().config.work / "packages" / channel
|
||||
|
|
|
@ -7,7 +7,7 @@ import pmb.chroot.apk_static
|
|||
from pmb.core.arch import Arch
|
||||
from pmb.helpers import logging
|
||||
import shlex
|
||||
from typing import List, Sequence, Set
|
||||
from collections.abc import Sequence
|
||||
|
||||
import pmb.build
|
||||
import pmb.chroot
|
||||
|
@ -28,7 +28,7 @@ from pmb.types import PathString
|
|||
|
||||
@Cache("chroot", "user_repository", mirrors_exclude=[])
|
||||
def update_repository_list(
|
||||
chroot: Chroot, user_repository=False, mirrors_exclude: List[str] = [], check=False
|
||||
chroot: Chroot, user_repository=False, mirrors_exclude: list[str] = [], check=False
|
||||
):
|
||||
"""
|
||||
Update /etc/apk/repositories, if it is outdated (when the user changed the
|
||||
|
@ -42,7 +42,7 @@ def update_repository_list(
|
|||
"""
|
||||
# Read old entries or create folder structure
|
||||
path = chroot / "etc/apk/repositories"
|
||||
lines_old: List[str] = []
|
||||
lines_old: list[str] = []
|
||||
if path.exists():
|
||||
# Read all old lines
|
||||
lines_old = []
|
||||
|
@ -118,7 +118,7 @@ def packages_split_to_add_del(packages):
|
|||
return (to_add, to_del)
|
||||
|
||||
|
||||
def packages_get_locally_built_apks(packages, arch: Arch) -> List[Path]:
|
||||
def packages_get_locally_built_apks(packages, arch: Arch) -> list[Path]:
|
||||
"""
|
||||
Iterate over packages and if existing, get paths to locally built packages.
|
||||
This is used to force apk to upgrade packages to newer local versions, even
|
||||
|
@ -130,12 +130,12 @@ def packages_get_locally_built_apks(packages, arch: Arch) -> List[Path]:
|
|||
the second is a list of apk file paths that are valid inside the chroots, e.g.
|
||||
["/mnt/pmbootstrap/packages/x86_64/hello-world-1-r6.apk", ...]
|
||||
"""
|
||||
channels: List[str] = pmb.config.pmaports.all_channels()
|
||||
local: List[Path] = []
|
||||
channels: list[str] = pmb.config.pmaports.all_channels()
|
||||
local: list[Path] = []
|
||||
|
||||
packages = set(packages)
|
||||
|
||||
walked: Set[str] = set()
|
||||
walked: set[str] = set()
|
||||
while len(packages):
|
||||
package = packages.pop()
|
||||
data_repo = pmb.parse.apkindex.package(package, arch, False)
|
||||
|
@ -163,9 +163,9 @@ def packages_get_locally_built_apks(packages, arch: Arch) -> List[Path]:
|
|||
return local
|
||||
|
||||
|
||||
# FIXME: List[Sequence[PathString]] weirdness
|
||||
# FIXME: list[Sequence[PathString]] weirdness
|
||||
# mypy: disable-error-code="operator"
|
||||
def install_run_apk(to_add: List[str], to_add_local: List[Path], to_del: List[str], chroot: Chroot):
|
||||
def install_run_apk(to_add: list[str], to_add_local: list[Path], to_del: list[str], chroot: Chroot):
|
||||
"""
|
||||
Run apk to add packages, and ensure only the desired packages get
|
||||
explicitly marked as installed.
|
||||
|
@ -186,7 +186,7 @@ def install_run_apk(to_add: List[str], to_add_local: List[Path], to_del: List[st
|
|||
if package.startswith("-"):
|
||||
raise ValueError(f"Invalid package name: {package}")
|
||||
|
||||
commands: List[Sequence[PathString]] = [["add"] + to_add]
|
||||
commands: list[Sequence[PathString]] = [["add"] + to_add]
|
||||
|
||||
# Use a virtual package to mark only the explicitly requested packages as
|
||||
# explicitly installed, not the ones in to_add_local
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import enum
|
||||
import filecmp
|
||||
from typing import List
|
||||
from pmb.meta import Cache
|
||||
from pmb.helpers import logging
|
||||
import os
|
||||
|
@ -19,7 +18,7 @@ import pmb.helpers.other
|
|||
from pmb.core import Chroot, ChrootType
|
||||
from pmb.core.context import get_context
|
||||
|
||||
cache_chroot_is_outdated: List[str] = []
|
||||
cache_chroot_is_outdated: list[str] = []
|
||||
|
||||
|
||||
class UsrMerge(enum.Enum):
|
||||
|
|
|
@ -5,7 +5,6 @@ from pmb.core.pkgrepo import pkgrepo_default_path
|
|||
from pmb.helpers import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
import pmb.chroot.binfmt
|
||||
import pmb.config
|
||||
import pmb.helpers.run
|
||||
|
@ -120,7 +119,7 @@ def mount(chroot: Chroot):
|
|||
# Get all mountpoints
|
||||
arch = chroot.arch
|
||||
channel = pmb.config.pmaports.read_config(pkgrepo_default_path())["channel"]
|
||||
mountpoints: Dict[Path, Path] = {}
|
||||
mountpoints: dict[Path, Path] = {}
|
||||
for src_template, target_template in pmb.config.chroot_mount_bind.items():
|
||||
src_template = src_template.replace("$WORK", os.fspath(get_context().config.work))
|
||||
src_template = src_template.replace("$ARCH", str(arch))
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import os
|
||||
from pathlib import Path, PurePath
|
||||
import shutil
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
import pmb.config
|
||||
import pmb.chroot
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
from typing import Generator, Optional
|
||||
from typing import Optional
|
||||
from collections.abc import Generator
|
||||
from pathlib import Path, PosixPath, PurePosixPath
|
||||
from pmb.types import PmbArgs
|
||||
from pmb.helpers import frontend
|
||||
|
|
|
@ -4,7 +4,7 @@ import os
|
|||
from pathlib import Path
|
||||
from pmb.types import AportGenEntry, PathString
|
||||
import sys
|
||||
from typing import Dict, List, Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
#
|
||||
# Exported functions
|
||||
|
@ -74,7 +74,7 @@ def sudo(cmd: Sequence[PathString]) -> Sequence[PathString]:
|
|||
return cmd
|
||||
|
||||
|
||||
defaults: Dict[str, PathString] = {
|
||||
defaults: dict[str, PathString] = {
|
||||
"cipher": "aes-xts-plain64",
|
||||
"config": Path(
|
||||
(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config")) + "/pmbootstrap.cfg"
|
||||
|
@ -784,7 +784,7 @@ Fastboot specific: $KERNEL_CMDLINE
|
|||
Heimdall specific: $PARTITION_INITFS
|
||||
uuu specific: $UUU_SCRIPT
|
||||
"""
|
||||
flashers: Dict[str, Dict[str, bool | List[str] | Dict[str, List[List[str]]]]] = {
|
||||
flashers: dict[str, dict[str, bool | list[str] | dict[str, list[list[str]]]]] = {
|
||||
"fastboot": {
|
||||
"depends": [], # pmaports.cfg: supported_fastboot_depends
|
||||
"actions": {
|
||||
|
@ -984,7 +984,7 @@ git_repos = {
|
|||
#
|
||||
# APORTGEN
|
||||
#
|
||||
aportgen: Dict[str, AportGenEntry] = {
|
||||
aportgen: dict[str, AportGenEntry] = {
|
||||
"cross": {
|
||||
"prefixes": ["busybox-static", "gcc", "musl", "grub-efi"],
|
||||
"confirm_overwrite": False,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright 2023 Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from pathlib import Path, PosixPath
|
||||
from typing import List
|
||||
from pmb.helpers import logging
|
||||
import configparser
|
||||
import os
|
||||
|
@ -45,7 +44,7 @@ def load(path: Path) -> Config:
|
|||
setattr(config, key, Path(cfg["pmbootstrap"][key]))
|
||||
# Yeah this really sucks and there isn't a better way to do it without external
|
||||
# libraries
|
||||
elif isinstance(getattr(Config, key), List) and isinstance(
|
||||
elif isinstance(getattr(Config, key), list) and isinstance(
|
||||
getattr(Config, key)[0], PosixPath
|
||||
):
|
||||
value = cfg["pmbootstrap"][key]
|
||||
|
@ -97,7 +96,7 @@ def serialize(config: Config, skip_defaults=True) -> configparser.ConfigParser:
|
|||
# Convert strings to paths
|
||||
elif type(getattr(Config, key)) == PosixPath:
|
||||
cfg["pmbootstrap"][key] = str(getattr(config, key))
|
||||
elif isinstance(getattr(Config, key), List) and isinstance(
|
||||
elif isinstance(getattr(Config, key), list) and isinstance(
|
||||
getattr(Config, key)[0], PosixPath
|
||||
):
|
||||
cfg["pmbootstrap"][key] = ",".join(os.fspath(p) for p in getattr(config, key))
|
||||
|
|
|
@ -124,7 +124,7 @@ def ask_for_channel(config: Config):
|
|||
channels_cfg = pmb.helpers.git.parse_channels_cfg(pkgrepo_default_path())
|
||||
count = len(channels_cfg["channels"])
|
||||
|
||||
# List channels
|
||||
# list channels
|
||||
logging.info("Choose the postmarketOS release channel.")
|
||||
logging.info(f"Available ({count}):")
|
||||
# Only show the first 3 releases. This includes edge, the latest supported
|
||||
|
@ -377,7 +377,7 @@ def ask_for_device_kernel(config: Config, device: str):
|
|||
" downstream kernels."
|
||||
)
|
||||
|
||||
# List kernels
|
||||
# list kernels
|
||||
logging.info(f"Available kernels ({len(kernels)}):")
|
||||
for type in sorted(kernels.keys()):
|
||||
logging.info(f"* {type}: {kernels[type]}")
|
||||
|
@ -554,7 +554,7 @@ def ask_for_mirror():
|
|||
with open(json_path) as handle:
|
||||
s = handle.read()
|
||||
|
||||
logging.info("List of available mirrors:")
|
||||
logging.info("list of available mirrors:")
|
||||
mirrors = json.loads(s)
|
||||
keys = mirrors.keys()
|
||||
i = 1
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
from typing import Optional
|
||||
from pmb.core.pkgrepo import pkgrepo_default_path, pkgrepo_paths, pkgrepo_relative_path
|
||||
from pmb.helpers import logging
|
||||
import os
|
||||
|
@ -132,7 +132,7 @@ def read_config(aports: Optional[Path] = None):
|
|||
return ret
|
||||
|
||||
|
||||
def all_channels() -> List[str]:
|
||||
def all_channels() -> list[str]:
|
||||
"""Get a list of all channels for all pkgrepos."""
|
||||
ret = set()
|
||||
for repo in pkgrepo_paths():
|
||||
|
@ -200,7 +200,7 @@ def switch_to_channel_branch(channel_new):
|
|||
return False
|
||||
|
||||
aports = pkgrepo_default_path()
|
||||
# List current and new branches/channels
|
||||
# list current and new branches/channels
|
||||
channels_cfg = pmb.helpers.git.parse_channels_cfg(aports)
|
||||
branch_new = channels_cfg["channels"][channel_new]["branch_pmaports"]
|
||||
branch_current = pmb.helpers.git.rev_parse(aports, extra_args=["--abbrev-ref"])
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import enum
|
||||
from pathlib import Path, PosixPath, PurePosixPath
|
||||
import platform
|
||||
from typing import Set
|
||||
|
||||
# Initialised at the bottom
|
||||
_cached_native_arch: "Arch"
|
||||
|
@ -69,7 +68,7 @@ class Arch(enum.Enum):
|
|||
return self == Arch.native()
|
||||
|
||||
@staticmethod
|
||||
def supported() -> Set["Arch"]:
|
||||
def supported() -> set["Arch"]:
|
||||
"""Officially supported host/target architectures for postmarketOS. Only
|
||||
specify architectures supported by Alpine here. For cross-compiling,
|
||||
we need to generate the "musl-$ARCH" and "gcc-$ARCH" packages (use
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
import enum
|
||||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
from pathlib import Path, PosixPath, PurePosixPath
|
||||
import pmb.config
|
||||
from pmb.core.arch import Arch
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from copy import deepcopy
|
||||
import enum
|
||||
import multiprocessing
|
||||
from typing import Any, List, Dict, TypedDict
|
||||
from typing import Any, TypedDict
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
|
@ -21,7 +21,7 @@ class SystemdConfig(enum.Enum):
|
|||
return self.value
|
||||
|
||||
@staticmethod
|
||||
def choices() -> List[str]:
|
||||
def choices() -> list[str]:
|
||||
return [e.value for e in SystemdConfig]
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ class AutoZapConfig(enum.Enum):
|
|||
|
||||
|
||||
class Config:
|
||||
aports: List[Path] = [
|
||||
aports: list[Path] = [
|
||||
Path(os.path.expanduser("~") + "/.local/var/pmbootstrap/cache_git/pmaports")
|
||||
]
|
||||
boot_size: int = 256
|
||||
|
@ -75,7 +75,7 @@ class Config:
|
|||
# automatically zap chroots that are for the wrong channel
|
||||
auto_zap_misconfigured_chroots: AutoZapConfig = AutoZapConfig.NO
|
||||
|
||||
providers: Dict[str, str] = {}
|
||||
providers: dict[str, str] = {}
|
||||
|
||||
def __init__(self):
|
||||
# Make sure we aren't modifying the class defaults
|
||||
|
@ -83,7 +83,7 @@ class Config:
|
|||
setattr(self, key, deepcopy(Config.get_default(key)))
|
||||
|
||||
@staticmethod
|
||||
def keys() -> List[str]:
|
||||
def keys() -> list[str]:
|
||||
keys = list(Config.__annotations__.keys())
|
||||
keys.remove("mirrors")
|
||||
keys += [f"mirrors.{k}" for k in Mirrors.__annotations__.keys()]
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
import enum
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
from pmb.core.chroot import ChrootType
|
||||
from pmb.types import PathString
|
||||
|
@ -17,9 +16,9 @@ class CrossToolTarget(enum.Enum):
|
|||
class CrossTool:
|
||||
__target: CrossToolTarget
|
||||
__package: str
|
||||
__paths: List[Path]
|
||||
__paths: list[Path]
|
||||
|
||||
def __init__(self, target: CrossToolTarget, package: str, paths: List[PathString]):
|
||||
def __init__(self, target: CrossToolTarget, package: str, paths: list[PathString]):
|
||||
self.__target = target
|
||||
self.__package = package
|
||||
self.__paths = list(map(lambda p: Path(p) if isinstance(p, str) else p, paths))
|
||||
|
@ -32,7 +31,7 @@ class CrossTool:
|
|||
return self.__package
|
||||
|
||||
@property
|
||||
def paths(self) -> List[Path]:
|
||||
def paths(self) -> list[Path]:
|
||||
return self.__paths
|
||||
|
||||
def should_install(self, target: ChrootType) -> bool:
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import os
|
||||
import glob
|
||||
from pathlib import Path
|
||||
from typing import Dict, Generator, List, Optional, Tuple
|
||||
from typing import Optional
|
||||
from collections.abc import Generator
|
||||
|
||||
import pmb.config
|
||||
from pmb.core.context import get_context
|
||||
|
@ -9,7 +10,7 @@ from pmb.meta import Cache
|
|||
|
||||
|
||||
@Cache(skip_extras=False)
|
||||
def pkgrepo_paths(skip_extras=False) -> List[Path]:
|
||||
def pkgrepo_paths(skip_extras=False) -> list[Path]:
|
||||
config = get_context().config
|
||||
paths = list(map(lambda x: Path(x), config.aports))
|
||||
if not paths:
|
||||
|
@ -32,7 +33,7 @@ def pkgrepo_default_path() -> Path:
|
|||
return pkgrepo_paths(skip_extras=True)[0]
|
||||
|
||||
|
||||
def pkgrepo_names(skip_exras=False) -> List[str]:
|
||||
def pkgrepo_names(skip_exras=False) -> list[str]:
|
||||
"""
|
||||
Return a list of all the package repository names.
|
||||
"""
|
||||
|
@ -97,7 +98,7 @@ def pkgrepo_iter_package_dirs(skip_extra_repos=False) -> Generator[Path, None, N
|
|||
Detect duplicates within the same aports repository but otherwise
|
||||
ignore all but the first. This allows for overriding packages.
|
||||
"""
|
||||
seen: Dict[str, List[str]] = dict(map(lambda a: (a, []), pkgrepo_names(skip_extra_repos)))
|
||||
seen: dict[str, list[str]] = dict(map(lambda a: (a, []), pkgrepo_names(skip_extra_repos)))
|
||||
for repo in pkgrepo_paths(skip_extra_repos):
|
||||
for g in glob.iglob(os.path.join(repo, "**/*/APKBUILD"), recursive=True):
|
||||
pdir = Path(g).parent
|
||||
|
@ -116,7 +117,7 @@ def pkgrepo_iter_package_dirs(skip_extra_repos=False) -> Generator[Path, None, N
|
|||
yield pdir
|
||||
|
||||
|
||||
def pkgrepo_relative_path(path: Path) -> Tuple[Path, Path]:
|
||||
def pkgrepo_relative_path(path: Path) -> tuple[Path, Path]:
|
||||
"""
|
||||
Return the path relative to the first aports repository.
|
||||
"""
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
from pmb.core.context import get_context
|
||||
from pmb.helpers import logging
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
import pmb.build
|
||||
import pmb.chroot.apk
|
||||
|
@ -50,7 +49,7 @@ def symlinks(flavor, folder: Path):
|
|||
chroot_native = Chroot.native()
|
||||
path_boot = Chroot(ChrootType.ROOTFS, context.device) / "boot"
|
||||
chroot_buildroot = Chroot.buildroot(arch)
|
||||
files: List[Path] = [
|
||||
files: list[Path] = [
|
||||
path_boot / f"boot.img{suffix}",
|
||||
path_boot / f"uInitrd{suffix}",
|
||||
path_boot / f"uImage{suffix}",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright 2023 Johannes Marbach, Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import os
|
||||
from typing import List, Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
import pmb.chroot
|
||||
import pmb.config.pmaports
|
||||
|
@ -73,7 +73,7 @@ def apk_with_progress(command: Sequence[PathString]):
|
|||
:raises RuntimeError: when the apk command fails
|
||||
"""
|
||||
fifo, fifo_outside = _prepare_fifo()
|
||||
_command: List[str] = []
|
||||
_command: list[str] = []
|
||||
for c in command:
|
||||
if isinstance(c, Arch):
|
||||
_command.append(str(c))
|
||||
|
|
|
@ -6,15 +6,15 @@ from pmb.helpers import logging
|
|||
import os
|
||||
import re
|
||||
import urllib.parse
|
||||
from typing import Dict, Optional
|
||||
from typing import Optional
|
||||
|
||||
from pmb.types import PmbArgs
|
||||
import pmb.helpers.file
|
||||
import pmb.helpers.http
|
||||
import pmb.helpers.pmaports
|
||||
|
||||
req_headers: Dict[str, str] = {}
|
||||
req_headers_github: Dict[str, str] = {}
|
||||
req_headers: dict[str, str] = {}
|
||||
req_headers_github: dict[str, str] = {}
|
||||
|
||||
ANITYA_API_BASE = "https://release-monitoring.org/api/v2"
|
||||
GITHUB_API_BASE = "https://api.github.com"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright 2023 Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import json
|
||||
from typing import List, Sequence, Tuple
|
||||
from collections.abc import Sequence
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.helpers import logging
|
||||
import os
|
||||
|
@ -82,7 +82,7 @@ def _parse_suffix(args: PmbArgs) -> Chroot:
|
|||
return Chroot(ChrootType.NATIVE)
|
||||
|
||||
|
||||
def _install_ondev_verify_no_rootfs(device: str, ondev_cp: List[Tuple[str, str]]):
|
||||
def _install_ondev_verify_no_rootfs(device: str, ondev_cp: list[tuple[str, str]]):
|
||||
chroot_dest = "/var/lib/rootfs.img"
|
||||
dest = Chroot(ChrootType.INSTALLER, device) / chroot_dest
|
||||
if dest.exists():
|
||||
|
@ -459,7 +459,7 @@ def kconfig(args: PmbArgs):
|
|||
raise RuntimeError("kconfig check failed!")
|
||||
|
||||
# Default to all kernel packages
|
||||
packages: List[str]
|
||||
packages: list[str]
|
||||
# FIXME (#2324): figure out the args.package vs args.packages situation
|
||||
if isinstance(args.package, list):
|
||||
packages = args.package
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
from pmb.core.context import get_context
|
||||
from pmb.core.pkgrepo import pkgrepo_path
|
||||
from pmb.helpers import logging
|
||||
|
@ -143,7 +142,7 @@ def parse_channels_cfg(aports: Path):
|
|||
)
|
||||
|
||||
# Meta section
|
||||
ret: Dict[str, Dict[str, str | Dict[str, str]]] = {"channels": {}}
|
||||
ret: dict[str, dict[str, str | dict[str, str]]] = {"channels": {}}
|
||||
ret["meta"] = {"recommended": cfg.get("channels.cfg", "recommended")}
|
||||
|
||||
# Channels
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Copyright 2023 Danct12 <danct12@disroot.org>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from typing import Dict, List, Sequence
|
||||
from collections.abc import Sequence
|
||||
from pmb.core.chroot import Chroot
|
||||
from pmb.core.pkgrepo import pkgrepo_iter_package_dirs, pkgrepo_names, pkgrepo_relative_path
|
||||
from pmb.helpers import logging
|
||||
|
@ -31,7 +31,7 @@ def check(pkgnames: Sequence[str]):
|
|||
|
||||
# Locate all APKBUILDs and make the paths be relative to the pmaports
|
||||
# root
|
||||
apkbuilds: Dict[str, List[str]] = dict(map(lambda x: (x, []), pkgrepo_names()))
|
||||
apkbuilds: dict[str, list[str]] = dict(map(lambda x: (x, []), pkgrepo_names()))
|
||||
found_pkgnames = set()
|
||||
# If a package exists in multiple aports we will lint all of them
|
||||
# since.. well, what else do we do?
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import os
|
||||
from pathlib import Path, PurePath
|
||||
from typing import List
|
||||
import pmb.helpers
|
||||
from pmb.core import Chroot
|
||||
import pmb.helpers.run
|
||||
|
@ -72,7 +71,7 @@ def bind_file(source: Path, destination: Path, create_folders=False):
|
|||
pmb.helpers.run.root(["mount", "--bind", source, destination])
|
||||
|
||||
|
||||
def umount_all_list(prefix: Path, source: Path = Path("/proc/mounts")) -> List[Path]:
|
||||
def umount_all_list(prefix: Path, source: Path = Path("/proc/mounts")) -> list[Path]:
|
||||
"""Parse `/proc/mounts` for all folders beginning with a prefix.
|
||||
|
||||
:source: can be changed for testcases
|
||||
|
|
|
@ -12,7 +12,7 @@ import pmb.config.init
|
|||
from pmb.types import PmbArgs
|
||||
import pmb.helpers.pmaports
|
||||
import pmb.helpers.run
|
||||
from typing import Dict, Any
|
||||
from typing import Any
|
||||
|
||||
|
||||
def folder_size(path: Path):
|
||||
|
@ -291,7 +291,7 @@ def lookup(key):
|
|||
pmb.helpers.other.cache["mycache"][key] = ret
|
||||
return ret
|
||||
"""
|
||||
cache: Dict[str, Any] = {
|
||||
cache: dict[str, Any] = {
|
||||
"apkindex": {},
|
||||
"pmb.helpers.repo.update": {"404": [], "offline_msg_shown": False},
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ See also:
|
|||
"""
|
||||
|
||||
import copy
|
||||
from typing import Any, Dict
|
||||
from typing import Any
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.core.context import get_context
|
||||
from pmb.helpers import logging
|
||||
|
@ -50,7 +50,7 @@ def get(pkgname, arch, replace_subpkgnames=False, must_exist=True):
|
|||
* None if the package was not found
|
||||
"""
|
||||
# Find in pmaports
|
||||
ret: Dict[str, Any] = {}
|
||||
ret: dict[str, Any] = {}
|
||||
pmaport = pmb.helpers.pmaports.get(pkgname, False)
|
||||
if pmaport:
|
||||
ret = {
|
||||
|
|
|
@ -12,13 +12,14 @@ from pmb.core.arch import Arch
|
|||
from pmb.core.pkgrepo import pkgrepo_iter_package_dirs
|
||||
from pmb.helpers import logging
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional, Sequence, Dict, Tuple
|
||||
from typing import Any, Optional
|
||||
from collections.abc import Sequence
|
||||
|
||||
from pmb.meta import Cache
|
||||
import pmb.parse
|
||||
|
||||
|
||||
def _find_apkbuilds(skip_extra_repos=False) -> Dict[str, Path]:
|
||||
def _find_apkbuilds(skip_extra_repos=False) -> dict[str, Path]:
|
||||
# Try to get a cached result first (we assume that the aports don't change
|
||||
# in one pmbootstrap call)
|
||||
apkbuilds = pmb.helpers.other.cache.get("pmb.helpers.pmaports.apkbuilds")
|
||||
|
@ -215,7 +216,7 @@ def find_optional(package: str) -> Optional[Path]:
|
|||
@Cache("pkgname", subpackages=True)
|
||||
def get_with_path(
|
||||
pkgname, must_exist=True, subpackages=True, skip_extra_repos=False
|
||||
) -> Tuple[Optional[Path], Optional[Dict[str, Any]]]:
|
||||
) -> tuple[Optional[Path], Optional[dict[str, Any]]]:
|
||||
"""Find and parse an APKBUILD file.
|
||||
|
||||
Run 'pmbootstrap apkbuild_parse hello-world' for a full output example.
|
||||
|
@ -243,7 +244,7 @@ def get_with_path(
|
|||
return None, None
|
||||
|
||||
|
||||
def get(pkgname, must_exist=True, subpackages=True, skip_extra_repos=False) -> Dict[str, Any]:
|
||||
def get(pkgname, must_exist=True, subpackages=True, skip_extra_repos=False) -> dict[str, Any]:
|
||||
return get_with_path(pkgname, must_exist, subpackages, skip_extra_repos)[1]
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ from pmb.core.arch import Arch
|
|||
from pmb.core.pkgrepo import pkgrepo_names
|
||||
from pmb.helpers import logging
|
||||
from pathlib import Path
|
||||
from typing import List, Optional
|
||||
from typing import Optional
|
||||
|
||||
import pmb.config.pmaports
|
||||
from pmb.meta import Cache
|
||||
|
@ -54,7 +54,7 @@ def apkindex_hash(url: str, length: int = 8) -> Path:
|
|||
# FIXME: make config.mirrors a normal dict
|
||||
# mypy: disable-error-code="literal-required"
|
||||
@Cache("user_repository", "mirrors_exclude")
|
||||
def urls(user_repository=False, mirrors_exclude: List[str] = []):
|
||||
def urls(user_repository=False, mirrors_exclude: list[str] = []):
|
||||
"""Get a list of repository URLs, as they are in /etc/apk/repositories.
|
||||
|
||||
:param user_repository: add /mnt/pmbootstrap/packages
|
||||
|
@ -62,7 +62,7 @@ def urls(user_repository=False, mirrors_exclude: List[str] = []):
|
|||
:returns: list of mirror strings, like ["/mnt/pmbootstrap/packages",
|
||||
"http://...", ...]
|
||||
"""
|
||||
ret: List[str] = []
|
||||
ret: list[str] = []
|
||||
config = get_context().config
|
||||
|
||||
# Get mirrordirs from channels.cfg (postmarketOS mirrordir is the same as
|
||||
|
@ -104,8 +104,8 @@ def urls(user_repository=False, mirrors_exclude: List[str] = []):
|
|||
|
||||
|
||||
def apkindex_files(
|
||||
arch: Optional[Arch] = None, user_repository=True, exclude_mirrors: List[str] = []
|
||||
) -> List[Path]:
|
||||
arch: Optional[Arch] = None, user_repository=True, exclude_mirrors: list[str] = []
|
||||
) -> list[Path]:
|
||||
"""Get a list of outside paths to all resolved APKINDEX.tar.gz files for a specific arch.
|
||||
|
||||
:param arch: defaults to native
|
||||
|
@ -158,7 +158,7 @@ def update(arch: Optional[Arch] = None, force=False, existing_only=False):
|
|||
# outdated: {URL: apkindex_path, ... }
|
||||
# outdated_arches: ["armhf", "x86_64", ... ]
|
||||
outdated = {}
|
||||
outdated_arches: List[Arch] = []
|
||||
outdated_arches: list[Arch] = []
|
||||
for url in urls(False):
|
||||
for arch in architectures:
|
||||
# APKINDEX file name from the URL
|
||||
|
|
|
@ -5,7 +5,8 @@ from pathlib import Path
|
|||
import subprocess
|
||||
from pmb.core.arch import Arch
|
||||
import pmb.helpers.run_core
|
||||
from typing import Optional, Sequence
|
||||
from typing import Optional
|
||||
from collections.abc import Sequence
|
||||
from pmb.types import Env, PathString
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ import subprocess
|
|||
import sys
|
||||
import threading
|
||||
import time
|
||||
from typing import Optional, Sequence
|
||||
from typing import Optional
|
||||
from collections.abc import Sequence
|
||||
import pmb.helpers.run
|
||||
|
||||
"""For a detailed description of all output modes, read the description of
|
||||
|
|
|
@ -7,7 +7,8 @@ import re
|
|||
import glob
|
||||
import shlex
|
||||
import sys
|
||||
from typing import Dict, List, Optional, Sequence
|
||||
from typing import Optional
|
||||
from collections.abc import Sequence
|
||||
from pathlib import Path
|
||||
|
||||
import pmb.build
|
||||
|
@ -34,8 +35,8 @@ from pmb.core.context import get_context
|
|||
|
||||
# Keep track of the packages we already visited in get_recommends() to avoid
|
||||
# infinite recursion
|
||||
get_recommends_visited: List[str] = []
|
||||
get_selected_providers_visited: List[str] = []
|
||||
get_recommends_visited: list[str] = []
|
||||
get_selected_providers_visited: list[str] = []
|
||||
|
||||
|
||||
def get_subpartitions_size(chroot: Chroot):
|
||||
|
@ -135,7 +136,7 @@ def copy_files_from_chroot(args: PmbArgs, chroot: Chroot):
|
|||
pmb.helpers.run.root(["rm", fifo])
|
||||
|
||||
# Get all folders inside the device rootfs (except for home)
|
||||
folders: List[str] = []
|
||||
folders: list[str] = []
|
||||
for path in mountpoint_outside.glob("*"):
|
||||
if path.name == "home":
|
||||
continue
|
||||
|
@ -542,7 +543,7 @@ def generate_binary_list(args: PmbArgs, chroot: Chroot, step):
|
|||
rootfs_{args.device} or installer_{args.device}
|
||||
:param step: partition step size in bytes
|
||||
"""
|
||||
binary_ranges: Dict[int, int] = {}
|
||||
binary_ranges: dict[int, int] = {}
|
||||
binary_list = []
|
||||
binaries = pmb.parse.deviceinfo().sd_embed_firmware.split(",")
|
||||
|
||||
|
@ -1188,7 +1189,7 @@ def get_recommends(args: PmbArgs, packages) -> Sequence[str]:
|
|||
"""
|
||||
global get_recommends_visited
|
||||
|
||||
ret: List[str] = []
|
||||
ret: list[str] = []
|
||||
if not args.install_recommends:
|
||||
return ret
|
||||
|
||||
|
@ -1229,7 +1230,7 @@ def get_recommends(args: PmbArgs, packages) -> Sequence[str]:
|
|||
|
||||
|
||||
def create_device_rootfs(args: PmbArgs, step, steps):
|
||||
# List all packages to be installed (including the ones specified by --add)
|
||||
# list all packages to be installed (including the ones specified by --add)
|
||||
# and upgrade the installed packages/apkindexes
|
||||
context = get_context()
|
||||
config = context.config
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
from pmb.core.context import get_context
|
||||
from pmb.helpers import logging
|
||||
import time
|
||||
|
@ -39,7 +38,7 @@ def mount(img_path: Path):
|
|||
# Mount and return on success
|
||||
init()
|
||||
|
||||
losetup_cmd: List[PathString] = ["losetup", "-f", img_path]
|
||||
losetup_cmd: list[PathString] = ["losetup", "-f", img_path]
|
||||
sector_size = pmb.parse.deviceinfo().rootfs_image_sector_size
|
||||
if sector_size:
|
||||
losetup_cmd += ["-b", str(int(sector_size))]
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
# Copyright 2023 Dylan Van Assche
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from typing import List
|
||||
from pmb.helpers import logging
|
||||
|
||||
from pmb.core import Config
|
||||
import pmb.helpers.pmaports
|
||||
|
||||
|
||||
def get_groups(config: Config) -> List[str]:
|
||||
def get_groups(config: Config) -> list[str]:
|
||||
"""Get all groups to which the user additionally must be added.
|
||||
The list of groups are listed in _pmb_groups of the UI and
|
||||
UI-extras package.
|
||||
|
||||
:returns: list of groups, e.g. ["feedbackd", "udev"]"""
|
||||
ret: List[str] = []
|
||||
ret: list[str] = []
|
||||
if config.ui == "none":
|
||||
return ret
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import copy
|
||||
from typing import Callable, Dict, Optional
|
||||
from typing import Callable, Optional
|
||||
|
||||
import inspect
|
||||
|
||||
|
@ -83,7 +83,7 @@ class Cache:
|
|||
|
||||
signature = inspect.signature(func)
|
||||
|
||||
passed_args: Dict[str, str] = {}
|
||||
passed_args: dict[str, str] = {}
|
||||
for i, (k, val) in enumerate(signature.parameters.items()):
|
||||
if k in self.params or k in self.kwargs:
|
||||
if i < len(args):
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from typing import List
|
||||
|
||||
from . import Cache, Wrapper
|
||||
|
||||
|
||||
|
@ -30,7 +28,7 @@ def test_cache_hits_basic():
|
|||
|
||||
|
||||
def test_cache_hits_kwargs():
|
||||
def multiply_2(x: int, y: int = 2, z: List[int] = []) -> int:
|
||||
def multiply_2(x: int, y: int = 2, z: list[int] = []) -> int:
|
||||
return x * y + sum(z)
|
||||
|
||||
multiply_2_cached = Cache("x", "y", "z")(multiply_2)
|
||||
|
@ -68,7 +66,7 @@ def test_cache_hits_kwargs():
|
|||
|
||||
|
||||
def test_build_key():
|
||||
def multiply_2(x: int, y: int = 2, z: List[int] = []) -> int:
|
||||
def multiply_2(x: int, y: int = 2, z: list[int] = []) -> int:
|
||||
return x * y + sum(z)
|
||||
|
||||
multiply_2_cached = Cache("x", "y", "z")(multiply_2)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Copyright 2023 Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import collections
|
||||
from typing import Any, Dict, List, Optional, Sequence
|
||||
from typing import Any, Optional
|
||||
from collections.abc import Sequence
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.core.context import get_context
|
||||
from pmb.helpers import logging
|
||||
|
@ -26,7 +27,7 @@ apkindex_map = {
|
|||
required_apkindex_keys = ["arch", "pkgname", "version"]
|
||||
|
||||
|
||||
def parse_next_block(path: Path, lines: List[str]):
|
||||
def parse_next_block(path: Path, lines: list[str]):
|
||||
"""Parse the next block in an APKINDEX.
|
||||
|
||||
:param path: to the APKINDEX.tar.gz
|
||||
|
@ -34,7 +35,7 @@ def parse_next_block(path: Path, lines: List[str]):
|
|||
function. Wrapped into a list, so it can be modified
|
||||
"by reference". Example: [5]
|
||||
:param lines: all lines from the "APKINDEX" file inside the archive
|
||||
:returns: Dictionary with the following structure:
|
||||
:returns: dictionary with the following structure:
|
||||
``{ "arch": "noarch", "depends": ["busybox-extras", "lddtree", ... ],
|
||||
"origin": "postmarketos-mkinitfs",
|
||||
"pkgname": "postmarketos-mkinitfs",
|
||||
|
@ -49,7 +50,7 @@ def parse_next_block(path: Path, lines: List[str]):
|
|||
:returns: None, when there are no more blocks
|
||||
"""
|
||||
# Parse until we hit an empty line or end of file
|
||||
ret: Dict[str, Any] = {}
|
||||
ret: dict[str, Any] = {}
|
||||
required_found = 0 # Count the required keys we found
|
||||
line = ""
|
||||
while len(lines):
|
||||
|
@ -207,7 +208,7 @@ def parse(path: Path, multiple_providers=True):
|
|||
return {}
|
||||
|
||||
# Parse the whole APKINDEX file
|
||||
ret: Dict[str, Any] = collections.OrderedDict()
|
||||
ret: dict[str, Any] = collections.OrderedDict()
|
||||
if lines[-1] == "\n":
|
||||
lines.pop() # Strip the trailing newline
|
||||
while True:
|
||||
|
@ -252,7 +253,7 @@ def parse_blocks(path: Path):
|
|||
lines = handle.read().decode().splitlines()
|
||||
|
||||
# Parse lines into blocks
|
||||
ret: List[str] = []
|
||||
ret: list[str] = []
|
||||
while True:
|
||||
block = pmb.parse.apkindex.parse_next_block(path, lines)
|
||||
if not block:
|
||||
|
@ -302,7 +303,7 @@ def providers(package, arch: Optional[Arch] = None, must_exist=True, indexes=Non
|
|||
|
||||
package = pmb.helpers.package.remove_operators(package)
|
||||
|
||||
ret: Dict[str, Any] = collections.OrderedDict()
|
||||
ret: dict[str, Any] = collections.OrderedDict()
|
||||
for path in indexes:
|
||||
# Skip indexes not providing the package
|
||||
index_packages = parse(path)
|
||||
|
|
|
@ -109,7 +109,7 @@ def bootimg(path: Path):
|
|||
)
|
||||
if (
|
||||
"linux kernel" in file_output.lower()
|
||||
or "ARM OpenFirmware FORTH Dictionary" in file_output
|
||||
or "ARM OpenFirmware FORTH dictionary" in file_output
|
||||
):
|
||||
raise RuntimeError(
|
||||
"File is a Kernel image, you might need the"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import copy
|
||||
from pathlib import Path
|
||||
from typing import Dict, Optional
|
||||
from typing import Optional
|
||||
from pmb.core.context import get_context
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.helpers import logging
|
||||
|
@ -170,7 +170,7 @@ class Deviceinfo:
|
|||
keymaps: Optional[str] = ""
|
||||
|
||||
@staticmethod
|
||||
def __validate(info: Dict[str, str], path: Path):
|
||||
def __validate(info: dict[str, str], path: Path):
|
||||
# Resolve path for more readable error messages
|
||||
path = path.resolve()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright 2023 Pablo Castellano, Oliver Smith
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import subprocess
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.core.config import Config
|
||||
from pmb.core.context import get_context
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright 2023 Martijn Braam
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import os
|
||||
from typing import List, Optional
|
||||
from typing import Optional
|
||||
from pmb.core.arch import Arch
|
||||
from pmb.helpers import logging
|
||||
import shlex
|
||||
|
@ -27,12 +27,12 @@ def scp_abuild_key(args: PmbArgs, user: str, host: str, port: str):
|
|||
key_name = os.path.basename(key)
|
||||
|
||||
logging.info(f"Copying signing key ({key_name}) to {user}@{host}")
|
||||
command: List[PathString] = ["scp", "-P", port, key, f"{user}@{host}:/tmp"]
|
||||
command: list[PathString] = ["scp", "-P", port, key, f"{user}@{host}:/tmp"]
|
||||
pmb.helpers.run.user(command, output="interactive")
|
||||
|
||||
logging.info(f"Installing signing key at {user}@{host}")
|
||||
keyname = os.path.join("/tmp", os.path.basename(key))
|
||||
remote_cmd_l: List[PathString] = [
|
||||
remote_cmd_l: list[PathString] = [
|
||||
"sudo",
|
||||
"-p",
|
||||
pmb.config.sideload_sudo_prompt,
|
||||
|
|
14
pmb/types.py
14
pmb/types.py
|
@ -3,12 +3,12 @@
|
|||
|
||||
from argparse import Namespace
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Tuple, TypedDict, Union
|
||||
from typing import Optional, TypedDict, Union
|
||||
|
||||
from pmb.core.arch import Arch
|
||||
|
||||
PathString = Union[Path, str]
|
||||
Env = Dict[str, PathString]
|
||||
Env = dict[str, PathString]
|
||||
|
||||
# These types are not definitive / API, they exist to describe the current
|
||||
# state of things so that we can improve our type hinting coverage and make
|
||||
|
@ -23,7 +23,7 @@ class PartitionLayout(TypedDict):
|
|||
|
||||
|
||||
class AportGenEntry(TypedDict):
|
||||
prefixes: List[str]
|
||||
prefixes: list[str]
|
||||
confirm_overwrite: bool
|
||||
|
||||
|
||||
|
@ -108,13 +108,13 @@ class PmbArgs(Namespace):
|
|||
no_sshd: str
|
||||
odin_flashable_tar: str
|
||||
offline: bool
|
||||
ondev_cp: List[Tuple[str, str]]
|
||||
ondev_cp: list[tuple[str, str]]
|
||||
on_device_installer: str
|
||||
ondev_no_rootfs: str
|
||||
overview: str
|
||||
# FIXME (#2324): figure out the args.package vs args.packages situation
|
||||
package: str | List[str]
|
||||
packages: List[str]
|
||||
package: str | list[str]
|
||||
packages: list[str]
|
||||
partition: str
|
||||
password: str
|
||||
path: Path
|
||||
|
@ -140,7 +140,7 @@ class PmbArgs(Namespace):
|
|||
rsync: str
|
||||
scripts: str
|
||||
second_storage: str
|
||||
selected_providers: Dict[str, str]
|
||||
selected_providers: dict[str, str]
|
||||
sparse: str
|
||||
split: bool
|
||||
src: str
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue