Commit graph

21 commits

Author SHA1 Message Date
Newbyte
0ade6cab4d
pmb: Use inspect.get_annotations()
On Python 3.10 and newer, this is the recommended way of accessing
annotations[1]. It also works with Mypyc, unlike directly accessing
__annotations__.

 [1]: https://docs.python.org/3/howto/annotations.html

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2634
2025-07-10 21:09:41 +02:00
slonkazoid
71f01ddbeb
pmb.core.config: remove +1 from nproc defaults
Since Linux has switched to EEVDF[1], the $(($(nproc)+2)) hack is no
longer faster. The new scheduler is way more efficient and performs
better with only `nproc` threads.

 [1]: https://docs.kernel.org/scheduler/sched-eevdf.html

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2595
2025-05-11 17:28:35 +02:00
Anri Dellal
192a29fb1b
pmbootstrap config: Fix setting attribute value to False (MR 2546)
_type(value) in super().__setattr__(key, _type(value)) always returns
True for a valid string, even if the string is "False".

This code also didn't fail when any other value besides True or False
was passed, though it must fail.

Fix #2554
2025-02-16 20:41:18 +01:00
Newbyte
4868cc9548
pmb.core.config: Add note about aports variable being class variable (MR 2525)
See https://docs.astral.sh/ruff/rules/mutable-class-default
2025-01-15 22:35:02 +01:00
Newbyte
e36801cc81
pmb.core.config: Mark mirrors and providers as class variables (MR 2525)
While it probably wasn't the intent, this is what they are in practice.
Mark them as such to help mypy.

See https://docs.astral.sh/ruff/rules/mutable-class-default
2025-01-15 22:35:02 +01:00
Oliver Smith
eb34843f4b
Update systemd repo URL
Now that systemd was merged into master, it is extra-repos/systemd
instead of staging/systemd.

As of writing, the repository is not published yet but this will happen
soon.

Related: https://postmarketos.org/edge/2025/01/09/systemd-soon/
2025-01-10 19:59:50 +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
5ed5817e80
pmb: Add more type hints (MR 2490) 2024-12-19 10:09:22 +00:00
Luca Weiss
49fd496c94
pmb.config: Set default ssh_key_glob to *.pub (MR 2251)
When generating an ssh key it's simple to change the name of the key to
something that's not e.g. id_rsa.pub or id_ed25519.pub, so let's try to
capture ssh keys for more users.
2024-11-07 01:14:06 +01:00
Newbyte
225d8b30a0
pmb: Add lots of type hints (MR 2464) 2024-10-30 12:39:45 +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
Oliver Smith
591a737733
Support setting custom mirrors + disabling mirrors (MR 2361)
Allow setting _custom mirrors in the config:
* alpine_custom
* pmaports_custom
* systemd_custom

When these are set, they are added to /etc/apk/repositories before real
repositories. This is used by bpo to build packages with a WIP
repository enabled, in addition to the final repository.

All mirrors can also be set to "none" to be disabled. This is important
for bootstrapping from pure Alpine without any binary repository, and
the bpo testsuite also uses this.

I've discussed with Caleb whether to name it _wip instead of _custom,
but the latter is more generic and people may also use this for other
use cases than the bpo wip repository thing.
2024-07-16 00:34:06 +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
acd938c6b2
Remove super() syntax from Python 2.0 (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
30fde53279
vermin: don't use StrEnum (MR 2252)
It was only introduced in 3.11. Instead just define __str__() manually
for the Enums where it's needed.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:42 +02:00
Caleb Connolly
c1aa5acdaa
config: add auto_zap_misconfigured_chroots (MR 2252)
This option will make pmbootstrap automatically zap chroots that are
initialized for the wrong channel, making it much faster to switch
between edge and systemd.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
133091248f
repo: use new config.mirrors (MR 2252)
Use the new config.mirrors section to handle repository URLs instead of
the old mirror_alpine / mirrors_postmarketos options. This let's us
add the systemd staging repo automatically when on the systemd staging
branch / systemd is enabled.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:39 +02:00
Caleb Connolly
1a01738d50
config: sanity check via types (MR 2252)
Replace the "sanity_check" code with type checking built into the Config
__setattr__ operator.

This keeps all the Config related code in one place.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:39 +02:00
Caleb Connolly
7a8deb0f5e
config: clean up parsing and add mirrors (MR 2252)
Add a new config section "mirrors", to replace the mirrors_alpine and
mirrors_postmarketos options. This will allow for more flexibility since
we can then handle the systemd staging repo (and others like plasma
nightly) with relative ease.

The loading/saving is fixed and now properly avoids writing out default
values, this way if the defaults are changed the user won't be stuck
with old values in their pmbootstrap.cfg.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:39 +02:00
Caleb Connolly
450bc6873d
core: move Config type (MR 2252)
Keeping the Config class in types seemed kinda weird and was just done
as a workaround to some cyclical imports. But now things are more in
shape let's move it to core.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:39 +02:00