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