sys-apps/dbus: stable 1.12.16 for ppc64, bug #687900
[gentoo.git] / sys-apps / dbus / dbus-1.12.16.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python{2_7,3_{5,6,7}} )
7 inherit autotools flag-o-matic linux-info 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 ~sparc64-solaris ~x64-solaris ~x86-solaris"
16 IUSE="debug doc elogind kernel_linux selinux static-libs systemd test user-session X"
17
18 REQUIRED_USE="?? ( elogind systemd )"
19
20 BDEPEND="
21         app-text/xmlto
22         app-text/docbook-xml-dtd:4.4
23         sys-devel/autoconf-archive
24         virtual/pkgconfig
25         doc? ( app-doc/doxygen )
26 "
27 COMMON_DEPEND="
28         >=dev-libs/expat-2.1.0
29         elogind? ( sys-auth/elogind )
30         selinux? ( sys-libs/libselinux )
31         systemd? ( sys-apps/systemd:0= )
32         X? (
33                 x11-libs/libX11
34                 x11-libs/libXt
35         )
36 "
37 DEPEND="${COMMON_DEPEND}
38         dev-libs/expat
39         test? (
40                 ${PYTHON_DEPS}
41                 >=dev-libs/glib-2.40:2
42         )
43 "
44 RDEPEND="${COMMON_DEPEND}
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 PATCHES=(
57         "${FILESDIR}/${PN}-enable-elogind.patch"
58         "${FILESDIR}/${PN}-daemon-optional.patch" # bug #653136
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         if [[ ${CHOST} == *-solaris* ]]; then
83                 # fix standards conflict, due to gcc being c99 by default nowadays
84                 sed -i \
85                         -e 's/_XOPEN_SOURCE=500/_XOPEN_SOURCE=600/' \
86                         configure.ac || die
87         fi
88
89         # required for bug 263909, cross-compile so don't remove eautoreconf
90         eautoreconf
91 }
92
93 src_configure() {
94         local rundir=$(usex kernel_linux /run /var/run)
95         sed -e "s;@rundir@;${EPREFIX}${rundir};g" "${FILESDIR}"/dbus.initd.in \
96                 > "${T}"/dbus.initd || die
97         multilib-minimal_src_configure
98 }
99
100 multilib_src_configure() {
101         local docconf myconf testconf
102
103         # so we can get backtraces from apps
104         case ${CHOST} in
105                 *-mingw*)
106                         # error: unrecognized command line option '-rdynamic' wrt #488036
107                         ;;
108                 *)
109                         append-flags -rdynamic
110                         ;;
111         esac
112
113         # libaudit is *only* used in DBus wrt SELinux support, so disable it, if
114         # not on an SELinux profile.
115         myconf=(
116                 --localstatedir="${EPREFIX}/var"
117                 --docdir="${EPREFIX}/usr/share/doc/${PF}"
118                 --htmldir="${EPREFIX}/usr/share/doc/${PF}/html"
119                 $(use_enable static-libs static)
120                 $(use_enable debug verbose-mode)
121                 --disable-asserts
122                 --disable-checks
123                 $(use_enable selinux)
124                 $(use_enable selinux libaudit)
125                 --disable-apparmor
126                 $(use_enable kernel_linux inotify)
127                 $(use_enable kernel_FreeBSD kqueue)
128                 $(use_enable elogind)
129                 $(use_enable systemd)
130                 $(use_enable user-session)
131                 --disable-embedded-tests
132                 --disable-modular-tests
133                 $(use_enable debug stats)
134                 --with-session-socket-dir="${EPREFIX}"/tmp
135                 --with-system-pid-file="${EPREFIX}${rundir}"/dbus.pid
136                 --with-system-socket="${EPREFIX}${rundir}"/dbus/system_bus_socket
137                 --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
138                 --with-dbus-user=messagebus
139                 $(use_with X x)
140         )
141
142         if [[ ${CHOST} == *-darwin* ]]; then
143                 myconf+=(
144                         --enable-launchd
145                         --with-launchd-agent-dir="${EPREFIX}"/Library/LaunchAgents
146                 )
147         fi
148
149         if multilib_is_native_abi; then
150                 docconf=(
151                         --enable-xml-docs
152                         $(use_enable doc doxygen-docs)
153                 )
154         else
155                 docconf=(
156                         --disable-xml-docs
157                         --disable-doxygen-docs
158                 )
159                 myconf+=(
160                         --disable-daemon
161                         --disable-selinux
162                         --disable-libaudit
163                         --disable-elogind
164                         --disable-systemd
165                         --without-x
166                 )
167         fi
168
169         einfo "Running configure in ${BUILD_DIR}"
170         ECONF_SOURCE="${S}" econf "${myconf[@]}" "${docconf[@]}"
171
172         if multilib_is_native_abi && use test; then
173                 mkdir "${TBD}" || die
174                 cd "${TBD}" || die
175                 testconf=(
176                         $(use_enable test asserts)
177                         $(use_enable test checks)
178                         $(use_enable test embedded-tests)
179                         $(use_enable test stats)
180                         $(has_version dev-libs/dbus-glib && echo --enable-modular-tests)
181                 )
182                 einfo "Running configure in ${TBD}"
183                 ECONF_SOURCE="${S}" econf "${myconf[@]}" "${testconf[@]}"
184         fi
185 }
186
187 multilib_src_compile() {
188         if multilib_is_native_abi; then
189                 # after the compile, it uses a selinuxfs interface to
190                 # check if the SELinux policy has the right support
191                 use selinux && addwrite /selinux/access
192
193                 einfo "Running make in ${BUILD_DIR}"
194                 emake
195
196                 if use test; then
197                         einfo "Running make in ${TBD}"
198                         emake -C "${TBD}"
199                 fi
200         else
201                 emake -C dbus libdbus-1.la
202         fi
203 }
204
205 src_test() {
206         DBUS_VERBOSE=1 virtx emake -j1 -C "${TBD}" check
207 }
208
209 multilib_src_install() {
210         if multilib_is_native_abi; then
211                 emake DESTDIR="${D}" install
212         else
213                 emake DESTDIR="${D}" install-pkgconfigDATA
214                 emake DESTDIR="${D}" -C dbus \
215                         install-libLTLIBRARIES install-dbusincludeHEADERS \
216                         install-nodist_dbusarchincludeHEADERS
217         fi
218 }
219
220 multilib_src_install_all() {
221         newinitd "${T}"/dbus.initd dbus
222
223         if use X; then
224                 # dbus X session script (#77504)
225                 # turns out to only work for GDM (and startx). has been merged into
226                 # other desktop (kdm and such scripts)
227                 exeinto /etc/X11/xinit/xinitrc.d
228                 doexe "${FILESDIR}"/80-dbus
229         fi
230
231         # needs to exist for dbus sessions to launch
232         keepdir /usr/share/dbus-1/services
233         keepdir /etc/dbus-1/{session,system}.d
234         # machine-id symlink from pkg_postinst()
235         keepdir /var/lib/dbus
236         # let the init script create the /var/run/dbus directory
237         rm -rf "${ED}"/var/run
238
239         dodoc AUTHORS ChangeLog NEWS README doc/TODO
240         readme.gentoo_create_doc
241
242         find "${ED}" -name '*.la' -delete || die
243 }
244
245 pkg_postinst() {
246         readme.gentoo_print_elog
247
248         # Ensure unique id is generated and put it in /etc wrt #370451 but symlink
249         # for DBUS_MACHINE_UUID_FILE (see tools/dbus-launch.c) and reverse
250         # dependencies with hardcoded paths (although the known ones got fixed already)
251         dbus-uuidgen --ensure="${EROOT}"/etc/machine-id
252         ln -sf "${EPREFIX}"/etc/machine-id "${EROOT}"/var/lib/dbus/machine-id
253
254         if [[ ${CHOST} == *-darwin* ]]; then
255                 local plist="org.freedesktop.dbus-session.plist"
256                 elog
257                 elog
258                 elog "For MacOS/Darwin we now ship launchd support for dbus."
259                 elog "This enables autolaunch of dbus at session login and makes"
260                 elog "dbus usable under MacOS/Darwin."
261                 elog
262                 elog "The launchd plist file ${plist} has been"
263                 elog "installed in ${EPREFIX}/Library/LaunchAgents."
264                 elog "For it to be used, you will have to do all of the following:"
265                 elog " + cd ~/Library/LaunchAgents"
266                 elog " + ln -s ${EPREFIX}/Library/LaunchAgents/${plist}"
267                 elog " + logout and log back in"
268                 elog
269                 elog "If your application needs a proper DBUS_SESSION_BUS_ADDRESS"
270                 elog "specified and refused to start otherwise, then export the"
271                 elog "the following to your environment:"
272                 elog " DBUS_SESSION_BUS_ADDRESS=\"launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET\""
273         fi
274
275         if use user-session; then
276                 ewarn "You have enabled user-session. Please note this can cause"
277                 ewarn "bogus behaviors in several dbus consumers that are not prepared"
278                 ewarn "for this dbus activation method yet."
279                 ewarn
280                 ewarn "See the following link for background on this change:"
281                 ewarn "https://lists.freedesktop.org/archives/systemd-devel/2015-January/027711.html"
282                 ewarn
283                 ewarn "Known issues are tracked here:"
284                 ewarn "https://bugs.gentoo.org/show_bug.cgi?id=576028"
285         fi
286 }