#!/bin/bash

## Copyright (C) 2021 - 2023 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

set -x
set -e

## 'adduser is a debianism' is required for 'anondate' which uses
## 'journalctl'. Group 'systemd-journal' might not exist yet during the build
## process, but 'Depends: systemd' would be a too heavy dependency and might
## cause dependency issues during the build process or distro morphing because
## package 'systemd' as well as package 'sdwdate' 'Provides: time-daemon'.
## 'adduser' is a debianism.
adduser sdwdate systemd-journal || true

gcc /usr/src/sdwdate/sclockadj.c -o /usr/libexec/sdwdate/sclockadj -ldl -D_GNU_SOURCE -Wdate-time -D_FORTIFY_SOURCE=3 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -Wl,-z,now

systemd-notify --ready
