Commit graph

76 commits

Author SHA1 Message Date
Stefan Hansson
aebf99e988
Prepare 3.4.0 release 2025-05-13 19:42:56 +02:00
Oliver Smith
c74735ea7a
Prepare 3.3.1 release 2025-02-27 01:09:19 +01:00
Oliver Smith
60a4ed7f84
Prepare 3.3.0 release 2025-02-27 00:39:06 +01:00
Stefan Hansson
bdcc188f05
pmb: Use explicit re-exports (MR 2545)
See https://docs.astral.sh/ruff/rules/unused-import
2025-02-23 11:40:44 +01:00
Stefan Hansson
0620232819
pmb: Remove unused imports (MR 2545) 2025-02-23 11:40:40 +01:00
Oliver Smith
afecbb151d
Prepare 3.2.0 release 2025-01-19 14:08:06 +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
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
Oliver Smith
79c6e4c36d
Prepare 3.0.0 release 2024-11-10 19:13:39 +01:00
Caleb Connolly
585c477239
config: find required programs every time pmbootstrap is run (MR 2475)
On debian systems in particular special handling is needed for
/usr/sbin. Let's do this once and then provide the host deps we use in a
nice accessible dictionary.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Tweaked-by: Oliver Smith <ollieparanoid@postmarketos.org>
2024-11-06 23:53:33 +01:00
Caleb Connolly
39235fedfb
show the status output on failure (MR 2472)
There is a lot of context and state management needed when using
pmbootstrap, sometimes it can be a lot to keep in your head. Let's print
the output of "pmbootstrap status" when stuff goes wrong, this might
help remind people if e.g. their pmaports checkout is on the wrong
branch, or they're building for the wrong device.

Additionally, don't print the "run pmbootstrap log for details" message
if pmbootstrap was called with --details-to-stdout

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-04 10:15:59 +09:00
Caleb Connolly
26ec1631ca
helpers: apk_static: move from pmb.chroot (MR 2463)
Move the apk_static module from pmb/chroot to pmb/helpers which is a
more suitable location.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-11-02 18:15:38 +01:00
Luca Weiss
3df0be358f
Replace gitlab.com with gitlab.postmarketos.org (MR 2443)
Try to finish the migration by changing various links and texts to point
to the new GitLab instance.
2024-10-21 18:12:21 +02:00
Hugo Osvaldo Barrera
84c512ea6a
Add some missing type hints (MR 2338)
Functions with no explicit return type are considered to return `Any`.
2024-08-21 15:47:26 +02:00
Oliver Smith
642a374bac
Add a checklist comment for upgrading min py ver (MR 2357) 2024-07-16 00:26:35 +02:00
Oliver Smith
9fd45fb334
Bump minimum python3 version to 3.10 (MR 2357) 2024-07-16 00:26:35 +02:00
Oliver Smith
aeb65f2991
Tweak errors for missing config/work dir (MR 2350)
* Use NonBugError instead of RuntimeError so users don't get a stack
  trace for this.
* Check for the pmbootstrap <= 3.0.0 config, and print a nice message
  asking users to recreate their config.
* Add a separate message if --config was used.
* Reword the generic "no config found" message to suggest 'pmbootstrap
  init' first, and only mention --config at the end. Most users will
  need to just run 'pmbootstrap init'.
2024-07-10 20:06:25 +02:00
Caleb Connolly
8da12a98a7
helpers: other: drop args from migrate_work_folder() (MR 2352)
Was erronesously passing args to cli.confirm.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-09 00:45:23 +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
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
e2461f00a2
Set version to 3.0.0_alpha (MR 2252)
Let pmbootstrap display 3.0.0_alpha on crash, so it's clear when people
are using the new codebase.

  Before you report this error, ensure that pmbootstrap is up to date.
  Find the latest version here: https://gitlab.com/postmarketOS/pmbootstrap/-/tags
  Your version: 3.0.0_alpha
2024-06-23 12:38:42 +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
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
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
Caleb Connolly
02f04ba3a8
core: move args.log to context.log (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:37 +02:00
Caleb Connolly
2a7c769e14
core: introduce global context (MR 2252)
We can't totally escape the need for some runtime state defined by args.
To make the migration easier, introduce a global "Context" class and
move some of the read-only global options there.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:37 +02:00
Caleb Connolly
31cc898dd5
treewide: adopt pathlib.Path and type hinting (MR 2252)
With the new chroot type, we can now write fancy paths in the pythonic
way. Convert most of the codebase over, as well as adding various other
type hints.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:37 +02:00
Caleb Connolly
71e7af57e6
pmb.helpers.logging: wrap logging module (MR 2252)
We use a custom verbose log level in pmbootstrap, unfortunately it isn't
possible to correctly type this due to some limitations in the logging
library [1], [2].

Given that our usecase is fairly simple, we can just wrap the module
with our own so we only have to tell mypy to ignore the error once
instead of at every callsite.

[1]: https://github.com/cryptax/droidlysis/issues/15
[2]: https://github.com/python/typing/discussions/980

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:37 +02:00
Caleb Connolly
4b6c198ca4
pmb: type hint main() (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:37 +02:00
Caleb Connolly
9301412f90
pmb.helpers: remove check for old device paths (MR 2252)
The migration to the new pmaports device layout was 3 years ago, I think
it's reasonable that this check is no longer needed.
2024-06-23 12:38:37 +02:00
Caleb Connolly
198f302a36
treewide: add a Chroot type and adopt pathlib.Path (MR 2252)
Introduce a new module: pmb.core to contain explicitly typed pmbootstrap
API. The first component being Suffix and SuffixType. This explicitly
defines what suffixes are possible, future changes should aim to further
constrain this API (e.g. by validating against available device
codenames or architectures for buildroot suffixes).

Additionally, migrate the entire codebase over to using pathlib.Path.
This is a relatively new part of the Python standard library that uses a
more object oriented model for path handling. It also uses strong type
hinting and has other features that make it much cleaner and easier to
work with than pure f-strings. The Chroot class overloads the "/"
operator the same way the Path object does, allowing one to write paths
relative to a given chroot as:

builddir = chroot / "home/pmos/build"

The Chroot class also has a string representation ("native", or
"rootfs_valve-jupiter"), and a .path property for directly accessing the
absolute path (as a Path object).

The general idea here is to encapsulate common patterns into type hinted
code, and gradually reduce the amount of assumptions made around the
codebase so that future changes are easier to implement.

As the chroot suffixes are now part of the Chroot class, we also
implement validation for them, this encodes the rules on suffix naming
and will cause a runtime exception if a suffix doesn't follow the rules.
2024-06-23 12:38:37 +02:00
Newbyte
9252400292
Prepare 2.3.1 release 2024-05-18 18:34:09 +02:00
Newbyte
6dce84647b
Prepare 2.3.0 release 2024-05-15 18:43:22 +02:00
Oliver Smith
db163aded6
Print ERROR: infront of {NonBug,BuildFailed}Error (MR 2298)
Make the handling of the custom NonBugError and BuildFailedError
exceptions more consistent with the handling of other exceptions, by
printing "ERROR: " infront of the actual error text. Then we don't need
to duplicate that where we raise the errors. pmbootstrap prints "ERROR"
in red.
2024-04-16 19:41:13 +00:00
Newbyte
2972f1d36e
pmb: Handle BuildFailedError (MR 2288)
Also breaks out hinting printing code into its own function to avoid
repetition.

Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2068
2024-04-10 20:49:21 +00:00
Newbyte
9723191fe5
pmb: Only log error if NonBugError is caught (MR 2279)
NonBugError means that the root cause originates from a bug outside of
pmbootstrap's code base. As such, no need to print a stacktrace or ask
the user to update pmbootstrap.
2024-03-27 21:50:28 +01:00
Alexander Martinz
7f271dd1cc
pmb: correct link after moving sources back to gitlab (MR 2270)
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
2024-03-08 14:04:00 +01:00
Pablo Correa Gómez
d2bcff3162
Drop support for python3.7 and python3.8 (MR 2265)
Even Debian oldstable is on python3.9 now, so should be safe, and
should also help the typing process that has now started
2024-02-29 00:47:33 +01:00
Oliver Smith
7102157bf1
Prepare 2.2.1 release 2024-02-11 21:37:39 +00:00
Oliver Smith
7f61262ae8
Prepare 2.2.0 release 2024-02-06 23:43:54 +00:00
Oliver Smith
4fb61591e8
Prepare 2.1.0 release 2023-12-03 20:14:47 +01:00
Oliver Smith
b721b08e19
Prepare 2.0.0 release 2023-08-01 07:51:02 +02:00
Newbyte
40fc6f4fd4
pmb: Remind users to ensure pmbootstrap is updated before reporting errors
Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Co-developed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230521070148.8311-1-newbyte@postmarketos.org%3E
2023-05-25 09:24:13 +02:00
Oliver Smith
6d0aa127d5
Prepare 1.53.0 release 2023-05-17 20:47:32 +02:00
Oliver Smith
a8695833d9
Prepare 1.52.0 release 2023-04-18 21:12:54 +02:00
Oliver Smith
6352ab9c2d
Move version to pmb.__version__
Move the pmbootstrap version to __version__ in the pmb module, so it can
still be found automatically after setup.py is replaced.

Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230407233026.1712-4-ollieparanoid@postmarketos.org%3E
2023-04-15 01:44:37 +02:00
Oliver Smith
5d28c5ccf3
pmbootstrap.py: move all features to pmb:main()
Prepare to modernize the python packaging. pmbootstrap.py will not be
part of the packaging, so add a note there and move both features
(python version check, ^C check) to pmb/__init__.py:main().

Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230407233026.1712-3-ollieparanoid@postmarketos.org%3E
2023-04-15 01:44:37 +02:00
Newbyte
bdbc7b3eb3
pmb: Set PMBOOTSTRAP_CMD to argv[0] in environment
This allows for scripts run by pmbootstrap to figure out how pmbootstrap
was invoked, and with that invoke pmbootstrap even in unconventional
setups where "pmbootstrap" isn't an available command in $PATH.

Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230325205337.105795-1-newbyte@postmarketos.org%3E
2023-04-02 14:57:04 +02:00