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

50 commits

Author SHA1 Message Date
Stefan Hansson
0620232819
pmb: Remove unused imports (MR 2545) 2025-02-23 11:40:40 +01:00
knuxify
00c670ffda
pmb.flasher: Fix passing command line flags (MR 2543)
Commit 37ec73c dropped the use of args to access command line arguments,
but did not add another way to pass command line arguments; thus,
optional flags to flash_kernel, flash_rootfs, flash_lk2nd, sideload and
list_devices were ignored.

Fix this by making sure the relevant arguments are passed for all
frontend methods.

Fixes #2522.
2025-02-01 22:38:55 +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
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
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
5ed5817e80
pmb: Add more type hints (MR 2490) 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
Caleb Connolly
7847488058
commands: remove deviceinfo_parse (MR 2463)
Since parse.deviceinfo() returns a custom class now, it can't be
trivially serialized as JSON.

This has been broken for months now so it's clear nobody is using this.
Let's take the chance to get rid of it.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-02 18:15:38 +01:00
Caleb Connolly
12846f3b8e
helpers: apk: move update_repository_list() from chroot.apk (MR 2463)
This function better belongs here, especially as it will be used outside
of the context of a chroot() soon.

Additionally, it's adjusted to take the rootfs path as its first
argument rather than a chroot, since it could operate on any rootfs.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-02 18:15:38 +01:00
Caleb Connolly
2f39edd584
commands: repo_bootstrap: type hint (MR 2463)
make mypy happy

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-02 18:15:38 +01:00
Newbyte
225d8b30a0
pmb: Add lots of type hints (MR 2464) 2024-10-30 12:39:45 +01:00
Caleb Connolly
acc989de65
commands: getattr autoinstall (MR 2461)
args.autoinstall attribute might not exist, use getattr like for others,
and add a fixme about the default value...

Fixes: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2476
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 18:59:42 +01:00
Newbyte
37ec73c07c
pmb.flasher: Remove use of args (MR 2441)
Also adapt pmb/install/recovery.py to new API for variables.py.

[ci:skip-build]: already built successfully in CI
2024-10-22 15:12:40 +02:00
jane400
afb036da0d
pmb.kconfig: refactor to remove args (MR 2346)
Co-authored-by: Stefan Hansson <newbyte@postmarketos.org>

Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2402
2024-10-22 00:04:32 +02:00
Newbyte
4a0825bdc0
pmb: Remove args from aportgen command (MR 2432) 2024-10-13 19:43:31 +02:00
Newbyte
405869db1b
pmb.commands.pull: Annotate return types (MR 2429) 2024-10-08 17:07:28 +02:00
Newbyte
4c0f346746
pmb: Migrate aportgen to Command (MR 2428) 2024-10-07 21:41:26 +02:00
Stefan Hansson
742300b090
pmb.commands: Add pkgver_bump (MR 2415)
Similar to pkgrel but for pkgver. Useful when dealing with e.g.
metapackages.

[ci:skip-build]: already built successfully in CI
2024-09-30 12:45:21 +02:00
Stefan Hansson
a1fdd01173
pmb.commands: Migrate if ... else chain to match (MR 2411)
We no longer care about supporting Python versions older than 3.10,
which is when match was introduced.
2024-09-26 18:27:00 +02:00
Stefan Hansson
8a64c9da8f
pmb: Migrate pkgrel_bump to Command (MR 2411)
Also remove args from functions that don't actually need it to
faciliate this.

This does not attempt to fix any of the bugs with pkgrel_bump.
2024-09-26 18:27:00 +02:00
Stefan Hansson
3d60673f64
pmb.commands.kconfig_check: Annotate None return types (MR 2411)
Otherwise we don't get type checking in these functions.
2024-09-26 17:34:06 +02:00
Oliver Smith
479bad049f
kconfig check: don't print URL for each warning (MR 2399)
Instead of printing an URL with each warning, print one once at the
end. This gives less cluttered output, and we don't have information
about each and every option on that wiki page anyway (and given that we
now have so many options, I don't think it's good use of time to add it
there.)
2024-09-08 00:09:16 +02:00
Oliver Smith
ade0657cd2
kconfig check: NonBugError for --file too (MR 2399)
Use NonBugError when printing the error for the --file code path too.
2024-09-08 00:09:16 +02:00
Oliver Smith
5e9c1601f2
kconfig check: use NonBugError (MR 2384)
Don't print a trace if kconfig check fails.
2024-08-12 19:32:19 +02:00
Oliver Smith
f1afdeaaa1
kconfig check: add --keep-going argument (MR 2384)
Abort the "pmbootstrap kconfig check" on the first error, unless the
--keep-going argument was passed. This makes it easier to go through the
failed kernels one by one until they are all fixed.
2024-08-12 19:32:10 +02:00
Anri Dellal
170829326c
kconfig: edit,migrate: use single package as argument (MR 2387) 2024-07-30 21:08:36 +03:00
Oliver Smith
36dd53f402
Run ruff check --fix (MR 2357)
Now that we have target-version = "py310" in [tool.ruff] in
pyproject.toml, ruff check complains about using typing.Optional and
typing.Union instead of newer syntax. Run the tool to fix it.
2024-07-16 00:26:35 +02:00
Anri Dellal
b8ca63dc2d
Fix types of pmb arguments (MR 2370)
- Change some arguments' types to bool to avoid type mismatch errors
  after refactoring in the future
- Add more arguments from parse/arguments with corresponding types
- Change type of pmbootstrap log --lines argument to int
2024-07-15 23:50:13 +02:00
Caleb Connolly
65d23905bc
treewide: another round of mypy fixes (MR 2344)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:01:13 +02:00
Anri Dellal
8948594d74
Fix "pmbootstrap log -c" crash (MR 2345)
Fixes #2387
2024-07-03 08:11:04 +00: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
18fa4e58a3
Ruff: fix typing.Xxx is deprecated, use xxx instead (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
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
Oliver Smith
ef594ddf24
pmb/commands/pull: fix path error with f-string (MR 2252)
Fix for:
  TypeError: can only concatenate str (not "PosixPath") to str
2024-06-23 12:38:42 +02:00
Oliver Smith
9e2bbf80e0
pull: move to pmb/commands/pull.py (MR 2252)
Fixes:
  TypeError: pull() takes 0 positional arguments but 1 was given
2024-06-23 12:38:42 +02:00
Caleb Connolly
3f11fa2500
tests: basic pkgrepo tests, clone pmaports (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
f2ca9c618e
ruff: run check --fix (MR 2252)
Get rid of unused imports and such

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
6087a9df8f
core: don't re-export get_context (MR 2252)
This makes testing a lot more annoying.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:40 +02:00
Caleb Connolly
62d700c3d8
commands: add pmbootstrap test (MR 2252)
This is to serve as a place to dump useful internal tests, starting with
one that simply parses all available APKINDEX files.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:40 +02:00
Caleb Connolly
15ffc2f370
repo_bootstrap: simplify custom mirrors (MR 2252)
We now have support for having mirrors per-aports repo, drop the
mirrors_postmarketos arg from chroot.init and instead have
repo_bootstrap call apk.update_repository_list() explicitly to exclude
the mirrors for the repository we're going to update.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:40 +02:00
Caleb Connolly
6857882cf0
build: finish builder rework (MR 2252)
Rename build.package() to build.packages() and take a list of packages
to build, since every caller was inside a for loop this simplifies
usage and let's us give nicer log output by doing all the builds first,
so log messages don't get lost in the middle.

Behaviour is cleaned up so this shouuuuld work pretty well now. It
properly descends into dependencies and will build dependencies even if
the package given doesn't need building. Technically this was only done
before during install where the dependencies were recursed in
chroot.apk.install().

It probably makes the most sense to have a mode where it doesn't build
dependencies but warns the user about it, at least when invoked via
pmbootstrap build.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:39 +02:00
Caleb Connolly
656ff3f5bb
commands: move shutdown command to pmb/commands (MR 2252)
Another one bites the dust

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:39 +02:00
Caleb Connolly
866e5bcfab
core: add an Arch type (MR 2252)
Move pmb/parse/arch.py over to core and refactor it as an Arch type,
similar to how Chroot was done. Fix all the uses (that I can find) of
arch in the codebase that need adjusting.

The new Arch type is an Enum, making it clear what architectures can be
represented and making it much easier to reason about. Since we support
~5 (kinda) different representations of an Architecture (Alpine, Kernel,
target triple, platform, and QEMU), we now formalise that the Alpine
format is what we represent internally, with methods to convert to any
of the others as-needed.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:39 +02:00
Caleb Connolly
450bc6873d
core: move Config type (MR 2252)
Keeping the Config class in types seemed kinda weird and was just done
as a workaround to some cyclical imports. But now things are more in
shape let's move it to core.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:39 +02:00
Caleb Connolly
f422b5c7ca
commands: port repo_bootstrap (MR 2252)
The repo_bootstrap command is totally standalone and has it's own state,
making it a good candidate for the pmb.commands submodule. Port it over
and move the require_bootstrap() helper function over to
pmb/helpers/pmaports.py

We also fix the call to pmb.build.package() which broke during rework.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:38 +02:00
Caleb Connolly
852ace63c4
commands: move index command to pmb/commands (MR 2252)
Use the new command runner for pmbootstrap index.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:38 +02:00
Caleb Connolly
de4c912692
WIP: 2024-06-05: args hacking and more (MR 2252)
Continue removing args and do some other optimisations.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:38 +02:00
Caleb Connolly
34dd9d42ba
WIP: start ripping out args (MR 2252)
Cease merging pmbootstrap.cfg into args, implement a Context type to let
us pull globals out of thin air (as an intermediate workaround) and rip
args out of a lot of the codebase.

This is just a first pass, after this we can split all the state that
leaked over into Context into types with narrower scopes (like a
BuildContext(), etc).

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:38 +02:00
Caleb Connolly
8526631589
commands: new submodule (MR 2252)
The current mechanism of invoking pmbootstrap actions can be a bit
confusing, and relies heavily on args being a big namespace with lots of
properties (which may or may not be valid depending on the context).

To aid in slowly removing args from the codebase, introduce a new
mechanism for running commands. This works by having a class for each
command, where the arguments are passed in as parameters to the
constructor.

No doubt this won't scale very far, but it's a skeleton we can continue
to build on as we migrate more commands over to not require args in
order to run.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:38 +02:00