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

3230 commits

Author SHA1 Message Date
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
a828303398
pyproject.toml: Set disallow_untyped_calls = true (MR 2514)
We pass this check now, might as well.
2024-12-20 16:45:49 +01:00
Newbyte
d81de1f61c
pyproject.toml: Set disallow_untyped_defs = true (MR 2514)
Woo-hoo!
2024-12-20 16:29:44 +01:00
Newbyte
01264bd39f
pmb: Add more types and fix type errors (MR 2514) 2024-12-20 16:29:33 +01:00
Newbyte
3ee75e61a5
pmb.parse.arguments: Type hint and remove unused arguments from add_kernel_arg() (MR 2514)
Presumably, args and kwargs are just here to retain compatibility with
add_argument() from argparse.ArgumentParser, but they aren't actually
used and consequently only give the illusion of compatibility. Just
remove them to simplify the function signature.
2024-12-20 15:37:28 +01:00
Newbyte
7bca381dea
pmb.parse.arguments: Ignore attr-defined on arg.completer (MR 2514)
Currently, I don't think mypy can understand monkeypatched code like
this. So, just ignore it.
2024-12-20 15:29:18 +01:00
Newbyte
fec23070bc
pmb.parse.test_version: Add unit tests for version.py (MR 2514) 2024-12-20 14:41:33 +01:00
Newbyte
a6025ed42a
pmb.parse.version: Convert rest[0] to integer before storing it in value (MR 2514)
Previously, value would sometimes be a string despite the docstring
clearly stating that it should be an integer. This seems to have been a
consequence of literally copying the original C code without considering
that strings work differently between the languages, where the
original assigning a character in a string to an integer results in the
integer having the ASCII value of that character, in Python you just get
the string value of that character. As such, match the original
implementation by explicitly converting from a string to an integer
using ord(), which gives the Unicode code of the provided character.

It is not clear to me why this disparity didn't cause any issues beyond
type errors found by mypy.

See 5d796b5678/src/version.c (L101)
2024-12-20 14:39:46 +01:00
Newbyte
c38933f2e6
pmb.parse.version: Link to older apk-tools (MR 2514)
The file version.c in modern apk-tools does not at all resemble this
file. Link to one from around the time when this code was written to
make cross-referencing easier.

Also, switch from cgit to GitLab because I couldn't be bothered to
figure out how to go through file revisions on cgit.
2024-12-20 14:02:21 +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
c8194302fc
pmb.qemu.run: Fix odd strings (MR 2513)
Artefact from when we reformatted the entire codebase with Ruff.
2024-12-19 18:52:25 +01:00
Robert Eckelmann
b87ae17414
docs: fix typos (MR 2510)
this fixes the typos found in #2524

Signed-off-by: Robert Eckelmann <longnoserob@postmarketos.org>
2024-12-19 16:36:21 +01:00
Newbyte
d02d6f4bc9
pmb.aportgen: Update APKINDEX for relevant arch before parsing it (MR 2509)
This might have saved me a couple of minutes of debugging, at least.
While working with the aportgen code I had two distinct issues:

 1. APKINDEX was outdated, so I got an error about not being able to
    download the supposedly latest version of BusyBox as it no longer
    existed on Alpine's mirror.
 2. APKINDEX had not been created by any other command, so aportgen
    would tell me that it couldn't find the "busybox" package.

The changes in this commit resolves both of these issues from my
testing.
2024-12-19 16:29:32 +01:00
Newbyte
4cc50fa439
pmb.aportgen: Unify tempdir preparation and checksum generation (MR 2509)
These were almost identical across the Busybox, GRUB EFI, and musl
generators. Unify them by creating functions they all (and any future
aportgen generators) can call instead of having to maintain three
separate copies of this code.
2024-12-19 16:29:32 +01:00
Alexandre Messier
78407655a4
pmb.flasher.frontend: detect lk2nd as subpackage dependency (MR 2511)
When lk2nd is a dependency of a device subpackage (e.g. a mainline
kernel subpackage), it is not detected.

If no lk2nd pacakge is found, also parse the dependencies of all
subpackages.

Signed-off-by: Alexandre Messier <alex@me.ssier.org>
2024-12-19 16:27:54 +01:00
Newbyte
5ed5817e80
pmb: Add more type hints (MR 2490) 2024-12-19 10:09:22 +00:00
Newbyte
206ba62417
pmb.aportgen: Annotate <options> as AportGenEntry in generate() (MR 2490)
Otherwise mypy thinks it differs slightly from the <fork_alpine> == True
vs the <fork_alpine> == False code path.
2024-12-19 10:09:22 +00:00
Newbyte
d5cdc3e145
pmb.helpers.repo_missing: Use f-string in get_relevant_packages() (MR 2490)
Otherwise this will crash as you cannot directly concatenate str with
Arch, but f-strings don't have this problem.
2024-12-19 10:09:22 +00:00
Newbyte
1a0827c95c
pmb/helpers/repo_missing: Remove <arch> from filter_aport_packages() docstring (MR 2490)
This argument doesn't exist. Presumably this was copied from
filter_arch_packages() without adapting the comment.
2024-12-19 10:09:22 +00:00
Newbyte
5d1a2ebd39
pmb.commands.pull: Remove bool return type from run() (MR 2490)
This is the only command to return a bool from run rather than None, and
this return type doesn't seem to get used anywhere, so let's just remove
it.
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
Newbyte
df2593400d
pmb.parse.kconfig: Rename options to arch_options in check_config_options_set (MR 2490)
Otherwise mypy gets confused by the type later in the code, and I also
think it might be confusing behaviour in general that <options> gets
overwritten in this loop.
2024-12-19 10:09:22 +00:00
Newbyte
b2d32a85e9
pmb.parse.kconfig.check_config_options_set: Update docstring (MR 2490)
The mentioned variable no longer exists, so update it to reflect how
things work now.
2024-12-19 10:09:22 +00:00
Newbyte
c8bd5abde1
pmb.helpers.http: Simplify retrieve_json() (MR 2490)
The parameters of this function were needlessly complicated. While I
understand the intent of trying to replicate the API of retrieve()
without duplicating the parameter list, in practice this feels like
reducing duplication to a fault to me. This is due to that the third
parameter, <allow_404>, doesn't make sense in the context of
retrieve_json() as it would raise an exception[1] if retrieve() returns
None (which is the effect of <allow_404> when a 404 occurs), thus merely
changing the exception that gets raised to a less descriptive one
instead of actually behaving like retrieve() would with that parameter
set to True.

With <allow_404> eliminated, there's just two parameters left, and I
don't think duplicating those is a big deal. So make the function easier
to read and annotate by getting rid of the args/kwargs logic.

 [1]: json.loads() raises an exception if its first argument is None
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
47984a8722
Fix spelling "infront" -> "in front"
Make codespell CI check pass again. This is trivial, so directly pushing
to master.
2024-12-10 17:20:24 +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
Anri Dellal
d4985c9699
.gitignore: add note for missing text editors (MR 2501)
The note suggests to make local changes to git configuration
instead of expanding .gitingore with more editor files
2024-12-05 23:25:13 +01:00
Anri Dellal
dbf3e21446
pmb.aportgen.device: fix skipping when analyzing boot image (MR 2507)
Fix #2516
2024-12-05 23:11:26 +01:00
Anri Dellal
c831302a57
pmb.install._install: add setup_locale() (MR 2497)
Moves locale setup code to separate function
Adds code to install keyboard configuration based on chosen locale
2024-12-03 13:17:15 +01:00
Anri Dellal
bdc4a4872e
pmb.helpers.locale: add unit tests (MR 2497) 2024-12-03 13:17:14 +01:00
Anri Dellal
556160b200
pmb.helpers.locale: new module (MR 2497)
Add module that provides utilities and information related to localization.

Initial implementation includes code to generate keyboard configs
for locale set by user.
2024-12-03 13:17:14 +01:00
Oliver Smith
3e18183aed
docs: document PMB_APK_FORCE_MISSING_REPOSITORIES (MR 2506) 2024-12-03 10:08:56 +01:00
Oliver Smith
1dcb68bdca
docs: add env vars page with PMB_SUDO (MR 2506)
Move the description of PMB_SUDO from the README to docs.
2024-12-03 10:08:43 +01:00
Oliver Smith
559710c69a
CI: docs: fail on warning (MR 2506) 2024-12-03 10:08:43 +01:00
Oliver Smith
77125ff9fb
docs: fix 'WARNING: Title underline too short' (MR 2506) 2024-12-03 10:08:43 +01:00
Oliver Smith
268478a202
docs/api/pmb.commands: fix "failed to import" (MR 2506)
Fix the following:

  WARNING: Failed to import pmb.commands.kconfig_check.
  WARNING: Failed to import pmb.commands.kconfig_edit.
  WARNING: Failed to import pmb.core.crosstool.

Crosstool has been dropped and kconfig_check/_edit code has been merged
into a kconfig module.
2024-12-03 10:08:43 +01:00
Oliver Smith
07f04ae12a
pmb.helpers.repo.update: support PMB_APK_FORCE_MISSING_REPOSITORIES (MR 2505)
Do not abort if one or more APKINDEX files cannot be downloaded, if
PMB_APK_FORCE_MISSING_REPOSITORIES is set. This is needed when
bootstrapping new stable branches. The same environment variable is
already used in pmbootstrap code to pass --force-missing-repositories to
apk in pmb.chroot.apk.install_run_apk().
2024-12-03 06:24:03 +01: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
Anri Dellal
3204577530
Fix apkbuild parsing in edge cases (MR 2503)
This commit removes separator in split function arguments, so arrays
where items are separates by tabulation don't fail to parse properly.
2024-11-30 11:53:17 +03: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
Caleb Connolly
cefe98fb69
test: aportgen: test deviceinfo fastboot content (MR 2477) (MR 2483)
Add some tests to ensure that we spit out correct deviceinfo options for
boot images of header v0, 2, and 3.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-29 16:50:04 +01:00
Caleb Connolly
f090e86126
test: parse: add tests for bootimg parsing (MR 2477) (MR 2483)
Add some unit tests to ensure that the parser correctly detects boot
images with header v0, 2, and 3.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-29 16:50:04 +01:00
Caleb Connolly
39a696ceed
test: conftest: adjust pmaports fixture (MR 2477) (MR 2483)
make sure that calls to get_upstream_remote() will succeed by setting
pmb.config.git_repos() for the entire run. This might pollute some other
tests...

TODO: make less things depend on pmaports being cloned...

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-29 16:50:04 +01:00
Caleb Connolly
1131db214a
Revert "CI: Add bootimg analysis integration test (MR 2467)" (MR 2483)
This test includes a binary blob which we want to avoid in our codebase.

It is also better suited as a unit test where it can contribute to code
coverage. Revert this and use a unit test version instead.

This reverts commit d19de946b3.
2024-11-29 16:49:54 +01:00
Newbyte
7b0db9f864
pmb.core.arch: Use annotations from future instead of quoted Arch type (MR 2498) 2024-11-29 10:43:09 +01:00