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