Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • postmarketOS/pmbootstrap
  • fossdd/pmbootstrap
  • Adrian/pmbootstrap
  • JustSoup321/pmbootstrap
  • longnoserob/pmbootstrap
  • sixthkrum/pmbootstrap
  • ollieparanoid/pmbootstrap
  • magdesign/pmbootstrap
  • anjandev/pmbootstrap
  • HenriDellal/pmbootstrap
  • Minecrell/pmbootstrap
  • chipiguay/pmbootstrap
  • ijiki16/pmbootstrap
  • whynothugo/pmbootstrap
  • amessier/pmbootstrap
  • Eisenbahnfan/pmbootstrap
  • user0-07161/pmbootstrap
  • SzczurekYT/pmbootstrap
  • neuschaefer/pmbootstrap
  • knuxify/pmbootstrap
  • Frieder.Hannenheim/pmbootstrap
21 results
Show changes
Commits on Source (13)
......@@ -11,4 +11,4 @@ fi
set -x
pip install --break-system-packages --no-warn-script-location mypy
python -m mypy --color-output --check-untyped-defs pmbootstrap.py
python -m mypy pmbootstrap.py
......@@ -3,6 +3,7 @@
from pmb.core.context import get_context
from pmb.core.arch import Arch
from pmb.helpers import logging
from pmb.types import Bootimg
from pathlib import Path
import os
import pmb.helpers.cli
......@@ -119,21 +120,24 @@ def ask_for_bootimg():
logging.fatal("ERROR: " + str(e) + ". Please try again.")
def generate_deviceinfo_fastboot_content(bootimg=None):
def generate_deviceinfo_fastboot_content(bootimg: Bootimg | None = None) -> str:
if bootimg is None:
bootimg = {
"cmdline": "",
"qcdt": "false",
"dtb_second": "false",
"base": "",
"kernel_offset": "",
"ramdisk_offset": "",
"second_offset": "",
"tags_offset": "",
"pagesize": "2048",
"mtk_label_kernel": "",
"mtk_label_ramdisk": "",
}
bootimg = Bootimg(
cmdline="",
qcdt="false",
qcdt_type=None,
dtb_offset=None,
dtb_second="false",
base="",
kernel_offset="",
ramdisk_offset="",
second_offset="",
tags_offset="",
pagesize="2048",
header_version=None,
mtk_label_kernel="",
mtk_label_ramdisk="",
)
content = f"""\
deviceinfo_kernel_cmdline="{bootimg["cmdline"]}"
......
......@@ -106,7 +106,6 @@ def get_pkgver(original_pkgver: str, original_source=False):
:param original_pkgver: unmodified pkgver from the package's APKBUILD.
:param original_source: the original source is used instead of overriding
it with --src.
:param now: use a specific date instead of current date (for test cases)
"""
if original_source:
return original_pkgver
......
......@@ -39,14 +39,14 @@ def arch_from_deviceinfo(pkgname, aport: Path) -> Arch | None:
@Cache("package")
def arch(package: str | dict[str, Any]):
def arch(package: str | dict[str, Any]) -> Arch:
"""
Find a good default in case the user did not specify for which architecture
a package should be built.
:param package: The name of the package or parsed APKBUILD
:returns: arch string like "x86_64" or "armhf". Preferred order, depending
:returns: Arch object. Preferred order, depending
on what is supported by the APKBUILD:
* native arch
* device arch (this will be preferred instead if build_default_device_arch is true)
......
......@@ -182,7 +182,7 @@ def run_abuild(context: Context, pkgname: str, arch: Arch, apkbuild_path: Path,
if os.path.islink(chroot / "mnt/linux" / kbuild_out) and os.path.lexists(
chroot / "mnt/linux" / kbuild_out
):
pmb.chroot.root(["rm", "/mnt/linux" / kbuild_out])
pmb.chroot.root(["rm", Path("/mnt/linux", kbuild_out)])
pmb.chroot.root(["ln", "-s", "/mnt/linux", build_path / "src"])
pmb.chroot.root(["ln", "-s", kbuild_out_source, build_path / "src" / kbuild_out])
......@@ -193,7 +193,7 @@ def run_abuild(context: Context, pkgname: str, arch: Arch, apkbuild_path: Path,
env = {
"CARCH": str(arch),
"CHOST": str(arch),
"CBUILD": Arch.native(),
"CBUILD": str(Arch.native()),
"SUDO_APK": "abuild-apk --no-progress",
}
cmd = ["abuild", "rootpkg"]
......@@ -207,7 +207,7 @@ def run_abuild(context: Context, pkgname: str, arch: Arch, apkbuild_path: Path,
if os.path.islink(chroot / "mnt/linux" / kbuild_out) and os.path.lexists(
chroot / "mnt/linux" / kbuild_out
):
pmb.chroot.root(["rm", "/mnt/linux" / kbuild_out])
pmb.chroot.root(["rm", Path("/mnt/linux", kbuild_out)])
pmb.chroot.root(["rm", build_path / "src"])
......
......@@ -23,6 +23,8 @@ def build(flavor, chroot: Chroot):
if pmaports_cfg.get("supported_mkinitfs_without_flavors", False):
pmb.chroot.root(["mkinitfs"], chroot)
else:
if flavor is None:
raise AssertionError("flavor was none despite mkinitfs supporting omitted flavor")
release_file = chroot / "usr/share/kernel" / flavor / "kernel.release"
with release_file.open() as handle:
release = handle.read().rstrip()
......
......@@ -55,7 +55,7 @@ def get_subpartitions_size(chroot: Chroot):
root = pmb.helpers.other.folder_size(chroot.path) / 1024
root *= 1.20
root += 50 + int(config.extra_space)
return (boot, root)
return (boot, round(root))
def get_nonfree_packages(device):
......
......@@ -105,9 +105,9 @@ def create_and_mount_image(args: PmbArgs, size_boot, size_root, size_reserve, sp
images = {img_path_full: size_mb_full}
if split:
images = {img_path_boot: size_mb_boot, img_path_root: size_mb_root}
for img_path, size_mb in images.items():
logging.info(f"(native) create {img_path.name} " f"({size_mb})")
pmb.chroot.root(["truncate", "-s", size_mb, img_path])
for img_path, image_size_mb in images.items():
logging.info(f"(native) create {img_path.name} " f"({image_size_mb})")
pmb.chroot.root(["truncate", "-s", image_size_mb, img_path])
# Mount to /dev/install
mount_image_paths = {img_path_full: "/dev/install"}
......
......@@ -9,6 +9,7 @@ import pmb.chroot
import pmb.chroot.other
import pmb.chroot.apk
from pmb.core import Chroot
from pmb.types import Bootimg
def is_dtb(path) -> bool:
......@@ -73,7 +74,7 @@ def get_qcdt_type(path) -> str | None:
return None
def bootimg(path: Path) -> dict[str, str]:
def bootimg(path: Path) -> Bootimg:
if not path.exists():
raise RuntimeError(f"Could not find file '{path}'")
......@@ -176,7 +177,22 @@ def bootimg(path: Path) -> dict[str, str]:
# Cleanup
pmb.chroot.user(["rm", "-r", temp_path])
return output
return Bootimg(
cmdline=output["cmdline"],
qcdt=output["qcdt"],
qcdt_type=output.get("qcdt_type"),
dtb_offset=output.get("dtb_offset"),
dtb_second=output["dtb_second"],
base=output["base"],
kernel_offset=output["kernel_offset"],
ramdisk_offset=output["ramdisk_offset"],
second_offset=output["second_offset"],
tags_offset=output["tags_offset"],
pagesize=output["pagesize"],
header_version=output.get("header_version"),
mtk_label_kernel=output["mtk_label_kernel"],
mtk_label_ramdisk=output["mtk_label_ramdisk"],
)
def trim_input(f) -> str:
......
......@@ -9,26 +9,6 @@ from pmb.core import Chroot
from pmb.core.context import get_context
def package_from_aports(pkgname_depend):
"""
:returns: None when there is no aport, or a dict with the keys pkgname,
depends, version. The version is the combined pkgver and pkgrel.
"""
# Get the aport
aport = pmb.helpers.pmaports.find_optional(pkgname_depend)
if not aport:
return None
# Parse its version
apkbuild = pmb.parse.apkbuild(aport / "APKBUILD")
pkgname = apkbuild["pkgname"]
version = apkbuild["pkgver"] + "-r" + apkbuild["pkgrel"]
# Return the dict
logging.verbose(f"{pkgname_depend}: provided by: {pkgname}-{version} in {aport}")
return {"pkgname": pkgname, "depends": apkbuild["depends"], "version": version}
def package_provider(
pkgname, pkgnames_install, suffix: Chroot = Chroot.native()
) -> pmb.core.apkindex_block.ApkindexBlock | None:
......@@ -90,31 +70,3 @@ def package_provider(
# 7. Pick the shortest provider. (Note: Normally apk would fail here!)
return pmb.parse.apkindex.provider_shortest(providers, pkgname)
def package_from_index(
pkgname_depend, pkgnames_install, package_aport, suffix: Chroot = Chroot.native()
):
"""
:returns: None when there is no aport and no binary package, or a dict with
the keys pkgname, depends, version from either the aport or the
binary package provider.
"""
# No binary package
provider = package_provider(pkgname_depend, pkgnames_install, suffix)
if not provider:
return package_aport
# Binary package outdated
if package_aport and pmb.parse.version.compare(package_aport["version"], provider.version) == 1:
logging.verbose(pkgname_depend + ": binary package is outdated")
return package_aport
# Binary up to date (#893: overrides aport, so we have sonames in depends)
if package_aport:
logging.verbose(
pkgname_depend + ": binary package is"
" up to date, using binary dependencies"
" instead of the ones from the aport"
)
return provider
......@@ -3,13 +3,14 @@
from argparse import Namespace
from pathlib import Path
from typing import Literal, TypedDict
from typing import Any, Literal, TypedDict
from pmb.core.arch import Arch
CrossCompileType = Literal["native"] | Literal["crossdirect"] | None
CrossCompileType = Literal["native", "crossdirect"] | None
PathString = Path | str
Env = dict[str, PathString]
Apkbuild = dict[str, Any]
# 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
......@@ -28,6 +29,23 @@ class AportGenEntry(TypedDict):
confirm_overwrite: bool
class Bootimg(TypedDict):
cmdline: str
qcdt: str
qcdt_type: str | None
dtb_offset: str | None
dtb_second: str
base: str
kernel_offset: str
ramdisk_offset: str
second_offset: str
tags_offset: str
pagesize: str
header_version: str | None
mtk_label_kernel: str
mtk_label_ramdisk: str
# Property list generated with:
# $ rg --vimgrep "((^|\s)args\.\w+)" --only-matching | cut -d"." -f3 | sort | uniq
class PmbArgs(Namespace):
......
......@@ -50,3 +50,5 @@ addopts = [
"--basetemp=.pytest_tmp"
]
[tool.mypy]
check_untyped_defs = true