forked from Mirror/pmbootstrap
The "pmbootstrap repo_missing" action is used exclusively by bpo. It calls it only with these arguments: pmbootstrap repo_missing --built --arch "$ARCH" A blocker for merging systemd into pmaports master is, that the current repo_missing code cannot display packages that are both in extra-repos/systemd and in another path. I have considered just not supporting this and discussed doing that with Caleb and Clayton, but we figured it would be a major obstacle in the future to not be able to easily override packages with systemd specific versions (currently we need this for 3 packages). Integrating this into the existing repo_missing code would be hacks upon hacks. Also the scope of the current repo_missing code has many extra features that are not used and would be extra effort to carry along: * Allow specifying a pkgname * Running without --built * --overview So I decided to replace the repo_missing code with a much simpler, more modern implementation, that does exactly what is needed: * Duplicate packages in systemd and non-systemd dirs are displayed * The output always include all packages, no matter if they are already built or not (same behavior as with --built) * Removed --overview and selecting specific packages too * The code for filling "repo" (either "systemd" or None) is more resilient now, as it can use proper relative paths to the root of pmaports. Unlike the previous implementation, it will not fail if subdirs are added to the systemd dir. I have made sure that the output is exactly the same as before on current pmaports master. Related: bpo issue 144 Related: bpo issue 140
57 lines
2 KiB
Python
57 lines
2 KiB
Python
# Copyright 2025 Oliver Smith
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
from pmb.core.arch import Arch
|
|
from pmb.core.context import get_context
|
|
from pathlib import Path
|
|
|
|
import pmb.build
|
|
import pmb.helpers.package
|
|
import pmb.helpers.pmaports
|
|
import glob
|
|
import os
|
|
|
|
|
|
def generate(arch: Arch) -> list[dict[str, list[str] | str | None]]:
|
|
"""Get packages that need to be built, with all their dependencies. Include
|
|
packages from extra-repos, no matter if systemd is enabled or not. This
|
|
is used by bpo to fill its package database.
|
|
|
|
:param arch: architecture (e.g. "armhf")
|
|
:returns: a list like the following:
|
|
[{"pkgname": "hello-world", "repo": None, "version": "1-r4"},
|
|
{"pkgname": "package-depending-on-hello-world", "version": "0.5-r0", "repo": None}]
|
|
"""
|
|
ret = []
|
|
pmaports_dirs = list(map(lambda x: Path(x), get_context().config.aports))
|
|
|
|
for pmaports_dir in pmaports_dirs:
|
|
pattern = os.path.join(pmaports_dir, "**/*/APKBUILD")
|
|
|
|
for apkbuild_path_str in glob.glob(pattern, recursive=True):
|
|
apkbuild_path = Path(apkbuild_path_str)
|
|
pkgname = apkbuild_path.parent.name
|
|
|
|
if not pmb.helpers.package.check_arch(pkgname, arch, False):
|
|
continue
|
|
|
|
relpath = apkbuild_path.relative_to(pmaports_dir)
|
|
repo = relpath.parts[1] if relpath.parts[0] == "extra-repos" else None
|
|
|
|
entry = pmb.helpers.package.get(pkgname, arch, True, try_other_arches=False)
|
|
|
|
if entry is None:
|
|
raise RuntimeError(f"Couldn't get package {pkgname} for arch {arch}")
|
|
|
|
ret += [
|
|
{
|
|
"pkgname": entry.pkgname,
|
|
"repo": repo,
|
|
"version": entry.version,
|
|
"depends": entry.depends,
|
|
}
|
|
]
|
|
|
|
# "or -1" is needed for mypy
|
|
# https://github.com/python/mypy/issues/9765#issuecomment-1238263745
|
|
ret = sorted(ret, key=lambda d: d.get("pkgname") or -1)
|
|
return ret
|