sys-devel/distcc: Add ~s390 keyword wrt bug #643082
[gentoo.git] / sys-devel / distcc / distcc-3.3.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python3_{5,6} )
7
8 inherit flag-o-matic python-single-r1 systemd toolchain-funcs user xdg-utils prefix
9
10 MY_P="${P/_}"
11 DESCRIPTION="Distribute compilation of C code across several machines on a network"
12 HOMEPAGE="http://distcc.org/"
13 SRC_URI="https://github.com/${PN}/${PN}/releases/download/v${PV}/${P}.tar.gz"
14
15 LICENSE="GPL-2+"
16 SLOT="0"
17 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
18 IUSE="gnome gssapi gtk hardened ipv6 selinux xinetd zeroconf"
19
20 RESTRICT="test"
21
22 CDEPEND="${PYTHON_DEPS}
23         dev-libs/popt
24         gnome? (
25                 >=gnome-base/libgnome-2
26                 >=gnome-base/libgnomeui-2
27                 x11-libs/gtk+:2
28                 x11-libs/pango
29         )
30         gssapi? ( net-libs/libgssglue )
31         gtk? ( x11-libs/gtk+:2 )
32         zeroconf? ( >=net-dns/avahi-0.6[dbus] )
33 "
34 DEPEND="${CDEPEND}
35         sys-libs/binutils-libs
36         virtual/pkgconfig"
37 RDEPEND="${CDEPEND}
38         !net-misc/pump
39         dev-util/shadowman
40         >=sys-devel/gcc-config-1.4.1
41         selinux? ( sec-policy/selinux-distcc )
42         xinetd? ( sys-apps/xinetd )"
43
44 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
45
46 S="${WORKDIR}/${MY_P}"
47
48 pkg_setup() {
49         enewuser distcc 240 -1 -1 daemon
50         python-single-r1_pkg_setup
51 }
52
53 src_prepare() {
54         eapply "${FILESDIR}/${PN}-3.0-xinetd.patch"
55         # bug #255188
56         eapply "${FILESDIR}/${PN}-3.2_rc1-freedesktop.patch"
57         # SOCKSv5 support needed for Portage, bug #537616
58         eapply "${FILESDIR}/${PN}-3.2_rc1-socks5.patch"
59         eapply_user
60
61         # Bugs #120001, #167844 and probably more. See patch for description.
62         use hardened && eapply "${FILESDIR}/distcc-hardened.patch"
63
64         sed -i \
65                 -e "/PATH/s:\$distcc_location:${EPREFIX}/usr/lib/distcc/bin:" \
66                 -e "s:@PYTHON@:${EPYTHON}:" \
67                 pump.in || die "sed failed"
68
69         sed \
70                 -e "s:@EPREFIX@:${EPREFIX:-/}:" \
71                 -e "s:@libdir@:/usr/lib:" \
72                 "${FILESDIR}/3.2/distcc-config" > "${T}/distcc-config" || die
73
74         hprefixify update-distcc-symlinks.py src/{serve,daemon}.c
75 }
76
77 src_configure() {
78         local myconf=(
79                 --disable-Werror
80                 $(use_with gtk)
81                 $(use_with gnome)
82                 $(use_with gssapi auth)
83                 $(use_with zeroconf avahi)
84         )
85
86         # --disable-rfc2553 b0rked, bug #254176
87         use ipv6 && myconf+=(--enable-rfc2553)
88
89         econf "${myconf[@]}"
90 }
91
92 src_install() {
93         # override GZIP_BIN to stop it from compressing manpages
94         emake DESTDIR="${D}" GZIP_BIN=false install
95         python_optimize
96
97         newinitd "${FILESDIR}/3.2/init" distccd
98         systemd_dounit "${FILESDIR}/distccd.service"
99         systemd_install_serviced "${FILESDIR}/distccd.service.conf"
100
101         cp "${FILESDIR}/3.2/conf" "${T}/distccd" || die
102         if use zeroconf; then
103                 cat >> "${T}/distccd" <<-EOF || die
104
105                 # Enable zeroconf support in distccd
106                 DISTCCD_OPTS="\${DISTCCD_OPTS} --zeroconf"
107                 EOF
108
109                 sed -i '/ExecStart/ s|$| --zeroconf|' "${D}$(systemd_get_systemunitdir)"/distccd.service || die
110         fi
111         doconfd "${T}/distccd"
112
113         newenvd - 02distcc <<-EOF || die
114         # This file is managed by distcc-config; use it to change these settings.
115         # DISTCC_LOG and DISTCC_DIR should not be set.
116         DISTCC_VERBOSE="${DISTCC_VERBOSE:-0}"
117         DISTCC_FALLBACK="${DISTCC_FALLBACK:-1}"
118         DISTCC_SAVE_TEMPS="${DISTCC_SAVE_TEMPS:-0}"
119         DISTCC_TCP_CORK="${DISTCC_TCP_CORK}"
120         DISTCC_SSH="${DISTCC_SSH}"
121         UNCACHED_ERR_FD="${UNCACHED_ERR_FD}"
122         DISTCC_ENABLE_DISCREPANCY_EMAIL="${DISTCC_ENABLE_DISCREPANCY_EMAIL}"
123         DCC_EMAILLOG_WHOM_TO_BLAME="${DCC_EMAILLOG_WHOM_TO_BLAME}"
124         EOF
125
126         keepdir /usr/lib/distcc
127
128         dobin "${T}/distcc-config"
129
130         if use gnome || use gtk; then
131                 einfo "Renaming /usr/bin/distccmon-gnome to /usr/bin/distccmon-gui"
132                 einfo "This is to have a little sensability in naming schemes between distccmon programs"
133                 mv "${ED}/usr/bin/distccmon-gnome" "${ED}/usr/bin/distccmon-gui" || die
134                 dosym distccmon-gui /usr/bin/distccmon-gnome
135         fi
136
137         if use xinetd; then
138                 insinto /etc/xinetd.d
139                 newins "doc/example/xinetd" distcc
140         fi
141
142         insinto /usr/share/shadowman/tools
143         newins - distcc <<<"${EPREFIX}/usr/lib/distcc/bin"
144         newins - distccd <<<"${EPREFIX}/usr/lib/distcc"
145
146         rm -r "${ED}/etc/default" || die
147         rm "${ED}/etc/distcc/clients.allow" || die
148         rm "${ED}/etc/distcc/commands.allow.sh" || die
149 }
150
151 pkg_postinst() {
152         # remove the old paths when switching from libXX to lib
153         if [[ $(get_libdir) != lib && ${SYMLINK_LIB} != yes && \
154                         -d ${EROOT%/}/usr/$(get_libdir)/distcc ]]; then
155                 rm -r -f "${EROOT%/}/usr/$(get_libdir)/distcc" || die
156         fi
157
158         if [[ ${ROOT} == / ]]; then
159                 eselect compiler-shadow update distcc
160                 eselect compiler-shadow update distccd
161         fi
162
163         use gnome && xdg_desktop_database_update
164
165         elog
166         elog "Tips on using distcc with Gentoo can be found at"
167         elog "https://wiki.gentoo.org/wiki/Distcc"
168         elog
169         elog "distcc-pump is known to cause breakage with multiple packages."
170         elog "Do NOT enable it globally."
171         elog
172         elog "To use the distccmon programs with Gentoo you should use this command:"
173         elog "# DISTCC_DIR=\"${DISTCC_DIR:-${BUILD_PREFIX}/.distcc}\" distccmon-text 5"
174
175         if use gnome || use gtk; then
176                 elog "Or:"
177                 elog "# DISTCC_DIR=\"${DISTCC_DIR:-${BUILD_PREFIX}/.distcc}\" distccmon-gnome"
178         fi
179
180         elog
181         elog "***SECURITY NOTICE***"
182         elog "Since distcc-3.3, whitelist is used for what distccd could execute. The whilelist"
183         elog "has been generated by compiler-shadow distccd.  To revert to the old behavior, "
184         elog "you need to pass --make-me-a-botnet to distccd in /etc/conf.d/distccd."
185         elog "Cf. https://github.com/distcc/distcc/pull/243."
186 }
187
188 pkg_prerm() {
189         if [[ -z ${REPLACED_BY_VERSION} && ${ROOT} == / ]]; then
190                 eselect compiler-shadow remove distcc
191         fi
192 }
193
194 pkg_postrm() {
195         use gnome && xdg_desktop_database_update
196 }