Commit Graph

2469 Commits

Author SHA1 Message Date
Newbyte 5577495dc5
pmb.helpers.run: Add some type hints (MR 2262) 2024-03-10 16:18:27 +00:00
Newbyte 85f777073e
pyproject.toml: Fix deprecation warning (MR 2262)
Fixes this warning:

warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`:
  - 'ignore' -> 'lint.ignore'
2024-03-10 16:18:23 +00:00
Clayton Craft a416e3ffae
pmb.config: kconfig check: add vfat to uefi check (MR 2269)
UEFI 2.0 spec requires FAT for the ESP[1], and we use the ESP for /boot so
let's make sure that the kernel always has support for mounting it.

1. https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html#file-system-format-1
2024-03-08 16:31:25 -08:00
Clayton Craft 1352c658a5
pmb.config: kconfig check: mark some EFI config as specific to ARM (MR 2269)
This fixes an issue where the kconfig uefi check fails on x86_64
kernels, since these vars do not exist in the kconfig for this arch.
2024-03-08 16:31:20 -08:00
Alexander Martinz 7f271dd1cc
pmb: correct link after moving sources back to gitlab (MR 2270)
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
2024-03-08 14:04:00 +01:00
Pablo Correa Gómez 762c725bb5
Remove unnecessary setup.cfg, non-universal is the default (MR 2265)
According to
https://wheel.readthedocs.io/en/stable/user_guide.html#building-wheels
universal = 1 is opt-in
2024-02-29 00:47:33 +01:00
Pablo Correa Gómez d2bcff3162
Drop support for python3.7 and python3.8 (MR 2265)
Even Debian oldstable is on python3.9 now, so should be safe, and
should also help the typing process that has now started
2024-02-29 00:47:33 +01:00
Pablo Correa Gómez d895f4a465
Migrate from setup.py to pyproject.toml (MR 2265)
In the process, drop the list of required python packages. This is
only needed for pip, as pmbootstrap checks by itself. This way we
avoid duplicating the minimum required version.

We also don't install the helpers anymore, as modern tooling does not
support installing things outside the python package dir
2024-02-29 00:47:33 +01:00
Newbyte 812a3e4a85
test: Test subpackages which set a different architecture (MR 2267) 2024-02-26 20:55:49 +01:00
Newbyte 71ac87e6af
pmb.parse._apkbuild: Fix subpackages with set arch but no custom function (MR 2267)
If there are multiple sections to a subpackage declaration, the middle one
(item 1 in the sequence in this case) is the custom function name which we
should use instead of the deduced one.

For example:
  $pkgname-something-separate:something_separate:noarch

Here, the subpackage is called $pkgname-something-separate, but function names
cannot contain hyphens, so it's instead given the custom name
something_separate where the hyphen is replaced by an underscore. At the end,
the architecture of the subpackage is also overriden as noarch instead of
whatever architecture the main package has.

However, it is also possible to only override architecture of a subpackage and
not the function name.

In such cases, we get this:
  $pkgname-something::noarch

We still have a "middle section" (item 1 in the sequence), but it will be
empty. As such, we not only need to check whether there are more than 1
subpackage part, but also whether that extra subpackage part is an empty string
or not.

This fixes an issue where pmbootstrap would not end up just setting the
properties of subpackages with a set arch but no custom function as
None instead of giving them proper depends, install, pkgdesc, et cetera
properties.
2024-02-26 20:55:49 +01:00
Raymond Hackley e0d5b49840
pmb/config: s/für/for/
Fix typo

Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20240226104630.5819-1-raymondhackley%40protonmail.com%3E
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-26 14:50:19 +00:00
Newbyte e6b6b73c0d
pmb.parse.arch: add armv8l -> armv7 mapping (MR 2259)
Supposedly this is the architecture reported by userspace when running
in 32-bit mode on aarch64.

Closes https://gitlab.com/postmarketOS/pmbootstrap/-/issues/2311
2024-02-22 19:47:32 +01:00
Oliver Smith 6ba138b6b2
logging: print text between *** in green (MR 2263)
Highlight messages like the following from pmbootstrap install:
  [19:45:59] *** (1/4) PREPARE NATIVE CHROOT ***

[ci:skip-build]: already built successfully in CI
2024-02-22 19:37:48 +01:00
Ferass El Hafidi 385fc2cfc1
README.md: mention parted bug in kernels between 5.8 and 6.0 (MR 2264)
Many have been unable to use pmbootstrap install on kernel versions
between 5.8 and 6.0 as parted was giving the following error:

	Error: Partition(s) 1, <...>, 64 on /dev/install have been
	       written, but we have been unable to inform the kernel
	       of the change, probably because it/they are in use.
	       As a result, the old partition(s) will remain in use.
	       You should reboot now before making further changes.

And pmb couldn't find /dev/loop0p1:

	ERROR: Unable to find the first partition of /dev/loop0,
	       expected it to be at /dev/loop0p1!

Related: pmbootstrap#2309

[ci:skip-build]: no code changes

Signed-off-by: Ferass El Hafidi <funderscore@postmarketos.org>
2024-02-22 14:59:23 +01:00
Clayton Craft 8abd698cab pmb.install: fall back to a valid hostname if none set (MR 2260)
If the device name does not make a valid hostname, fall back to some
simple valid hostname. Some device names (e.g. 'generic-x86_64') are
valid names for apk packages and such, but are not valid host names. It
assumes that the user (real, or CI) doesn't care if it's unset and just
expects pmb to work and not conditionally crash based on the device they
selected.

Situations where the user sets an invalid hostname are still validated
separately and cause an exception so that they know their config was
wrong and to fit it.

This fixes an issue that came up in CI when doing `pmb config device
generic-x86_64` followed by `pmb install`.

I considered trying to convert invalid host names into valid ones, but I
didn't feel like it was worth the trouble of adding stuff to convert and
re-validate when we can just set a static, boring, but definitely valid
default if the device name is not valid.
2024-02-16 18:57:49 +00:00
Oliver Smith 2d90b558c1
CI: mypy: make compatible with "pmbootstrap ci" (MR 2258) 2024-02-16 10:04:25 +01:00
Newbyte c18bff1c67
CI: add Mypy check (MR 2258) 2024-02-16 10:04:25 +01:00
Newbyte 8835dd846c
pmb.parse._apkbuild: Disable attr-defined for entire module (MR 2258)
Due to that logging.verbose is "monkeypatched" into logging and not
present by default in the module, Mypy isn't able to pick up that it
exists. As such, just disable the check altogether in this file for
now.
2024-02-16 10:04:25 +01:00
Newbyte 40f3dddbfe
pmb.helpers.aportupgrade: Remove unused return values (MR 2258)
Neither the return value from upgrade_git_package nor
the one from upgrade_stable_package actually gets used anywhere, so
just remove it.
2024-02-16 10:04:25 +01:00
Newbyte bc530a107f
pmb.helpers.aportupgrade: Don't return any value from upgrade (MR 2258)
The return value of this function is never used. Additionally, the type
hint for it was incorrect as it may return None. As such, don't bother
returning anything both to appease Mypy and also to remove unused
and consequently presumably untested functionality.
2024-02-16 10:04:25 +01:00
Newbyte cb3807a9f6
pmb.helpers.aportupgrade: Check for none pkgver_match in upgrade_git_package (MR 2258)
Appeases Mypy.
2024-02-16 10:04:24 +01:00
Newbyte bcfab8cfc3
pmb.helpers.aportupgrade: Import urllib.parse explicitly (MR 2258)
Apparently importing urllib doesn't by itself import the urllib.parse
module, which mypy complains about.

Reference: https://stackoverflow.com/a/41502702/9315690
2024-02-16 10:04:24 +01:00
Newbyte 3aad061c68
pmb.parse.arguments: Check for argcomplete in sys.modules instead (MR 2258)
Repurposing argcomplete as a boolean telling whether the module
argcomplete was found results in a variable with two distinct purposes
and types, which is bad practice and confuses Mypy. As such, don't
assign False to argcomplete if the module is not found and instead just
check for whether it exists in sys.modules to determine whether it was
imported successfully.
2024-02-16 10:04:24 +01:00
Clayton Craft aa594b76fa
pmb.config: do not prompt for nonfree fw/userland (MR 2255)
This drops the prompt for using non-free firmware in images. The logic
for searching/installing non-free fw subpackages for devices is kept,
and will always be installed. This is to support the many device
packages in pmaports that still have nonfree-firmware subpackages. Going
forward, device packages can list firmware in `depends=` (for required
fw) or `pmb_recommends` (for optional fw).

nonfree-userland wasn't used in pmaports as far as I could find.
2024-02-15 16:00:56 -08:00
Oliver Smith 0bed6a0437
pmb.install…get_selected_providers: tweak comment (MR 2261) 2024-02-15 20:43:13 +00:00
Clayton Craft 3f390303b3
pmb.install: discover selected providers in dependencies too (MR 2261)
Sometimes dependencies of packages we are explicitly adding to world
define selected providers that we should account for. This improves
get_selected_providers to discover/add these selected providers in
dependencies too, recursively.

Fixes #2306
2024-02-15 20:43:13 +00:00
Pablo Correa Gómez f893cd3081
config: add note on why mirrors are http and not https (MR 2256)
It has been a confusion point in the past:

https://gitlab.com/postmarketOS/pmbootstrap/-/merge_requests/2128

https://gitlab.com/postmarketOS/pmbootstrap/-/merge_requests/2094
2024-02-15 20:02:51 +00:00
Pablo Correa Gómez 57701084de
config: organize defaults matching config_keys and order alphabetically (MR 2256)
Makes it much easier to read
2024-02-15 20:02:39 +00:00
Newbyte cc3a7eb2ff
b4-config: Remove (MR 2257)
We no longer use SourceHut for pmbootstrap development, so this is no
longer relevant.
2024-02-14 17:50:56 +01:00
Oliver Smith 7102157bf1
Prepare 2.2.1 release 2024-02-11 21:37:39 +00:00
xtex ea107170d9
envkernel: Install envkernel.fish (MR 2249) 2024-02-10 01:29:05 +00:00
xtex 5df2ef234e
envkernel.fish: Support out-of-tree usage of envkernel.fish (MR 2249) 2024-02-10 01:29:05 +00:00
xtex 3609a68aaf
envkernel: only export alias when defined (MR 2249)
MR !2229 make pmbootstrap optional and break fish compat
2024-02-10 01:29:05 +00:00
Andras Sebok 0c8b9c805f
pmb.aportgen: drop deviceinfo_screen_* (MR 2253) 2024-02-09 20:13:59 +01:00
Oliver Smith 18698ab251
install: get_recommends: fix infinite recursion (MR 2250)
Keep track of the packages visited and skip them if they are passed
again.

Fixes: 19f8a3b8 ("pmb.install: support pmb_recommends for any package")
2024-02-07 09:47:12 +00:00
Oliver Smith 7f61262ae8
Prepare 2.2.0 release 2024-02-06 23:43:54 +00:00
Oliver Smith a890b2cd26
pmb.build.init: fix apk wrapper for x86 on x86_64 (MR 2247)
Only install the abuild-apk wrapper if cpu emulation is required. This
fixes building for x86 on x86_64.

Fix for:
  >>> postmarketos-base-ui-gnome: Analyzing dependencies...
  /usr/local/bin/abuild-apk: line 11: /native/usr/bin/abuild-apk: not found

Fixes: c5ca06d5 ("pmb: only enable abuild-apk wrapper for buildroot (MR 2246)")
2024-02-06 20:03:50 +00:00
Luca Weiss 54a616621f
kconfig check: Enable more options for community (MR 2245)
Enable some configs that were collected over the last year(s) and enable
them for the community kconfig check.
2024-02-06 19:02:34 +00:00
jane400 178486a64e
kconfig check: enable NFT_COMPAT for iptables-nft wrapper (MR 2245)
we're not in the nftables only world yet, things like docker and
tailscale only work with the `iptables` command. those programs
expect iptable-modules, which we make available to nftables over
the nftables/iptables compat layer.
2024-02-06 19:02:30 +00:00
Caleb Connolly 7e3ce1ef14
build.envkernel: simplify and fix unhandled error path (MR 2243)
Drop the weird flag file stuff for state management, and just always
mount the source code in, and always unmount it on exit - including in
the error path.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-06 18:22:37 +00:00
Caleb Connolly 384c843a25
pmb.build: ensure all specified packages are built with --force (MR 2244)
When running build --force, if a later package is a dependency of an
earlier package, it will be "visited" by the dependency resolver,
erroneously causing it to be skipped when later in the session it's
visited to force build. This is because previously visited packages are
marked as such in a hashmap, but skip_already_built() assumes that a
package which has been visited would have already been built.

Fix this by overriding skip_already_built() if doing a force build. This
works because package dependencies are only built if the APKBUILD
version is newer than the binary repo, even when --force is specified.
So there is no risk of an infinite loop here.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-06 18:07:07 +00:00
Caleb Connolly c5ca06d502
pmb: only enable abuild-apk wrapper for buildroot (MR 2246)
Some packages like kernels are cross compiled from the native chroot.
the apk_wrapper won't work here! So only enable it for buildroot chroots

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-06 16:15:09 +01:00
Jacob Ludvigsen 2bd1eb26d8
install: more comprehensive subdivision of btrfs subvols (MR 2233)
Why
Btrfs has some goodness (snapshots, switching between different rw snapshot)
which plays particularly well with certain "subvolume layouts".

What
This MR seeks to implement such a layout, namely a flat btrfs layout,
where the top level subvolume (i.e. the btrfs filesystem/partition itself)
remains unmounted in all situations,
except when making changes to direct child subvolumes of the filesystem.

- rename all subvols to follow the common @* btrfs subvol naming scheme.
- add subvol @root, because roots home directory shouldn't be rolled back.
- make subvol @var not Copy-on-Write (nodatacow) to avoid write
- multiplication on logs, VMs, databases, containers and flatpaks.
- add subvol @snapshots because that lets us change the root subvol to a
read-write snapshot of @ without affecting snapshots.
- add subvol @srv because it contains data for Web and FTP servers,
which shouldn't roll back together with root subvol.
- add subvol @tmp because we don't want to snapshot temporary files.
This subvol remains unmounted on the device,
unless conditions as laid out in pmaports!4737 are met.
- add check and error for btrfs when using rsync installation.
2024-02-06 12:04:20 +00:00
Clayton Craft e139a34472
pmb.install: honor -y, don't prompt when target disk is >100GiB (MR 2239)
fixes #2303
2024-02-06 03:51:42 -08:00
Clayton Craft b06d751822
pmb.install: include dependencies when searching for pmb_recommends (MR 2238) 2024-02-06 03:35:55 -08:00
Clayton Craft 0722e962d0
pmb.install: fix crash on empty subpackage in get_recommends (MR 2238) 2024-02-06 03:35:54 -08:00
Caleb Connolly a72b21de0c
build: use native abuild-apk (MR 2242)
Speed up using abuild to install build dependencies by introducing a
wrapper which invokes abuild-apk in the native chroot with
LD_PRELOAD_PATH

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-02-06 00:26:13 +01:00
Caleb Connolly 9526a9d437
build: use host native gzip (MR 2242)
Instead of installing a gzip wrapper, run gzip from the native chroot
which we bind mount in.

Signed-off-by: Caleb Connolly <kc@postmarketos.org>
2024-02-06 00:23:19 +01:00
Oliver Smith 37a7f3924d
Fix preserving proxy variables (MR 2237)
Fix "pmbootstrap chroot" and others not passing the proxy environment
variables correctly. Thanks to notfound405 for pointing this out!

Instead of only preserving proxy environment variables in
pmb.helpers.run_core, which should never be called directly, do it in
the calling functions:

* pmb.helpers.run.user
* pmb.helpers.run.root
* pmb.chroot.root
* pmb.chroot.user

This fixes that the environment variables were only really passed by
pmb.helpers.run.user, because the other functions would result in
something like:
  HTTP_PROXY=mytestproxy sudo env -i /usr/bin/sh -c '…'
This is needed to either elevate to root, or to elevate to root first
and then enter the chroot as root or user. Due to the "env -i", the
environment intentionally gets cleaned, but unintentionally also removes
the proxy environment variables that were explicitly set.

By adjusting the functions, they now run a variant of:
  sudo env -i /usr/bin/sh -c 'HTTP_PROXY=mytestproxy …'

The escaping is simplified in this example, run "pmbootstrap -v" to see
the not very readable, but proper escaping with shutil.quote().

Remove the previous test for preserving the environment variables in
pmb.helpers.run_core (as it should never be called directly), and test
instead the new behavior.

Fixes: issue 2299
Fixes: 13c4ac42 ("pmb.helpers.run_core: fix proxy env var logic")
2024-01-25 20:12:53 +00:00
Fiona Klute 23a8d14d4a
Don't drop parameters in run-script (MR 2230)
Note that the parameters aren't included directly in the sh -c command
string, but instead as additional parameters after. That avoids having
to find a cross-shell approach for quoting them in a way that works
inside the string (there doesn't seem to be one).

That's also the reason for the additional "sh" parameter: The first
parameter after the command string becomes the command name ($0), the
ones after positional parameters.
2024-01-23 23:11:55 +00:00