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

2035 commits

Author SHA1 Message Date
Oliver Smith
6a776fc67c
helpers.run.core.add_proxy_env_vars: fix variables (MR 2525)
Looks like there was a missing comma when this was added initially.
Caught this while reviewing the formatting patch.
2025-01-15 22:55:27 +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
2be49f8caf
pmb.install: Remove unnecessary calls to round() (MR 2525)
These values are already integers, so calling round() on them is
effectively a no-op.
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
7037d9ab46
pmb.helpers.aportupgrade: Remove unnecessary regex (MR 2525)
See https://docs.astral.sh/ruff/rules/unnecessary-regular-expression
2025-01-15 22:35:02 +01:00
Newbyte
d6f0c80431
pmb: Use raw strings for regexes (MR 2525)
See https://docs.astral.sh/ruff/rules/unraw-re-pattern
2025-01-15 22:35:02 +01:00
Newbyte
077efe3623
pmb.chroot.apk: Use unpacking operator to create command in install_run_apk() (MR 2525)
The unpacking operator can unpack any iterable of any type, unlike the +
operator which only works on some sequences and requires them to be of
the same type usually. Using it allows us to get rid of the line that
disables the "operator" error code for this function.
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
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
Newbyte
38b333372d
pmb.helpers.locale: Use frozenset for primary_layouts (MR 2525)
This shouldn't change at runtime, so avoid any potential issues with it
being a mutable class variable by making it immutable.
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
f43af8a115
pmb.commands.repo_bootstrap: Remove unnecessary noqa comment (MR 2525)
Not sure why this was added, but Ruff doesn't complain if I remove it.
2025-01-15 22:35:02 +01:00
Newbyte
5d707e154c
pmb.helpers.run_core: Remove unnecessary str(...) (MR 2525)
Integers automatically get converted to strings when used in f-strings
like this, so just get rid of this explicit conversion.
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
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
Oliver Smith
3f9f1c96c1
install: support systemd for disabling services (MR 2529)
Write a preset file and run "systemctl preset" afterwards:

    % sh -c echo 'disable sshd.service' > /usr/lib/systemd/system-preset/80-pmbootstrap-install-disable-sshd.preset
    % systemctl preset sshd.service
    % systemctl is-enabled sshd.service
    disabled
2025-01-12 15:33:02 +01:00
Oliver Smith
786c62767e
install: merge disable_sshd(), disable_firewall() (MR 2529)
These functions are identical, except for the service name. Merge them
in preparation to add systemd support.
2025-01-12 15:33:02 +01:00
Robert Eckelmann
a2f177433f
Cosmetic: pmb/install/_install.py: tweak strings (MR 2529)
Merge strings that have a break in the same line. These were generated
when running "ruff format" initially.

Old:
  logging.info("Firewall is not supported in checked out pmaports" " branch.")
New:
  logging.info("Firewall is not supported in checked out pmaports branch.")

Signed-off-by: Robert Eckelmann <longnoserob@postmarketos.org>
Tweaked-by: Oliver Smith <ollieparanoid@postmarketos.org>
2025-01-12 15:32:57 +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
21c1aa7c61
pmb.core.test_pkgrepo: Remove reference to master_staging_systemd (MR 2528)
This branch was removed from pmaports when we merged systemd into
master.
2025-01-10 19:28:39 +01:00
Oliver Smith
35d1a7b1b3
repo_missing: ensure pkgs don't depend on themselves
For some reason, gnome-shell-mobile depends on itself with current
resolving code. Ensure this does not happen.
2025-01-10 17:56:11 +01:00
Oliver Smith
6da1b6d635
repo_missing: fix picking wrong package info
Fix that repo_missing would pick the wrong package information if a
package is in both the normal repository and the split repository.

This would lead to having the wrong version and depends:

        "pkgname": "gnome-shell-mobile",
        "repo": null,  # not in the systemd repo
        "version": "99946.1-r1",
        "depends": [

Instead of the correct version:

        "pkgname": "gnome-shell-mobile",
        "repo": null,  # not in the systemd repo
        "version": "46.1-r1",
        "depends": [

Fix this by calling pmb.parse.apkbuild() directly with the APKBUILD path
when iterating over the APKBUILDs, instead of pmb.helpers.package.get().
2025-01-10 17:48:34 +01:00
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
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
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
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