6be58e9b972842ff0997e7fea9aea70d3b84347d
[gentoo.git] / net-fs / samba / samba-4.8.6-r3.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 PYTHON_COMPAT=( python2_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 iprint ldap pam python
27 quota selinux syslog system-heimdal +system-mitkrb5 systemd test winbind zeroconf"
28
29 MULTILIB_WRAPPED_HEADERS=(
30         /usr/include/samba-4.0/policy.h
31         /usr/include/samba-4.0/dcerpc_server.h
32         /usr/include/samba-4.0/ctdb.h
33         /usr/include/samba-4.0/ctdb_client.h
34         /usr/include/samba-4.0/ctdb_protocol.h
35         /usr/include/samba-4.0/ctdb_private.h
36         /usr/include/samba-4.0/ctdb_typesafe_cb.h
37         /usr/include/samba-4.0/ctdb_version.h
38 )
39
40 # sys-apps/attr is an automagic dependency (see bug #489748)
41 CDEPEND="
42         >=app-arch/libarchive-3.1.2[${MULTILIB_USEDEP}]
43         dev-lang/perl:=
44         dev-libs/libaio[${MULTILIB_USEDEP}]
45         dev-libs/libbsd[${MULTILIB_USEDEP}]
46         dev-libs/iniparser:0
47         dev-libs/popt[${MULTILIB_USEDEP}]
48         dev-python/subunit[${PYTHON_USEDEP},${MULTILIB_USEDEP}]
49         >=dev-util/cmocka-1.1.1[${MULTILIB_USEDEP}]
50         net-libs/libnsl:=[${MULTILIB_USEDEP}]
51         sys-apps/attr[${MULTILIB_USEDEP}]
52         >=sys-libs/ldb-1.3.6[ldap(+)?,python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
53         <sys-libs/ldb-1.4.0[ldap(+)?,python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
54         sys-libs/libcap
55         sys-libs/ncurses:0=[${MULTILIB_USEDEP}]
56         sys-libs/readline:0=
57         >=sys-libs/talloc-2.1.11[python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
58         >=sys-libs/tdb-1.3.15[python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
59         >=sys-libs/tevent-0.9.36[python?,${PYTHON_USEDEP},${MULTILIB_USEDEP}]
60         sys-libs/zlib[${MULTILIB_USEDEP}]
61         virtual/libiconv
62         pam? ( sys-libs/pam )
63         acl? ( virtual/acl )
64         addns? (
65                 net-dns/bind-tools[gssapi]
66                 dev-python/dnspython:=[${PYTHON_USEDEP}]
67         )
68         ceph? ( sys-cluster/ceph )
69         cluster? (
70                 net-libs/rpcsvc-proto
71                 !dev-db/ctdb
72         )
73         cups? ( net-print/cups )
74         debug? ( dev-util/lttng-ust )
75         dmapi? ( sys-apps/dmapi )
76         fam? ( virtual/fam )
77         gnutls? (
78                 dev-libs/libgcrypt:0
79                 >=net-libs/gnutls-1.4.0
80         )
81         gpg? ( app-crypt/gpgme )
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 gnutls winbind )
115         addns? ( python )
116         ads? ( acl gnutls 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.5.1-compile_et_fix.patch"
135         "${FILESDIR}/${PN}-4.8.6-no-pydsdb-when-no-addc.patch"
136 )
137
138 #CONFDIR="${FILESDIR}/$(get_version_component_range 1-2)"
139 CONFDIR="${FILESDIR}/4.4"
140
141 WAF_BINARY="${S}/buildtools/bin/waf"
142
143 SHAREDMODS=""
144
145 pkg_setup() {
146         python-single-r1_pkg_setup
147         if use cluster ; then
148                 SHAREDMODS="idmap_rid,idmap_tdb2,idmap_ad"
149         elif use ads ; then
150                 SHAREDMODS="idmap_ad"
151         fi
152 }
153
154 src_prepare() {
155         default
156
157         # un-bundle dnspython
158         sed -i -e '/"dns.resolver":/d' "${S}"/third_party/wscript || die
159
160         # unbundle iso8601 unless tests are enabled
161         use test || sed -i -e '/"iso8601":/d' "${S}"/third_party/wscript || die
162
163         # ugly hackaround for bug #592502
164         cp /usr/include/tevent_internal.h "${S}"/lib/tevent/ || die
165
166         sed -e 's:<gpgme\.h>:<gpgme/gpgme.h>:' \
167                 -i source4/dsdb/samdb/ldb_modules/password_hash.c \
168                 || die
169
170         # Friggin' WAF shit
171         multilib_copy_sources
172 }
173
174 multilib_src_configure() {
175         # when specifying libs for samba build you must append NONE to the end to
176         # stop it automatically including things
177         local bundled_libs="NONE"
178         if ! use system-heimdal && ! use system-mitkrb5 ; then
179                 bundled_libs="heimbase,heimntlm,hdb,kdc,krb5,wind,gssapi,hcrypto,hx509,roken,asn1,com_err,NONE"
180         fi
181
182         local myconf=(
183                 --enable-fhs
184                 --sysconfdir="${EPREFIX}/etc"
185                 --localstatedir="${EPREFIX}/var"
186                 --with-modulesdir="${EPREFIX}/usr/$(get_libdir)/samba"
187                 --with-piddir="${EPREFIX}/run/${PN}"
188                 --bundled-libraries="${bundled_libs}"
189                 --builtin-libraries=NONE
190                 --disable-rpath
191                 --disable-rpath-install
192                 --nopyc
193                 --nopyo
194                 $(multilib_native_use_with acl acl-support)
195                 $(multilib_native_usex addc '' '--without-ad-dc')
196                 $(multilib_native_use_with addns dnsupdate)
197                 $(multilib_native_use_with ads)
198                 $(multilib_native_use_enable ceph cephfs)
199                 $(multilib_native_use_with cluster cluster-support)
200                 $(multilib_native_use_enable cups)
201                 $(multilib_native_use_with dmapi)
202                 $(multilib_native_use_with fam)
203                 $(multilib_native_use_with gpg gpgme)
204                 $(multilib_native_use_enable iprint)
205                 $(multilib_native_use_with pam)
206                 $(multilib_native_usex pam "--with-pammodulesdir=${EPREFIX}/$(get_libdir)/security" '')
207                 $(multilib_native_use_with quota quotas)
208                 $(multilib_native_use_with syslog)
209                 $(multilib_native_use_with systemd)
210                 $(multilib_native_use_with winbind)
211                 $(multilib_native_usex python '' '--disable-python')
212                 $(multilib_native_use_enable zeroconf avahi)
213                 $(multilib_native_usex test '--enable-selftest' '')
214                 $(usex system-mitkrb5 '--with-system-mitkrb5' '')
215                 $(use_enable gnutls)
216                 $(use_with debug lttng)
217                 $(use_with ldap)
218         )
219         multilib_is_native_abi && myconf+=( --with-shared-modules=${SHAREDMODS} )
220
221         CPPFLAGS="-I${SYSROOT}${EPREFIX}/usr/include/et ${CPPFLAGS}" \
222                 waf-utils_src_configure ${myconf[@]}
223 }
224
225 multilib_src_compile() {
226         waf-utils_src_compile
227 }
228
229 multilib_src_install() {
230         waf-utils_src_install
231
232         # Make all .so files executable
233         find "${ED}" -type f -name "*.so" -exec chmod +x {} +
234
235         if multilib_is_native_abi ; then
236                 # install ldap schema for server (bug #491002)
237                 if use ldap ; then
238                         insinto /etc/openldap/schema
239                         doins examples/LDAP/samba.schema
240                 fi
241
242                 # create symlink for cups (bug #552310)
243                 if use cups ; then
244                         dosym ../../../bin/smbspool /usr/libexec/cups/backend/smb
245                 fi
246
247                 # install example config file
248                 insinto /etc/samba
249                 doins examples/smb.conf.default
250
251                 # Fix paths in example file (#603964)
252                 sed \
253                         -e '/log file =/s@/usr/local/samba/var/@/var/log/samba/@' \
254                         -e '/include =/s@/usr/local/samba/lib/@/etc/samba/@' \
255                         -e '/path =/s@/usr/local/samba/lib/@/var/lib/samba/@' \
256                         -e '/path =/s@/usr/local/samba/@/var/lib/samba/@' \
257                         -e '/path =/s@/usr/spool/samba@/var/spool/samba@' \
258                         -i "${ED%/}"/etc/samba/smb.conf.default || die
259
260                 # Install init script and conf.d file
261                 newinitd "${CONFDIR}/samba4.initd-r1" samba
262                 newconfd "${CONFDIR}/samba4.confd" samba
263
264                 systemd_dotmpfilesd "${FILESDIR}"/samba.conf
265                 systemd_dounit "${FILESDIR}"/nmbd.service
266                 systemd_dounit "${FILESDIR}"/smbd.{service,socket}
267                 systemd_newunit "${FILESDIR}"/smbd_at.service 'smbd@.service'
268                 systemd_dounit "${FILESDIR}"/winbindd.service
269                 systemd_dounit "${FILESDIR}"/samba.service
270         fi
271
272         if use pam && use winbind ; then
273                 newpamd "${CONFDIR}/system-auth-winbind.pam" system-auth-winbind
274                 # bugs #376853 and #590374
275                 insinto /etc/security
276                 doins examples/pam_winbind/pam_winbind.conf || die
277         fi
278
279         keepdir /var/cache/samba
280         keepdir /var/lib/ctdb
281         keepdir /var/lib/samba/{bind-dns,private}
282         keepdir /var/lock/samba
283         keepdir /var/log/samba
284         keepdir /var/run/{ctdb,samba}
285 }
286
287 multilib_src_test() {
288         if multilib_is_native_abi ; then
289                 "${WAF_BINARY}" test || die "test failed"
290         fi
291 }
292
293 pkg_postinst() {
294         ewarn "Be aware the this release contains the best of all of Samba's"
295         ewarn "technology parts, both a file server (that you can reasonably expect"
296         ewarn "to upgrade existing Samba 3.x releases to) and the AD domain"
297         ewarn "controller work previously known as 'samba4'."
298
299         elog "For further information and migration steps make sure to read "
300         elog "https://samba.org/samba/history/${P}.html "
301         elog "https://wiki.samba.org/index.php/Samba4/HOWTO "
302 }