_wireplumber_service() {
  # Service defaults are optional in build roots without systemd's tools.
  if ! command -v systemctl >/dev/null 2>&1; then
    printf 'wireplumber: skipping service %s; systemctl is unavailable\n' "$1" >&2
    return 0
  fi

  # Keep diagnostics (including masks), but do not fail package setup for
  # optional user-service configuration. Never start a service here.
  if ! systemctl --global "$1" wireplumber.service; then
    printf 'wireplumber: could not %s wireplumber.service; retry systemctl --global %s wireplumber.service on the target system\n' "$1" "$1" >&2
  fi
}

post_install() {
  _wireplumber_service enable
}

# No upgrade action: preserve the administrator's service state. The
# pre-0.4.4-2 reenable migration predates Devario and required Arch's
# vercmp utility.

pre_remove() {
  _wireplumber_service disable
}

# vim:set ft=bash sw=2 sts=-1 et:
