#!/bin/bash
# Created by Tobias Powalowski <tpowa@archlinux.org>

build ()
{
    #dbus-core files
    apps="/usr/bin/dbus-cleanup-sockets /usr/bin/dbus-daemon /usr/bin/dbus-monitor /usr/bin/dbus-send /usr/bin/dbus-uuidgen"
    for i in $apps; do
        add_binary "$i"
    done
    add_file "/etc/rc.d/dbus"
    add_binary "/usr/lib/dbus-1.0/dbus-daemon-launch-helper"
    add_dir "/var/lib/dbus"
    add_full_dir "/etc/dbus-1"
    add_dir "/etc/dbus-1/session.d"
    add_dir "/etc/dbus-1/systemd.d"
    add_full_dir "/usr/share/dbus-1"
    #systemd files
    apps="/usr/bin/systemd-ask-password /usr/bin/systemd-tmpfiles /usr/bin/systemd-tty-ask-password-agent \
          /usr/bin/systemd-delta /usr/bin/systemd-detect-virt /bin/systemd /usr/bin/journalctl \
	  /usr/bin/loginctl /usr/bin/systemctl /usr/bin/systemd-analyze /usr/bin/systemd-cat \
	  /usr/bin/systemd-cgls /usr/bin/systemd-cgtop /usr/bin/systemd-inhibit /usr/bin/systemd-machine-id-setup \
	  /usr/bin/systemd-notify /usr/bin/systemd-nspawn /usr/bin/systemd-stdio-bridge"
    for i in $apps; do
        add_binary "$i"
    done
    add_dir "/etc/tmpfiles.d"
    add_dir "/etc/modules-load.d"
    add_dir "/etc/binfmt.d/"
    add_dir "/etc/sysctl.d/"
    add_file "/etc/os-release"
    ### add_full_dir cannot handle emtpy dirs
    add_dir "/etc/systemd/system/local-fs.target.wants"
    add_dir "/etc/systemd/system/sysinit.target.wants"
    add_dir "/etc/systemd/user"
    add_dir "/etc/xdg/systemd/user"
    add_dir "/usr/lib/systemd/system/graphical.target.wants"
    add_dir "/usr/lib/systemd/system-shutdown"
    add_dir "/usr/lib/systemd/system-sleep"
    add_dir "/usr/lib/systemd/user-generators"
    add_full_dir "/etc/systemd"
    add_full_dir "/etc/xdg"
    add_full_dir "/usr/lib/systemd"
    add_full_dir "/usr/share/systemd"
    add_full_dir "/usr/share/polkit-1"
    add_full_dir "/usr/lib/tmpfiles.d"
    add_full_dir "/usr/lib/modules-load.d"
    for i in /usr/lib/libsystemd*; do
        add_file "$i"
    done
    add_dir "/var/lib/systemd"
    add_file "/usr/lib/security/pam_systemd.so"
    add_file "/usr/share/archboot/systemd/etc/locale.conf" "/etc/locale.conf"
    add_file "/usr/share/archboot/systemd/etc/timezone.conf" "/etc/timezone.conf"
    add_file "/usr/share/archboot/systemd/etc/vconsole.conf" "/etc/vconsole.conf"
    add_file "/usr/share/archboot/systemd/etc/hostname" "/etc/hostname"
    add_file "/usr/share/archboot/systemd/etc/systemd/system/getty@.service" "/etc/systemd/system/getty@.service"
    add_file "/usr/share/archboot/systemd/etc/systemd/system/serial-getty@.service" "/etc/systemd/system/serial-getty@.service"
    add_file "/usr/share/archboot/systemd/etc/systemd/system/autovt@.service" "/etc/systemd/system/autovt@.service"
    add_file "/usr/share/archboot/systemd/etc/systemd/system/getty.target.wants/getty@tty1.service" \
             "/etc/systemd/system/getty.target.wants/getty@tty1.service"
}

help ()
{
cat<<HELPEOF
  This hook includes systemd support on an arch boot image.
HELPEOF
} 
