Commit graph

2990 commits

Author SHA1 Message Date
Newbyte
1aa0b05014
pmb.install.blockdevice: Avoid reusing size_mb variable in create_and_mount_image() (MR 2464)
Reusing this variable might lead to confusing bugs later if this code is
changed in the future, and also leads to mypy being confused about the
type of size_mb as it then gets assigned both str and int values.
2024-10-29 14:21:01 +01:00
Newbyte
f507aed9aa
pmb.build.autodetect: Fix return type and docstring for arch() (MR 2464)
At some point, this function was updated to use the Arch type instead of
plain strings, but the return type was left omitted and the docstring
outdated.
2024-10-29 13:49:37 +01:00
Newbyte
a89ecb11d2
pmb.build._package: Remove reference to nonexistent parameter (MR 2464)
No parameter called "now" exists for this function, so don't document
it.
2024-10-29 13:08:07 +01:00
Newbyte
44f28be2b1
CI: Don't set colour output for mypy (MR 2464)
This is already the default: https://mypy.readthedocs.io/en/stable/config_file.html#confval-color_output
2024-10-29 12:55:14 +01:00
Newbyte
f65eb27453
pyproject.toml: Add tool.mypy section (MR 2464)
And remove --check-untyped-defs from mypy.sh script to avoid
duplication.
2024-10-29 12:53:00 +01:00
Oliver Smith
7269d05b20
pmb.helpers.repo.download: proper error for 404 (MR 2462)
Flush the progress bar displayed by the function before logging a
warning message for 404 not found responses from the server. Without
flushing, this message gets lost.

In addition to the warning, display a NOTE and ERROR at the end to
explain what went wrong:

  [20:16:50] Update package index for x86_64 (4 file(s))
  [20:16:51] WARNING: file not found: http://mirror.postmarketos.org/postmarketos_get_404_test/edge/main/x86_64/APKINDEX.tar.gz
  [20:16:51] NOTE: check the [mirrors] section in 'pmbootstrap config'
  [20:16:51] ERROR: getting APKINDEX from binary package mirror failed!

Without handling this properly, pmbootstrap would fail slightly later
with a much less useful error:

  [15:14:28] ERROR: expected str, bytes or os.PathLike object, not NoneType

Fixes: pmbootstrap issue 2424
2024-10-27 20:52:13 +01:00
Oliver Smith
3ead8f8859
migrate_work_folder: print suffix in migration msg (MR 2460) 2024-10-27 20:47:06 +01:00
Oliver Smith
60cae5811b
migrate_work_folder: 7-2.x: skip update git url 2x (MR 2460)
Don't update the git URL again when coming from 7-2.x where this step
was already done. This didn't fail, but was potentially confusing for
the user since the git URLs were already upgraded from 7 -> 7-2x.
2024-10-27 20:47:00 +01:00
Caleb Connolly
50321d41f6
build: package: skip prioritizing deps of pkg which are a subpkg of pkg (MR 2459)
Some packages in aports have their own subpackages in their
dependencies, for some reason. This causes our resolver to assume there
is a cyclical dependency.

Adjust the resolver to safely ignore these dependencies, since they'll
be built as a part of the package that depends on them.

For example, modemmanager depends on libmm-glib which is a subpackage of
modemmanager. Currently to build modemmanager in pmaports it would be
necessary to manually modify the APKBUILD after copying it from aports.
This change avoids that.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 19:36:04 +01:00
Oliver Smith
497188eb30
CI: force IPv4 for gitlab.postmarketos.org (MR 2459) 2024-10-27 19:35:59 +01:00
Caleb Connolly
acc989de65
commands: getattr autoinstall (MR 2461)
args.autoinstall attribute might not exist, use getattr like for others,
and add a fixme about the default value...

Fixes: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2476
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 18:59:42 +01:00
Newbyte
9f5642fd44
pmb.helpers.args: Remove please_i_really_need_args() (MR 2442)
All call sites that use this have been removed. This was only introduced
as a stopgap until we could refactor more code to not use args
everywhere, and that has now been achived. As such, remove this so it
doesn't get used in more locations.
2024-10-27 17:49:15 +01:00
Caleb Connolly
657c25c904
build: package: error when --src and --arch but no APKBUILD (MR 2458)
See
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2473

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 17:03:00 +01:00
Caleb Connolly
d4d7ba0368
test: parse: apkindex: check that cache works (MR 2455)
Add a basic test to ensure that the cache does get hit as we expect.
This doesn't test for cache conflicts.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 16:42:54 +01:00
Caleb Connolly
12f9e43a08
parse: apkindex: don't require python 3.12 (MR 2455)
Use a different way of keying the apkindex path cache.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 16:42:49 +01:00
Caleb Connolly
2106e13f97
build: package: allow building old versions of packages with --force (MR 2457)
It may be desirable to test older versions of packages, allow them to be
built when --force is specified and print a warning that they won't be
installed automatically.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-27 16:17:12 +01:00
Vikram Alagh
8ac2e48a21
install: losetup: check if the back-file attribute for a loop device is null (MR 2456)
Seems to be ChromeOS specific:

> this happens every time on my machine. I am on ChromeOS 129.0.6668.112
> using a Debian bookworm chroot through Crouton. I am not sure why
> this is happening nor which layer is responsible for this. I deleted
> the chroot and created another one but the problem persists.

Commit msg tweaked by Oliver.
2024-10-27 16:03:17 +01:00
Newbyte
e8e146c68a
CI: Add multipath-tools dependency (MR 2450)
Provides kpartx.
2024-10-27 13:14:11 +01:00
Newbyte
3c47a52f91
pmb.install.losetup: Remove debug print (MR 2450)
Looks like an unintended leftover from debugging.

---

This was needlessly reverted by
1ec55fc11a. While revreting
0975d06437 was good, this commit did not
cause any harm.
2024-10-27 13:14:11 +01:00
Newbyte
bbf20a030b
pmb.install.losetup: Annotate return types (MR 2430) (MR 2450)
And fix type errors.

---

This was needlessly reverted by
1ec55fc11a. While revreting
0975d06437 was good, this commit did not
cause any harm.
2024-10-27 13:14:11 +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
Luca Weiss
d64573f1b1
ci: Remove outdated sphinx-build command check (MR 2451)
We now run the job in chroot, so remove the unnecessary check. If
sphinx-build is missing for some reason, it will fail a bit further in
the script anyways.
2024-10-27 02:29:20 +02: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
ca5c77fa20
pmb.core.config: Fix type of jobs variable (MR 2434)
I don't think there's any case where the number of jobs would have to be
a string. It's also being assigned an integer elsewhere the code (in
ask_for_additional_options() inside of init.py), so an integer seems
like what we actually want. Also fix type errors resulting of this.
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
Newbyte
9348cacff5
pmb.helpers.mount: Add more type hints (MR 2434) 2024-10-27 00:38:16 +02:00
Luca Weiss
a1e982aa1e
pmb.helpers: Handle workdir version suffix from 2.3.x (MR 2447)
For the gitlab.com -> gitlab.postmarketos.org migration we needed to
also migrate the workdir in pmb v2 since pmb v3 is not ready yet.

Therefore we need to handle that "7-2.x" workdir version and migrate
correctly when switching to pmbootstrap v3.

See https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2445
2024-10-26 15:53:45 +02:00
Clayton Craft
83d6a26291
pmb.config: add the full hexdump to the list of installed build packages (MR 2454)
This works around https://gitlab.postmarketos.org/postmarketOS/
pmaports/-/issues/3268, by always installing hexdump when building
packages. The full hexdump is small (like 80KB), and even though this
isn't required in most situations it seems like the best of a group
of bad workarounds, until upstream/busybox fix the bug in the pmaports
issue.
2024-10-24 09:39:37 -07:00
Caleb Connolly
6066772ca8
CI: ruff: run ALLL the checks before failing (MR 2448)
So we don't go through the pain of pushing 3 times to get 3 different
ruff failures in CI.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-23 23:22:04 +02:00
Caleb Connolly
8627ee7e73
test: parse: add test_apkindex (MR 2448)
Add a test to parse some APKINDEX data.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-23 23:22:04 +02:00
Caleb Connolly
a874025bbe
parse: apkindex: fix provider_priority type (MR 2448)
should be an int, but was always a string...

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-23 23:17:03 +02:00
Caleb Connolly
da78b11dfd
core: drop unused crosstool.py (MR 2448)
I guess this is leftover from some experimentation.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-23 23:16:28 +02:00
Caleb Connolly
b151871976
test: chroot: apk: fix missing return in _apkindex_package() (MR 2448)
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-10-23 23:16:28 +02: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
Clayton Craft
2305cc5db6
pmb.parse.apkindex: fix crash when origin or timestamp are unset (MR 2449)
Sometimes these fields are not set, e.g.:

pdb> p ret
{'depends': ['build-base', 'bash', 'bison', 'findutils', 'flex', 'musl-dev', 'openssl-dev', 'perl', 'python3'], 'arch': 'noarch', 'version': '20241022.022230', 'pkgname': '.makedepends-linux-lenovo-21bx', 'provides': []}

I hit this crash when I installed the build deps for the
linux-lenovo-21bx package in the native chroot, and then ran
`pmbootstrap stats`
[ci:skip-build]: already built successfully in CI
2024-10-22 11:11:28 +02:00
Newbyte
11c7d23575
pmb.parse.arguments: Make -x and -n mutually exclusive in kconfig edit (MR 2346)
It doesn't make sense to both request the nconfig UI and the xconfig UI
at the same time. Make them mutually exclusive.
2024-10-22 00:04:33 +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
Clayton Craft
4f3ede3329
ci: add basic integration testing for pmb (MR 2444) 2024-10-21 23:48:20 +02:00
Luca Weiss
35cd64086f
Improvements to documentation (MR 2440)
* Make sure all Python modules are documented by adding a bit of shell
  to .ci/docs.sh
* Remove non-existing module references from .rst
* Fix various warnings from sphinx by adjusting Python docstrings
* Add class member docs to ApkindexBlock
2024-10-21 21:46:26 +02:00
Clayton Craft
c7a97df79a
pmb.core.arch: add noarch (MR 2446)
When a `noarch` APKBUILD is changed in local pmaports, `pmb install`
will build it automatically but image creation will fail with the
following error:

```
$ pmbootstrap install
...
[12:00:43] Build is necessary for package 'postmarketos-base-ui': binary package out of date (binary: 28-r6, local pmaports: 29-r0)
[12:00:48] => edge/postmarketos-base-ui: Done!
...
[12:01:02] (rootfs_lenovo-21bx) % apk --no-progress --repository /home/clayton/.local/var/pmbootstrap/packages/edge add -u --virtual .pmbootstrap /mnt/pmbootstrap/packages/edge/aarch64/postmarketos-base-ui-wifi-iwd-29-r0.apk /mnt/pmbootstrap/packages/edge/aarch64/postmarketos-base-ui-qt-wayland-29-r0.apk /mnt/pmbootstrap/packages/edge/aarch64/postmarketos-base-ui-qt-tweaks-29-r0.apk /mnt/pmbootstrap/packages/edge/aarch64/postmarketos-base-ui-29-r0.apk /mnt/pmbootstrap/packages/edge/aarch64/postmarketos-base-ui-audio-none-29-r0.apk /mnt/pmbootstrap/packages/edge/aarch64/postmarketos-base-ui-networkmanager-29-r0.apk /mnt/pmbootstrap/packages/edge/aarch64/postmarketos-base-ui-wifi-iwd-29-r0.apk --no-interactive
...
[12:01:04] ERROR: Invalid architecture: 'noarch', expected something like: x86_64, aarch64, riscv64, armhf, x86, armv7
[12:01:04] See also: <https://postmarketos.org/troubleshooting>
[12:01:04] Traceback (most recent call last):
  File "/home/clayton/src/pmbootstrap/pmb/core/arch.py", line 42, in from_str
    return Arch(arch)
           ^^^^^^^^^^
  File "/usr/lib/python3.12/enum.py", line 757, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/enum.py", line 1171, in __new__
    raise ve_exc
ValueError: 'noarch' is not a valid Arch

```

[caleb: fixed tests]
2024-10-21 21:41:16 +02:00
Luca Weiss
327010cff1
pmb.parse.apkindex: Add missing type hints in package() (MR 2438)
Make sure to annotate the parameters.
2024-10-21 21:05:18 +02:00
Luca Weiss
9a5b5fc5e1
pmb.helpers.pkgrel_bump: Add type hints and fix auto_apkindex_package (MR 2438) 2024-10-21 21:05:17 +02:00
Luca Weiss
99f770d27c
pmb.core.apkindex_block: Don't mark depends as optional (MR 2438)
In the code where the object is made (pmb/parse/apkindex.py) depends
already will become an empty array when there's no dependencies.

And there's no point in having a differentiation between None and empty
array.
2024-10-21 21:05:17 +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
Clayton Craft
47dc493701
pmb.parse.depends.package_provider: add type hinting and fix references (MR 2439)
pmb.parse.apkindex.providers now returns a dict of string:ApkindexBlock,
probably from 71772b9b6

This adds type hinting to package_provider to reflect this, and fixes
code that calls it to properly deal with the possible return types.
Without this, building FDE images is broken.
2024-10-18 13:45:57 +02:00
Luca Weiss
4019636f72
ci: Run docs job in chroot (MR 2413)
Use the new "Artifacts" directive for .ci/docs.sh and run the job in the
pmbootstrap chroot to avoid needing to install sphinx dependencies on
the host.

Fixes #2352
2024-10-17 19:01:30 +02:00
Luca Weiss
342900aee1
ci: Add support for artifacts (MR 2413)
And make the docs job run in the chroot now and grab the 'public/'
directory so we have the built docs.
2024-10-17 18:53:44 +02:00
Luca Weiss
9e3d7af96b
helpers: make get_topdir return Path (MR 2413)
Since the return value is a file path, let's make it a Path object. Also
update the docstring to reflect reality.
2024-10-17 18:53:44 +02:00