mkdir -pv "$PKGDIR"/usr/lib/systemd/system-preset

abinfo "Writing 80-aosc-os-base.preset ..."
cat > "$PKGDIR"/usr/lib/systemd/system-preset/80-aosc-os-base.preset << EOF
## 80-aosc-os-base.preset
## Systemd unit preset for AOSC OS Base/Non-Desktop distributions.

# Device support
enable lvm2-monitor.service
enable smartd.service
enable gpm.service
enable lircd.service
enable acpid.service

# Scheduled tasks
enable fcron.service
enable fstrim.timer
enable fc-cache.service

# Network services
enable bluetooth.service
enable ModemManager.service
enable NetworkManager.service
enable sshd.service

# Disable systemd-networkd and systemd-networkd-wait-online
disable systemd-networkd.service
disable systemd-networkd-wait-online.service

# Automatic system update checker.
enable repo-refresh.timer
EOF

if ! ab_match_archgroup retro; then
    abinfo "Writing 80-aosc-os-base.preset (timesyncd) ..."
    cat >> "$PKGDIR"/usr/lib/systemd/system-preset/80-aosc-os-base.preset << EOF

# systemd-timesyncd (NTP).
enable systemd-timesyncd
EOF
else
    abinfo "Writing 80-aosc-os-base.preset (!timesyncd) ..."
    cat >> "$PKGDIR"/usr/lib/systemd/system-preset/80-aosc-os-base.preset << EOF

# systemd-timesyncd (NTP).
disable systemd-timesyncd
EOF
fi

if ab_match_arch amd64; then
    abinfo "Writing 79-aosc-os-amd64-tlp.preset ..."
    cat > "$PKGDIR"/usr/lib/systemd/system-preset/79-aosc-os-amd64-tlp.preset << EOF
## 79-aosc-os-amd64-tlp.preset
## Systemd unit preset to enable TLP on AMD64.

# TLP services
enable tlp.service
enable tlp-sleep.service
enable thermald.service
EOF
fi
