mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-12 19:09:56 +03:00
make mypy happy (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
f2ca9c618e
commit
0365438134
10 changed files with 19 additions and 14 deletions
|
@ -6,6 +6,7 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
|
||||||
sys.path.insert(0, os.path.abspath('..')) # Allow modules to be found
|
sys.path.insert(0, os.path.abspath('..')) # Allow modules to be found
|
||||||
|
@ -41,7 +42,7 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||||
html_theme = 'sphinx_rtd_theme'
|
html_theme = 'sphinx_rtd_theme'
|
||||||
html_favicon = 'https://wiki.postmarketos.org/favicon.ico'
|
html_favicon = 'https://wiki.postmarketos.org/favicon.ico'
|
||||||
|
|
||||||
html_theme_options = {'style_nav_header_background': '008b69',}
|
html_theme_options: Dict[str, Any] = {'style_nav_header_background': '008b69',}
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = 'pmboostrapdoc'
|
htmlhelp_basename = 'pmboostrapdoc'
|
||||||
|
|
|
@ -92,4 +92,4 @@ def generate(pkgname: str, fork_alpine: bool):
|
||||||
pmb.helpers.run.user(
|
pmb.helpers.run.user(
|
||||||
["mv", aportgen, path_target])
|
["mv", aportgen, path_target])
|
||||||
|
|
||||||
logging.info("*** pmaport generated: " + path_target)
|
logging.info(f"*** pmaport generated: {path_target}")
|
||||||
|
|
|
@ -60,7 +60,7 @@ def generate_apkbuild(pkgname: str, deviceinfo: Deviceinfo, patches: List[str]):
|
||||||
|
|
||||||
makedepends.sort()
|
makedepends.sort()
|
||||||
makedepends_fmt = ("\n" + " " * 12).join(makedepends)
|
makedepends_fmt = ("\n" + " " * 12).join(makedepends)
|
||||||
patches = ("\n" + " " * 12).join(patches)
|
patches_str = ("\n" + " " * 12).join(patches)
|
||||||
content = f"""\
|
content = f"""\
|
||||||
# Reference: <https://postmarketos.org/vendorkernel>
|
# Reference: <https://postmarketos.org/vendorkernel>
|
||||||
# Kernel config based on: arch/{carch}/configs/(CHANGEME!)
|
# Kernel config based on: arch/{carch}/configs/(CHANGEME!)
|
||||||
|
@ -86,7 +86,7 @@ def generate_apkbuild(pkgname: str, deviceinfo: Deviceinfo, patches: List[str]):
|
||||||
source="
|
source="
|
||||||
$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
|
$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
|
||||||
$_config
|
$_config
|
||||||
{patches}
|
{patches_str}
|
||||||
"
|
"
|
||||||
builddir="$srcdir/$_repository-$_commit"
|
builddir="$srcdir/$_repository-$_commit"
|
||||||
_outdir="out"
|
_outdir="out"
|
||||||
|
|
|
@ -140,6 +140,8 @@ def packages_get_locally_built_apks(packages, arch: Arch) -> List[Path]:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
Run apk to add packages, and ensure only the desired packages get
|
||||||
|
|
|
@ -116,6 +116,8 @@ def flash_lk2nd(deviceinfo: Deviceinfo, method: str):
|
||||||
# Get the lk2nd package (which is a dependency of the device package)
|
# Get the lk2nd package (which is a dependency of the device package)
|
||||||
device_pkg = f"device-{deviceinfo.codename}"
|
device_pkg = f"device-{deviceinfo.codename}"
|
||||||
apkbuild = pmb.helpers.pmaports.get(device_pkg)
|
apkbuild = pmb.helpers.pmaports.get(device_pkg)
|
||||||
|
if not apkbuild:
|
||||||
|
raise RuntimeError(f"Failed to find {device_pkg} in pmaports")
|
||||||
lk2nd_pkg = None
|
lk2nd_pkg = None
|
||||||
for dep in apkbuild["depends"]:
|
for dep in apkbuild["depends"]:
|
||||||
if dep.startswith("lk2nd"):
|
if dep.startswith("lk2nd"):
|
||||||
|
|
|
@ -551,9 +551,7 @@ def qemu(args: PmbArgs):
|
||||||
|
|
||||||
def stats(args: PmbArgs):
|
def stats(args: PmbArgs):
|
||||||
# Chroot suffix
|
# Chroot suffix
|
||||||
chroot = Chroot.native()
|
chroot = Chroot.buildroot(args.arch or Arch.native())
|
||||||
if args.arch != Arch.native():
|
|
||||||
chroot = Chroot.buildroot(args.arch)
|
|
||||||
|
|
||||||
# Install ccache and display stats
|
# Install ccache and display stats
|
||||||
pmb.chroot.apk.install(["ccache"], chroot)
|
pmb.chroot.apk.install(["ccache"], chroot)
|
||||||
|
|
|
@ -12,7 +12,9 @@ import pmb.build
|
||||||
import pmb.helpers.run
|
import pmb.helpers.run
|
||||||
import pmb.helpers.pmaports
|
import pmb.helpers.pmaports
|
||||||
|
|
||||||
|
# FIXME: dest_paths[repo], repo expected to be a Literal.
|
||||||
|
# We should really make Config.mirrors not a TypedDict.
|
||||||
|
# mypy: disable-error-code="index"
|
||||||
def check(pkgnames: Sequence[str]):
|
def check(pkgnames: Sequence[str]):
|
||||||
"""Run apkbuild-lint on the supplied packages.
|
"""Run apkbuild-lint on the supplied packages.
|
||||||
|
|
||||||
|
@ -54,7 +56,7 @@ def check(pkgnames: Sequence[str]):
|
||||||
options = pmb.config.apkbuild_custom_valid_options
|
options = pmb.config.apkbuild_custom_valid_options
|
||||||
|
|
||||||
# For each pkgrepo run the linter on the relevant packages
|
# For each pkgrepo run the linter on the relevant packages
|
||||||
for repo, apkbuild_paths in apkbuilds.items():
|
for pkgrepo, apkbuild_paths in apkbuilds.items():
|
||||||
pmb.chroot.root(["apkbuild-lint"] + apkbuild_paths,
|
pmb.chroot.root(["apkbuild-lint"] + apkbuild_paths,
|
||||||
check=False, output="stdout",
|
check=False, output="stdout",
|
||||||
output_return=True,
|
output_return=True,
|
||||||
|
|
|
@ -233,7 +233,7 @@ def get_with_path(pkgname, must_exist=True, subpackages=True, skip_extra_repos=F
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
def get(pkgname, must_exist=True, subpackages=True, skip_extra_repos=False) -> Optional[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]
|
return get_with_path(pkgname, must_exist, subpackages, skip_extra_repos)[1]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@ def apkindex_hash(url: str, length: int=8) -> Path:
|
||||||
return Path(f"APKINDEX.{ret}.tar.gz")
|
return Path(f"APKINDEX.{ret}.tar.gz")
|
||||||
|
|
||||||
|
|
||||||
|
# FIXME: make config.mirrors a normal dict
|
||||||
|
# mypy: disable-error-code="literal-required"
|
||||||
@Cache("user_repository", "mirrors_exclude")
|
@Cache("user_repository", "mirrors_exclude")
|
||||||
def urls(user_repository=True, mirrors_exclude: List[str] = []):
|
def urls(user_repository=True, mirrors_exclude: List[str] = []):
|
||||||
"""Get a list of repository URLs, as they are in /etc/apk/repositories.
|
"""Get a list of repository URLs, as they are in /etc/apk/repositories.
|
||||||
|
@ -82,7 +84,7 @@ def urls(user_repository=True, mirrors_exclude: List[str] = []):
|
||||||
for repo in pkgrepo_names() + ["alpine"]:
|
for repo in pkgrepo_names() + ["alpine"]:
|
||||||
if repo in mirrors_exclude:
|
if repo in mirrors_exclude:
|
||||||
continue
|
continue
|
||||||
mirror = config.mirrors[repo] # mypy: disable-error-code="literal-required"
|
mirror = config.mirrors[repo]
|
||||||
mirrordirs = []
|
mirrordirs = []
|
||||||
if repo == "alpine":
|
if repo == "alpine":
|
||||||
# FIXME: This is a bit of a mess
|
# FIXME: This is a bit of a mess
|
||||||
|
|
|
@ -72,9 +72,7 @@ class PmbArgs(Namespace):
|
||||||
flash_method: str
|
flash_method: str
|
||||||
folder: str
|
folder: str
|
||||||
force: bool
|
force: bool
|
||||||
fork_alpine: str
|
fork_alpine: bool
|
||||||
# This is a filthy lie
|
|
||||||
from_argparse: "PmbArgs"
|
|
||||||
full_disk_encryption: str
|
full_disk_encryption: str
|
||||||
hook: str
|
hook: str
|
||||||
host: str
|
host: str
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue