systemd/systemd-services: use systemd preset macro to configure services (MR 5377) (MR 5563)
also remove the rc_update workaround Co-authored-by: jane400 <pmos@j4ne.de>
This commit is contained in:
@@ -3,17 +3,16 @@
|
||||
# need to be forked just for the service, or don't provide
|
||||
# a service file at all.
|
||||
|
||||
# How to add a new service file (4 steps):
|
||||
# How to add a new service file (5 steps):
|
||||
pkgname=systemd-services
|
||||
# 1. bump pkgver
|
||||
pkgver=15
|
||||
pkgver=16
|
||||
pkgrel=0
|
||||
pkgdesc="Systemd service files"
|
||||
url="https://postmarketos.org"
|
||||
arch="noarch"
|
||||
options="!check"
|
||||
license="BSD-3-Clause"
|
||||
triggers="$pkgname.trigger=/usr/lib/systemd"
|
||||
|
||||
# 2. Add a new entry to subpackes in the format
|
||||
# <pkgname>-systemd:_service where pkgname is the name
|
||||
@@ -136,14 +135,60 @@ source="$(flatpath \
|
||||
$_xdg_desktop_portal_wlr_sources \
|
||||
)"
|
||||
|
||||
# 5. Add any *system* or *user* unit files that should be passed to 'systemctl
|
||||
# preset'. Variables with *system* unit files should use "_system_presets" and
|
||||
# variables with *user* unit files should use "_user_presets".
|
||||
_apk_polkit_rs_system_presets="apk-polkit-server.service"
|
||||
_bluez_system_presets="bluetooth.service"
|
||||
_geoclue_system_presets="geoclue.service"
|
||||
_gnome_clocks_user_presets="gnome-clocks.service"
|
||||
_hexagonrpcd_system_presets="hexagonrpcd-sdsp.service"
|
||||
_iwd_system_presets="iwd.service"
|
||||
_mmsd_tng_user_presets="mmsd-tng.service"
|
||||
_modemmanager_system_presets="ModemManager.service"
|
||||
_nftables_system_presets="nftables.service"
|
||||
_openssh_server_pam_system_presets="sshd.service"
|
||||
_pd_mapper_system_presets="pd-mapper.service"
|
||||
_phosh_system_presets="phosh.service"
|
||||
_plasma_mobile_system_presets="plasma-mobile.service"
|
||||
_q6voiced_system_presets="q6voiced.service"
|
||||
_qbootctl_system_presets="qbootctl.service"
|
||||
_rmtfs_system_presets="rmtfs.service"
|
||||
_rtkit_system_presets="rtkit-deamon.service"
|
||||
_sleep_inhibitor_system_presets="sleep-inhibitor.service"
|
||||
_tqftpserv_system_presets="tqftpserv.service"
|
||||
_wireplumber_user_presets="wireplumber.service"
|
||||
_wpa_supplicant_system_presets="wpa_supplicant.service"
|
||||
_xdg_desktop_portal_user_presets="xdg-desktop-portal-rewrite-launchers.service"
|
||||
|
||||
_service() {
|
||||
local name=$(echo ${subpkgname%%-systemd})
|
||||
local n=$(echo ${subpkgname%-systemd} | sed s/-/_/g)
|
||||
pkgdesc="$name systemd service files"
|
||||
install_if="systemd-services=$pkgver-r$pkgrel systemd $name"
|
||||
install="" # defined later if presets are configured for the service
|
||||
|
||||
for f in $(eval "echo \$_${n}_sources"); do
|
||||
install -Dm644 "$srcdir/$(flatpath "$f")" "$subpkgdir"/usr/lib/systemd/"$f"
|
||||
done
|
||||
|
||||
for t in user system; do
|
||||
local presets
|
||||
presets="$(eval "echo \$_${n}_${t}_presets" || true)"
|
||||
[ -z "$presets" ] && continue
|
||||
presets="$(echo "$presets" | tr -s '[:space:]' ' ')"
|
||||
|
||||
if [ -z "$install" ]; then
|
||||
cat <<- EOF > "$subpkgname.post-install"
|
||||
#!/bin/sh
|
||||
. /usr/lib/systemd/systemd-apk-macros.sh
|
||||
EOF
|
||||
cp "$subpkgname.post-install" "$subpkgname.pre-deinstall"
|
||||
install="$subpkgname.post-install $subpkgname.pre-deinstall"
|
||||
fi
|
||||
echo "systemd_service_post_install "$t" $presets" >> "$subpkgname.post-install"
|
||||
echo "systemd_service_pre_deinstall "$t" $presets" >> "$subpkgname.pre-deinstall"
|
||||
done
|
||||
}
|
||||
|
||||
package() {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Because these service files are installed with install_if, they might
|
||||
# get installed after some other package has tried to enable them.
|
||||
# we provide an "rc-update" binary which wraps systemctl, it also makes
|
||||
# a list of services that failed to enable so we can try them again
|
||||
# now that everything has been installed.
|
||||
|
||||
if [ ! -e /run/rc-update.failed ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while read -r cmd service; do
|
||||
echo "=> $cmd $service"
|
||||
systemctl "$cmd" "$service"
|
||||
done < /run/rc-update.failed
|
||||
|
||||
rm -f /run/rc-update.failed
|
||||
Reference in New Issue
Block a user