net-fs/samba: Resurrect samba-3.6.23-r1
[portage-overlay.git] / net-fs / samba / samba-3.6.23-r1.ebuild
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/net-fs/samba/Attic/samba-3.6.23-r1.ebuild,v 1.12 2014/11/02 12:33:27 swift Exp $
4
5 EAPI=5
6
7 inherit pam versionator multilib multilib-minimal eutils flag-o-matic systemd
8
9 MY_PV=${PV/_/}
10 MY_P="${PN}-${MY_PV}"
11
12 DESCRIPTION="Library bits of the samba network filesystem"
13 HOMEPAGE="http://www.samba.org/"
14 SRC_URI="mirror://samba/stable/${MY_P}.tar.gz"
15 LICENSE="GPL-3"
16 SLOT="0"
17 KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 sparc x86 ~amd64-fbsd ~x86-fbsd ~arm-linux ~x86-linux"
18 IUSE="acl addns ads +aio avahi caps +client cluster cups debug dmapi doc examples fam
19         ldap ldb +netapi pam quota +readline selinux +server +smbclient smbsharemodes
20         swat syslog +winbind"
21
22 DEPEND="dev-libs/popt
23         >=sys-libs/talloc-2.0.8-r1[${MULTILIB_USEDEP}]
24         >=sys-libs/tdb-1.2.13[${MULTILIB_USEDEP}]
25         >=sys-libs/tevent-0.9.19[${MULTILIB_USEDEP}]
26         >=virtual/libiconv-0-r1[${MULTILIB_USEDEP}]
27         ads? ( >=virtual/krb5-0-r1[${MULTILIB_USEDEP}] sys-fs/e2fsprogs
28                 client? ( sys-apps/keyutils ) )
29         avahi? ( net-dns/avahi[dbus] )
30         caps? ( >=sys-libs/libcap-2.22-r2[${MULTILIB_USEDEP}] )
31         client? ( !net-fs/mount-cifs
32                 >=dev-libs/iniparser-3.1-r1[${MULTILIB_USEDEP}] )
33         cluster? ( >=dev-db/ctdb-1.13 )
34         cups? ( net-print/cups )
35         debug? ( dev-libs/dmalloc )
36         dmapi? ( sys-apps/dmapi )
37         fam? ( >=virtual/fam-0-r1[${MULTILIB_USEDEP}] )
38         ldap? ( >=net-nds/openldap-2.4.38-r1[${MULTILIB_USEDEP}] )
39         ldb? ( sys-libs/ldb )
40         pam? ( >=virtual/pam-0-r1[${MULTILIB_USEDEP}]
41                 winbind? ( >=dev-libs/iniparser-3.1-r1[${MULTILIB_USEDEP}] )
42         )
43         readline? ( >=sys-libs/readline-5.2 )
44         syslog? ( virtual/logger )"
45
46 RDEPEND="${DEPEND}
47         kernel_linux? ( ads? ( net-fs/cifs-utils[ads] )
48                         client? ( net-fs/cifs-utils ) )
49         selinux? ( sec-policy/selinux-samba )
50 "
51
52 # Disable tests since we don't want to build that much here
53 RESTRICT="test"
54
55 SBINPROGS=""
56 BINPROGS=""
57 KRBPLUGIN=""
58 PLUGINEXT=".so"
59 SHAREDMODS=""
60
61 S=${WORKDIR}/${MY_P}
62
63 # TODO:
64 # - enable iPrint on Prefix/OSX and Darwin?
65 # - selftest-prefix? selftest?
66 # - AFS?
67
68 CONFDIR="${FILESDIR}/$(get_version_component_range 1-2)"
69
70 REQUIRED_USE="
71         ads? ( ldap )
72         swat? ( server )
73 "
74
75 pkg_pretend() {
76         if [[ ${MERGE_TYPE} != binary ]]; then
77                 if use winbind &&
78                         [[ $(tc-getCC)$ == *gcc* ]] &&
79                         [[ $(gcc-major-version)$(gcc-minor-version) -lt 43 ]]
80                 then
81                         eerror "It is a known issue that ${P} will not build with "
82                         eerror "winbind use flag enabled when using gcc < 4.3 ."
83                         eerror "Please use at least the latest stable gcc version."
84                         die "Using sys-devel/gcc < 4.3 with winbind use flag."
85                 fi
86         fi
87 }
88
89 pkg_setup() {
90         if use server ; then
91                 SBINPROGS="${SBINPROGS} bin/smbd bin/nmbd"
92                 BINPROGS="${BINPROGS} bin/testparm bin/smbstatus bin/smbcontrol bin/pdbedit
93                         bin/profiles bin/sharesec bin/eventlogadm bin/smbta-util
94                         $(usex client "" "bin/smbclient")"
95
96                 use swat && SBINPROGS="${SBINPROGS} bin/swat"
97                 use winbind && SBINPROGS="${SBINPROGS} bin/winbindd"
98                 use ads && use winbind && KRBPLUGIN="${KRBPLUGIN} bin/winbind_krb5_locator"
99         fi
100
101         if use client ; then
102                 BINPROGS="${BINPROGS} bin/smbclient bin/net bin/smbget bin/smbtree
103                         bin/nmblookup bin/smbpasswd bin/rpcclient bin/smbcacls bin/smbcquotas
104                         bin/ntlm_auth"
105
106         fi
107
108         use cups && BINPROGS="${BINPROGS} bin/smbspool"
109 #       use ldb && BINPROGS="${BINPROGS} bin/ldbedit bin/ldbsearch bin/ldbadd bin/ldbdel bin/ldbmodify bin/ldbrename";
110
111         if use winbind ; then
112                 BINPROGS="${BINPROGS} bin/wbinfo"
113                 SHAREDMODS="${SHAREDMODS}idmap_rid,idmap_hash"
114                 use ads && SHAREDMODS="${SHAREDMODS},idmap_ad"
115                 use cluster && SHAREDMODS="${SHAREDMODS},idmap_tdb2"
116                 use ldap && SHAREDMODS="${SHAREDMODS},idmap_ldap,idmap_adex"
117         fi
118 }
119
120 src_prepare() {
121         cp "${FILESDIR}/samba-3.4.2-lib.tevent.python.mk" "lib/tevent/python.mk"
122
123         # ensure that winbind has correct ldflags (QA notice)
124         sed -i \
125                 -e 's|LDSHFLAGS="|LDSHFLAGS="\\${LDFLAGS} |g' \
126                 source3/configure || die "sed failed"
127         epatch "${CONFDIR}"/smb.conf.default.patch
128
129         #bug #399141 wrap newer iniparser version
130         has_version ">=dev-libs/iniparser-3.0.0" && \
131                 append-cppflags "-Diniparser_getstr\(d,i\)=iniparser_getstring\(d,i,NULL\)"
132
133         multilib_copy_sources
134 }
135
136 multilib_src_configure() {
137         local myconf=()
138
139         # we can't alter S since build system writes to '../' and therefore
140         # we need to duplicate the whole structure
141         cd source3 || die
142
143         # Filter out -fPIE
144         [[ ${CHOST} == *-*bsd* ]] && myconf+=( --disable-pie )
145
146         #Allowing alpha/s390/sh to build
147         if use alpha || [[ ${ABI} == s390 ]] || use sh ; then
148                 local CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS}
149                 replace-flags -O? -O1
150         fi
151
152         # http://wiki.samba.org/index.php/CTDB_Setup
153         use cluster && myconf+=( --disable-pie )
154
155         # Upstream refuses to make this configurable
156         myconf+=( ac_cv_header_sys_capability_h=$(usex caps) )
157
158         # Notes:
159         # - automount is only needed in conjunction with NIS and we don't have that
160         # anymore => LDAP?
161         # - --without-dce-dfs and --without-nisplus-home can't be passed to configure but are disabled by default
162         econf "${myconf[@]}" \
163                 --with-piddir="${EPREFIX}"/var/run/samba \
164                 --sysconfdir="${EPREFIX}"/etc/samba \
165                 --localstatedir="${EPREFIX}"/var \
166                 $(multilib_native_use_enable debug developer) \
167                 --enable-largefile \
168                 --enable-socket-wrapper \
169                 --enable-nss-wrapper \
170                 $(multilib_native_use_enable swat) \
171                 $(multilib_native_use_enable debug dmalloc) \
172                 $(multilib_native_use_enable cups) \
173                 --disable-iprint \
174                 $(use_enable fam) \
175                 --enable-shared-libs \
176                 --disable-dnssd \
177                 $(multilib_native_use_enable avahi) \
178                 --with-fhs \
179                 --with-privatedir="${EPREFIX}"/var/lib/samba/private \
180                 --with-rootsbindir="${EPREFIX}"/var/cache/samba \
181                 --with-lockdir="${EPREFIX}"/var/cache/samba \
182                 --with-swatdir="${EPREFIX}"/usr/share/doc/${PF}/swat \
183                 --with-configdir="${EPREFIX}"/etc/samba \
184                 --with-logfilebase="${EPREFIX}"/var/log/samba \
185                 --with-pammodulesdir=$(getpam_mod_dir) \
186                 $(multilib_native_use_with dmapi) \
187                 --without-afs \
188                 --without-fake-kaserver \
189                 --without-vfs-afsacl \
190                 $(use_with ldap) \
191                 $(use_with ads) \
192                 $(use_with ads krb5 "${EPREFIX}"/usr) \
193                 $(use_with ads dnsupdate) \
194                 --without-automount \
195                 $(use_with pam) \
196                 $(use_with pam pam_smbpass) \
197                 $(use_with syslog) \
198                 $(use_with quota quotas) \
199                 $(use_with quota sys-quotas) \
200                 --without-utmp \
201                 --without-lib{talloc,tdb} \
202                 $(use_with netapi libnetapi) \
203                 $(use_with smbclient libsmbclient) \
204                 $(use_with smbsharemodes libsmbsharemodes) \
205                 $(use_with addns libaddns) \
206                 $(use_with cluster ctdb "${EPREFIX}"/usr) \
207                 $(use_with cluster cluster-support) \
208                 $(multilib_native_use_with acl acl-support) \
209                 $(use_with aio aio-support) \
210                 --with-sendfile-support \
211                 $(use_with winbind) \
212                 --with-shared-modules=${SHAREDMODS} \
213                 --without-included-popt \
214                 --without-included-iniparser
215 }
216
217 multilib_src_compile() {
218         cd source3 || die
219
220         # compile libs
221         if use addns ; then
222                 einfo "make addns library"
223                 emake libaddns
224         fi
225         if use netapi ; then
226                 einfo "make netapi library"
227                 emake libnetapi
228         fi
229         if use smbclient ; then
230                 einfo "make smbclient library"
231                 emake libsmbclient
232         fi
233         if use smbsharemodes ; then
234                 einfo "make smbsharemodes library"
235                 emake libsmbsharemodes
236         fi
237
238         # compile modules
239         emake modules
240
241         # compile pam moudles
242         if use pam ; then
243                 einfo "make pam modules"
244                 emake pam_modules
245         fi
246
247         # compile winbind nss modules
248         if use winbind ; then
249                 einfo "make nss modules"
250                 emake nss_modules
251         fi
252
253         # compile utilities
254         if multilib_is_native_abi; then
255                 if [ -n "${BINPROGS}" ] ; then
256                         einfo "make binprogs"
257                         emake ${BINPROGS}
258                 fi
259                 if [ -n "${SBINPROGS}" ] ; then
260                         einfo "make sbinprogs"
261                         emake ${SBINPROGS}
262                 fi
263         fi
264
265         if [ -n "${KRBPLUGIN}" ] ; then
266                 einfo "make krbplugin"
267                 emake ${KRBPLUGIN}${PLUGINEXT}
268         fi
269 }
270
271 multilib_src_install() {
272         cd source3 || die
273
274         # pkgconfig files installation needed, bug #464818
275         local pkgconfigdir=/usr/$(get_libdir)/pkgconfig
276
277         # install libs
278         if use addns ; then
279                 einfo "install addns library"
280                 emake installlibaddns DESTDIR="${D}"
281         fi
282         if use netapi ; then
283                 einfo "install netapi library"
284                 emake installlibnetapi DESTDIR="${D}"
285                 insinto $pkgconfigdir
286                 doins pkgconfig/netapi.pc
287         fi
288         if use smbclient ; then
289                 einfo "install smbclient library"
290                 emake installlibsmbclient DESTDIR="${D}"
291                 insinto $pkgconfigdir
292                 doins pkgconfig/smbclient.pc
293         fi
294         if use smbsharemodes ; then
295                 einfo "install smbsharemodes library"
296                 emake installlibsmbsharemodes DESTDIR="${D}"
297                 insinto $pkgconfigdir
298                 doins pkgconfig/smbsharemodes.pc
299         fi
300
301         # install modules
302         emake installmodules DESTDIR="${D}"
303
304         if use pam ; then
305                 einfo "install pam modules"
306                 emake installpammodules DESTDIR="${D}"
307
308                 if use winbind ; then
309                         newpamd "${CONFDIR}/system-auth-winbind.pam" system-auth-winbind
310                         doman ../docs/manpages/pam_winbind.8
311                         # bug #376853
312                         insinto /etc/security
313                         doins ../examples/pam_winbind/pam_winbind.conf || die
314                 fi
315
316                 newpamd "${CONFDIR}/samba.pam" samba
317                 dodoc pam_smbpass/README
318         fi
319
320         # Nsswitch extensions. Make link for wins and winbind resolvers
321         if use winbind ; then
322                 einfo "install libwbclient"
323                 emake installlibwbclient DESTDIR="${D}"
324                 dolib.so ../nsswitch/libnss_wins.so
325                 dosym libnss_wins.so /usr/$(get_libdir)/libnss_wins.so.2
326                 dolib.so ../nsswitch/libnss_winbind.so
327                 dosym libnss_winbind.so /usr/$(get_libdir)/libnss_winbind.so.2
328                 insinto $pkgconfigdir
329                 doins pkgconfig/wbclient.pc
330                 einfo "install libwbclient related manpages"
331                 doman ../docs/manpages/idmap_rid.8
332                 doman ../docs/manpages/idmap_hash.8
333                 if use ldap ; then
334                         doman ../docs/manpages/idmap_adex.8
335                         doman ../docs/manpages/idmap_ldap.8
336                 fi
337                 if use ads ; then
338                         doman ../docs/manpages/idmap_ad.8
339                 fi
340         fi
341
342         # install binaries
343         if multilib_is_native_abi; then
344                 insinto /usr
345                 for prog in ${SBINPROGS} ; do
346                         dosbin ${prog}
347                         doman ../docs/manpages/${prog/bin\/}*
348                 done
349
350                 for prog in ${BINPROGS} ; do
351                         dobin ${prog}
352                         doman ../docs/manpages/${prog/bin\/}*
353                 done
354
355                 # install scripts
356                 if use client ; then
357                         dobin script/findsmb
358                         doman ../docs/manpages/findsmb.1
359                 fi
360         fi
361
362         # install krbplugin
363         if [ -n "${KRBPLUGIN}" ] ; then
364                 if has_version app-crypt/mit-krb5 ; then
365                         insinto /usr/$(get_libdir)/krb5/plugins/libkrb5
366                         doins ${KRBPLUGIN}${PLUGINEXT}
367                 elif has_version app-crypt/heimdal ; then
368                         insinto /usr/$(get_libdir)/plugin/krb5
369                         doins ${KRBPLUGIN}${PLUGINEXT}
370                 fi
371                 insinto /usr
372                 for prog in ${KRBPLUGIN} ; do
373                         doman ../docs/manpages/${prog/bin\/}*
374                 done
375         fi
376 }
377
378 multilib_src_install_all() {
379         # install server components
380         if use server ; then
381                 doman docs/manpages/vfs* docs/manpages/samba.7
382
383                 diropts -m0700
384                 keepdir /var/lib/samba/private
385
386                 diropts -m1777
387                 keepdir /var/spool/samba
388
389                 diropts -m0755
390                 keepdir /var/{cache,log}/samba
391                 keepdir /var/lib/samba/{netlogon,profiles}
392                 keepdir /var/lib/samba/printers/{W32X86,WIN40,W32ALPHA,W32MIPS,W32PPC,X64,IA64,COLOR}
393                 keepdir /usr/$(get_libdir)/samba/{auth,pdb,rpc,idmap,nss_info,gpext}
394
395                 newconfd "${CONFDIR}/samba.confd" samba
396                 newinitd "${CONFDIR}/samba.initd" samba
397
398                 insinto /etc/samba
399                 doins "${CONFDIR}"/{smbusers,lmhosts}
400
401                 if use ldap ; then
402                         insinto /etc/openldap/schema
403                         doins examples/LDAP/samba.schema
404                 fi
405
406                 if use swat ; then
407                         insinto /etc/xinetd.d
408                         newins "${CONFDIR}/swat.xinetd" swat
409                         script/installswat.sh "${ED}" "${EROOT}/usr/share/doc/${PF}/swat" "${S}"
410                 fi
411
412                 dodoc MAINTAINERS.txt README* Roadmap WHATSNEW.txt docs/THANKS
413         fi
414
415         # install the spooler to cups
416         if use cups ; then
417                 dosym /usr/bin/smbspool $(cups-config --serverbin)/backend/smb
418         fi
419
420         # install misc files
421         insinto /etc/samba
422         doins examples/smb.conf.default
423         doman docs/manpages/smb.conf.5
424
425         insinto /usr/"$(get_libdir)"/samba
426         doins codepages/{valid.dat,upcase.dat,lowcase.dat}
427
428         # install docs
429         if use doc ; then
430                 dohtml -r docs/htmldocs/.
431                 dodoc docs/*.pdf
432         fi
433
434         # install examples
435         if use examples ; then
436                 insinto /usr/share/doc/${PF}/examples
437
438                 if use smbclient ; then
439                         doins -r examples/libsmbclient
440                 fi
441
442                 if use winbind ; then
443                         doins -r examples/pam_winbind examples/nss
444                 fi
445
446                 if use server ; then
447                         cd examples || die
448                         doins -r auth autofs dce-dfs LDAP logon misc pdb \
449                                 perfcounter printer-accounting printing scripts tridge \
450                                 validchars VFS
451                 fi
452         fi
453
454         # Remove empty installation directories
455         rmdir --ignore-fail-on-non-empty \
456                 "${ED}/usr/$(get_libdir)/samba" \
457                 "${ED}/usr"/{sbin,bin} \
458                 "${ED}/usr/share"/{man,locale,} \
459                 "${ED}/var"/{run,lib/samba/private,lib/samba,lib,cache/samba,cache,} \
460         #       || die "tried to remove non-empty dirs, this seems like a bug in the ebuild"
461
462         systemd_dotmpfilesd "${FILESDIR}"/samba.conf
463         systemd_dounit "${FILESDIR}"/nmbd.service
464         systemd_dounit "${FILESDIR}"/smbd.{service,socket}
465         systemd_newunit "${FILESDIR}"/smbd_at.service 'smbd@.service'
466         systemd_dounit "${FILESDIR}"/winbindd.service
467 }
468
469 pkg_postinst() {
470         elog "Samba 3.6 has adopted a number of improved security defaults that"
471         elog "will impact on existing users of Samba."
472         elog "                  client ntlmv2 auth = yes"
473         elog "                  client use spnego principal = no"
474         elog "                  send spnego principal = no"
475         elog ""
476         elog "SMB2 protocol support in 3.6.0 is fully functional and can be "
477         elog "enabled by setting 'max protocol = smb2'. SMB2 is a new "
478         elog "implementation of the SMB protocol used by Windows Vista and higher"
479         elog ""
480         elog "For further information make sure to read the release notes at"
481         elog "http://samba.org/samba/history/${P}.html and "
482         elog "http://samba.org/samba/history/${PN}-3.6.0.html"
483 }