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

541 commits

Author SHA1 Message Date
Oliver Smith
7b164acb70
pmb.helpers.repo.urls: remove commented out print (MR 2361) 2024-07-16 00:34:06 +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
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
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
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
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
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
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
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
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
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
Oliver Smith
91aee0b34c
Fix custom pmaports dir (pmbootstrap --args) (MR 2342)
The aports argument is a list of paths now, so iterate over each of them
when checking if they exist.

Fix for:
INFO:root:ERROR: 'list' object has no attribute 'exists'
2024-07-02 17:40:35 +02:00
Oliver Smith
6c4b4c4993
CI: ignore 'import tomllib' in vermin (MR 2333) 2024-06-30 18:04:31 +02:00
Oliver Smith
1dfaafe577
kconfig check: move rules to kconfigcheck.toml (MR 2333)
Move all kconfig rules from pmb.config to a separate toml file
pmb/data/kconfigcheck.toml. This is a fallback, pmbootstrap now prefers
loading kconfigcheck.toml from the currently checked out pmaports branch
if it exists.

This finally allows having separate kconfig check rules per pmaports
branch and makes the workflow of adjusting these rules much more
pleasant as the rules and kernel configs can just be adjusted at the
same time in pmaports!

This patch also moves the definition of what rules should be checked for
community and main devices, those that have pmb:kconfigcheck-community
in their linux APKBUILD, to the new kconfigcheck.toml. This should make
it much more intuitive, previously one needed to find the place in the
pmbootstrap source and edit it there.

Furthermore the "enforce_check" logic is removed. Previously pmbootstrap
would print warnings for failed config checks in some cases, but not
exit with error which was very confusing. Now exit 0 means all checks
passed and exit 1 means, that there is at least one error.

Use toml for the file, as discussed in pmbootstrap issue 2165. Python
3.11 has a native toml reader, use tomli for previous Python versions
for compatibility.
2024-06-30 18:04:31 +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
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
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
cebd784d84
Prefer f-strings (MR 2327) 2024-06-23 19:13:57 +02:00
Hugo Osvaldo Barrera
f3f392ef66
Use simplified Python 3.8 syntax (MR 2327)
This commit was generated with:

    ruff check --fix --extend-select=UP .
2024-06-23 19:13:52 +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
794048e2d5
pull: fix aports branches not being recognized (MR 2252)
Fix for:
  $ pmbootstrap pull
  [21:09:43] aports_upstream (branch: 3.20-stable): not on one of the official branches (master), skipping pull!

Replace the get_branches_official() function that according to git log
was never able to tell if an aports branch was official. The new
function branch_looks_official() can do that by just checking if the
branch follows the typical naming pattern.

The comment I had put into get_branches_official earlier was not true
anymore, by now this did not only get used by "pmbootstrap status", but
also by "pmbootstrap pull".
2024-06-23 12:38:42 +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
d4d6382897
helpers: pkgrel_bump: fix formatting (MR 2252)
f-strings

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:42 +02:00
Caleb Connolly
4108b95d72
ruff: run check --fix (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
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
77f66eb43d
build: package: more dependency resolution fixes (MR 2252)
It was the case that packages were being queued in the wrong order,
since the dependency resolver queues the package before descending into
it's dependencies. This was a bit of a goof since the top level package
was always added last. If we add it first then we can just reverse the
queue and now everything is fine...

Additionally, the logic on when a dependency should be built was a bit
wonky. A case is added for when a dependency exists only in the source
repo and the requisite package isn't marked for build. The solver will
now build the dependency regardless. This is surely an edgecase but
somehow I ran into it, I suspect due to a bug elsewhere...

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
c4b4c41b8d
helpers: logging: fixes + details_to_stdout in color (MR 2252)
* Fix details_to_stdout which was broken due to a previous commit.
* Improve support for custom colors with "@COLOR@" (e.g. "@BLUE@"), stop
  it from being printed unformatted to the logfile.
* Rework how the logfd is handled so that --details-to-stdout won't
  disable all color output.

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
3f11fa2500
tests: basic pkgrepo tests, clone pmaports (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
25e41ff3f7
helpers: logging: get rid of context and args (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:41 +02:00
Caleb Connolly
2cf44da301
meta: cache: rework cache clear (MR 2252)
This makes a looot more sense. Add a disable method too for use in
tests.

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
f2ca9c618e
ruff: run check --fix (MR 2252)
Get rid of unused imports and such

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
42d9f4e3cd
helpers: aportupgrade: fix req_headers init (MR 2252)
I broke this while adding type hints.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:40 +02:00
Caleb Connolly
0970b9d00b
helpers: file: fix apkbuild cache clear (MR 2252)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:40 +02:00
Caleb Connolly
7b9b274ac8
helpers: logging: log debug info during init (MR 2252)
Currently it can be quite annoying to parse a pmbootstrap log containing
multiple commands, since there are no newlines to differentiate between
invocations of pmbootstrap, the arguments it's called with aren't
logged, and neither is information about the system.

Fix all of this by printing some newlines to the log file and logging
the pmbootstrap version, the Python version, and the arguments
pmbootstrap was called with.

Extra care is taken to redact the "--password" option - users should
NOT treat this password as secure (since it's in their shell history)
but that doesn't mean we should go out of our way to leak password.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:40 +02:00
Caleb Connolly
bfd3f6a42c
helpers: repo: fix APKINDEX path handling (MR 2252)
We were appending .tar.gz twice! since commit ("treewide: adopt
pathlib.Path and type hinting")

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-23 12:38:40 +02:00