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

3330 commits

Author SHA1 Message Date
Casey Connolly
1bcc24f65a test: add dummy pmaports repo
Add a dummmy version of pmaports for testing. This gives us much better
control and simplifies a lot of the logic.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-06-13 21:47:42 +02:00
Casey Connolly
49a86cc303 initfs: fix ls and init chroot
We don't always have an initramfs-extra anymore, implement the
deviceinfo check for this. Also ensure we init the chroot before trying
to use it.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-06-13 21:47:42 +02:00
Casey Connolly
9dc294dbbf pmbootstrap: unshare PID namespaec
Put ourselves in a new PID namespace so that daemons we might start in
the chroot like adbd will be killed on exit.

This simplifies "shutdown" since we no longer need to kill these
processes.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-06-13 21:47:42 +02:00
Casey Connolly
e8a9ce615f chroot: shutdown: simplify
We don't need to bother unmounting stuff anymore since that will be
handled automatically when all processes in the namespace exit.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-06-13 21:47:42 +02:00
Casey Connolly
f7dd2e75dd build: kconfig: fixes
fix cross type changes

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-06-13 21:47:42 +02:00
Casey Connolly
4b189f1bba build: init: fix init_compiler for native
Handle the case where cross compilation is not needed since
cross_compiler can still be called when not actually cross compiling.
Install gcc since kernel packages don't actually depend on it
explicitly.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-06-13 21:47:42 +02:00
Casey Connolly
2c9004c9c6 pmbootstrap: sanitize the environment a little
Clean up the environment a little, set shell to something known

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-06-13 21:47:42 +02:00
Casey Connolly
b9d6a304dc try to add FDE support but it doesn't work
Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-06-13 21:47:42 +02:00
Casey Connolly
ecf1d54e39 WIP: install: rootless disk image
Refactor the install code to stop using loop devices and instead create
and manipulate a disk image directly. Both ext4 and vfat have mechanisms
for formatting and populating partitions at an offset inside an image,
other filesystems likely do as well but so far have not been implemented
or tested.

With this "pmbootstrap install" works for standard EFI disk images (e.g.
QEMU, X64 or trailblazer) entirely rootless.

Since the creation of the disk images happens in the same user namespace
as everything else, the resulting disk images have correct ownership and
permissions even though from the host perspective they are all subuids.

This gets image building working properly *for the default case*. We can
now build disk images! In particular, we can build disk images with a 4k
sector size even on a host with a 512 byte sector size (or block size in
the filesystem). This is surprisingly hard for some reason since not all
libfdisk tools have the right flags. Thankfully sfdisk does.

In addition, we now generate UUIDs ourselves, to break the loop between
generating fstab and running mkfs (since we also populate the disk image
/with/ mkfs, we need to already know the UUID when we run it...).

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-06-13 21:47:42 +02:00
Casey Connolly
9a6e32fb6d
Revert "chroot: allow mounting the device rootfs (MR 2252)"
This reverts commit f331b95824.
2025-05-30 21:29:28 +02:00
Casey Connolly
d8886b086a
init: sandbox: also map rootfs user 10000
Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:28 +02:00
Casey Connolly
6be3079620
parse: deviceinfo: make boot_part_start int and set default
We use a default boot partition offset of 2048 sectors, encode this into
the Deviceinfo type and handle converting to int so we don't have to do
it everywhere we use this.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:28 +02:00
Casey Connolly
62205e5b02
remove ondev support
The on-device installer has been unsupported for a while, start removing
it from pmbootstrap to simplify the partitioning code, for example we no
longer need to support having some "reserved" space in the rootfs.

This follows various discussions which essentially indicated that future
on device installation methods will take a different approach which will
not require bespoke partitioning.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:28 +02:00
Casey Connolly
0179e7d12b
install: default to fat32 for boot
This is more compatible than ext2 especially on x86/efi systems

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:28 +02:00
Casey Connolly
2f3f36397f
init: add run/sudo helpers
These helpers could be used to run commands as root prior to unsharing
namespaces, for example to probe the binfmt module. They aren't used
currently but are left in just in case...

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:28 +02:00
Casey Connolly
be5e18cf99
unshare binfmt
Rework how we handle binfmt_misc so it will work inside a user
namespace.

* Use a custom mountpoint (only accessible inside the mount namespace),
  this is the crux of the change, allowing us to mount it as non-root
  and avoid messing with any host configs too!
* No longer explicitly modprobe binfmt_misc, any modern system should
  probe it automatically when we try to mount it... I think so anyways
  heh

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:27 +02:00
Casey Connolly
c997ce83c2
chroot: mount: resolve bind mounts
They might be symlinks in some quirky setups, we need the absolute paths
for bind mounts to work correctly.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:27 +02:00
Casey Connolly
84aa801349
chroot: init: clean up imports
Remove some unused ones?

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:27 +02:00
Casey Connolly
4302531d99
commands: add a shell command
This command spawns an interactive shell on your host but inside the
user and mount namespaces that pmbootstrap set up. It is mostly useful
for debugging issues with permissions, etc.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:27 +02:00
Casey Connolly
5ce9b22ab6
types: remove unused arg
This property exists on Context but not in args. It is parsed from the
config file.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 21:29:23 +02:00
Casey Connolly
7e399492e4
config: file: don't mark executable
Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:23:00 +02:00
Casey Connolly
9a6d97b8ff
unshare pmbootstrap!
Use sandbox functions to unshare the entire pmbootstrap process with
user namespaces.

This lets us do whatever we want without polluting the global mount
namepsace, and eliminates the need for "pmbootstrap shutdown".

Currently install is broken since it uses loop devices, this should be
addressed by using something like systemd.repartd (or doing all the
offset calculation and gpt stuff ourselves).

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:23:00 +02:00
Casey Connolly
2f4378a70c
pmb: helpers: mount: use sandbox mount/umount helpers
these properly handle being in a user namespace.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:23:00 +02:00
Casey Connolly
e2b5b8b6b6
pmb: chroot: create chroot path explicitly
don't rely on our "mkdir -p" for /dev

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:23:00 +02:00
Casey Connolly
693df05e3f
pmb: chroot: use sandbox to set up /dev
sandbox has some nice and clever function to set up /dev as a tmpfs
inside the chroot. Since we can't run mknod() in the user namespace it
bind mounts from the host instead.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:23:00 +02:00
Casey Connolly
0a99875305
pmb: chroot: set user shell explicitly
If the host environment leaks in we might set the wrong shell!

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:23:00 +02:00
Casey Connolly
c0595b0437
pass in original UID
detect running as root before entering the user namespace.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:23:00 +02:00
Casey Connolly
4ca57db3f0
remove sudo wrapper
we are already root now thanks to user namespaces 😎

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:23:00 +02:00
Casey Connolly
7c6df10861
remove sudo timer
We don't need those where we're going (user namespaces).

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:22:59 +02:00
Casey Connolly
8d34c2a4e9
pmb: sideload: tighter network timeout
when phone is offline reduce the wait time a little...

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:22:59 +02:00
Casey Connolly
4c482e0b73
pmb: sandbox: use newuidmap/newgidmap for become_user()
This really needs to be fixed up properly, basically we want to map
ourselves in as root, then support the groups <1000 (e.g. abuild uses
group id 300) and finally use our UID namespace (the biiig UIDs) for the
pmos user.

You need "USER:100000:65536" in your /etc/subuid and /etc/subgid files
where "USER" is your username.

This basically results in the chroot perms matching your user for root
and some freaky UIDs for the build user.

Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
2025-05-30 13:22:59 +02:00
Casey Connolly
e4560a9aca
pmb: sandbox: split out mount setup
allow it to be called directly.

Signed-off-by: Casey Connolly <casey@postmarketos.org>
2025-05-30 13:22:59 +02:00
Casey Connolly
31eaa927c8
pmb: import mkosi-sandbox
Import mkosi sandbox script which we will use as a library.

Signed-off-by: Casey Connolly <caleb@postmarketos.org>
2025-05-30 13:22:59 +02:00
Oliver Smith
26c310f374
init: systemd: fix always switching pma to edge
Fix that pmbootstrap doesn't recognize v25.06 with systemd enabled as
valid channel and suggests switching to edge. This happens because
pmb.config.pmaports.read_config() unconditionally prepends "systemd-"
before the channel name if systemd is enabled, even though the init code
doesn't expect this.

The result is when running 'yes "" | pmbootstrap init' (as we do in BPO
and CI), pmbootstrap attempts to replace the correctly checked out
v25.06 branch with edge:

Fix for:
  [20:36:37] Available (12):
  [20:36:37] * edge: Rolling release / Most devices / Occasional breakage: https://postmarketos.org/edge
  [20:36:37] * v25.06: Upcoming stable release (DO NOT USE)
  [20:36:37] * v24.12: Latest release / Recommended for best stability
  [20:36:37] Channel [edge]:
  [20:36:37] Currently checked out branch 'v25.06' of pmaports.git is on channel 'v25.06'.
  [20:36:37] Switching to branch 'master' on channel 'edge'...
  …
  ERROR: pmbootstrap switched to the wrong branch: master

Related: https://builds.sr.ht/~postmarketos/job/1497179#task-bpo_setup-23

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2613
2025-05-30 11:08:34 +02:00
Clayton Craft
c39ac5fe99
pmb.qemu.run: fix x86_64 CPU check for EFI support (MR 2612)
Apparently python reads uname for this value, the correct value for
64-bit intel/amd stuff is `x86_64` even though python's docs list
`amd64` as an example of a value `platform.machine()` can return 🤷

fixes #2612
[ci:skip-build]: already built successfully in CI
2025-05-27 11:33:16 +02:00
Oliver Smith
63dea3993d
pmb.config.apk_tools_min_version: add v3.22
Prepare for the upcoming postmarketOS v25.06 release.
2025-05-26 22:02:00 +02:00
Newbyte
548a1dfe2e
pmb: Warn users about downstream ports
And make the archived port detection more robust while at it.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2549
2025-05-25 19:26:57 +02:00
Newbyte
cd672222c4
pmb: Split devices by category during codename selection
This also reworks list_codenames() somewhat. The option to show archived
devices is removed as it never actually was used. It should be easy to
restore if someone is interested.

Closes https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/issues/2558

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2549
2025-05-25 19:26:57 +02:00
Newbyte
a9c3628297
pmb.helpers.logging: Fix type for args
This is supposed to be `object` rather than `str` according to typeshed:
57cb510fd2/stdlib/logging/__init__.pyi (L129-L212)

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2549
2025-05-25 19:26:57 +02:00
Newbyte
a1057c9770
pmb.config.__init__: Add escape sequence for magenta text
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2549
2025-05-25 19:26:57 +02:00
Newbyte
c426c14f47
pmb.helpers.pmaports: Clean up some strings
Use f-strings to make them easier to read and combine some not-so-long
ones into one line for easier grepping.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2549
2025-05-25 19:26:52 +02:00
Newbyte
5783d1c507
Prepare 3.4.1 release 2025-05-25 15:13:41 +02:00
Clayton Craft
f4001310f2
pmb.qemu.run: command_qemu: refactor applying arch-specific options
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2560
2025-05-25 12:05:56 +02:00
Clayton Craft
b214fa6c4a
pmb.qemu.run: add support for EFI on aarch64
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2560
2025-05-25 12:05:56 +02:00
Clayton Craft
4a7ec11f4c
pmb.qemu.run: use virgl on aarch64 hosts
This enables faster/more featureful 3D accel support in VMs, which is necessary
for running some future UIs.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2560
2025-05-25 12:05:56 +02:00
Oliver Smith
cdb51686c3
CI: fix coverage regex
Use exactly the same regex as in BPO where this works.

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2609
2025-05-25 11:55:27 +02:00
Pablo Correa Gómez
7ca76314cd
ci: add test coverage to the GitLab UI
This is a small nit, but allows to see the coverage percentage change
across MRs. It gives a small dopamine boost to see an MR you sent has
tests and made a small impact in the overall coverage :)

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2596
2025-05-25 11:48:33 +02:00
Alexey Andreyev
8f564edd78
docs/mirrors: mention env variables example
Mention Environment Variables section too

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2598
2025-05-25 11:44:14 +02:00
Alexey Andreyev
383266a7a8
docs/index: update local deploy example with pmb.ci
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2599
2025-05-25 11:42:01 +02:00
Alexey Andreyev
a61fd50d6f
docs/index: introduce local deploy example
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2599
2025-05-25 11:42:01 +02:00