Use https by default
[gentoo.git] / sys-devel / distcc / distcc-3.1-r10.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 PYTHON_COMPAT=( python2_7 )
8
9 inherit eutils fdo-mime flag-o-matic multilib python-single-r1 systemd toolchain-funcs user
10
11 DESCRIPTION="Distribute compilation of C code across several machines on a network"
12 HOMEPAGE="http://distcc.org/"
13 SRC_URI="http://distcc.googlecode.com/files/${P}.tar.bz2"
14
15 LICENSE="GPL-2"
16 SLOT="0"
17 KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~sparc-fbsd ~x86-fbsd"
18 IUSE="avahi gtk hardened ipv6 selinux xinetd"
19
20 RESTRICT="test"
21
22 CDEPEND="${PYTHON_DEPS}
23         dev-libs/popt
24         avahi? ( >=net-dns/avahi-0.6[dbus] )
25         gtk? ( x11-libs/gtk+:2 )"
26 DEPEND="${CDEPEND}
27         virtual/pkgconfig"
28 RDEPEND="${CDEPEND}
29         !net-misc/pump
30         >=sys-devel/gcc-config-1.4.1
31         selinux? ( sec-policy/selinux-distcc )
32         xinetd? ( sys-apps/xinetd )"
33
34 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
35
36 DISTCC_LOG=""
37 DCCC_PATH="/usr/$(get_libdir)/distcc/bin"
38 DISTCC_VERBOSE="0"
39
40 pkg_setup() {
41         enewuser distcc 240 -1 -1 daemon
42         python-single-r1_pkg_setup
43 }
44
45 src_prepare() {
46         epatch "${FILESDIR}/${PN}-3.0-xinetd.patch"
47         # bug #253786
48         epatch "${FILESDIR}/${PN}-3.0-fix-fortify.patch"
49         # bug #255188
50         epatch "${FILESDIR}/${P}-freedesktop.patch"
51         # bug #258364
52         epatch "${FILESDIR}/${P}-python.patch"
53         # bug #351979
54         epatch "${FILESDIR}/${P}-argc-fix.patch"
55         epatch_user
56
57         sed -i -e "/PATH/s:\$distcc_location:${DCCC_PATH}:" pump.in || die
58
59         # Bugs #120001, #167844 and probably more. See patch for description.
60         use hardened && epatch "${FILESDIR}/distcc-hardened.patch"
61 }
62
63 src_configure() {
64         local myconf="--disable-Werror --with-docdir=/usr/share/doc/${PF}"
65         # More legacy stuff?
66         [ "$(gcc-major-version)" = "2" ] && filter-lfs-flags
67
68         # --disable-rfc2553 b0rked, bug #254176
69         use ipv6 && myconf="${myconf} --enable-rfc2553"
70
71         econf \
72                 $(use_with avahi) \
73                 $(use_with gtk) \
74                 ${myconf}
75 }
76
77 src_install() {
78         # In rare cases, parallel make install failed
79         MAKEOPTS+=" -j1"
80         default
81
82         dobin "${FILESDIR}/3.0/distcc-config"
83
84         newinitd "${FILESDIR}/${PV}/init" distccd
85         systemd_dounit "${FILESDIR}/distccd.service"
86         systemd_install_serviced "${FILESDIR}/distccd.service.conf"
87
88         cp "${FILESDIR}/3.1/conf" "${T}/distccd" || die
89         if use avahi; then
90                 cat >> "${T}/distccd" <<-EOF
91
92                 # Enable zeroconf support in distccd
93                 DISTCCD_OPTS="\${DISTCCD_OPTS} --zeroconf"
94                 EOF
95
96                 sed -i '/ExecStart/ s|$| --zeroconf|' "${ED}"/usr/lib/systemd/system/distccd.service || die
97         fi
98         doconfd "${T}/distccd"
99
100         cat > "${T}/02distcc" <<-EOF
101         # This file is managed by distcc-config; use it to change these settings.
102         DISTCC_LOG="${DISTCC_LOG}"
103         DCCC_PATH="${DCCC_PATH}"
104         DISTCC_VERBOSE="${DISTCC_VERBOSE}"
105         EOF
106         doenvd "${T}/02distcc"
107
108         # create the masquerade directory
109         dodir "${DCCC_PATH}"
110         for f in cc c++ gcc g++; do
111                 dosym /usr/bin/distcc "${DCCC_PATH}/${f}"
112                 if [ "${f}" != "cc" ]; then
113                         dosym /usr/bin/distcc "${DCCC_PATH}/${CTARGET:-${CHOST}}-${f}"
114                 fi
115         done
116
117         # create the distccd pid directory
118         keepdir /var/run/distccd
119         fowners distcc:daemon /var/run/distccd
120
121         if use gtk; then
122                 einfo "Renaming /usr/bin/distccmon-gnome to /usr/bin/distccmon-gui"
123                 einfo "This is to have a little sensability in naming schemes between distccmon programs"
124                 mv "${ED}/usr/bin/distccmon-gnome" "${ED}/usr/bin/distccmon-gui" || die
125                 dosym distccmon-gui /usr/bin/distccmon-gnome
126         fi
127
128         if use xinetd; then
129                 insinto /etc/xinetd.d
130                 newins "doc/example/xinetd" distcc
131         fi
132
133         rm -rf "${D}/etc/default" || die
134         rm -f "${D}/etc/distcc/clients.allow" || die
135         rm -f "${D}/etc/distcc/commands.allow.sh" || die
136
137         python_fix_shebang "${ED}"
138         python_optimize "${ED}"/$(python_get_sitedir)
139 }
140
141 pkg_postinst() {
142         use gtk && fdo-mime_desktop_database_update
143
144         if use ipv6; then
145                 elog
146                 elog "IPv6 is not supported yet by ${P}."
147         fi
148         elog
149         elog "Tips on using distcc with Gentoo can be found at"
150         elog "https://www.gentoo.org/doc/en/distcc.xml"
151         elog
152         elog "How to use pump mode with Gentoo:"
153         elog "# distcc-config --set-hosts \"foo,cpp,lzo bar,cpp,lzo baz,cpp,lzo\""
154         elog "# pump emerge -u world"
155         elog
156         elog "To use the distccmon programs with Gentoo you should use this command:"
157         elog "# DISTCC_DIR=\"${DISTCC_DIR}\" distccmon-text 5"
158
159         if use gtk; then
160                 elog "Or:"
161                 elog "# DISTCC_DIR=\"${DISTCC_DIR}\" distccmon-gnome"
162         fi
163
164         elog
165         elog "***SECURITY NOTICE***"
166         elog "If you are upgrading distcc please make sure to run etc-update to"
167         elog "update your /etc/conf.d/distccd and /etc/init.d/distccd files with"
168         elog "added security precautions (the --listen and --allow directives)"
169         elog
170 }
171
172 pkg_postrm() {
173         use gtk && fdo-mime_desktop_database_update
174 }