This changes the output from e.g.
WARNING: xiaomi-markw is archived: None
to
WARNING: xiaomi-markw is archived: No reason given (this is a bug)
which I think is better and makes it clear that this is not behaviour
one should rely upon. All archived ports should have a reason given, but
this has not been (and still isn't as I'm writing this) enforced in
pmaports, so we can't rely on there being one.
Related: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6085
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/
pmb.helpers.cli.ask() returns a string, so previously this function was
just lying about its return type (which happened to be fine in the
context it was used, but still not what we want).
pmb.helpers.cli.ask() takes a string and only work with Path by
accident, so explicitly convert <default> to a string if it is not None.
Additionally, while this function claimed to return a Path, it actually
returned a string, so fix that too.
Pmbootstrap finds all its host dependencies during init, ensure we do
that for pytest too.
Adapt require_programs() to use subprocess directly rather than have to
solve the weird dependency chain of pmb.helpers.run which depends on the
global context being initialised before it's usable.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
"y" only works here by accident as it's considered truthy by Python and
as such gets handled equivalently to True in the current implementation
of pmb.helpers.cli.confirm(), but it's still relying on unintended
behaviour. Change this to use a bool as intended.
Since a user can modify the glob to be somewhat arbitrary, use that to
check if any ssh keys exist and ask in pmbootstrap init.
Otherwise ssh_key_glob would only work if it was a subset of
~/.ssh/id_*.pub, so e.g. ~/.ssh/id_foo.pub but ~/.ssh/foo.pub wouldn't
work.
We don't care about the output of "losetup --json" here, we just want to
make sure that the argument exists. If it does not exist, we already
give an error to the user.
Set the output to null so it does not clutter the log since it runs with
every pmbootstrap command now.
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>
In Debian, /usr/sbin is not in PATH of regular users unless using sudo.
Fix that pmbootstrap won't find kpartx and losetup in /usr/sbin, and
complains about these even though they are installed.
Fixes: issue 2489
We shouldn't overwrite config.aports if the user specified a custom
--aports directory. We only want to do this to update the default if
they're using a custom workdir.
Make the code here less aggressive, and correctly use the last entry in
config.aports as "pmaports" instead of the first.
Fixes: #2386
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
When pmbootstrap starts up, it loads the config file (or uses the
defaults) and then merged some arguments (e.g. --work) into it. However
in config.init.frontend() we were creating yet another new Config, but
it's too late to merge args in at this point...
Rework this slightly to fix that major oversight and remove the totally
unnecessary hack of calling pmb.config.load() again.
This fixes calling pmbootstrap init with --work
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
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.
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.
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'
```
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>
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.
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>
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)
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.
Get rid of config.mirror_alpine and mirrors_postmarketos and make sure
they get migrated over for existing users.
mirrors_postmarketos being a list was always a bit off, but now we have
per-aports mirrors which make a lot more sense for what we're trying to
do with systemd.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Replace the "sanity_check" code with type checking built into the Config
__setattr__ operator.
This keeps all the Config related code in one place.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
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>