Have messages like the following in "pmbootstrap log" to better
understand why resolving packages fails. The bug with -dev pkgs not
being recognized will be fixed in a follow-up patch.
> systemd: missing dependency linux-pam-dev, trying to queue other packages first
> linux-pam: missing dependency systemd-dev, trying to queue other packages first
> dbus: missing dependency systemd-dev, trying to queue other packages first
Print a warning when breaking cyclical dependencies, for example with
current kde-nightly branch:
> WARNING: cyclical build dependency, building kirigami with binary package of qqc2-desktop-style
Set "stuck = False" in the "while disarray and not stuck" loop
directly, instead of setting it in the queue_item() function that gets
called from it. This way the loop logic can be understood without
looking at queue_item().
Most of the time when building it's reasonably safe to fall back on an
older binary package for building in order to break cyclical
dependencies (e.g. dbus and systemd depend on each other at build time,
but it's safe to build both against older versions of the other).
Implement the necessary logic to break cyclical dependencies by
detecting them and checking for the existence of a binary package.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Tweaked-by: Oliver Smith <ollieparanoid@postmarketos.org>
Decide the order to build packages in by looking through the build queue
and making sure dependencies are queued before any packages that depend
on them, bailing out in the case of cyclical dependencies.
This should handle subpackages too.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
When building with --src or --force, other logic to detect when to build
a package is skipped. However there are no (known) cases when someone
might want to build a package if the resulting binary package version
will be older than an existing binary package. Catch this case and fail
with recommendations for user action (update pmaports, clear local
binary repo).
This should help avoid the situation where you accidentally build an old
version of a package and it never actually gets installed.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Tweaked-by: Oliver Smith <ollieparanoid@postmarketos.org>
This function is really hard to understand, try to make this a bit
better by adjusting the wording to better reflect what it does.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
build_packages like apk-tools and alpine-base might get picked up and
queued for build as dependencies of other packages. We don't want this
since we always ensure they are queued first. Avoid queuing them in this
case.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
It turns out the current behaviour was not preserving the old behaviour
at all, and was wrong. We want to build ALL outdated or new packages we
encounter via the dependency graph.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
We handle this correctly for dependencies of the base package but not
the base package itself.... Fix this.
Should avoid duplication here ideally.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
A previous attempt inserted subpackage depends into the package depends
list returned by get_depends().
This meant that pmb would try to install subpackage depends when
building the package, which breaks for some cases like device packages
with kernel variants since the depends of different subpackages might
conflict with each other.
Let's instead just add the subpackage depends to the build queue, so
they get built like package depends, without being pulled in as build
dependencies for the package.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Bail on empty build queue after checking if build_packages need
building. So if apk-tools / alpine-base / etc are outdated but nothing
else is they'll still be built.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Now that we have target-version = "py310" in [tool.ruff] in
pyproject.toml, ruff check complains about using typing.Optional and
typing.Union instead of newer syntax. Run the tool to fix it.
In ("build: special case building abuild (MR 2356)") we tried to ensure
that abuild would be built before anything else, however this
implementation failed miserably if the first package given didn't
actually need to be built (since we skip building deps of packages that
aren't flagged for build).
Let's take a different stab at this by actually inserting build_packages
into the build queue if they need building. They're inserted at the end
just before the queue is reversed, so they will always be built first.
This makes the order of pmb.config.build_packages important, enshrine
this with a comment.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
If you build a package with --src but some dep is outdated, force you
to build it (or otherwise handle the situation yourself). We can't guess
what to do here.
This could be made configurable (opt-in) in the future.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
We might have just built some other package which will later be used to
build more packages. Handle all of them and don't special case abuild.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Since abuild is an implicit dependency of everything, we need special
case handling for it. Insert it as a dependency of the first package in
the build queue so that it will be built if outdated, then after
building re-install it in the chroot so all subsequent packages will use
the freshly built abuild.
This is currently used for systemd where we use an abuild fork
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
During rework this got lost, re-incorporate it so packages built with
--src have a relevant pkgver.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This is a potential security risk. Tighten things up so we only allow
local checksums to mismatch but remote ones must be correct.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This avoids copying local build artifacts and other things, if they're
in .gitignore then abuild shouldn't need them anyway.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
We can fairly easily patch abuild by appending anything we want to the
APKBUILD file after copying it to the chroot.
Leverage this to override the verify() function so that it doesn't die
when checksums don't match.
Instead let's build the package anyway, but set a flag and print a
warning with instructions on how to generate the checksums.
We should continue to require APKBUILDs in pmaports to have valid
checksums.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
It was the case that packages were being queued in the wrong order,
since the dependency resolver queues the package before descending into
it's dependencies. This was a bit of a goof since the top level package
was always added last. If we add it first then we can just reverse the
queue and now everything is fine...
Additionally, the logic on when a dependency should be built was a bit
wonky. A case is added for when a dependency exists only in the source
repo and the requisite package isn't marked for build. The solver will
now build the dependency regardless. This is surely an edgecase but
somehow I ran into it, I suspect due to a bug elsewhere...
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Rename build.package() to build.packages() and take a list of packages
to build, since every caller was inside a for loop this simplifies
usage and let's us give nicer log output by doing all the builds first,
so log messages don't get lost in the middle.
Behaviour is cleaned up so this shouuuuld work pretty well now. It
properly descends into dependencies and will build dependencies even if
the package given doesn't need building. Technically this was only done
before during install where the dependencies were recursed in
chroot.apk.install().
It probably makes the most sense to have a mode where it doesn't build
dependencies but warns the user about it, at least when invoked via
pmbootstrap build.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
The package builder has long been a pain point since it recurses the
entire dependency tree.
Convert it to run in two stages, first it walks through the package
dependencies, descending into each one and processing them in a queue.
If a package is determined to need building then it gets pushed onto the
build_queue.
Then, it pops each package off the build queue (which is actually a
stack..) and builds it.
This avoids recursion entirely and should open the door to optimisations
in the future.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Move pmb/parse/arch.py over to core and refactor it as an Arch type,
similar to how Chroot was done. Fix all the uses (that I can find) of
arch in the codebase that need adjusting.
The new Arch type is an Enum, making it clear what architectures can be
represented and making it much easier to reason about. Since we support
~5 (kinda) different representations of an Architecture (Alpine, Kernel,
target triple, platform, and QEMU), we now formalise that the Alpine
format is what we represent internally, with methods to convert to any
of the others as-needed.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Use a different binary repo depending on the source repository for the
package. This makes it possible to split out systemd packages into their
own repository.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>