Commit graph

2784 commits

Author SHA1 Message Date
Caleb Connolly
afbecb7184
helpers: mount: fix rootfs mount path (MR 2344)
Subtle...

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:01:13 +02:00
Caleb Connolly
7741f74d44
helpers: toml: fix mypy on import (MR 2344)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:01:13 +02:00
Caleb Connolly
6301212d99
install: partition: drop unused args (MR 2344)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:01:12 +02:00
Caleb Connolly
f794b36f26
meta: cache: fix type hinting on cached functions (MR 2344)
By using a TypeVar we can make mypy give proper hints for the arguments
and return type of cached functions, rather than just showing "Wrapper"
as the type.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:01:12 +02:00
Caleb Connolly
5881d01cce
chroot: init: build a nice log message for outdated chroots (MR 2344)
* Cache the function so we only do the check once per-run
* check all chroot's at once so the message will be printed near the
  start of output (rather than halfway through after building packages
  or something).

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:00:14 +02:00
Caleb Connolly
62fa40e104
config: workdir: make chroots_outdated() return a list (MR 2344)
This can be used to build nicer log messages. For funsies let's try out
@overload as well.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:00:14 +02:00
Caleb Connolly
95d68d8854
helpers: args: improve please_i_really_need_args() logging (MR 2344)
dumping a stack trace directly to the console is not nice, keep it to
the log file.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:00:14 +02:00
Caleb Connolly
fce06843fc
helpers: repo: drop cache key in update (MR 2344)
Simplify the caching here and use logging.warn_once.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:00:14 +02:00
Caleb Connolly
55c912d410
helpers: logging: add warn_once() (MR 2344)
Add a warn_once() function using Cache. Since we use f-strings
everywhere we don't really need the varargs.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:00:14 +02:00
Oliver Smith
a57b338e9e
pmb.helpers.ui.check_option: fix for UI = none (MR 2348)
Don't crash on master_staging_systemd (and in the future the merged
systemd branch) if "none" is selected as UI.

Fix for:
  ERROR: Could not find aport for package: postmarketos-ui-none
2024-07-05 00:48:52 +02:00
Anri Dellal
8948594d74
Fix "pmbootstrap log -c" crash (MR 2345)
Fixes #2387
2024-07-03 08:11:04 +00:00
Oliver Smith
67767b99ad
pmb.types: fix aports not being a list (MR 2342)
The --aports argument gets parsed into a list, see
pmb/parse/arguments.py:

    parser.add_argument(
        "-p",
        "--aports",
        help="postmarketos aports (pmaports) path",
        type=lambda x: [Path(p.strip()) for p in x.split(",")],
    )

Adjust pmb.types to reflect this.

Fix for:
  pmb/helpers/args.py:58: error: "Path" has no attribute "__iter__"; maybe "__enter__"? (not iterable)  [attr-defined]
2024-07-02 17:40:35 +02:00
Oliver Smith
9bbe5ebe30
pmb.types: remove _aports_real (MR 2342)
According to git grep, nothing uses this. Looks like a refactoring
leftover so remove it.
2024-07-02 17:40:35 +02:00
Oliver Smith
91aee0b34c
Fix custom pmaports dir (pmbootstrap --args) (MR 2342)
The aports argument is a list of paths now, so iterate over each of them
when checking if they exist.

Fix for:
INFO:root:ERROR: 'list' object has no attribute 'exists'
2024-07-02 17:40:35 +02:00
Arnav Singh
6915c6a17b
pmb.build._package: Fix installing cross-compile deps in native chroot (MR 2341) 2024-07-02 17:37:03 +02:00
Caleb Connolly
3d04e011f9
config: use is instead of == (MR 2343)
make ruff happy

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-02 13:33:23 +02:00
Oliver Smith
6c4b4c4993
CI: ignore 'import tomllib' in vermin (MR 2333) 2024-06-30 18:04:31 +02:00
Oliver Smith
1dfaafe577
kconfig check: move rules to kconfigcheck.toml (MR 2333)
Move all kconfig rules from pmb.config to a separate toml file
pmb/data/kconfigcheck.toml. This is a fallback, pmbootstrap now prefers
loading kconfigcheck.toml from the currently checked out pmaports branch
if it exists.

This finally allows having separate kconfig check rules per pmaports
branch and makes the workflow of adjusting these rules much more
pleasant as the rules and kernel configs can just be adjusted at the
same time in pmaports!

This patch also moves the definition of what rules should be checked for
community and main devices, those that have pmb:kconfigcheck-community
in their linux APKBUILD, to the new kconfigcheck.toml. This should make
it much more intuitive, previously one needed to find the place in the
pmbootstrap source and edit it there.

Furthermore the "enforce_check" logic is removed. Previously pmbootstrap
would print warnings for failed config checks in some cases, but not
exit with error which was very confusing. Now exit 0 means all checks
passed and exit 1 means, that there is at least one error.

Use toml for the file, as discussed in pmbootstrap issue 2165. Python
3.11 has a native toml reader, use tomli for previous Python versions
for compatibility.
2024-06-30 18:04:31 +02:00
Oliver Smith
b6058e3569
pmb.helpers.frontend.kconfig: modernize (MR 2333)
Create new pmb/commands/kconfig_check.py and _edit.py files and move
related code there.
2024-06-30 18:04:31 +02:00
Oliver Smith
6f6cf1e8da
kconfig check: remove --kconfig-check-{name} args (MR 2333)
Prepare to move the kconfigcheck config into pmaports, so it can be
different per branch and so we can adjust it at the same time as
adjusting the kernel configs.

Once it is moved, pmbootstrap will not know the cateogry names in
advance anymore, so remove the logic for having category-specific
argument names.

In a future patch, we could add an option to manually override the
categories to be tested with one specific category (taking a string
argument), if there is demand for that.
2024-06-30 18:04:31 +02:00
Caleb Connolly
9daa888f0f
core: chroot: validate name for rootfs chroot (MR 2332)
Make sure we get a valid name in the rootfs type chroot.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-30 17:51:45 +02:00
Caleb Connolly
35eff91564
treewide: drop context.device (MR 2332)
this turns out to have never been set??? We have config.device anyways,
so let's use that instead.

Tweaked-by: Oliver Smith <ollieparanoid@postmarketos.org>
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-30 17:51:45 +02:00
Caleb Connolly
84332cdce0
config: init: args.keymap -> config.keymap (MR 2332)
Note by Oliver: this patch also removes the args argument from
ask_for_username.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-30 17:51:35 +02:00
Anri Dellal
0c932c273d
Fix bootimg_analyze error (MR 2339)
Fix error:
rm: can't remove '/tmp/bootimg_parser': No such file or directory

Fixes #2379
2024-06-30 17:40:01 +02:00
jane400
3a9284da8a
pmb.parse.deviceinfo: add default for gpu_accelerated (MR 2340)
this fixes pmb.config.init: ask_for_ui.
2024-06-30 17:36:32 +02:00
jane400
0a1e3eeeb1
pmb.config: add default ui option for ask_for_ui (MR 2340)
Tweaked-By: Oliver Smith <ollieparanoid@postmarketos.org>
2024-06-30 17:36:08 +02:00
gompa
8390a093d8
Fix quotation reuse (MR 2336)
Python 3.10.12 fails without this patch:

File "/media/gompa/73d88639-a730-456c-a428-6d500b4020b7/pmbootstrap/pmb/parse/arguments.py", line 844 help="Alpine Linux mirror, default: " f"{default_config.mirrors["alpine"]}",
SyntaxError: f-string: unmatched '['

Related: https://peps.python.org/pep-0701/
(Commit message written by Oliver)
2024-06-24 21:55:53 +02:00
Newbyte
8c0bc2e0e8
pmb.helpers.frontend: Print paths as a shell-friendly string (MR 2337)
Instead of

    [PosixPath('/home/newbyte/.local/var/pmbootstrap/cache_git/pmaports')]

you get

    /home/neboula/.local/var/pmbootstrap/cache_git/pmaports

like before.

Fixes envkernel.sh failing during activation.

Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2378
2024-06-24 21:12:31 +02:00
Newbyte
d50ce1c59b
pmb: Annotate args (MR 2337)
Checking if TYPE_CHECKING avoids the circular dependency.
2024-06-24 20:59:06 +02:00
Newbyte
235d25618f
pmb.build.kconfig: Annotate None return types (MR 2337)
Otherwise mypy doesn't check the return type
2024-06-24 20:45:21 +02:00
Newbyte
706a853db0
pmb.build.kconfig: Install make and gcc (MR 2337)
Otherwise pmbootstrap can't run these a few lines later. I don't know
how this worked before, but this makes $ pmbootstrap kconfig migrate
function again.
2024-06-24 20:35:51 +02:00
Newbyte
cf35e12c03
pmb.build.kconfig.get_arch: Return Arch instead of str (MR 2337)
crosscompile() in autodetect.py expects <arch> to be an Arch type
instead of a str, which is also probably what we want to move the entire
codebase towards. As such, let's convert this string into an Arch here.
2024-06-24 20:26:47 +02:00
Newbyte
b07fb4b24f
pmb.build._package: Move comment to docstring (MR 2337)
This explains a parameter, so let's put it in the right place.
2024-06-24 20:23:01 +02:00
Newbyte
ca6d0eba28
pmb.build: Properly type cross-compilation types (MR 2337) 2024-06-24 20:23:01 +02:00
Hugo Osvaldo Barrera
d6d088b68b
Remove needless lint exceptions (MR 2334)
- Ruff won't complain about long lines which end in a long URL.
- The typing exception is no longer required.
2024-06-24 13:14:40 +02:00
Oliver Smith
c4e7878832
ci/ruff format: display diff when it would make changes (MR 2331) 2024-06-24 13:12:04 +02:00
Oliver Smith
0155c4227a
kconfig edit: don't run check right afterwards (MR 2329)
This is currently broken, and I'm about to rewrite a lot of related
code. Just don't run the check for now, we can bring this back
afterwards if we want to.
2024-06-23 19:16:26 +02:00
Oliver Smith
5acd280823
pmb.build.kconfig.menuconfig: fix f-string + arch (MR 2329)
Fix for:
  TypeError: can only concatenate str (not "Arch") to str
2024-06-23 19:16:26 +02:00
Oliver Smith
a8413c61a5
pmb.chroot.run.user: fix missing return (MR 2329)
Fix broken output_return=True, causing "pmbootstrap kconfig edit" to
break.
2024-06-23 19:16:26 +02:00
Oliver Smith
2cf80bb534
gitlab-ci: remove 'allow_failure: true' (MR 2327)
Now that it is all passing, let's keep it that way!
2024-06-23 19:13:57 +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
61cb4f4abb
Enable the UP family of lints (MR 2327)
These are based on the originally from pyupgrade. They replace older
syntax with newer (and more concise) syntax. Some of the replaced syntax
is deprecated.
2024-06-23 19:13:57 +02:00
Hugo Osvaldo Barrera
cebd784d84
Prefer f-strings (MR 2327) 2024-06-23 19:13:57 +02:00
Hugo Osvaldo Barrera
8057715e83
Use Python 3.8-style type annotations (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
f3f392ef66
Use simplified Python 3.8 syntax (MR 2327)
This commit was generated with:

    ruff check --fix --extend-select=UP .
2024-06-23 19:13:52 +02:00
Hugo Osvaldo Barrera
fa2a7c502d
Remove exception for lint (MR 2328)
There are no violations of this lint any more. This lint only checks
that an import is the beginning of a block; it will not be a problem if
a test needs to include an import.
2024-06-23 17:44:24 +02:00
Hugo Osvaldo Barrera
8398bc1218
Do not use bare except (MR 2325)
A bare except catches things like ctrl+c (KeyboardInterrupt). If don't
want to catch this exception. Remove the bare except and restore the
default lint.
2024-06-23 15:40:13 +02:00
Hugo Osvaldo Barrera
cb4aa809e1
Check python formatting in CI (MR 2325)
Fixes: https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2324
2024-06-23 15:40:13 +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