This allows us to get rid of some of the validation in sanity_checks()
as mypy handles this validation at "build time", and any typos in the
enum instantiation would be a runtime error rather than a silent
failure.
Additionally, it allows us to encode some of the behaviour of the
different output types into the type definition itself by using methods.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2642
With recent changes we don't install alpine-base in the chroots anymore.
It still gets installed as postmarketos-base depends on it (for now,
this will change soon in master). But it is not guaranteed to be
installed before other packages which may run "rc-update" in their
postinst scripts.
Fix this by explicitly installing alpine-base early on during
"pmbootstrap install".
Fix for e.g. v24.12:pine64-pinephone:phosh images:
(342/976) Installing eg25-manager-openrc (0.4.6-r5)
(343/976) Installing device-pine64-pinephone-openrc (7-r0)
Executing device-pine64-pinephone-openrc-7-r0.post-install
lib/apk/exec/device-pine64-pinephone-openrc-7-r0.post-install: line 3: rc-update: not found
ERROR: device-pine64-pinephone-openrc-7-r0.post-install: script exited with error 127
Related: https://builds.sr.ht/~postmarketos/job/1473669#task-img-743
Fixes: 12d125ab ("chroot: don't depende on alpine-base")
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2585
With recent rework in postmarketos-initramfs, we no longer need to mount
the /boot partition in the initramfs (assuming initramfs-extra is not
used). On devices that boot without accessing the boot file system (e.g.
Android boot images, fastboot, ...), that makes it possible to install
postmarketOS on a single (potentially encrypted) partition that contains
both root (/) and /boot files.
This avoids the extra complexity of the subpartition setup we usually use
on such devices, and also avoids having to flash two partitions (when using
--split to avoid the subpartitions).
Add a --single-partition option to pmbootstrap install that allows
installing postmarketOS in this mode. For now this is just an option that
must be selected explicitly, in the future we could choose to make this the
default for Android-based devices with a large enough boot partition.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2512
Previous reasons to write the locales to /etc/profile.d/.. was because
musl-locales do only support reading from environment variables and not
/etc/locale.conf.
However systemd-localed (and glibc) uses /etc/locale.conf to read and
write locale configurations. gnome-control-center, for example, uses
localed to change locales.
In the sake of a single source of truth, allow pmb to write to
/etc/locale.conf and allow its consumers (e.g. g-c-c via systemd) to
read/change these variables.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2547
Merge strings that have a break in the same line. These were generated
when running "ruff format" initially.
Old:
logging.info("Firewall is not supported in checked out pmaports" " branch.")
New:
logging.info("Firewall is not supported in checked out pmaports branch.")
Signed-off-by: Robert Eckelmann <longnoserob@postmarketos.org>
Tweaked-by: Oliver Smith <ollieparanoid@postmarketos.org>
For some reason this also requires a fix in pmb.install._install.py,
didn't bother investigating why but the necessary change seems fine to
me.
Requires mypy 1.14 (maybe 1.14.1, not sure).
On some kernels (notably, WSL2) parted fails to inform the kernel
about the new partition layout, leading to errors when trying to
create the new filesystems.
This change runs an additional `partprobe` after updating the
partition table, informing the kernel about the new layout.
Fixes: #2422
Signed-off-by: Dominik Bayerl <dominik.bayerl@carissma.eu>
[caleb: move call so it runs after partition_cgpt() as well]
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
Otherwise, if pmb.parse.deviceinfo().cgpt_kpart is an empty string, for
example, we end up passing an empty string to get_partition_layout()
instead of False.
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.
The previous version would fail if the suffix contained a dash as well,
e.g. postmarketos-base-ui-audio-some-new-thing. Fix it and add example
comments.
When building a systemd image, this patch installs pmos-base-systemd
(and its dependencies) first before building the rest of the device
chroot. This is a workaround for...
The pmos-base-systemd package provides distro-wide systemd presets for
services, and when it's added to the `install_packages` list then
there's no guarantee that apk will install it *before* service packages
execute `systemctl preset`. In other words: `preset` may be run before
the distro presets are actually installed, and crushing expectations. By
making sure pmos-base-systemd is installed in the chroot first, we can
provide some guarantee that presets will be there when services are
installed a bit later.
When using fastboot-bootpart flash method to split root/boot partitions
out, it was no longer possible to flash the Android boot partition.
Add a new flash_boot action to handle this.
This will allow us to migrate devices like the OnePlus 6 to have the
boot partition (ESP) on system, and the rootfs on userdata rather than
the current subpartition method.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
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.
One flaw of pathlib is that Path("/tmp/") / "/some/relative/path"
results in Path("/some/relative/path")....
Fix the places in the codebase where we get this wrong.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
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>
The call to chroot.apk.install() will automatically build packages, so
we don't need to call it again beforehand.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
We used to called pmb.chroot.shutdown() with "only_install_related=True"
here to unmount everything in the chroot so we could reliably "df" it to
figure out the rootfs image size.
Since ("pmb.chroot: only init once"), the chroot is no longer
automatically spun back up when we run mkinitfs, and the in-pmbootstrap
marker isn't recreated.
We only actually need to unmount the chroot anyway, so let's restrict it
to just that and remount things again afterwards.
This avoids weird side effects (like the native chroot being
shutdown?!), but this is something we should look into more in the
future since we're still doing a finnicky balancing act to manage chroot
state here.
Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
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>