1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-13 19:39:51 +03:00
Commit graph

339 commits

Author SHA1 Message Date
Oliver Smith
06bd8d98a1
cross-native2: set CGO_CFLAGS, CGO_LDFLAGS (MR 2565)
Cross compiling go programs with cross-native2 fails for armv7, riscv64
and armhf unless we use CGO_ENABLED=1 in the APKBUILD (see related
aports issue).

Add --sysroot to CGO_CFLAGS, so cgo can find the includes and doesn't
fail with:

  go build -buildmode=pie -modcacherw -trimpath -buildvcs=false -ldflags "-s -w -X main.Version=2.6.1" -o mkinitfs ./cmd/mkinitfs
  # runtime/cgo
  _cgo_export.c:3:10: fatal error: stdlib.h: No such file or directory

Add it to LDFLAGS too for linking against libraries from the sysroot.

Related: https://gitlab.alpinelinux.org/alpine/aports/-/issues/15809
Related: https://stackoverflow.com/a/38835938
2025-03-09 15:27:27 +01:00
Clayton Craft
a5f7d6087a
pmb.build: install checkdepends when building (MR 2563)
Fixes a bug where checkdepends are not being installed, and packages
that run tests that depend on something in checkdepends fail because
it's missing. For example, the `plasma-workspace` forked pkg in pmaports
tells abuild to run `xwfb-run` in `check()`, this binary comes from
`xwayland-run`, which is listed in the `checkdepends`. However this
isn't being installed and so `pmb build` ultimately fails to build the
package.
2025-03-06 14:15:23 -08:00
Caleb Connolly
09053af572
build: backend: remove trailing spaces (MR 2474)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2025-02-27 01:29:35 +01:00
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
Stefan Hansson
bdcc188f05
pmb: Use explicit re-exports (MR 2545)
See https://docs.astral.sh/ruff/rules/unused-import
2025-02-23 11:40:44 +01:00
Newbyte
6415aea8af
pmb: Remove unnecessary pass statements (MR 2537)
See https://docs.astral.sh/ruff/rules/unnecessary-placeholder
2025-02-02 22:48:50 +01:00
Newbyte
8e09be579a
pmb.build.autodetect: Remove FIXME about type hinting arch (MR 2522)
This has been done now.
2025-01-15 23:25:57 +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
752c1df039
pmb.build.other: Fix broken f-string (MR 2525)
I'm guessing this was meant to be an f-string given that it uses the
formatting syntax for those.
2025-01-15 22:34:57 +01:00
Newbyte
871a3128d8
docs, pmb: Add missing copyright headers (MR 2516)
I tried my best to get the right author based on git commit history, but
in the case of code being moved from one file to make another I might
have gotten something wrong.
2025-01-02 16:45:03 +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
Newbyte
5ed5817e80
pmb: Add more type hints (MR 2490) 2024-12-19 10:09:22 +00:00
Caleb Connolly
aa847501c8
build: envkernel: overmount outdir/Makefile to use local include (MR 2504)
the kernel has pending patches in -next which adjust the generated
Makefile in the output directory to include the source tree makefile
with an absolute path, this breaks envkernel which relies on it being a
relative path.

Fix this by mounting our own Makefile instead using the relative path.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-12-01 19:40:28 +01:00
Caleb Connolly
932ac18791
build: envkernel: default to .output again (MR 2504)
We used to use .output as the default kbuild_out but this was removed
recently, add it back!

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-12-01 19:40:23 +01:00
Caleb Connolly
91f0a4feeb
build: newapkbuild: initialize chroot before use (MR 2495)
Otherwise abuild will try and fail to create /dev/null

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
[ci:skip-build]: already built successfully in CI
2024-11-22 12:18:52 +01:00
Caleb Connolly
04635dcb3e
build: envkernel: cleanup behaviour (MR 2491)
recent changes to the kernels build infra in -next seem to have exposed
some issues with "pmbootstrap build --envkernel", specifically in the
case where the APKBUILD doesn't build out-of-tree.

We used to rely on the fact that the kernel output directory contains a
Makefile which points to the source directory, however this Makefile
now(?) contains an absolute path on the host, which won't match what's
in the chroot.

As a result, it's now necessary to build with the same output directory
as the APKBUILD.

We probably need some smarter code here... and/or more consistent
APKBUILDs.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-20 22:49:32 +01:00
Newbyte
472726a9dc
pmb: Add more type hints (MR 2489) 2024-11-14 23:16:29 +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
Caleb Connolly
a72a60f546
core: pkgrepo: support arbitrarily named pmaports directories (MR 2470)
There was an oversight when this API was originally created and it
implicitly assumed that the pmaports repository was always named
"pmaports". This unfortunately broke some peoples workflows.

Introduce a new "pkgrepo_name()" function and adjust the codebase to use
it, as well as adjusting pkgrepo internally to special case the
"pmaports" repo so that it's always named pmaports no matter what the
directory itself is named.

This is probably more complexity than we should be dealing with here, we
should probably create a new type to encode this behaviour.

Fixes: #2412
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-03 12:26:32 +01:00
Newbyte
225d8b30a0
pmb: Add lots of type hints (MR 2464) 2024-10-30 12:39:45 +01:00
Newbyte
6b55ce7b53
pmb.build.envkernel: Convert Arch.native() to str (MR 2464)
We don't want an actual Arch object in the environment object.
2024-10-29 23:08:36 +01:00
Newbyte
98f1491426
pmb.build.envkernel: Properly construct path to remove (MR 2464)
Can't construct a path by using the / operator on strings, so use the
Path constructor instead.
2024-10-29 23:08:36 +01:00
Newbyte
f507aed9aa
pmb.build.autodetect: Fix return type and docstring for arch() (MR 2464)
At some point, this function was updated to use the Arch type instead of
plain strings, but the return type was left omitted and the docstring
outdated.
2024-10-29 13:49:37 +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
Newbyte
ca5c77fa20
pmb.core.config: Fix type of jobs variable (MR 2434)
I don't think there's any case where the number of jobs would have to be
a string. It's also being assigned an integer elsewhere the code (in
ask_for_additional_options() inside of init.py), so an integer seems
like what we actually want. Also fix type errors resulting of this.
2024-10-27 00:38:16 +02:00
jane400
afb036da0d
pmb.kconfig: refactor to remove args (MR 2346)
Co-authored-by: Stefan Hansson <newbyte@postmarketos.org>

Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2402
2024-10-22 00:04:32 +02: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
Luca Weiss
c3016e02c5
newapkbuild: globbing and Path fixes (MR 2416) 2024-09-30 18:58:37 +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