Commit graph

3341 commits

Author SHA1 Message Date
Oliver Smith
3ddb725e8a
repo_missing: ensure abuild is not twice in deps
Fix that abuild gets added twice in packages that exist in both the main
and split systemd repository:

        "pkgname": "gnome-settings-daemon-mobile",
        "repo": null,
        "version": "99946.0-r0",
        "depends": [
            "abuild",
            "abuild",
            "alsa-lib-dev",
            "colord-dev",

This fixes the following error in bpo when it tries to use the output of
"pmbootstrap repo_missing":

  UNIQUE constraint failed: package_dependency.package_id, package_dependency.dependency_id

Related: https://postmarketos.org/edge/2025/01/09/systemd-soon/
2025-01-10 16:29:17 +01:00
Oliver Smith
02591cfda2
repo_missing: if abuild is forked, add it as dep (MR 2410)
In the systemd repository, we currently have a forked version of
abuild, which needs to be used to build all other packages. Check if we
have a forked abuild, and if it is the case, add it to the dependencies
of all other packages.

Closes: issue 2401
2025-01-10 13:04:48 +01:00
Oliver Smith
8d446c2aeb
Rewrite repo_missing for bpo + systemd split repo (MR 2410)
The "pmbootstrap repo_missing" action is used exclusively by bpo. It
calls it only with these arguments:

  pmbootstrap repo_missing --built --arch "$ARCH"

A blocker for merging systemd into pmaports master is, that the
current repo_missing code cannot display packages that are both in
extra-repos/systemd and in another path. I have considered just not
supporting this and discussed doing that with Caleb and Clayton, but we
figured it would be a major obstacle in the future to not be able to
easily override packages with systemd specific versions (currently we
need this for 3 packages).

Integrating this into the existing repo_missing code would be hacks upon
hacks. Also the scope of the current repo_missing code has many extra
features that are not used and would be extra effort to carry along:
* Allow specifying a pkgname
* Running without --built
* --overview

So I decided to replace the repo_missing code with a much simpler, more
modern implementation, that does exactly what is needed:
* Duplicate packages in systemd and non-systemd dirs are displayed
* The output always include all packages, no matter if they are already
  built or not (same behavior as with --built)
* Removed --overview and selecting specific packages too
* The code for filling "repo" (either "systemd" or None) is more
  resilient now, as it can use proper relative paths to the root of
  pmaports. Unlike the previous implementation, it will not fail if
  subdirs are added to the systemd dir.

I have made sure that the output is exactly the same as before on
current pmaports master.

Related: bpo issue 144
Related: bpo issue 140
2025-01-10 13:04:48 +01:00
magdesign
62e32e15a9
docs: use pmOS green color in html output (MR 2520)
Tweaked-By: Oliver Smith <ollieparanoid@postmarketos.org>
2025-01-06 14:00:58 +01:00
Oliver Smith
0640a21fba
editorconfig: new file (MR 2520) 2025-01-06 13:54:12 +01:00
Newbyte
c401555fb8
pyproject.toml: Enable Ruff preview (MR 2516)
We need this to check for copyright headers being absent (CPY001). In
the future, once that rule makes it out of preview, we can revert this
commit.
2025-01-02 16:45:03 +01:00
Newbyte
426dbec794
pyproject.toml: Add CPY001 to Ruff linting (MR 2516)
This lints copyright headers to ensure we don't forget them.
Unfortunately, it is only available in Ruff preview right now, so the
following commit will enable that for the Ruff CI check. However, this
could be reverted in the future once this check makes it into Ruff "not
preview".

Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2526
2025-01-02 16:45:03 +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
7f7af62697
pmb.parse.version: Use _ for "value" variable in validate() (MR 2516)
This variable is unused, mark it as such to appease Ruff.
2025-01-02 16:45:01 +01:00
Newbyte
3d2c85a4ab
CI: Simplify Ruff check (MR 2517)
As of 139c205424, we ignore F401 in
__init__.py through the pyproject.toml configuration file, so we don't
need to treat it differently here in the CI script too.
2025-01-02 16:20:57 +01:00
Newbyte
415893fb74
pmb.parse.version: Replace token_value() with Token enum (MR 2518)
Hopefully makes for easier to read code, and potentially also faster
once we have mypyc and the enum can get compiled into plain integers
instead of the strings we previously were working with.
2025-01-02 15:42:22 +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
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