sys-apps/dbus-1.10.24: alpha stable, bug 648306
[gentoo.git] / sys-apps / dbus / dbus-1.10.24.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 PYTHON_COMPAT=( python{2_7,3_{4,5,6}} )
6
7 inherit autotools ltprune linux-info flag-o-matic python-any-r1 readme.gentoo-r1 systemd virtualx user multilib-minimal
8
9 DESCRIPTION="A message bus system, a simple way for applications to talk to each other"
10 HOMEPAGE="https://dbus.freedesktop.org/"
11 SRC_URI="https://dbus.freedesktop.org/releases/dbus/${P}.tar.gz"
12
13 LICENSE="|| ( AFL-2.1 GPL-2 )"
14 SLOT="0"
15 KEYWORDS="alpha amd64 ~arm ~arm64 ~hppa ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~x86-solaris"
16 IUSE="debug doc elogind selinux static-libs systemd test user-session X"
17
18 #RESTRICT="test"
19
20 REQUIRED_USE="
21         ?? ( elogind systemd )
22         test? ( debug )
23 "
24
25 CDEPEND="
26         >=dev-libs/expat-2
27         selinux? ( sys-libs/libselinux )
28         elogind? ( sys-auth/elogind )
29         systemd? ( sys-apps/systemd:0= )
30         X? (
31                 x11-libs/libX11
32                 x11-libs/libXt
33                 )
34 "
35 DEPEND="${CDEPEND}
36         app-text/xmlto
37         app-text/docbook-xml-dtd:4.4
38         virtual/pkgconfig
39         doc? ( app-doc/doxygen )
40         test? (
41                 >=dev-libs/glib-2.36:2
42                 ${PYTHON_DEPS}
43                 )
44 "
45 RDEPEND="${CDEPEND}
46         selinux? ( sec-policy/selinux-dbus )
47 "
48
49 DOC_CONTENTS="
50         Some applications require a session bus in addition to the system
51         bus. Please see \`man dbus-launch\` for more information.
52 "
53
54 # out of sources build dir for make check
55 TBD="${WORKDIR}/${P}-tests-build"
56
57 PATCHES=(
58         "${FILESDIR}/${PN}-enable-elogind.patch"
59 )
60
61 pkg_setup() {
62         enewgroup messagebus
63         enewuser messagebus -1 -1 -1 messagebus
64
65         use test && python-any-r1_pkg_setup
66
67         if use kernel_linux; then
68                 CONFIG_CHECK="~EPOLL"
69                 linux-info_pkg_setup
70         fi
71 }
72
73 src_prepare() {
74         # Tests were restricted because of this
75         sed -i \
76                 -e 's/.*bus_dispatch_test.*/printf ("Disabled due to excess noise\\n");/' \
77                 -e '/"dispatch"/d' \
78                 bus/test-main.c || die
79
80         default
81
82         # required for bug 263909, cross-compile so don't remove eautoreconf
83         eautoreconf
84 }
85
86 multilib_src_configure() {
87         local docconf myconf
88
89         # so we can get backtraces from apps
90         case ${CHOST} in
91                 *-mingw*)
92                         # error: unrecognized command line option '-rdynamic' wrt #488036
93                         ;;
94                 *)
95                         append-flags -rdynamic
96                         ;;
97         esac
98
99         # libaudit is *only* used in DBus wrt SELinux support, so disable it, if
100         # not on an SELinux profile.
101         myconf=(
102                 --localstatedir="${EPREFIX}/var"
103                 --docdir="${EPREFIX}/usr/share/doc/${PF}"
104                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
105                 $(use_enable static-libs static)
106                 $(use_enable debug verbose-mode)
107                 --disable-asserts
108                 --disable-checks
109                 $(use_enable selinux)
110                 $(use_enable selinux libaudit)
111                 --disable-apparmor
112                 $(use_enable kernel_linux inotify)
113                 $(use_enable kernel_FreeBSD kqueue)
114                 $(use_enable elogind)
115                 $(use_enable systemd)
116                 $(use_enable user-session)
117                 --disable-embedded-tests
118                 --disable-modular-tests
119                 $(use_enable debug stats)
120                 --with-session-socket-dir="${EPREFIX}"/tmp
121                 --with-system-pid-file="${EPREFIX}"/var/run/dbus.pid
122                 --with-system-socket="${EPREFIX}"/var/run/dbus/system_bus_socket
123                 --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
124                 --with-dbus-user=messagebus
125                 $(use_with X x)
126                 )
127
128         if [[ ${CHOST} == *-darwin* ]]; then
129                 myconf+=(
130                         --enable-launchd
131                         --with-launchd-agent-dir="${EPREFIX}"/Library/LaunchAgents
132                 )
133         fi
134
135         if multilib_is_native_abi; then
136                 docconf=(
137                         --enable-xml-docs
138                         $(use_enable doc doxygen-docs)
139                 )
140         else
141                 docconf=(
142                         --disable-xml-docs
143                         --disable-doxygen-docs
144                 )
145                 myconf+=(
146                         --disable-selinux
147                         --disable-libaudit
148                         --disable-elogind
149                         --disable-systemd
150                         --without-x
151
152                         # expat is used for the daemon only
153                         # fake the check for multilib library build
154                         ac_cv_lib_expat_XML_ParserCreate_MM=yes
155                 )
156         fi
157
158         einfo "Running configure in ${BUILD_DIR}"
159         ECONF_SOURCE="${S}" econf "${myconf[@]}" "${docconf[@]}"
160
161         if multilib_is_native_abi && use test; then
162                 mkdir "${TBD}" || die
163                 cd "${TBD}" || die
164                 einfo "Running configure in ${TBD}"
165                 ECONF_SOURCE="${S}" econf "${myconf[@]}" \
166                         $(use_enable test asserts) \
167                         $(use_enable test checks) \
168                         $(use_enable test embedded-tests) \
169                         $(has_version dev-libs/dbus-glib && echo --enable-modular-tests)
170         fi
171 }
172
173 multilib_src_compile() {
174         if multilib_is_native_abi; then
175                 # after the compile, it uses a selinuxfs interface to
176                 # check if the SELinux policy has the right support
177                 use selinux && addwrite /selinux/access
178
179                 einfo "Running make in ${BUILD_DIR}"
180                 emake
181
182                 if use test; then
183                         einfo "Running make in ${TBD}"
184                         emake -C "${TBD}"
185                 fi
186         else
187                 emake -C dbus libdbus-1.la
188         fi
189 }
190
191 src_test() {
192         DBUS_VERBOSE=1 virtx emake -j1 -C "${TBD}" check
193 }
194
195 multilib_src_install() {
196         if multilib_is_native_abi; then
197                 emake DESTDIR="${D}" install
198         else
199                 emake DESTDIR="${D}" install-pkgconfigDATA
200                 emake DESTDIR="${D}" -C dbus \
201                         install-libLTLIBRARIES install-dbusincludeHEADERS \
202                         install-nodist_dbusarchincludeHEADERS
203         fi
204 }
205
206 multilib_src_install_all() {
207         newinitd "${FILESDIR}"/dbus.initd-r1 dbus
208
209         if use X; then
210                 # dbus X session script (#77504)
211                 # turns out to only work for GDM (and startx). has been merged into
212                 # other desktop (kdm and such scripts)
213                 exeinto /etc/X11/xinit/xinitrc.d
214                 doexe "${FILESDIR}"/80-dbus
215         fi
216
217         # needs to exist for dbus sessions to launch
218         keepdir /usr/share/dbus-1/services
219         keepdir /etc/dbus-1/{session,system}.d
220         # machine-id symlink from pkg_postinst()
221         keepdir /var/lib/dbus
222         # let the init script create the /var/run/dbus directory
223         rm -rf "${ED}"/var/run
224
225         dodoc AUTHORS ChangeLog HACKING NEWS README doc/TODO
226         readme.gentoo_create_doc
227
228         prune_libtool_files --all
229 }
230
231 pkg_postinst() {
232         readme.gentoo_print_elog
233
234         # Ensure unique id is generated and put it in /etc wrt #370451 but symlink
235         # for DBUS_MACHINE_UUID_FILE (see tools/dbus-launch.c) and reverse
236         # dependencies with hardcoded paths (although the known ones got fixed already)
237         dbus-uuidgen --ensure="${EROOT}"/etc/machine-id
238         ln -sf "${EPREFIX}"/etc/machine-id "${EROOT}"/var/lib/dbus/machine-id
239
240         if [[ ${CHOST} == *-darwin* ]]; then
241                 local plist="org.freedesktop.dbus-session.plist"
242                 elog
243                 elog
244                 elog "For MacOS/Darwin we now ship launchd support for dbus."
245                 elog "This enables autolaunch of dbus at session login and makes"
246                 elog "dbus usable under MacOS/Darwin."
247                 elog
248                 elog "The launchd plist file ${plist} has been"
249                 elog "installed in ${EPREFIX}/Library/LaunchAgents."
250                 elog "For it to be used, you will have to do all of the following:"
251                 elog " + cd ~/Library/LaunchAgents"
252                 elog " + ln -s ${EPREFIX}/Library/LaunchAgents/${plist}"
253                 elog " + logout and log back in"
254                 elog
255                 elog "If your application needs a proper DBUS_SESSION_BUS_ADDRESS"
256                 elog "specified and refused to start otherwise, then export the"
257                 elog "the following to your environment:"
258                 elog " DBUS_SESSION_BUS_ADDRESS=\"launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET\""
259         fi
260
261         if use user-session; then
262                 ewarn "You have enabled user-session. Please note this can cause"
263                 ewarn "bogus behaviors in several dbus consumers that are not prepared"
264                 ewarn "for this dbus activation method yet."
265                 ewarn
266                 ewarn "See the following link for background on this change:"
267                 ewarn "https://lists.freedesktop.org/archives/systemd-devel/2015-January/027711.html"
268                 ewarn
269                 ewarn "Known issues are tracked here:"
270                 ewarn "https://bugs.gentoo.org/show_bug.cgi?id=576028"
271         fi
272 }