*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / net-fs / samba / samba-4.10.10.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 PYTHON_COMPAT=( python3_{6,7} )
6 PYTHON_REQ_USE='threads(+),xml(+)'
7
8 inherit python-single-r1 waf-utils multilib-minimal linux-info systemd pam
9
10 MY_PV="${PV/_rc/rc}"
11 MY_P="${PN}-${MY_PV}"
12
13 SRC_PATH="stable"
14 [[ ${PV} = *_rc* ]] && SRC_PATH="rc"
15
16 SRC_URI="mirror://samba/${SRC_PATH}/${MY_P}.tar.gz"
17 [[ ${PV} = *_rc* ]] || \
18 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86"
19
20 DESCRIPTION="Samba Suite Version 4"
21 HOMEPAGE="https://www.samba.org/"
22 LICENSE="GPL-3"
23
24 SLOT="0"
25
26 IUSE="acl addc addns ads ceph client cluster cups debug dmapi fam gnutls gpg
27 iprint json ldap pam profiling-data python quota selinux syslog system-heimdal
28 +system-mitkrb5 systemd test winbind zeroconf"
29
30 MULTILIB_WRAPPED_HEADERS=(
31         /usr/include/samba-4.0/policy.h
32         /usr/include/samba-4.0/dcerpc_server.h
33         /usr/include/samba-4.0/ctdb.h
34         /usr/include/samba-4.0/ctdb_client.h
35         /usr/include/samba-4.0/ctdb_protocol.h
36         /usr/include/samba-4.0/ctdb_private.h
37         /usr/include/samba-4.0/ctdb_typesafe_cb.h
38         /usr/include/samba-4.0/ctdb_version.h
39 )
40
41 # sys-apps/attr is an automagic dependency (see bug #489748)
42 CDEPEND="
43         >=app-arch/libarchive-3.1.2[${MULTILIB_USEDEP}]
44         dev-lang/perl:=
45         dev-libs/libaio[${MULTILIB_USEDEP}]
46         dev-libs/libbsd[${MULTILIB_USEDEP}]
47         dev-libs/iniparser:0
48         dev-libs/popt[${MULTILIB_USEDEP}]
49         dev-python/subunit[${PYTHON_USEDEP},${MULTILIB_USEDEP}]
50         >=dev-util/cmocka-1.1.1[${MULTILIB_USEDEP}]
51         net-libs/libnsl:=[${MULTILIB_USEDEP}]
52         sys-apps/attr[${MULTILIB_USEDEP}]
53         >=sys-libs/ldb-1.5.6[ldap(+)?,python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
54         <sys-libs/ldb-1.6.0[ldap(+)?,python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
55         sys-libs/libcap
56         sys-libs/ncurses:0=[${MULTILIB_USEDEP}]
57         sys-libs/readline:0=
58         >=sys-libs/talloc-2.1.16[python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
59         >=sys-libs/tdb-1.3.18[python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
60         >=sys-libs/tevent-0.9.39[python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
61         sys-libs/zlib[${MULTILIB_USEDEP}]
62         virtual/libiconv
63         pam? ( sys-libs/pam )
64         acl? ( virtual/acl )
65         addns? (
66                 net-dns/bind-tools[gssapi]
67                 dev-python/dnspython:=[${PYTHON_USEDEP}]
68         )
69         ceph? ( sys-cluster/ceph )
70         cluster? (
71                 net-libs/rpcsvc-proto
72                 !dev-db/ctdb
73         )
74         cups? ( net-print/cups )
75         debug? ( dev-util/lttng-ust )
76         dmapi? ( sys-apps/dmapi )
77         fam? ( virtual/fam )
78         gnutls? (
79                 dev-libs/libgcrypt:0
80                 >=net-libs/gnutls-1.4.0
81         )
82         gpg? ( app-crypt/gpgme )
83         json? ( dev-libs/jansson )
84         ldap? ( net-nds/openldap[${MULTILIB_USEDEP}] )
85         system-heimdal? ( >=app-crypt/heimdal-1.5[-ssl,${MULTILIB_USEDEP}] )
86         system-mitkrb5? ( >=app-crypt/mit-krb5-1.15.1[${MULTILIB_USEDEP}] )
87         systemd? ( sys-apps/systemd:0= )
88         zeroconf? ( net-dns/avahi )
89 "
90 DEPEND="${CDEPEND}
91         ${PYTHON_DEPS}
92         app-text/docbook-xsl-stylesheets
93         dev-libs/libxslt
94         net-libs/libtirpc[${MULTILIB_USEDEP}]
95         virtual/pkgconfig
96         || (
97                 net-libs/rpcsvc-proto
98                 <sys-libs/glibc-2.26[rpc(+)]
99         )
100         test? (
101                 !system-mitkrb5? (
102                         >=sys-libs/nss_wrapper-1.1.3
103                         >=net-dns/resolv_wrapper-1.1.4
104                         >=net-libs/socket_wrapper-1.1.9
105                         >=sys-libs/uid_wrapper-1.2.1
106                 )
107         )"
108 RDEPEND="${CDEPEND}
109         python? ( ${PYTHON_DEPS} )
110         client? ( net-fs/cifs-utils[ads?] )
111         selinux? ( sec-policy/selinux-samba )
112         !dev-perl/Parse-Yapp
113 "
114
115 REQUIRED_USE="
116         addc? ( python gnutls json winbind )
117         addns? ( python )
118         ads? ( acl gnutls ldap winbind )
119         cluster? ( ads )
120         gpg? ( addc )
121         test? ( python )
122         ?? ( system-heimdal system-mitkrb5 )
123         ${PYTHON_REQUIRED_USE}
124 "
125
126 # the test suite is messed, it uses system-installed samba
127 # bits instead of what was built, tests things disabled via use
128 # flags, and generally just fails to work in a way ebuilds could
129 # rely on in its current state
130 RESTRICT="test"
131
132 S="${WORKDIR}/${MY_P}"
133
134 PATCHES=(
135         "${FILESDIR}/${PN}-4.4.0-pam.patch"
136         "${FILESDIR}/${PN}-4.5.1-compile_et_fix.patch"
137         "${FILESDIR}/${PN}-4.9.2-timespec.patch"
138 )
139
140 #CONFDIR="${FILESDIR}/$(get_version_component_range 1-2)"
141 CONFDIR="${FILESDIR}/4.4"
142
143 WAF_BINARY="${S}/buildtools/bin/waf"
144
145 SHAREDMODS=""
146
147 pkg_setup() {
148         python-single-r1_pkg_setup
149         if use cluster ; then
150                 SHAREDMODS="idmap_rid,idmap_tdb2,idmap_ad"
151         elif use ads ; then
152                 SHAREDMODS="idmap_ad"
153         fi
154 }
155
156 src_prepare() {
157         default
158
159         # un-bundle dnspython
160         sed -i -e '/"dns.resolver":/d' "${S}"/third_party/wscript || die
161
162         # unbundle iso8601 unless tests are enabled
163         if ! use test ; then
164                 sed -i -e '/"iso8601":/d' "${S}"/third_party/wscript || die
165         fi
166
167         # ugly hackaround for bug #592502
168         cp /usr/include/tevent_internal.h "${S}"/lib/tevent/ || die
169
170         sed -e 's:<gpgme\.h>:<gpgme/gpgme.h>:' \
171                 -i source4/dsdb/samdb/ldb_modules/password_hash.c \
172                 || die
173
174         # Friggin' WAF shit
175         multilib_copy_sources
176 }
177
178 multilib_src_configure() {
179         # when specifying libs for samba build you must append NONE to the end to
180         # stop it automatically including things
181         local bundled_libs="NONE"
182         if ! use system-heimdal && ! use system-mitkrb5 ; then
183                 bundled_libs="heimbase,heimntlm,hdb,kdc,krb5,wind,gssapi,hcrypto,hx509,roken,asn1,com_err,NONE"
184         fi
185
186         local myconf=(
187                 --enable-fhs
188                 --sysconfdir="${EPREFIX}/etc"
189                 --localstatedir="${EPREFIX}/var"
190                 --with-modulesdir="${EPREFIX}/usr/$(get_libdir)/samba"
191                 --with-piddir="${EPREFIX}/run/${PN}"
192                 --bundled-libraries="${bundled_libs}"
193                 --builtin-libraries=NONE
194                 --disable-rpath
195                 --disable-rpath-install
196                 --nopyc
197                 --nopyo
198                 $(multilib_native_use_with acl acl-support)
199                 $(multilib_native_usex addc '' '--without-ad-dc')
200                 $(multilib_native_use_with addns dnsupdate)
201                 $(multilib_native_use_with ads)
202                 $(multilib_native_use_enable ceph cephfs)
203                 $(multilib_native_use_with cluster cluster-support)
204                 $(multilib_native_use_enable cups)
205                 $(multilib_native_use_with dmapi)
206                 $(multilib_native_use_with fam)
207                 $(multilib_native_use_with gpg gpgme)
208                 $(multilib_native_use_with json)
209                 $(multilib_native_use_enable iprint)
210                 $(multilib_native_use_with pam)
211                 $(multilib_native_usex pam "--with-pammodulesdir=${EPREFIX}/$(get_libdir)/security" '')
212                 $(multilib_native_use_with quota quotas)
213                 $(multilib_native_use_with syslog)
214                 $(multilib_native_use_with systemd)
215                 $(multilib_native_use_with winbind)
216                 $(multilib_native_usex python '' '--disable-python')
217                 $(multilib_native_use_enable zeroconf avahi)
218                 $(multilib_native_usex test '--enable-selftest' '')
219                 $(usex system-mitkrb5 "--with-system-mitkrb5 $(multilib_native_usex addc --with-experimental-mit-ad-dc '')" '')
220                 $(use_enable gnutls)
221                 $(use_with debug lttng)
222                 $(use_with ldap)
223                 $(use_with profiling-data)
224         )
225
226         multilib_is_native_abi && myconf+=( --with-shared-modules=${SHAREDMODS} )
227
228         CPPFLAGS="-I${SYSROOT}${EPREFIX}/usr/include/et ${CPPFLAGS}" \
229                 waf-utils_src_configure ${myconf[@]}
230 }
231
232 multilib_src_compile() {
233         waf-utils_src_compile
234 }
235
236 multilib_src_install() {
237         waf-utils_src_install
238
239         # Make all .so files executable
240         find "${ED}" -type f -name "*.so" -exec chmod +x {} + || die
241
242         if multilib_is_native_abi ; then
243                 # install ldap schema for server (bug #491002)
244                 if use ldap ; then
245                         insinto /etc/openldap/schema
246                         doins examples/LDAP/samba.schema
247                 fi
248
249                 # create symlink for cups (bug #552310)
250                 if use cups ; then
251                         dosym ../../../bin/smbspool /usr/libexec/cups/backend/smb
252                 fi
253
254                 # install example config file
255                 insinto /etc/samba
256                 doins examples/smb.conf.default
257
258                 # Fix paths in example file (#603964)
259                 sed \
260                         -e '/log file =/s@/usr/local/samba/var/@/var/log/samba/@' \
261                         -e '/include =/s@/usr/local/samba/lib/@/etc/samba/@' \
262                         -e '/path =/s@/usr/local/samba/lib/@/var/lib/samba/@' \
263                         -e '/path =/s@/usr/local/samba/@/var/lib/samba/@' \
264                         -e '/path =/s@/usr/spool/samba@/var/spool/samba@' \
265                         -i "${ED%/}"/etc/samba/smb.conf.default || die
266
267                 # Install init script and conf.d file
268                 newinitd "${CONFDIR}/samba4.initd-r1" samba
269                 newconfd "${CONFDIR}/samba4.confd" samba
270
271                 systemd_dotmpfilesd "${FILESDIR}"/samba.conf
272                 systemd_dounit "${FILESDIR}"/nmbd.service
273                 systemd_dounit "${FILESDIR}"/smbd.{service,socket}
274                 systemd_newunit "${FILESDIR}"/smbd_at.service 'smbd@.service'
275                 systemd_dounit "${FILESDIR}"/winbindd.service
276                 systemd_dounit "${FILESDIR}"/samba.service
277         fi
278
279         if use pam && use winbind ; then
280                 newpamd "${CONFDIR}/system-auth-winbind.pam" system-auth-winbind
281                 # bugs #376853 and #590374
282                 insinto /etc/security
283                 doins examples/pam_winbind/pam_winbind.conf
284         fi
285
286         keepdir /var/cache/samba
287         keepdir /var/lib/ctdb
288         keepdir /var/lib/samba/{bind-dns,private}
289         keepdir /var/lock/samba
290         keepdir /var/log/samba
291         keepdir /var/run/{ctdb,samba}
292 }
293
294 multilib_src_install_all() {
295         # Attempt to fix bug #673168
296         find "${ED}" -type d -name "Yapp" -print0 \
297                 | xargs -0 --no-run-if-empty rm -r || die
298 }
299
300 multilib_src_test() {
301         if multilib_is_native_abi ; then
302                 "${WAF_BINARY}" test || die "test failed"
303         fi
304 }
305
306 pkg_postinst() {
307         ewarn "Be aware the this release contains the best of all of Samba's"
308         ewarn "technology parts, both a file server (that you can reasonably expect"
309         ewarn "to upgrade existing Samba 3.x releases to) and the AD domain"
310         ewarn "controller work previously known as 'samba4'."
311
312         elog "For further information and migration steps make sure to read "
313         elog "https://samba.org/samba/history/${P}.html "
314         elog "https://wiki.samba.org/index.php/Samba4/HOWTO "
315 }