Commit graph

144 commits

Author SHA1 Message Date
Caleb Connolly
2ee916f5d6
build: add pmb:cross-native2 (MR 2474)
Set things up so that we can run abuild on the native chroot and use
it's cross compilation features rather than running it and the build
system through QEMU. This massively speeds up building when it works.

cross-native used to be quite limited in functionality and didn't
integrate into abuild itself, this commit fixes that.

Packages can opt-in to this by adding pmb:cross-native2 to their options
and configuring makedepends_host and makedepends_build.

This also speeds up building packages like postmarketos-initramfs since
it entirely avoids running commands through QEMU (usually abuild itself
would be run through QEMU).

Lastly, we preserve the old pmb:cross-kernel options, this can be used to
enable the old cross compiler behaviour which is used for cross
compiling kernels in pmaports. This allows them to keep being supporting
while we adapt them to the new cross-native2.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2025-02-27 01:29:35 +01:00
Newbyte
3061e702ab
pmb: Reformat with Ruff 0.9 (MR 2525)
See https://astral.sh/blog/ruff-v0.9.0
2025-01-15 22:35:02 +01:00
Newbyte
c797b30dfe
pmb: Use unpacking operator to concatenate collections (MR 2525)
See https://docs.astral.sh/ruff/rules/collection-literal-concatenation

This is also slightly faster according to a microbenchmark that
shows it taking around 19% less time to run:
https://github.com/astral-sh/ruff/pull/1957#issue-1538092351
2025-01-15 22:35:02 +01:00
Newbyte
678ce1db52
pmb.build._package: Replace sum() with functools.reduce() (MR 2525)
See https://docs.astral.sh/ruff/rules/quadratic-list-summation
2025-01-15 22:35:02 +01:00
Newbyte
0925b3e425
pmb: Add more type hints (MR 2513)
And fix some consequential type errors.

[ci:skip-build]: already built successfully in CI
2024-12-19 18:52:25 +01:00
Oliver Smith
2a7864b080
Tweak messages for 'Could not find aport' (MR 2480)
Replace aports -> pmaports in these messages.

$ pmbootstrap build systemd
[17:37:02] NOTE: The package 'systemd' exists in extra-repos/systemd, but systemd is currently disabled
[17:37:02] ERROR: Could not find package 'systemd' in pmaports
2024-11-10 17:43:39 +01:00
Newbyte
225d8b30a0
pmb: Add lots of type hints (MR 2464) 2024-10-30 12:39:45 +01:00
Newbyte
a89ecb11d2
pmb.build._package: Remove reference to nonexistent parameter (MR 2464)
No parameter called "now" exists for this function, so don't document
it.
2024-10-29 13:08:07 +01:00
Caleb Connolly
50321d41f6
build: package: skip prioritizing deps of pkg which are a subpkg of pkg (MR 2459)
Some packages in aports have their own subpackages in their
dependencies, for some reason. This causes our resolver to assume there
is a cyclical dependency.

Adjust the resolver to safely ignore these dependencies, since they'll
be built as a part of the package that depends on them.

For example, modemmanager depends on libmm-glib which is a subpackage of
modemmanager. Currently to build modemmanager in pmaports it would be
necessary to manually modify the APKBUILD after copying it from aports.
This change avoids that.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 19:36:04 +01:00
Caleb Connolly
657c25c904
build: package: error when --src and --arch but no APKBUILD (MR 2458)
See
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2473

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 17:03:00 +01:00
Caleb Connolly
2106e13f97
build: package: allow building old versions of packages with --force (MR 2457)
It may be desirable to test older versions of packages, allow them to be
built when --force is specified and print a warning that they won't be
installed automatically.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 16:17:12 +01:00
Stefan Hansson
71772b9b6b
pmb.parse.apkindex: Introduce proper typing (MR 2425)
And adjust other code.

Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2455
2024-10-13 20:12:34 +02:00
Clayton Craft
e56eadd6e9
pmb.build: make sure cross compiler config is appropriate for each given package (MR 2433)
Here's the problem: Imagine a queue with 2 packages in it, the 1st
package uses crossdirect and the second uses cross-native. When building
the 1st package, pmb will configure the native chroot for crossdirect
as expected. When it gets to the 2nd package, the chroot env/config
might not be appropriate for actually doing a native cross compile.

This re-inits the cross compiler stuff if the cross compile method
changes while processing the queue.

Another approach that might solve this problem is to not re-use chroots
when building packages... I didn't think this was a good way to go
because it would greatly increase runtime (having to recreate chroots
multiple times)
2024-10-11 14:06:47 -07:00
Stefan Hansson
521628ba50
pmb.build._package: Use deduced arch for error message (MR 2424)
Otherwise Arch may be None here which results in an error.
2024-10-07 23:57:07 +02:00
Oliver Smith
806d9a3925
build: package: fix missing f for f-string 2024-09-18 16:32:03 +02:00
Oliver Smith
0931eb924b
build: package: fix built pkgs count not going up
Fix #2448
2024-09-17 17:00:09 +02:00
Oliver Smith
b462a781ff
build: package: remove obsolete FIXME comment (MR 2388)
Logic for breaking dependency loops with existing binary packages is now
implemented, so remove the related comment.
2024-09-17 02:35:12 +02:00
Oliver Smith
fcbc96b2f1
build: package: proper missing dep error (MR 2388)
When a dependency cannot be found in source or binary packages of the
selected architecture, then don't look for binary packages in other
architectures package indexes.

This leads to a confusing error down the line when building packages for
extra_repos_systemd (and e.g. stable branches), because we don't have
binary packages for all arches that pmbootstrap supports, and so it
tries to fetch a non-existing APKINDEX.

Instead, print a nice error about a non-existing dependency.
2024-09-17 02:27:45 +02:00
Oliver Smith
0109af5245
prioritise_build_queue: subpkgs -> main pkgs (MR 2388)
Adjust the dependency resolver, so it uses the main pkgnames in
dependency resolution, instead of subpackages. This fixes for example
that it couldn't find -dev packages even though the binary packages for
those existed.

> 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
2024-09-17 02:27:44 +02:00
Oliver Smith
7c4c63f9fc
build: package: split has_cyclical_dep in function (MR 2388)
Split has_cyclical_dependency logic into an extra function, so it is
easier to read.
2024-09-17 02:27:44 +02:00
Oliver Smith
b76963ab03
pmb: build: add debug log about missing deps (MR 2388)
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
2024-09-17 02:27:44 +02:00
Oliver Smith
22865fdfa7
build: package: rename do_continue -> missing_deps (MR 2388)
Make the code easier to understand with a more meaningful variable name.
2024-09-17 02:27:44 +02:00
Oliver Smith
9542ed006d
build: package: better error for remaining pkgs (MR 2388)
List each pkgname in a new line, instead of having a one line list of
dictionaries with lots of attributes.
2024-09-17 02:27:44 +02:00
Oliver Smith
de7fdf6c97
build: package: add warning for cyclical build dep (MR 2388)
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
2024-09-17 02:27:44 +02:00
Oliver Smith
ed2077bfb1
build: package: move stuck var out of queue_item (MR 2388)
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().
2024-09-17 02:27:44 +02:00
Caleb Connolly
63ef3f1305
build: package: break cyclical dependencies in build queue (MR 2388)
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>
2024-09-17 02:27:44 +02:00
Caleb Connolly
52b85b2605
build: package: fix logging in pkgver mismatch (MR 2388)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-09-17 02:27:44 +02:00
Caleb Connolly
d4d6292545
build: package: build packages in the right order (MR 2388)
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>
2024-09-17 02:27:44 +02:00
Caleb Connolly
b7045702fb
build: package: include package count in msg about installing deps (MR 2388) 2024-09-17 02:27:44 +02:00
Caleb Connolly
03bccfd037
build: package: bail out if newer binary package exists (MR 2388)
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>
2024-09-17 02:27:44 +02:00
Caleb Connolly
bdc2c07837
build: package: improve readability of is_cached_or_cache() (MR 2388)
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>
2024-09-17 02:27:44 +02:00
Caleb Connolly
b63e7fa594
build: package: don't queue build_packages as dependencies (MR 2388)
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>
2024-09-17 02:27:44 +02:00
Caleb Connolly
69fa230f3f
build: package: build outdated dependencies for packages (MR 2388)
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>
2024-09-17 02:27:39 +02:00
Caleb Connolly
1fe7b9931c
build: package: queue subpkg depends for base package too (MR 2380)
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>
2024-07-21 17:38:04 +02:00
Caleb Connolly
e5dc22b838
build: package: queue subpkg depends for build (MR 2379)
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>
2024-07-21 17:25:31 +02:00
Caleb Connolly
3680a0d7de
Revert "build: package: add subpkg depends (MR 2377)" (MR 2379)
This reverts commit 6002a73329.
2024-07-21 17:08:42 +02:00
Caleb Connolly
6002a73329
build: package: add subpkg depends (MR 2377)
Recurse dependencies of subpackages too.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-19 16:58:26 +02:00
Caleb Connolly
d8e5037336
build: package: build build packages even when nothing else is queued (MR 2376)
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>
2024-07-18 03:41:05 +02:00
Oliver Smith
36dd53f402
Run ruff check --fix (MR 2357)
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.
2024-07-16 00:26:35 +02:00
Caleb Connolly
2ce06e9791
build: package: properly ensure build-base packages are built first (MR 2363)
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>
2024-07-12 00:37:12 +02:00
Caleb Connolly
889a1e011d
build: package: fail gracefully if --src and dependencies need building (MR 2363)
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>
2024-07-12 00:37:12 +02:00
Caleb Connolly
d2f40a9a29
build: package: update all build_packages in buildroot after building (MR 2363)
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>
2024-07-12 00:37:12 +02:00
Caleb Connolly
234673ce03
build: special case building abuild (MR 2356)
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>
2024-07-09 00:19:57 +02:00
Caleb Connolly
c5135ac62a
build: use get_pkgver() again (MR 2353)
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>
2024-07-09 00:07:53 +02:00
Arnav Singh
6915c6a17b
pmb.build._package: Fix installing cross-compile deps in native chroot (MR 2341) 2024-07-02 17:37:03 +02:00
Newbyte
b07fb4b24f
pmb.build._package: Move comment to docstring (MR 2337)
This explains a parameter, so let's put it in the right place.
2024-06-24 20:23:01 +02:00
Newbyte
ca6d0eba28
pmb.build: Properly type cross-compilation types (MR 2337) 2024-06-24 20:23:01 +02:00
Oliver Smith
18fa4e58a3
Ruff: fix typing.Xxx is deprecated, use xxx instead (MR 2327) 2024-06-23 19:13:57 +02:00
Hugo Osvaldo Barrera
e421bb2d41
Auto-format codebase with ruff (MR 2325)
See: https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2324
Closes: https://gitlab.com/postmarketOS/pmbootstrap/-/merge_requests/2278
2024-06-23 15:40:13 +02:00
Caleb Connolly
e6c737f342
ruff: run check --fix (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:42 +02:00