forked from Mirror/pmbootstrap
treewide: adopt pathlib.Path and type hinting (MR 2252)
With the new chroot type, we can now write fancy paths in the pythonic way. Convert most of the codebase over, as well as adding various other type hints. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
00383bf354
commit
31cc898dd5
64 changed files with 513 additions and 385 deletions
|
@ -1,5 +1,6 @@
|
|||
# Copyright 2023 Danct12 <danct12@disroot.org>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from pathlib import Path
|
||||
from pmb.helpers import logging
|
||||
import os
|
||||
|
||||
|
@ -20,7 +21,7 @@ def check(args: PmbArgs, pkgnames):
|
|||
|
||||
# Mount pmaports.git inside the chroot so that we don't have to copy the
|
||||
# package folders
|
||||
pmaports = "/mnt/pmaports"
|
||||
pmaports = Path("/mnt/pmaports")
|
||||
pmb.build.mount_pmaports(args, pmaports)
|
||||
|
||||
# Locate all APKBUILDs and make the paths be relative to the pmaports
|
||||
|
@ -28,9 +29,8 @@ def check(args: PmbArgs, pkgnames):
|
|||
apkbuilds = []
|
||||
for pkgname in pkgnames:
|
||||
aport = pmb.helpers.pmaports.find(args, pkgname)
|
||||
if not os.path.exists(aport + "/APKBUILD"):
|
||||
raise ValueError("Path does not contain an APKBUILD file:" +
|
||||
aport)
|
||||
if not (aport / "APKBUILD").exists():
|
||||
raise ValueError(f"Path does not contain an APKBUILD file: {aport}")
|
||||
relpath = os.path.relpath(aport, args.aports)
|
||||
apkbuilds.append(f"{relpath}/APKBUILD")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue