PKGNAME=systemd
PKGSEC=admin
PKGDEP="glib lz4 xz acl bash cryptsetup curl elfutils kbd kmod libcap \
        libidn2 libmicrohttpd linux-pam util-linux-runtime hwdata \
        libgpg-error iptables qrencode aosc-aaa libseccomp pcre2 zstd \
        libfido2 tpm2-tss p11-kit openssl zlib bzip2"
# See comments for MESON_AFTER__LOONGSON3.
PKGDEP__LOONGSON3="glib lz4 xz acl bash cryptsetup curl elfutils kbd \
        kmod libcap libidn2 libmicrohttpd linux-pam util-linux-runtime \
        hwdata libgpg-error iptables qrencode aosc-aaa pcre2 zstd \
        libfido2 tpm2-tss p11-kit openssl zlib bzip2"
PKGDEP__RETRO=" \
        glib acl bash kbd libcap linux-pam util-linux hwdata aosc-aaa \
        kmod polkit dbus openssl zlib bzip2"
PKGDEP__ARMV4="${PKGDEP__RETRO}"
PKGDEP__ARMV6HF="${PKGDEP__RETRO}"
PKGDEP__ARMV7HF="${PKGDEP__RETRO}"
PKGDEP__I486="${PKGDEP__RETRO}"
PKGDEP__LOONGSON2F="${PKGDEP__RETRO}"
PKGDEP__M68K="${PKGDEP__RETRO}"
PKGDEP__POWERPC="${PKGDEP__RETRO}"
PKGDEP__PPC64="${PKGDEP__RETRO}"
BUILDDEP="gobject-introspection gperf gtk-doc intltool jinja2 llvm lxml \
          pyelftools libxkbcommon apparmor"
BUILDDEP__RETRO="docbook-xsl gperf intltool jinja2 libxslt"
BUILDDEP__ARMV4="${BUILDDEP__RETRO}"
BUILDDEP__ARMV6HF="${BUILDDEP__RETRO}"
BUILDDEP__ARMV7HF="${BUILDDEP__RETRO}"
BUILDDEP__I486="${BUILDDEP__RETRO}"
BUILDDEP__LOONGSON2F="${BUILDDEP__RETRO}"
BUILDDEP__M68K="${BUILDDEP__RETRO}"
BUILDDEP__POWERPC="${BUILDDEP__RETRO}"
BUILDDEP__PPC64="${BUILDDEP__RETRO}"
PKGDES="System and service manager"

# FIXME: configure loop during mass upgrade of base packages.
PKGRECOM="dbus"

ABTYPE=meson
# FIXME: Hibernation is currently disabled when installing AOSC OS via LiveKit.
#
# Note: maximum value in microseconds for the difference between RTC and epoch,
# exceeding which is considered an RTC error (15 years).
#
# Note: -Ddefault-dns-over-tls=no, technically, this should have been
# "opportunistic," if not "yes." However, this is likely going to cause problem,
# so following upstream to select "no" by default.
#
# Note: Leaving -Ddns-servers= empty to avoid advertising any DNS server by
# default.
MESON_AFTER=(
    '-Dmode=release'
    '-Dsplit-bin=false'
    '-Dlink-udev-shared=true'
    '-Dlink-systemctl-shared=true'
    '-Dlink-networkd-shared=true'
    '-Dlink-timesyncd-shared=true'
    '-Dlink-journalctl-shared=true'
    '-Dlink-boot-shared=true'
    '-Dfirst-boot-full-preset=true'
    '-Dstatic-libsystemd=false'
    '-Dstatic-libudev=true'
    '-Dstandalone-binaries=false'
    '-Dinitrd=true'
    '-Dcompat-mutable-uid-boundaries=false'
    '-Ddebug-shell=/bin/bash'
    '-Ddebug-tty=/dev/tty9'
    '-Ddebug-extra='
    '-Dmemory-accounting-default=true'
    '-Dbump-proc-sys-fs-file-max=true'
    '-Dbump-proc-sys-fs-nr-open=true'
    '-Dlog-trace=false'
    '-Dutmp=true'
    '-Dhibernate=true'
    '-Dldconfig=true'
    '-Dresolve=true'
    '-Defi=true'
    '-Dtpm=true'
    '-Denvironment-d=true'
    '-Dbinfmt=true'
    '-Drepart=enabled'
    '-Dsysupdate=enabled'
    '-Dcoredump=true'
    '-Dpstore=true'
    '-Doomd=true'
    '-Dlogind=true'
    '-Dhostnamed=true'
    '-Dlocaled=true'
    '-Dmachined=true'
    '-Dnspawn=enabled'
    '-Dportabled=true'
    '-Dsysext=true'
    '-Duserdb=true'
    '-Dhomed=enabled'
    '-Dnetworkd=true'
    '-Dtimedated=true'
    '-Dtimesyncd=true'
    '-Dremote=enabled'
    '-Dcreate-log-dirs=true'
    '-Dnss-myhostname=true'
    '-Dnss-mymachines=enabled'
    '-Dnss-resolve=enabled'
    '-Dnss-systemd=true'
    '-Dfirstboot=true'
    '-Drandomseed=true'
    '-Dbacklight=true'
    '-Dvconsole=true'
    '-Dvmspawn=enabled'
    '-Dquotacheck=true'
    '-Dsysusers=true'
    '-Dtmpfiles=true'
    '-Dimportd=enabled'
    '-Dhwdb=true'
    '-Drfkill=true'
    '-Dxdg-autostart=true'
    '-Dman=enabled'
    '-Dhtml=disabled'
    '-Dtranslations=true'
    '-Dinstall-sysconfdir=true'
    '-Dfallback-hostname=aosc'
    '-Dstatus-unit-format-default=combined'
    '-Dtime-epoch=0'
    '-Dclock-valid-range-usec-max=473364000000000'
    '-Ddefault-user-shell=/bin/bash'
    '-Dadm-group=true'
    '-Dwheel-group=true'
    '-Dnobody-user=systemd-nobody'
    '-Dnobody-group=systemd-nogroup'
    '-Ddev-kvm-mode=0666'
    '-Dgroup-render-mode=0666'
    '-Ddefault-kill-user-processes=false'
    '-Dgshadow=true'
    '-Ddefault-locale=C.UTF-8'
    '-Dnspawn-locale=C.UTF-8'
    '-Dlocalegen-path=/usr/bin/locale-gen'
    '-Dservice-watchdog=3min'
    '-Ddefault-dnssec=allow-downgrade'
    '-Ddefault-dns-over-tls=no'
    '-Ddefault-mdns=yes'
    '-Ddefault-llmnr=yes'
    '-Ddns-over-tls=openssl'
    '-Ddns-servers='
    '-Dntp-servers=aoscos.pool.ntp.org'
    '-Dseccomp=enabled'
    '-Dselinux=disabled'
    '-Dapparmor=enabled'
    '-Dsmack=false'
    '-Dpolkit=enabled'
    '-Dima=false'
    '-Dacl=enabled'
    '-Daudit=disabled'
    '-Dblkid=enabled'
    '-Dfdisk=enabled'
    '-Dkmod=enabled'
    '-Dpam=enabled'
    '-Dpwquality=enabled'
    '-Dmicrohttpd=enabled'
    '-Dlibcryptsetup=enabled'
    '-Dlibcryptsetup-plugins=enabled'
    '-Dlibcurl=enabled'
    '-Didn=false'
    '-Dlibidn2=enabled'
    '-Dlibidn=disabled'
    '-Dqrencode=enabled'
    '-Dp11kit=enabled'
    '-Dlibfido2=enabled'
    '-Dtpm2=enabled'
    '-Delfutils=enabled'
    '-Dzlib=enabled'
    '-Dbzip2=enabled'
    '-Dxz=enabled'
    '-Dlz4=enabled'
    '-Dzstd=enabled'
    '-Ddefault-compression=zstd'
    '-Dxkbcommon=enabled'
    '-Dpcre2=enabled'
    '-Dglib=enabled'
    '-Ddbus=enabled'
    '-Dsbat-distro=aosc'
    '-Dsbat-distro-generation=1'
    '-Dsbat-distro-summary=AOSC'
    '-Dsbat-distro-pkgname=systemd'
    "-Dsbat-distro-version=${__VER}-${__REL:-0}"
    '-Dsbat-distro-url=https://packages.aosc.io/packages/systemd'
    '-Defi-color-normal=white,black'
    '-Defi-color-entry=white,black'
    '-Defi-color-highlight=cyan,black'
    '-Defi-color-edit=black,lightgray'
    '-Dbashcompletiondir=/usr/share/bash-completion/completions'
    '-Dzshcompletiondir=/usr/share/zsh/site-functions'
    '-Dok-color=green'
    '-Durlify=true'
    '-Dfexecve=false'
    '-Doss-fuzz=false'
    '-Dllvm-fuzz=false'
    '-Dkernel-install=true'
    '-Danalyze=true'
    '-Dbpf-framework=disabled'
)
# FIXME: GNU C Library needs the stack to be executable for MIPS hard-float
# ABIs, unless explicitly configured at build time to require minimum kernel
# version 4.8 or newer.
#
# Unfortunately, glibc in Core 11 and earlier was configured to require kernel
# version 3.4 or newer, which causes lots of existing binaries to have
# executable stack. This conflicts with MemoryDenyWriteExecute=yes, which is
# the default for lots of systemd service units.
#
# The ideal solution would be to rebuild the world, however that's virtually
# impossible, especially for an process architecture with such limited resource
# and focus. Luckily, disabling seccomp support for systemd also removes the
# restriction on executable stack, so let's take this until most of the
# packages have been rebuilt with Core 12 or newer.
# Link: https://t.me/c/1109254909/672325
MESON_AFTER__LOONGSON3=(
    "${MESON_AFTER[@]}"
    '-Dseccomp=false'
)
MESON_AFTER__RETRO=(
    "${MESON_AFTER[@]}"
    '-Dapparmor=disabled'
    '-Dxkbcommon=disabled'
    '-Dxz=disabled'
    '-Dzlib=disabled'
    '-Dbzip2=disabled'
    '-Dlz4=disabled'
    '-Delfutils=disabled'
    '-Dlibcryptsetup=disabled'
    '-Dqrencode=disabled'
    '-Dmicrohttpd=disabled'
    '-Dlibidn2=disabled'
    '-Dlibcurl=disabled'
    '-Defi=false'
    '-Dtpm=false'
    '-Dhwdb=false'
    '-Dseccomp=disabled'
    '-Dpcre2=disabled'
    '-Dbinfmt=false'
    '-Dvconsole=false'
    '-Dquotacheck=false'
    '-Dfirstboot=false'
    '-Drandomseed=false'
    '-Drfkill=false'
    '-Dmachined=false'
    '-Dportabled=false'
    '-Dnetworkd=false'
    '-Dresolve=false'
    '-Dcoredump=false'
    '-Dutmp=false'
    '-Dldconfig=false'
    '-Dlogind=false'
    '-Dnss-myhostname=false'
    '-Dnss-systemd=false'
    '-Dpstore=false'
    '-Duserdb=false'
    '-Dfdisk=false'
    '-Dp11kit=disabled'
    '-Drepart=disabled'
    '-Ddns-over-tls=false'
    '-Doomd=false'
    '-Dhomed=disabled'
    '-Dkernel-install=false'
    '-Dsysext=false'
    '-Dpwquality=disabled'
    '-Dlibcryptsetup=disabled'
    '-Dlibcryptsetup-plugins=disabled'
    '-Dlibfido2=disabled'
    '-Dtpm2=disabled'
    '-Dsysupdate=false'
    '-Dimportd=disabled'
    '-Dremote=disabled'
    '-Dnss-mymachines=disabled'
    '-Dnss-resolve=disabled'
    '-Dbacklight=false'
    '-Dhtml=disabled'
    '-Dhibernate=false'
    '-Dhostnamed=false'
    '-Dinitrd=false'
    '-Dmemory-accounting-default=false'
    '-Dvmspawn=disabled'
    '-Dxdg-autostart=false'
    '-Dnsresourced=false'
    '-Dmountfsd=false'
    '-Dstoragetm=false'
    '-Djournal-storage-default=none'
)

PKGBREAK="systemd-sysv<=1"
PKGREP="systemd-sysv<=1"

# armel version sync.
PKGEPOCH=1

PKGBREAK="openresolv<=3.9.0 \
          dracut<=059-4" # Missing systemd-executor, cannot boot
PKGREP="openresolv<=3.9.0"
PKGPROV="openresolv==1:0 udev_spiral"

# Needed by Afterglow, whereas FAIL_ARCH defaults to mainline-only.
FAIL_ARCH="!(mainline|retro)"
