# Compiling Time: 7.90 SBU
# Maintainer: crazy <crazy@frugalware.org>
# Maintainer: DeX77 <dex77@frugalware.org>

### NOTE: if you bump/relbump this package you need rebuild
## 	  kernel-initrd

USE_SYSV_COMPAT=${USE_SYSV_COMPAT:-"y"}

pkgname=systemd
pkgver=231
pkgrel=4
pkgdesc="A System and Service Manager"
url="http://www.freedesktop.org/wiki/Software/systemd"
depends=('kmod' 'cryptsetup-luks>=1.7.2')
makedepends=('docbook-xsl' 'docbook-xml' 'intltool>=0.51.0-2' \
	'gperf>=3.0.4-3' 'gnu-efi>=3.0.3' 'lxml>=3.5.0' 'gobject-introspection>=1.46.0-2')
rodepends=('dbus' "libsystemd=$pkgver" 'scriptlet-core')
options+=('scriptlet')
_F_github_tag=y
_F_github_tag_v=y
Finclude github
source+=(
	frugalware_getty.patch \
	frugalware_utmp.patch \
	display-manager-legacy.service \
	console.conf \
	65-permissions.rules \
	blacklist \
	media.mount \
	var-lock.mount \
	var-run.mount \
	vconsole.conf \
	xorg-set-resolution.c \
	xorg-set-resolution.service \
	adjust-systemd-user-pam-config-file.patch \
	usb-load-ehci-first.conf)

sha1sums=('47768103290d2023c3452bc36bc77f7b1fd798ea' \
          'a2f1c341894c4841a64a56138362817ae2c57905' \
          '2aa6ed34d80abee40b179e93c5eccba623fbdc7c' \
          '8ee24b6906739855a48aded896a0f12154815343' \
          'abaa5c83d5adf2c5be188ce0de488bfa2b5a4505' \
          '439e2be7278ecedb4a4f090241bb484a7a25a9c3' \
          '4657cbad76a3d5c8aade4dba166b3f8704c7b07f' \
          'f896279eca1bcd02db36b215470593734fd894ee' \
          'b784cca7ac15405edc2e5c4c1851d712bb6bcc38' \
          '31b8d2530e0c8a70358ad5a6c7d8a0fbf43d1bca' \
          '66c90190613ef915e5b2b1da37abd19791f7b16d' \
          'a29bf4a084ae46e9d995b6616ad5980ff0030c82' \
          '58dfc8f9e97b34413e6163c8a4713df67bdead5b' \
          '067d45c3e64f3d1dc66f707f702212e95f4162b2' \
          'ecb14db2a916c96781ee2fcb8d0cd44dbe978dd7')

rodepends=('hwdata' 'systemd-sysvinit')

replaces=('sysvinit-tools' 'sysvinit-initscripts')
provides=('sysvinit-tools' 'sysvinit-initscripts')
conflicts=('sysvinit-tools' 'sysvinit-initscripts')

groups=('base' 'core')
archs=('i686' 'x86_64')

#TODO : Remove backup, source rc for SysVinit when all rc scripts used systemd
backup=(etc/{vconsole.conf,systemd/{system.conf,user.conf,logind.conf,journald.conf},machine-id,machine-info,locale.conf,udev/udev.conf,sysconfig/blacklist,tmpfiles.d/console.conf,dbus-1/system.d/org.freedesktop.{hostname,locale,login,systemd,timedate}1.conf,X11/xorg.conf.d/00-keyboard.conf})

subpkgs=('systemd-sysvinit')
subdescs=('systemd System V init tools')
subrodepends=("$pkgname=$pkgver")
subreplaces=('sysvinit')
subgroups=('base core')
subarchs=('i686 x86_64')
subprovides=('sysvinit')
subconflicts=('sysvinit')
subdepends=('pam>=1.1.8-3 kmod>=22-3 libcap>=2.24-3 lz4>=r131-6 libgcrypt>=1.6.4-3')

subpkgs+=('systemd-remote')
subdescs+=('systemd remote journald')
subrodepends+=("$pkgname=$pkgver")
subreplaces+=('')
subgroups+=('base-extra')
subarchs+=('i686 x86_64')
subprovides+=('')
subconflicts+=('')
subdepends+=('libmicrohttpd>=0.9.48-2 lz4>=r131-6')

subpkgs+=('systemd-pull')
subdescs+=('systemd container retrieval')
subrodepends+=("$pkgname=$pkgver")
subreplaces+=('')
subgroups+=('network-extra')
subarchs+=('i686 x86_64')
subprovides+=('')
subconflicts+=('')
subdepends+=('curl>=7.46.0-3 libgcrypt>=1.6.4-3 libcap>=2.24-4')

subpkgs+=('libsystemd')
subdescs+=('systemd libs')
subrodepends+=("")
subreplaces+=('')
subgroups+=('base core')
subarchs+=('i686 x86_64')
subprovides+=('')
subconflicts+=('')
subdepends+=('xz>=5.2.2-3 lz4>=r131-6 libgcrypt>=1.6.4-3 xfsprogs-acl>=2.2.52-4 libidn>=1.32-3 elfutils>=0.164-2 libcap>=2.24-4 bzip2>=1.0.6-3 zlib>=1.2.8-3')

Fconfopts+="	--disable-selinux \
		--with-pamlibdir=/lib/security \
		--with-rootprefix= \
		--with-dbussystemservicedir=/usr/share/dbus-1/system-services \
		--disable-audit \
		--disable-ima \
		--disable-kdbus \
		--enable-lz4 \
		--enable-gnuefi \
		--with-sysvinit-path=/etc/rc.d \
		--with-rc-local-script-path-start=/etc/rc.d/rc.local \
		--with-rc-local-script-path-stop=/etc/rc.d/rc.local \
		--with-ntp-servers=0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org,3.pool.ntp.org \
		--without-kill-user-processes" ## <-- do not remove this one , no matter what
# TODO: Open Source projects are of course particularly welcome to use the pool in their default setup, but we ask that you get a vendor
## zone when using the pool as a default configuration.

if ! Fuse $USE_SYSV_COMPAT; then
Fconfopts+="	--with-sysvinit-path= \
		--with-sysvrcd-path="
fi

build()
{

	Fcd
	Fpatchall
	## replaces frugalware_autovt.patch
	Fsed "#NAutoVTs=.*" "NAutoVTs=11" src/login/logind.conf.in

	## well fix some bad groups/rules for us

	## should fix bluetooth
	Fsed 'dialout' 'uucp' sysusers.d/basic.conf.in
	Fsed 'GROUP="dialout"' 'GROUP="uucp"' rules/*.rules

	## we dont use tape and this rule wont match a tape anyway
	Fsed 'tape' 'storage' sysusers.d/basic.conf.in
	Fsed 'GROUP="tape"' 'GROUP="storage"' rules/*.rules

	## FIXME: figure 'disk' group we  have just storage

	Fsed '$(datadir)/pkgconfig' '/usr/lib/pkgconfig' Makefile.{am,in}
	./autogen.sh || Fdie
	Fmake
	Fmakeinstall
	#http://0pointer.de/public/systemd-man/tmpfiles.d.html
	Fcp console.conf etc/tmpfiles.d/console.conf

	# Split tools provided by sysvinit to avoid conflict
	Fmkdir sbin
	Fln /lib/systemd/systemd /sbin/init
	Fln /bin/systemctl /sbin/reboot
	Fln /bin/systemctl /sbin/halt
	Fln /bin/systemctl /sbin/poweroff
	Fln /bin/systemctl /sbin/shutdown
	Fln /bin/systemctl /sbin/telinit
	Fln /bin/systemctl /sbin/runlevel
	Fsplit systemd-sysvinit sbin/{init,reboot,halt,poweroff,shutdown,telinit,runlevel}
	Fsplit systemd-sysvinit usr/share/man/man8/{halt,poweroff,reboot,runlevel,shutdown,telinit}.*

	Frm etc/systemd/system/*.target.wants

	## we want tty1 at least to be *NOT* cleared but the getty@ Unit has : TTYVTDisallocate=yes
	## and since this is uses for symliks to any @ttyx.service we'll still clear the tty
	## override that..
	Fmkdir etc/systemd/system/getty@tty1.service.d
cat > $Fdestdir/etc/systemd/system/getty@tty1.service.d/noclear.conf << EOF
[Service]
TTYVTDisallocate=no
EOF

	# /etc/sysconfig/desktop compatibility
	Frm /lib/systemd/system/display-manager.service # Will be upstreamed for next release
	Ffile /lib/systemd/system/display-manager-legacy.service

	# we have runlevel 4 as the x11 target, not 5
	Fln multi-user.target /lib/systemd/system/runlevel5.target
	Fln graphical.target /lib/systemd/system/runlevel4.target

	# Make sure these directories are properly owned
	Fmkdir lib/systemd/system/basic.target.wants
	Fmkdir lib/systemd/system/default.target.wants
	Fmkdir lib/systemd/system/dbus.target.wants
	Fmkdir lib/systemd/system/syslog.target.wants

	Fexec touch $Fdestdir/etc/{machine-id,machine-info,locale.conf}

	Ffile /etc/sysconfig/blacklist

	Ffile /etc/vconsole.conf

	Fmkdir /etc/X11/xorg.conf.d

	Fexec touch $Fdestdir/etc/X11/xorg.conf.d/00-keyboard.conf

	Fmkdir /etc/modprobe.d

	Fln /etc/sysconfig/blacklist /etc/modprobe.d/blacklist.conf

	# We need this to stop kernel WARNING about ehci_hcd beeing loaded after ohci/uhci
	Ffile /etc/modprobe.d/usb-load-ehci-first.conf

	# Compatibility units. Look into an upgrade path to remove them after 1.8.
	Ffile /lib/systemd/system/media.mount
	Ffile /lib/systemd/system/var-run.mount
	Ffile /lib/systemd/system/var-lock.mount
	Fln ../media.mount /lib/systemd/system/local-fs.target.wants/media.mount
	Fln ../var-run.mount /lib/systemd/system/local-fs.target.wants/var-run.mount
	Fln ../var-lock.mount /lib/systemd/system/local-fs.target.wants/var-lock.mount

	Frm /etc/bash_completion.d
	Frm /lib/udev/hwdb.d # Use the one from hwdata

	Fmkdir /usr/libexec
	Fexec cc -Wall -Wextra $CFLAGS $Fsrcdir/xorg-set-resolution.c -o $Fdestdir/usr/libexec/xorg-set-resolution
	Ffile /lib/systemd/system/xorg-set-resolution.service

	Fsplit systemd-remote lib/systemd/systemd-journal-gatewayd
	Fsplit systemd-remote lib/systemd/systemd-journal-remote
	Fsplit systemd-remote lib/systemd/systemd-journal-upload

	Fsplit systemd-pull lib/systemd/systemd-pull

	## libsystemd-shared not sure about this one
	Fsplit libsystemd lib/security
	Fsplit libsystemd lib/systemd/libsystemd*
	Fsplit libsystemd usr/lib/libsystemd*
	Fsplit libsystemd usr/lib/libnss*
	Fsplit libsystemd usr/lib/libudev*
	Fsplit libsystemd usr/lib/pkgconfig/lib*.pc
}

# optimization OK
