This trigger has a lot going on, so let's make sure it always passes
shellcheck. It's not picked up by the normal search for triggers in this
script because the actual logic for the trigger is broken out from the
.trigger file.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6892
This reworks the preset, reload/restart, and cleanup handling and moves
it from a (proposed [1]) abuild patch that would generate install
scripts for every -systemd package to a series of commit hooks and
a trigger that would exist in this package. This was made
possible by using `treescan`, which quickly[2] recursively scans
/usr/lib/systemd and allows the commit hook and trigger to diff units
before and after an install or uninstall transaction.
I chose to put the trigger and commit hook in pmos-base-systemd instead
of the systemd package because:
1) It's annoying to have to rebuild systemd just to update the logic in
this script. Rebuilding this package is MUCH faster (nothing to
compile)
2) IF the systemd package moves elsewhere (i.e. out of pmaports), it's
unclear if this preset stuff would follow it, and it's safer for us to
keep it separate so know it's always being included in pmOS+systemd
installs. It can always be moved later if we decide to.
More info on how the three situations are handled by this patch:
Presets: Pre-commit hook captures current unit file list (using
treescan) before changes, then the trigger on /usr/lib/systemd/system
captures (using treescan) the state after changes and diffs them. It
picks out only unit files that were added, and runs systemctl preset to
apply any preset config that might exist for them.
Reload/restart: This relies on manual post-upgrade scripts in packages
that need it. post-upgrade scripts should mark units with systemctl
set-property ... Markers=+needs-reload/restart. Actual reload/restart
handled by the existing systemd.trigger that queries these markers...
This is going to be a bit annoying for package maintainers[3], but I
don't think many packages will *need* this. As of today, there are 0
packages explicitly requesting reload/restart on upgrade. This also
means there will be no automatic detection of whether a unit should be
reloaded/restarted. AFAIK Fedora doesn't support this, packages have to
explicitly request a reload or restart.
Cleanup: The pre-commit hook uses treescan to capture systemd unit
directory state before transactions and the trigger identifies removed
units (using treescan + diff). It then finds broken symlinks in
/etc/systemd/ that point to any newly removed unit files from the
transaction, and removes only them.
Benefits:
- Simple abuild patch for -systemd split func
- Uses existing APK mechanisms (commit hooks, triggers). Hooks can see
before/after transaction state for cleanup.
- Logic updates don't require rebuilding all packages.
Tradeoffs:
- Requires additional per-package complexity to support
reload/restart functionality.
- Moves unit discovery/parsing for preset and cleanup from build-time to
runtime (every device does this work vs. once at build)
- Package behavior varies based on installed trigger/hook
versions rather than being deterministic per package version.
- There's a (tiny) risk of some operations being race-y, e.g. if the
user is actively enabling/disabling/adding unit files between apk
running the pre-commit hook and the trigger firing... It seems
unlikely this will cause issues, but 🤷♂️
1. https://gitlab.alpinelinux.org/alpine/abuild/-/merge_requests/394
2. I used hyperfine to measure performance of treescan on my laptop,
with lots of units installed, and it was ~20ms without disk caching
3. A post-upgrade that would mark a unit for reload might look like
this:
```
if [ -d "/run/systemd/system" ]; then
echo "Marking sshd.service for reload..."
systemctl set-property sshd.service Markers=+needs-reload
fi
```
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6892
These packages were previously built by a WIP abuild patch that added
install scripts to each -systemd subpkg for handling preset application
on install and symlink cleanup on uninstall. This functionality has been
replaced by a trigger/commit hook, so we need to rebuild these packages
to drop the install scripts that were previously generated.
[ci:ignore-count]
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6892
This could be folded into aports/qemu.. but I'm not sure if
they'd accept it since the path these install to seems(?) to be
systemd-specific? Once there's -systemd split pkg support in abuild,
then maybe it'll make sense to move this to aports.
fixes#3394
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6950
[ci:skip-build]: already built successfully in CI
When building immutable images, we'll be putting /etc into
/usr/share/factory, and then using systemd-tmpfiles to symlink all of
that stuff under /etc. When systemd installs into this dir, it leads to
accidentally adding some "example" config to the system's runtime
config, e.g. adding pam config with a comment like this which completely
breaks login/auth for many UIs (Phosh, Plasma Mobile, etc) :
# You really want to adjust this to your local distribution. If you use this
# unmodified you are not building systems safely and securely.
I could technically just scrub this dir when building immutable images,
but tbh I can't think of any reason why we'd want to ship this in the
first place.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6915
This does a hack to removing the need to build the stuff in src/boot for
enabling bless-boot. Previously I tried to enable bless-boot by adding
-Dbootloader=enable, which would be required without this hack, but
cross-compiling systemd/src/boot failed on 32-bit archs and it seemed
unnecessary to go down that rabbit hole to debug/fix.
Why? Because:
1) It's not actually needed for building the stuff I care about enabling
in this MR (systemd-bless-boot and its generator). These things build
and work just fine without building stuff in src/boot.
2) Even if it worked, we would have to remove the artifacts made
from src/boot and not package them here. They would conflict with the
systemd-boot package in Alpine.
So it seems pointless to waste time fixing some weird cross-compiling
issue for some components that don't actually need to be built to enable
the extra features I want and would be discarded anyways in package()
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6840
This commit (and the one before it) seem to have broken building new
images, apk hits a conflict with udevd and systemd-udevd:
systemd-udevd-257.7-r1:
conflicts: systemd-257.7-r1[eudev=257.7-r1]
satisfies: systemd-257.7-r1[systemd-udevd=257.7-r1]
systemd-257.7-r1:
conflicts: systemd-udevd-257.7-r1[eudev=257.7-r1]
satisfies: postmarketos-base-systemd-48-r0[systemd]
systemd-journald-257.7-r1[so:libsystemd-shared-257.so]
systemd-logind-257.7-r1[systemd=257.7-r1]
systemd-logind-257.7-r1[so:libsystemd-shared-257.so]
systemd-timesyncd-257.7-r1[systemd=257.7-r1]
systemd-timesyncd-257.7-r1[so:libsystemd-shared-257.so]
systemd-udevd-257.7-r1[so:libsystemd-shared-257.so]
This reverts commit a6a31b3fe7.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6794
We currently don't build systemd for armhf anymore. Disable all other
packages in the systemd repo too, as these can't be built without the
systemd dependency.
FWIW all of Phosh, Gnome Mobile and Plasma Mobile already have major
packages not building for armhf so they couldn't be used on this arch
anyway.
Once pmb issue 2618 is resolved, we can re-enable systemd for armhf.
Co-authored-by: Oliver Smith <ollieparanoid@postmarketos.org>
Related to !6637Fixes#3783
[ci:skip-build], [ci:skip-vercheck]: changing arch= only
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6710
This is a workaround for pmb#2618, basically.
To build systemd with BPF support (so things like unpriv. nspawn work),
we have to install linux-stable-dev to get a special header(vmlinux.h).
This kernel (linux-stable) isn't build in Alpine for armhf. Normally
that's not a problem, we could just add linux-stable-dev conditionally
to the makedepends, right? No... not possible until pmb#2618 is fixed.
Given this arch is used by only 3 devices in testing (the rest are in
`downstream` or `archive`), I think it makes sense to disable systemd on
this arch until someone has the motivation to fix the pmb bug.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6637
[ci:skip-build]: already built successfully in CI
This is needed by some(all?) Xwayland implementations too, so don't make
installing it exclusive to having the actual X11 xorg-server installed.
This fixes an issue where Xwayland doesn't work on COSMIC.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6658
[ci:skip-build]: already built successfully in CI
These options are things that other required kconfig depend on, found
when creating a new config from scratch and noticing a few required
kconfig wasn't making it into the final config.
I don't expect this to have any impact on existing kernel packages that
already pass the kconfig check, because they would already need to have
these options enabled.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6641
This test is apparently wrong a lot now, so let's disable it. Audio
apps should inhibit sleep/suspend on their own, or worst case you can do
something like `systemd-inhibit <audio app>`.
We still want sleep-inhibitor around for now to inhibit sleep/shutdown
when an SSH client is connected or when apk is running.
Fixes#3745
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6612
[ci:skip-build]: already built successfully in CI
On a merged /usr system, this results in a broken symlink since
sbin/udevd is really usr/sbin/udevd, and usr/sbin/../usr/lib/ is not a
real thing. This should have no effect on unmerged /usr systems, since
sbin/../../usr/lib/.... is still a correct (if ugly) path.
It's quite difficult to create a relative symlink for these things
that works reliably on a merged AND unmerged /usr install, so for now
I'm going to make the symlink source path absolute so that we can be
confident it'll work on either type of installation, and we can revisit
making them relative after usr merge is done/deployed on all installs.
Part-of: https://gitlab.postmarketos.org/postmarketos/pmaports/-/merge_requests/6598
This change makes the zram_swap service depend on a deviceinfo being
present in the rootfs (which may not always be the case, e.g. when
building an image with mkosi), and it replaces the ExecStartPre with
a dependency on modprobe@zram.service so that modprobe is only called
once if other services happen to also depend on this module (which is
unlikely, but a nicer way to handle this)
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6566
This splits off two new subpackages in postmarketos-base, allowing for
tools (e.g. mkosi) to build a very small "postmarketOS" rootfs.
postmarketos-base depends on these two new packages, so there should be
no functional change outside of enabling this specific use case.
The versioned replaces is meant to fix installing this new package on
existing installs. In some cases apk installs this package *before*
installing the `postmarketos-base-systemd` update that accompanies this
patch.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6565
Shells (and DEs!) that set environment from /etc/profile.d will end
up sourcing 20locale.sh from alpine-baselayout. This file will set
`LANG=C.UTF8`, and this will override whatever systemd-localed/systemd
sets LANG to. In other words, locale.conf is effectively ignored. I
hit this issue when debugging why the date in COSMIC was always `M05`
instead of `May`, and why various COSMIC components failed to detect the
locale (because it was set to C.UTF8)
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6535
[ci:skip-build]: already built successfully in CI
The APKBUILD reference seems to suggest that versioned provides= can
have any valid version string (e.g. 0.12-r3) in the `provides=` var, and
that it doesn't have to match `$pkgver-r$pkgrel` for the APKBUILD. IIRC
this test intends to catch typos like `provides=foo=$pkgver-$pkgrel`, so
this makes it pass when any valid version string is given.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6475
[ci:skip-build]: already built successfully in CI
Installing systemd-resolved by default is still probably not a good
idea (e.g. until #1430 is fixed, at least?), but this adds config for
NM and sd-resolved to get the stub resolver set up automatically when
systemd-resolved is installed manually by a user.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6250
[ci:skip-build]: already built successfully in CI
This removes the audio-none subpkg, and the dependency that
postmarketos-base-ui had on it.
This renames the pmos-base-ui-audio virtual that the pw and pa backends
provided to `postmarketos-base-ui-audio-backend`.
To allow UIs to select no audio components, a new pmos-base-ui-audio
subpkg was added. UIs that need audio should depend on the virtual
pkg `postmarketos-base-ui-audio`. UIs that don't want audio can simply
depend on postmarketos-ui-base and no audio stuff will be pulled in.
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6408
This is used by the DE's upstream (popOS), and works reasonably well so
let's install it by default so that apps that depend on secret manager
things work OOTB.
[ci:skip-build]: already built successfully in CI
[ci:skip-vercheck]
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6410
This patch is in 257, so we can drop it when upgrading. Without this
patch, we'd have to the enable sysv compat stuff in systemd just to get
this legacy.conf file generated/installed, which totally doesn't seem
worth it (the sysv compat stuff seems to be a lot!)
Fixes#3616
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6352
[ci:skip-build]: already built successfully in CI