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

2035 commits

Author SHA1 Message Date
Oliver Smith
591a737733
Support setting custom mirrors + disabling mirrors (MR 2361)
Allow setting _custom mirrors in the config:
* alpine_custom
* pmaports_custom
* systemd_custom

When these are set, they are added to /etc/apk/repositories before real
repositories. This is used by bpo to build packages with a WIP
repository enabled, in addition to the final repository.

All mirrors can also be set to "none" to be disabled. This is important
for bootstrapping from pure Alpine without any binary repository, and
the bpo testsuite also uses this.

I've discussed with Caleb whether to name it _wip instead of _custom,
but the latter is more generic and people may also use this for other
use cases than the bpo wip repository thing.
2024-07-16 00:34:06 +02:00
Oliver Smith
7b164acb70
pmb.helpers.repo.urls: remove commented out print (MR 2361) 2024-07-16 00:34:06 +02:00
Oliver Smith
7c3af8c391
pmb.config: remove config file migration logic (MR 2361)
We have decided to let the user generate a pmbootstrap_v3.cfg file
instead of attempting to automatically migrate the file. This way we
don't need to worry about potential migration bugs and users can also
temporarily go back to v2 to compare behavior with v3 without problems.

Remove migration logic related to mirror_alpine and
mirrors_postmarketos, before I add support for using multiple
repositories with these again (as needed for bpo). This reduces
complexity and removes a note about "multiple mirrors are not supported"
that won't be valid anymore.
2024-07-16 00:34:06 +02:00
Oliver Smith
e7af3c49a5
init: mirror selection: set systemd mirror too (MR 2361)
When selecting a different mirror in "pmbootstrap init", then select the
systemd mirror as well. It will always be the normal postmarketOS mirror
plus some path appended. Currently it is the path for the staging
repository, this will change when the systemd changes are merged to
pmaports master and bpo can build it. I'll adjust this before we release
pmbootstrap v3.

I have considered changing the code so that we don't store a separate
systemd mirror in the config. But I think it's useful to be able to
point to systemd mirrors with different paths for debugging purposes,
and also it would make the logic more complex once we re-introduce
support for multiple mirrors of the same type for bpo. So I've
intentionally kept that part as-is.
2024-07-16 00:34:06 +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
3e0eba8561
pmb/types: manual ruff fixes (MR 2357)
Manual fixes for things that ruff didn't fix automatically.

From python3 docs:
> Union[X, Y] is equivalent to X | Y and means either X or Y.
2024-07-16 00:26:35 +02:00
Oliver Smith
7b451b25de
Run ruff format (MR 2357) 2024-07-16 00:26:35 +02: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
Oliver Smith
9fd45fb334
Bump minimum python3 version to 3.10 (MR 2357) 2024-07-16 00:26:35 +02:00
HenriDellal
2b577a8694
Fix pmbootstrap install --android-recovery-zip (MR 2368)
Tweaked-By: Oliver Smith <ollieparanoid@postmarketos.org>
2024-07-16 00:04:15 +02:00
Anri Dellal
d8e174b04c
flasher boot: fix missing args (MR 2369)
Closes #2407
Closes #2408
2024-07-15 23:52:33 +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
Arnav Singh
b98c5e2cab
config: init: fix crash in mirrors prompt (MR 2367)
This was missed in fc010bc7c8

Before this fix:

```
...

[18:34:35] Enable background timer to prevent repeated sudo authorization? (y/n) [n]: y
(020272) [18:34:44] ERROR: 'Config' object has no attribute 'mirrors_postmarketos'
(020272) [18:34:44] See also: <https://postmarketos.org/troubleshooting>
(020272) [18:34:44] Traceback (most recent call last):
  File "/home/arnavion/src/pmbootstrap/pmb/__init__.py", line 72, in main
    return config_init.frontend(args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arnavion/src/pmbootstrap/pmb/config/init.py", line 729, in frontend
    ask_for_additional_options(config)
  File "/home/arnavion/src/pmbootstrap/pmb/config/init.py", line 542, in ask_for_additional_options
    logging.info("Selected mirror:" f" {','.join(context.config.mirrors_postmarketos)}")
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arnavion/src/pmbootstrap/pmb/core/config.py", line 130, in __getattribute__
    return super().__getattribute__(key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Config' object has no attribute 'mirrors_postmarketos'
```
2024-07-15 23:47:40 +02:00
Caleb Connolly
1af44fb159
helpers: args: don't announce config options overwritten by args (MR 2366)
Was left in for debugging

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-13 18:49:45 +02:00
Caleb Connolly
01b53b0b49
config: init: set aports when non-default work dir is picked (MR 2366)
If you init and set a custom work dir it will not be relative to
pmaports anymore. Detect this and reset config.aports to be relative to
the new workdir.

Fixes #2406

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-13 18:49:22 +02:00
Caleb Connolly
2ce06e9791
build: package: properly ensure build-base packages are built first (MR 2363)
In ("build: special case building abuild (MR 2356)") we tried to ensure
that abuild would be built before anything else, however this
implementation failed miserably if the first package given didn't
actually need to be built (since we skip building deps of packages that
aren't flagged for build).

Let's take a different stab at this by actually inserting build_packages
into the build queue if they need building. They're inserted at the end
just before the queue is reversed, so they will always be built first.

This makes the order of pmb.config.build_packages important, enshrine
this with a comment.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-12 00:37:12 +02:00
Caleb Connolly
889a1e011d
build: package: fail gracefully if --src and dependencies need building (MR 2363)
If you build a package with --src but some dep is outdated, force you
to build it (or otherwise handle the situation yourself). We can't guess
what to do here.

This could be made configurable (opt-in) in the future.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-12 00:37:12 +02:00
Caleb Connolly
d2f40a9a29
build: package: update all build_packages in buildroot after building (MR 2363)
We might have just built some other package which will later be used to
build more packages. Handle all of them and don't special case abuild.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-12 00:37:12 +02:00
Caleb Connolly
7544823265
chroot: apk: add quiet option (MR 2363)
Let us install packages without announcing. Useful if there is some more
contextual message display already.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-12 00:37:12 +02:00
Caleb Connolly
de268b1b82
chroot: init: use local repos (MR 2363)
Ensure we get our fork of apk straight away without having to run `apk
upgrade -a` immediately afterwards.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-12 00:37:11 +02:00
Caleb Connolly
02f9da9a64
build: init: simplify installing build deps (MR 2363)
No reason to handle abuild separately here.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-12 00:37:11 +02:00
Anri Dellal
30d8ea997f
Refactor bootimg_analyze (MR 2359) 2024-07-11 21:54:53 +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
Oliver Smith
9dfa89c58c
Use pmbootstrap_v3.cfg as config file (MR 2350)
Using pmbootstrap v3 with the old config can cause problems, for example
when having $WORK in the pmaports dir instead of the actual work path.
This is not supported anymore by v3 to reduce complexity. The format of
how mirrors are stored in the config also has changed.

Use a separate config file, so users can go back from v3 to 2.3.x if
they need to (for figuring out a regression) and so users won't run into
bugs when moving from 2.3.x to v3.
2024-07-10 20:06:25 +02:00
Anri Dellal
3d9607aa99
init: fix bootimg_analyze step (MR 2358) 2024-07-09 17:21:44 +03:00
Caleb Connolly
ebef789f7c
Bump work version to zap for pmb 3.0.0 (MR 2352)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-09 00:45:27 +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
Caleb Connolly
234673ce03
build: special case building abuild (MR 2356)
Since abuild is an implicit dependency of everything, we need special
case handling for it. Insert it as a dependency of the first package in
the build queue so that it will be built if outdated, then after
building re-install it in the chroot so all subsequent packages will use
the freshly built abuild.

This is currently used for systemd where we use an abuild fork

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-09 00:19:57 +02:00
Caleb Connolly
9bd5860381
helpers: frontend: checksum: make sure chroot is mounted (MR 2354)
chroot's aren't automatically initialized when running a command in them
anymore. Add the explicit chroot.init() call before checksum.

Fixes #2395

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-09 00:12:30 +02:00
Caleb Connolly
c5135ac62a
build: use get_pkgver() again (MR 2353)
During rework this got lost, re-incorporate it so packages built with
--src have a relevant pkgver.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-09 00:07:53 +02:00
Oliver Smith
319d9681f3
TEMP: pmb.chroot.apk: fix installing local packages
As we don't call apk from outside of the chroot, the paths need to be
adjusted to be /mnt/pmbootstrap instead of the outside paths.

This should be reverted together with the other TEMP commit after we
upgraded apk to fix this properly (see issue 2388).

Fixes: f5122420 ("TEMP: chroot: apk: run apk through QEMU again (MR 2351)")
2024-07-08 23:33:06 +02:00
Caleb Connolly
f512242073
TEMP: chroot: apk: run apk through QEMU again (MR 2351)
This revers b82c4eb167 ("chroot: always run apk static (MR 2252)")
since the current iteration of the apk-tools /usr merge patches
don't handle --root properly and will behave differently based on your
host systems directory structure (specifially for /usr merge).

This commit can be reverted once we fix apk-tools.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:54:11 +02:00
Clayton Craft
0a60750684
parse: arguments: fix type of --config (MR 2347)
Add the missing runtime conversion when --config is given on the
cmdline.

This expects a pathlib.Path object as the argument, but args.config is
only a string.
2024-07-08 16:30:58 +02:00
Oliver Smith
852b8d6c7d
args: remove dead code (MR 2349)
Remove a bunch of commented out code:
* debug leftovers
* update_work(): a function that used to replace $WORK in all kinds of
  arguments to pmbootstrap, with the actual work dir. This seemed like a
  good idea when I made this initially, but in hindsight it's clear that
  this made args just much more complex. I'm glad that Caleb removed
  this. Now $WORK only gets removed in one place, for mount points,
  which makes much more sense.
* args.from_argparse and related comment: pmbootstrap used to make a
  full copy of its args, so in some cases it could go back before $WORK
  was replaced IIRC. This isn't great, but even worse is that this
  caused each stack trace to say something like infinite recursion on
  args. I'm also glad that Caleb got rid of this :)
2024-07-08 16:22:38 +02:00
Caleb Connolly
0e62eaac67
ruff: format (MR 2344)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:09:42 +02:00
Caleb Connolly
71646f0a1d
config: don't switch to edge from systemd (MR 2344)
Since master_staging_systemd doesn't have its own channel, handle the
special case where the user ran pmbootstrap init while on the systemd
branch, with systemd enabled. In this case it's probably unintuitive to
switch pmaports to the master branch.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:05:35 +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
Caleb Connolly
852efe1f8e
helpers: package: overload types (MR 2344)
Correct return types based on arguments

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-07-08 16:01:13 +02:00
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