Commit graph

197 commits

Author SHA1 Message Date
Newbyte
01faedcf37
pmb.types: Fix type for PmbArgs.output (MR 2522)
And remove hack needed to accomodate this wrong type.
2025-01-15 23:25:57 +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
8d446c2aeb
Rewrite repo_missing for bpo + systemd split repo (MR 2410)
The "pmbootstrap repo_missing" action is used exclusively by bpo. It
calls it only with these arguments:

  pmbootstrap repo_missing --built --arch "$ARCH"

A blocker for merging systemd into pmaports master is, that the
current repo_missing code cannot display packages that are both in
extra-repos/systemd and in another path. I have considered just not
supporting this and discussed doing that with Caleb and Clayton, but we
figured it would be a major obstacle in the future to not be able to
easily override packages with systemd specific versions (currently we
need this for 3 packages).

Integrating this into the existing repo_missing code would be hacks upon
hacks. Also the scope of the current repo_missing code has many extra
features that are not used and would be extra effort to carry along:
* Allow specifying a pkgname
* Running without --built
* --overview

So I decided to replace the repo_missing code with a much simpler, more
modern implementation, that does exactly what is needed:
* Duplicate packages in systemd and non-systemd dirs are displayed
* The output always include all packages, no matter if they are already
  built or not (same behavior as with --built)
* Removed --overview and selecting specific packages too
* The code for filling "repo" (either "systemd" or None) is more
  resilient now, as it can use proper relative paths to the root of
  pmaports. Unlike the previous implementation, it will not fail if
  subdirs are added to the systemd dir.

I have made sure that the output is exactly the same as before on
current pmaports master.

Related: bpo issue 144
Related: bpo issue 140
2025-01-10 13:04:48 +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
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
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
Newbyte
225d8b30a0
pmb: Add lots of type hints (MR 2464) 2024-10-30 12:39:45 +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
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
Stefan Hansson
71772b9b6b
pmb.parse.apkindex: Introduce proper typing (MR 2425)
And adjust other code.

Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2455
2024-10-13 20:12:34 +02:00
Newbyte
4c0f346746
pmb: Migrate aportgen to Command (MR 2428) 2024-10-07 21:41:26 +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
Oliver Smith
0478c30e5c
install: fix --no-local-pkgs
As chroot.glob() now returns a generator, convert it to a list first to
check if it is empty. This may not be the most efficient method, but
since we expect it to be empty here it is fine.

Without this patch, it always shows the error even if there are no
locally built packages:

  ERROR: --no-local-pkgs specified, but locally built packages found. Consider 'pmbootstrap zap -p' to delete them.
2024-09-19 02:09:43 +02:00
Caleb Connolly
7db312c981
helpers: frontend: fix newapkbuild. args.force -> context.force (MR 2388)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-09-17 02:27:44 +02:00
Caleb Connolly
895187cd51
sideload: fix --user (MR 2391)
Was using config.user and ignoring --user arg

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-08-25 22:06:17 +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
ae4094c1db
Fix "pmbootstrap build_init" (MR 2386)
Do not fail with:
  ERROR: 'Namespace' object has no attribute 'image'

Adjust the similar check for args.rootfs to be in the same style while
at it.
2024-07-30 00:41:58 +02:00
Oliver Smith
86d38d451b
Fix pmbootstrap config mirrors.… <NEW_VALUE> (MR 2385)
Don't fail with:
  type object 'Config' has no attribute 'mirrors.pmaports'

Fixes: issue 2420
2024-07-28 21:01:26 +02:00
Oliver Smith
b14a872fad
Fix "pmbootstrap config args /new/path" (MR 2374)
Fix writing config options that are stored as CSV-list. Without this
patch:

$ pmbootstrap config aports /tmp/pmaports
[23:43:58] Config changed: aports='/tmp/pmaports'
$ pmbootstrap config aports
[PosixPath('/'), PosixPath('t'), PosixPath('m'), PosixPath('p'), PosixPath('/'), PosixPath('p'), PosixPath('m'), PosixPath('a'), PosixPath('p'), PosixPath('o'), PosixPath('r'), PosixPath('t'), PosixPath('s')]

Storing strings as CSV list isn't great and we probably want to
implement this more elegantly, see the related issue. But let's fix this
first.

Related: pmbootstrap issue 2412
2024-07-17 23:59:18 +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
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
6f6cf1e8da
kconfig check: remove --kconfig-check-{name} args (MR 2333)
Prepare to move the kconfigcheck config into pmaports, so it can be
different per branch and so we can adjust it at the same time as
adjusting the kernel configs.

Once it is moved, pmbootstrap will not know the cateogry names in
advance anymore, so remove the logic for having category-specific
argument names.

In a future patch, we could add an option to manually override the
categories to be tested with one specific category (taking a string
argument), if there is demand for that.
2024-06-30 18:04:31 +02:00
Newbyte
8c0bc2e0e8
pmb.helpers.frontend: Print paths as a shell-friendly string (MR 2337)
Instead of

    [PosixPath('/home/newbyte/.local/var/pmbootstrap/cache_git/pmaports')]

you get

    /home/neboula/.local/var/pmbootstrap/cache_git/pmaports

like before.

Fixes envkernel.sh failing during activation.

Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2378
2024-06-24 21:12: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
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
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
f331b95824
chroot: allow mounting the device rootfs (MR 2252)
Add a new flag --image which can be used to mount the rootfs generated
with "pmbootstrap install".

For now this is quite limited in scope. But it's enough to allow for
building a package, updating it in the QEMU image, and then booting it.

The major "gotcha" with this is that the QEMU uses the kernel and
initramfs from the device chroot unless you run it with --efi.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
3034768a1a
chroot: apk: fix local repos with apk.static (MR 2252)
It turns out that apk with the --root argument will still treat local
repositories relative to the host. This makes sense considering the
intended usecase, however as a result the recent change to use
apk.static for all apk commands inside the target root will break the
use of local packages.

To fix this, adjust how we populate /etc/apk/repositories, changing the
default to no longer include the local user repo. Instead we pass
--repository to apk.static with the host path to the repo.

The only time we want to add the user repo to /etc/apk/repositories
inside the chroot is when the user enters the chroot, so a special case
is added to helpers/frontend.py for the chroot command.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
53bdb523e3
checksum: remove args (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
8fbc3a450d
build: strict: fix call to chroot.zap (MR 2252)
args lol

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
0365438134
make mypy happy (MR 2252)
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
d9ffb87424
helpers: more small cleanup (MR 2252)
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
1a01738d50
config: sanity check via types (MR 2252)
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>
2024-06-23 12:38:39 +02:00
Caleb Connolly
7a8deb0f5e
config: clean up parsing and add mirrors (MR 2252)
Add a new config section "mirrors", to replace the mirrors_alpine and
mirrors_postmarketos options. This will allow for more flexibility since
we can then handle the systemd staging repo (and others like plasma
nightly) with relative ease.

The loading/saving is fixed and now properly avoids writing out default
values, this way if the defaults are changed the user won't be stuck
with old values in their pmbootstrap.cfg.

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
560cea46ea
treewide: migrate to pkgrepo API (MR 2252)
Make use of the new pmb.core.pkgrepo API to handle multiple aports and
extra-repos.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:39 +02:00
Caleb Connolly
3473422639
chroot: fix args.user (MR 2252)
config.user and args.user are distinct, don't combine them.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:38 +02:00
Caleb Connolly
d8d55c3e52
aportgen: fix fork_alpine flag (MR 2252)
Broke during rework

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:38 +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
97bd8b96ec
parse: deviceinfo: make Deviceinfo a class (MR 2252)
Introduce a Deviceinfo class and use it rather than the dictionary. This
gives us sweet sweet autocomplete, and lays the foundation for having a
proper deviceinfo validator in the future.

Additionally, continue refactoring out args...

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
d9e1da98b2
more n more (MR 2252)
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
48cd886401
more wip (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:38 +02:00