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

580 commits

Author SHA1 Message Date
Stefan Hansson
32389415e3
pmb.config: Add pmb:cross-native2 to custom valid options (MR 2564)
This is needed for the linter to know about this option.

Fixes 2ee916f5d6
2025-03-08 04:03:35 +01:00
Caleb Connolly
92fca6614b
config: add pigz to build_packages (MR 2561)
Speed up compressing packages after build by using pigz which does
parallelised compression!

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2025-03-01 13:21:25 +00:00
Oliver Smith
c74735ea7a
Prepare 3.3.1 release 2025-02-27 01:09:19 +01:00
Anri Dellal
6411aa4791
helpers.cli: Fix regex validation (MR 2557)
According to Python documentation, p.match checks
if characters at the beginning of string match the regex

This commit changes validation to full length of string
2025-02-27 00:24:08 +01:00
Anri Dellal
f85899ef3d
pmbootstrap chroot: fix --image bugs (MR 2556)
- Properly run commands at host to mount rootfs
- Always refuse to zap chroot_image, since it is never added to workdir.cfg

Co-authored-by: Newbyte <newbyte@postmarketos.org>
2025-02-27 00:06:45 +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
Hugo Osvaldo Barrera
5a152aebae
test: move all tests into separate module (MR 2551)
When installing pmboostrap, all tests are installed alongside it. There
doesn't seem to be any way to selectively exclude some files inside
python modules, so move all test into a separate module instead.

This is the typical convention in python projects.

See: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/79862
Fixes: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2541
2025-02-13 01:28:20 +01:00
Hugo Osvaldo Barrera
c2bcc81589
pmb.config.init: prompt for pmaports path (MR 2502)
Allows easily using an existing checkout. The default path remains the
same.

Fixes: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2506
[ci:skip-build]: already built successfully in CI
2025-02-12 13:50:13 +01:00
Hugo Osvaldo Barrera
aed6c7f61e
pmb.config.init: resolve double-negation (MR 2502) 2025-02-12 13:50:13 +01:00
Newbyte
cda5d61593
pmb.config.init: Reformat some strings (MR 2535)
We extended the maximum line length at some point, so let's make use of
it.

[ci:skip-build]: already built successfully in CI
2025-02-10 13:22:07 +00:00
Newbyte
86aec42713
pmb.config.init: Improve message when "Archived:" header is missing (MR 2535)
This changes the output from e.g.

    WARNING: xiaomi-markw is archived: None

to

    WARNING: xiaomi-markw is archived: No reason given (this is a bug)

which I think is better and makes it clear that this is not behaviour
one should rely upon. All archived ports should have a reason given, but
this has not been (and still isn't as I'm writing this) enforced in
pmaports, so we can't rely on there being one.

Related: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6085
2025-02-10 13:22:07 +00:00
Oliver Smith
afecbb151d
Prepare 3.2.0 release 2025-01-19 14:08:06 +01:00
Newbyte
9a31fe43b3
pmb.config.other: Don't require selected UI package to exist (MR 2530)
Without this, `$ pmbootstrap init` crashes if a nonexistent UI package
is selected. This can happen if one previously selected a UI package in
a former checkout of pmaports, but then switched away to a different one
that doesn't have the UI package. For example, if someone is working on
a new UI in a feature branch and then switches away from it, or if a UI
is removed from the canonical pmaports repository altogether.
2025-01-16 12:25:02 +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
01abf537bb
pmb.config.init: Simplify removal of select from providers_cfg (MR 2525)
See https://docs.astral.sh/ruff/rules/if-key-in-dict-del
2025-01-15 22:35:02 +01:00
Newbyte
c2787aa76f
pmb: Replace list(...)[0] with next(iter(...)) (MR 2525)
See https://docs.astral.sh/ruff/rules/unnecessary-iterable-allocation-for-first-element
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
89210e42fc
pmb.config.pmaports: Make pmbootstrap automatically switch away from master_staging_systemd (MR 2528) 2025-01-10 19:28:39 +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
510469b304
pmb.config.pmaports: Get rid of cast hack for SectionProxy (MR 2519)
For some reason this also requires a fix in pmb.install._install.py,
didn't bother investigating why but the necessary change seems fine to
me.

Requires mypy 1.14 (maybe 1.14.1, not sure).
2025-01-02 14:17:55 +01:00
Newbyte
5ed5817e80
pmb: Add more type hints (MR 2490) 2024-12-19 10:09:22 +00:00
Newbyte
8d1ff21e9e
pmb.config.init: Use separate answer variable for sudo timer (MR 2490)
Otherwise mypy gets confused about the type as in this case the variable
gets set to a boolean and not a string.
2024-12-19 10:09:22 +00:00
Newbyte
6026b0e9ee
pmb.config.init: Explicitly convert string to int for config.extra_space (MR 2490)
See code comment for explanation.
2024-12-19 10:09:22 +00:00
Newbyte
73091016ae
pmb.config.init: Fix types in ask_for_systemd() (MR 2490)
pmb.helpers.cli.ask() returns a string, so previously this function was
just lying about its return type (which happened to be fine in the
context it was used, but still not what we want).
2024-12-19 10:09:22 +00:00
Newbyte
87900112c1
pmb.config.init: Fix types in ask_for_work_path() (MR 2490)
pmb.helpers.cli.ask() takes a string and only work with Path by
accident, so explicitly convert <default> to a string if it is not None.

Additionally, while this function claimed to return a Path, it actually
returned a string, so fix that too.
2024-12-19 10:09:22 +00:00
Stephan Gerhold
9f433b2b1d
pmb/config: enable "flasher boot" for fastboot-bootpart (MR 2508)
Devices using fastboot-bootpart typically boot directly from the boot file
system. They might still support "fastboot boot" though, which can be used
to boot a modified kernel more easily. Enable this similar to the existing
"flash_boot" action.
2024-12-16 13:37:29 +01:00
Oliver Smith
f9bca7cf09
Prepare 3.1.0 release
Prepare a new release, so pmbotostrap can be used with Alpine 3.21 /
postmarketOS v24.12. Also the big rewrite is done, so we can do more
frequent releases again.

Related: https://wiki.postmarketos.org/wiki/Pmbootstrap_release
2024-12-10 17:04:18 +01:00
Caleb Connolly
bb12609753
test: conftest: require_programs() automatically (MR 2483)
Pmbootstrap finds all its host dependencies during init, ensure we do
that for pytest too.

Adapt require_programs() to use subprocess directly rather than have to
solve the weird dependency chain of pmb.helpers.run which depends on the
global context being initialised before it's usable.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-29 16:50:04 +01:00
Oliver Smith
6836a55d60
pmb.config.apk_tools_min_version: add v3.21 2024-11-18 20:25:41 +01:00
Newbyte
0e9a2e596f
pmb.config.init: Call pmb.helpers.cli.confirm() correctly (MR 2489)
"y" only works here by accident as it's considered truthy by Python and
as such gets handled equivalently to True in the current implementation
of pmb.helpers.cli.confirm(), but it's still relying on unintended
behaviour. Change this to use a bool as intended.
2024-11-14 22:34:52 +01:00
Oliver Smith
79c6e4c36d
Prepare 3.0.0 release 2024-11-10 19:13:39 +01:00
Oliver Smith
0a0f6ead33
Replace skip_extra_repos -> with_extra_repos (MR 2480)
Replace the boolean skip_extra_repos with a new with_extra_repos
argument that can be default, enabled or disabled.

This will be used to explicitly enable extra repos in a package search
even if systemd is currently disabled, so we can display a hint when a
package was not found because systemd is disabled in a follow-up patch.
2024-11-10 17:43:39 +01:00
Luca Weiss
26f9d56b20
pmb.config: Print ssh keys filenames that will be copied during init (MR 2251)
Make it clear to the user which SSH keys get copied to the device, and
also link to the wiki page that tells the user how to change
ssh_key_glob.
2024-11-07 01:14:06 +01:00
Luca Weiss
ca9610a153
pmb.config: use ssh_key_glob for ask_for_ssh_keys (MR 2251)
Since a user can modify the glob to be somewhat arbitrary, use that to
check if any ssh keys exist and ask in pmbootstrap init.

Otherwise ssh_key_glob would only work if it was a subset of
~/.ssh/id_*.pub, so e.g. ~/.ssh/id_foo.pub but ~/.ssh/foo.pub wouldn't
work.
2024-11-07 01:14:02 +01:00
Oliver Smith
ee154ccdf9
require_programs: losetup --json: set output=null (MR 2475)
We don't care about the output of "losetup --json" here, we just want to
make sure that the argument exists. If it does not exist, we already
give an error to the user.

Set the output to null so it does not clutter the log since it runs with
every pmbootstrap command now.
2024-11-06 23:53:33 +01:00
Oliver Smith
54e55f26ef
require_programs: run losetup with absolute path (MR 2475)
Use the absolute path for it, so it works in Debian too as we run it
without sudo here to just check if the argument is supported.
2024-11-06 23:53:33 +01:00
Caleb Connolly
765ba770dd
chroot: merge executibles_absolute_path() logic into require_programs() (MR 2475)
Remove this chroot-specific helper and merge it in with the existing
require_programs() logic. Now we have one unified way to discover and
use programs from the host and where we can put any additional special
handling we might need.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-06 23:53:33 +01:00
Caleb Connolly
585c477239
config: find required programs every time pmbootstrap is run (MR 2475)
On debian systems in particular special handling is needed for
/usr/sbin. Let's do this once and then provide the host deps we use in a
nice accessible dictionary.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Tweaked-by: Oliver Smith <ollieparanoid@postmarketos.org>
2024-11-06 23:53:33 +01:00
Oliver Smith
c4194759f5
require_programs: Debian: find kpartx and losetup (MR 2475)
In Debian, /usr/sbin is not in PATH of regular users unless using sudo.
Fix that pmbootstrap won't find kpartx and losetup in /usr/sbin, and
complains about these even though they are installed.

Fixes: issue 2489
2024-11-06 23:53:29 +01:00
Caleb Connolly
d57b9e31e1
config: init: support --aports too (MR 2470)
We shouldn't overwrite config.aports if the user specified a custom
--aports directory. We only want to do this to update the default if
they're using a custom workdir.

Make the code here less aggressive, and correctly use the last entry in
config.aports as "pmaports" instead of the first.

Fixes: #2386
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-03 12:26:32 +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
Caleb Connolly
70dc855281
config: init: dont clobber config (MR 2470)
When pmbootstrap starts up, it loads the config file (or uses the
defaults) and then merged some arguments (e.g. --work) into it. However
in config.init.frontend() we were creating yet another new Config, but
it's too late to merge args in at this point...

Rework this slightly to fix that major oversight and remove the totally
unnecessary hack of calling pmb.config.load() again.

This fixes calling pmbootstrap init with --work

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-03 12:26:26 +01:00
Caleb Connolly
8b880b7198
config: export workdir modules (MR 2463)
Make intellisense happy

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-02 17:49:41 +01:00
Newbyte
225d8b30a0
pmb: Add lots of type hints (MR 2464) 2024-10-30 12:39:45 +01:00
Newbyte
e0a2fbf28c
pmb.config: Check for kpartx and losetup with --json support (MR 2450)
Running these inside the chroot is tricky, and we ended up reverting
previous commits that attempted to make them run there (see
1ec55fc11a). As such, just accept defeat
and ensure that the host has these.

Also see https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2465
2024-10-27 13:14:10 +01:00
Newbyte
612e212a5b
pmb.config.init: Use NonBugError if programs are missing (MR 2450)
We fully expect this to happen if a user hasn't configured their host
system properly. As such, don't treat it like a programming error.
2024-10-27 13:13:10 +01:00
Newbyte
ddd920b1b5
pmb.config.init: Add more type hints (MR 2434) 2024-10-27 00:38:16 +02:00
Newbyte
82a9059dc8
pmb.config.init: Don't convert sudo timer return value to str (MR 2434)
config.sudo_timer is a bool, and the returned value here is a bool. No
point in converting it to a str.
2024-10-27 00:38:16 +02: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
Newbyte
9467c8008c
pmb.config.init: Fixup strings (MR 2434)
These are artefacts from when our line length was shorter. Ruff didn't
really do a great job at fixing them up when autoformatting.
2024-10-27 00:38:16 +02:00