summaryrefslogtreecommitdiff
blob: 8b3724b2c87906a656befe4d47b301a45cad3d8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=4

inherit linux-info pam

DESCRIPTION="systemd is a system and service manager for Linux"
HOMEPAGE="http://www.freedesktop.org/wiki/Software/systemd"
SRC_URI="http://www.freedesktop.org/software/systemd/${P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="audit gtk pam plymouth selinux +tcpwrap"

COMMON_DEPEND=">=sys-apps/dbus-1.4.8-r1
	sys-libs/libcap
	>=sys-fs/udev-163[systemd]
	audit? ( sys-process/audit )
	gtk? (
		dev-libs/dbus-glib
		>=dev-libs/glib-2.26
		x11-libs/gtk+:2
		>=x11-libs/libnotify-0.7 )
	pam? ( virtual/pam )
	selinux? ( sys-libs/libselinux )
	tcpwrap? ( sys-apps/tcp-wrappers )
	>=sys-apps/util-linux-2.19
	plymouth? ( >=sys-boot/plymouth-0.8.4 )"

# Vala-0.10 doesn't work with libnotify 0.7.1
VALASLOT="0.12"
MINKV="2.6.38"

RDEPEND="${COMMON_DEPEND}
	sys-apps/systemd-units"
DEPEND="${COMMON_DEPEND}
	gtk? ( dev-lang/vala:${VALASLOT} )
	>=sys-kernel/linux-headers-${MINKV}"

check_no_uevent_hotplug_helper() {
	local path
	if linux_config_exists; then
		path="$(linux_chkconfig_string UEVENT_HELPER_PATH)"
		path="${path#\"}"
		path="${path%\"}"
		path="${path#\'}"
		path="${path%\'}"
		if test "${path}" != ""; then
			qewarn "The kernel should be configured with"
			qewarn "CONFIG_UEVENT_HELPER_PATH=\"\". Also, be sure to check"
			qewarn "that /proc/sys/kernel/hotplug is empty."
		fi
	fi
}

pkg_pretend() {
	local CONFIG_CHECK="AUTOFS4_FS CGROUPS DEVTMPFS ~FANOTIFY ~IPV6"
	linux-info_pkg_setup
	check_no_uevent_hotplug_helper
	kernel_is -ge ${MINKV//./ } || die "Kernel version at least ${MINKV} required"
}

pkg_setup() {
	enewgroup lock # used by var-lock.mount
	enewgroup tty 5 # used by mount-setup for /dev/pts
}

src_prepare() {
	# Force the rebuild of .vala sources
	touch src/*.vala
}

src_configure() {
	local myconf="
		--with-distro=gentoo
		--with-rootdir=
		--localstatedir=/var
		$(use_enable audit)
		$(use_enable gtk)
		$(use_enable pam)
		$(use_enable selinux)
		$(use_enable tcpwrap)
	"

	use gtk && export VALAC="$(type -p valac-${VALASLOT})"

	use plymouth && export have_plymouth=1

	econf ${myconf}
}

src_install() {
	emake DESTDIR="${D}" install

	dodoc "${D}"/usr/share/doc/systemd/*
	rm -rf "${D}"/usr/share/doc/systemd

	cd "${D}"/usr/share/man/man8/
	for i in halt poweroff reboot runlevel shutdown telinit; do
		mv ${i}.8 systemd.${i}.8 || die
	done

	keepdir /run
}

check_mtab_is_symlink() {
	if test ! -L "${ROOT}"etc/mtab; then
		ewarn "${ROOT}etc/mtab must be a symlink to ${ROOT}proc/self/mounts!"
		ewarn "To correct that, execute"
		ewarn "    $ ln -sf '${ROOT}proc/self/mounts' '${ROOT}etc/mtab'"
	fi
}

systemd_machine_id_setup() {
	einfo "Setting up /etc/machine-id..."
	if ! "${ROOT}"bin/systemd-machine-id-setup; then
		ewarn "Setting up /etc/machine-id failed, to fix it please see"
		ewarn "  http://lists.freedesktop.org/archives/dbus/2011-March/014187.html"
	elif test ! -L "${ROOT}"var/lib/dbus/machine-id; then
		# This should be fixed in the dbus ebuild, but we warn about it here.
		ewarn "${ROOT}var/lib/dbus/machine-id ideally should be a symlink to"
		ewarn "${ROOT}etc/machine-id to make it clear that they have the same"
		ewarn "content."
	fi
}

check_var_run_is_symlink() {
	if test ! -L "${ROOT}"var/run; then
		einfo "${ROOT}var/run should be a symlink to ${ROOT}run. This is not"
		einfo "trivial to change, and there is no hurry as it is currently"
		einfo "bind-mounted at boot-time. You may be able to create the"
		einfo "symlink by lazily unmounting ${ROOT}var/run first."
	fi
}

pkg_postinst() {
	check_mtab_is_symlink
	systemd_machine_id_setup
	check_var_run_is_symlink

	# Inform user about extra configuration
	elog "You may need to perform some additional configuration for some"
	elog "programs to work, see the systemd manpages for loading modules and"
	elog "handling tmpfiles:"
	elog "    $ man modules-load.d"
	elog "    $ man tmpfiles.d"

	ewarn "This is a work-in-progress ebuild. You may brick your system. Have fun!"
}