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

174 commits

Author SHA1 Message Date
Luca Weiss
606eb669fc
pmb.aportgen: Add default value to fork_alpine parameter
No need to specify this when fork_alpine has nothing to do with the
usage.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2610
2025-06-04 10:12:55 +02:00
Oliver Smith
26c310f374
init: systemd: fix always switching pma to edge
Fix that pmbootstrap doesn't recognize v25.06 with systemd enabled as
valid channel and suggests switching to edge. This happens because
pmb.config.pmaports.read_config() unconditionally prepends "systemd-"
before the channel name if systemd is enabled, even though the init code
doesn't expect this.

The result is when running 'yes "" | pmbootstrap init' (as we do in BPO
and CI), pmbootstrap attempts to replace the correctly checked out
v25.06 branch with edge:

Fix for:
  [20:36:37] Available (12):
  [20:36:37] * edge: Rolling release / Most devices / Occasional breakage: https://postmarketos.org/edge
  [20:36:37] * v25.06: Upcoming stable release (DO NOT USE)
  [20:36:37] * v24.12: Latest release / Recommended for best stability
  [20:36:37] Channel [edge]:
  [20:36:37] Currently checked out branch 'v25.06' of pmaports.git is on channel 'v25.06'.
  [20:36:37] Switching to branch 'master' on channel 'edge'...
  …
  ERROR: pmbootstrap switched to the wrong branch: master

Related: https://builds.sr.ht/~postmarketos/job/1497179#task-bpo_setup-23

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2613
2025-05-30 11:08:34 +02:00
Newbyte
548a1dfe2e
pmb: Warn users about downstream ports
And make the archived port detection more robust while at it.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2549
2025-05-25 19:26:57 +02:00
Newbyte
cd672222c4
pmb: Split devices by category during codename selection
This also reworks list_codenames() somewhat. The option to show archived
devices is removed as it never actually was used. It should be easy to
restore if someone is interested.

Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2558

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2549
2025-05-25 19:26:57 +02:00
Stefan Hansson
017522382f
pmb.config.init: Use heapq for sorting timings
This works because heapq sorts based on the first value in tuples
and heap[0] always is the smallest element.

See:
 - https://docs.python.org/2/library/heapq.html#basic-examples
 - https://docs.python.org/3/library/heapq.html

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2582
2025-05-25 11:37:12 +02:00
Anri Dellal
d7b12d98e6
pmb: Rename pmb:gpu-accel and deviceinfo_gpu_accelerated
pmb:gpu-accel -> pmb:drm
deviceinfo_gpu_accelerated -> deviceinfo_drm

Allow deviceinfo_gpu_accelerated as deprecated property

Keep pmb:gpu-accel as valid option to avoid failures for older branches
of pmaports.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2591
2025-05-08 17:33:11 +02:00
Jens Reidel
ec0163ce63
Add option to auto-select the best mirror
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2559
2025-04-11 17:27:33 +02:00
Anri Dellal
6411aa4791
helpers.cli: Fix regex validation (MR 2557)
According to Python documentation, p.match checks
if characters at the beginning of string match the regex

This commit changes validation to full length of string
2025-02-27 00:24:08 +01:00
Hugo Osvaldo Barrera
c2bcc81589
pmb.config.init: prompt for pmaports path (MR 2502)
Allows easily using an existing checkout. The default path remains the
same.

Fixes: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2506
[ci:skip-build]: already built successfully in CI
2025-02-12 13:50:13 +01:00
Hugo Osvaldo Barrera
aed6c7f61e
pmb.config.init: resolve double-negation (MR 2502) 2025-02-12 13:50:13 +01:00
Newbyte
cda5d61593
pmb.config.init: Reformat some strings (MR 2535)
We extended the maximum line length at some point, so let's make use of
it.

[ci:skip-build]: already built successfully in CI
2025-02-10 13:22:07 +00:00
Newbyte
86aec42713
pmb.config.init: Improve message when "Archived:" header is missing (MR 2535)
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
2025-02-10 13:22:07 +00: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
01abf537bb
pmb.config.init: Simplify removal of select from providers_cfg (MR 2525)
See https://docs.astral.sh/ruff/rules/if-key-in-dict-del
2025-01-15 22:35:02 +01:00
Newbyte
c2787aa76f
pmb: Replace list(...)[0] with next(iter(...)) (MR 2525)
See https://docs.astral.sh/ruff/rules/unnecessary-iterable-allocation-for-first-element
2025-01-15 22:35:02 +01:00
Oliver Smith
eb34843f4b
Update systemd repo URL
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/
2025-01-10 19:59:50 +01:00
Newbyte
8d1ff21e9e
pmb.config.init: Use separate answer variable for sudo timer (MR 2490)
Otherwise mypy gets confused about the type as in this case the variable
gets set to a boolean and not a string.
2024-12-19 10:09:22 +00:00
Newbyte
6026b0e9ee
pmb.config.init: Explicitly convert string to int for config.extra_space (MR 2490)
See code comment for explanation.
2024-12-19 10:09:22 +00:00
Newbyte
73091016ae
pmb.config.init: Fix types in ask_for_systemd() (MR 2490)
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).
2024-12-19 10:09:22 +00:00
Newbyte
87900112c1
pmb.config.init: Fix types in ask_for_work_path() (MR 2490)
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.
2024-12-19 10:09:22 +00:00
Caleb Connolly
bb12609753
test: conftest: require_programs() automatically (MR 2483)
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>
2024-11-29 16:50:04 +01:00
Newbyte
0e9a2e596f
pmb.config.init: Call pmb.helpers.cli.confirm() correctly (MR 2489)
"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.
2024-11-14 22:34:52 +01:00
Luca Weiss
26f9d56b20
pmb.config: Print ssh keys filenames that will be copied during init (MR 2251)
Make it clear to the user which SSH keys get copied to the device, and
also link to the wiki page that tells the user how to change
ssh_key_glob.
2024-11-07 01:14:06 +01:00
Luca Weiss
ca9610a153
pmb.config: use ssh_key_glob for ask_for_ssh_keys (MR 2251)
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.
2024-11-07 01:14:02 +01:00
Oliver Smith
ee154ccdf9
require_programs: losetup --json: set output=null (MR 2475)
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.
2024-11-06 23:53:33 +01:00
Oliver Smith
54e55f26ef
require_programs: run losetup with absolute path (MR 2475)
Use the absolute path for it, so it works in Debian too as we run it
without sudo here to just check if the argument is supported.
2024-11-06 23:53:33 +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
Oliver Smith
c4194759f5
require_programs: Debian: find kpartx and losetup (MR 2475)
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
2024-11-06 23:53:29 +01:00
Caleb Connolly
d57b9e31e1
config: init: support --aports too (MR 2470)
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>
2024-11-03 12:26:32 +01:00
Caleb Connolly
70dc855281
config: init: dont clobber config (MR 2470)
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>
2024-11-03 12:26:26 +01:00
Newbyte
225d8b30a0
pmb: Add lots of type hints (MR 2464) 2024-10-30 12:39:45 +01:00
Newbyte
e0a2fbf28c
pmb.config: Check for kpartx and losetup with --json support (MR 2450)
Running these inside the chroot is tricky, and we ended up reverting
previous commits that attempted to make them run there (see
1ec55fc11a). As such, just accept defeat
and ensure that the host has these.

Also see https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2465
2024-10-27 13:14:10 +01:00
Newbyte
612e212a5b
pmb.config.init: Use NonBugError if programs are missing (MR 2450)
We fully expect this to happen if a user hasn't configured their host
system properly. As such, don't treat it like a programming error.
2024-10-27 13:13:10 +01:00
Newbyte
ddd920b1b5
pmb.config.init: Add more type hints (MR 2434) 2024-10-27 00:38:16 +02:00
Newbyte
82a9059dc8
pmb.config.init: Don't convert sudo timer return value to str (MR 2434)
config.sudo_timer is a bool, and the returned value here is a bool. No
point in converting it to a str.
2024-10-27 00:38:16 +02:00
Newbyte
9467c8008c
pmb.config.init: Fixup strings (MR 2434)
These are artefacts from when our line length was shorter. Ruff didn't
really do a great job at fixing them up when autoformatting.
2024-10-27 00:38:16 +02:00
JustSoup321
56a4329f4f
pmb.{config, helpers, install}: add _pmb_default support (MR 2301) 2024-09-30 18:37:01 +02:00
JustSoup321
3559ee4030
pmb.init: make default hostnames pass regex (MR 2393) 2024-09-01 15:01:02 +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
f47115b61b
Add FIXME comment about docs for mirrors.systemd (MR 2371) 2024-07-22 11:54:45 +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
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
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
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
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
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
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
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
Oliver Smith
18fa4e58a3
Ruff: fix typing.Xxx is deprecated, use xxx instead (MR 2327) 2024-06-23 19:13:57 +02:00