blob: 5f227c892da5c912121f0335fe00e03c6357ef8f [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001HOMEPAGE = "https://www.samba.org/"
2SECTION = "console/network"
3
4LICENSE = "GPL-3.0+ & LGPL-3.0+ & GPL-2.0+"
5LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504 \
6 file://${COREBASE}/meta/files/common-licenses/LGPL-3.0;md5=bfccfe952269fff2b407dd11f2f3083b \
7 file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6 "
8
9SAMBA_MIRROR = "http://samba.org/samba/ftp"
10MIRRORS += "\
11${SAMBA_MIRROR} http://mirror.internode.on.net/pub/samba \n \
12${SAMBA_MIRROR} http://www.mirrorservice.org/sites/ftp.samba.org \n \
13"
14
15SRC_URI = "${SAMBA_MIRROR}/stable/samba-${PV}.tar.gz \
16 file://smb.conf \
17 file://16-do-not-check-xsltproc-manpages.patch \
18 file://20-do-not-import-target-module-while-cross-compile.patch \
19 file://21-add-config-option-without-valgrind.patch \
20 file://netdb_defines.patch \
21 file://glibc_only.patch \
22 file://iconv-4.7.0.patch \
23 file://dnsserver-4.7.0.patch \
24 file://smb_conf-4.7.0.patch \
25 file://volatiles.03_samba \
26 file://0001-waf-add-support-of-cross_compile.patch \
27 file://0001-lib-replace-wscript-Avoid-generating-nested-main-fun.patch \
28 file://0002-util_sec.c-Move-__thread-variable-to-global-scope.patch \
Andrew Geisslere231d582020-05-05 08:53:09 -050029 file://0001-Add-options-to-configure-the-use-of-libbsd.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050030 "
31SRC_URI_append_libc-musl = " \
32 file://samba-pam.patch \
33 file://samba-4.3.9-remove-getpwent_r.patch \
34 file://cmocka-uintptr_t.patch \
35 file://0001-samba-fix-musl-lib-without-innetgr.patch \
36 "
37
38SRC_URI[md5sum] = "e7906580bf06dae087e99ef8254f327d"
39SRC_URI[sha256sum] = "49eb6426e97cbf538e416e51ed8535930382512ad2d13d5ffd7f4336aa7faf63"
40
41UPSTREAM_CHECK_REGEX = "samba\-(?P<pver>4\.10(\.\d+)+).tar.gz"
42
43inherit systemd waf-samba cpan-base perlnative update-rc.d
44# remove default added RDEPENDS on perl
45RDEPENDS_${PN}_remove = "perl"
46
Andrew Geisslere231d582020-05-05 08:53:09 -050047DEPENDS += "readline virtual/libiconv zlib popt libtalloc libtdb libtevent libldb libaio libpam libtasn1 jansson"
Andrew Geissler82c905d2020-04-13 13:39:40 -050048
49inherit features_check
50REQUIRED_DISTRO_FEATURES = "pam"
51
52DEPENDS_append_libc-musl = " libtirpc"
53CFLAGS_append_libc-musl = " -I${STAGING_INCDIR}/tirpc"
54LDFLAGS_append_libc-musl = " -ltirpc"
55
56INITSCRIPT_NAME = "samba"
57INITSCRIPT_PARAMS = "start 20 3 5 . stop 20 0 1 6 ."
58
59SYSTEMD_PACKAGES = "${PN}-base ${PN}-ad-dc winbind"
60SYSTEMD_SERVICE_${PN}-base = "nmb.service smb.service"
61SYSTEMD_SERVICE_${PN}-ad-dc = "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'samba.service', '', d)}"
62SYSTEMD_SERVICE_winbind = "winbind.service"
63
64# There are prerequisite settings to enable ad-dc, so disable the service by default.
65# Reference:
66# https://wiki.samba.org/index.php/Setting_up_Samba_as_an_Active_Directory_Domain_Controller
67SYSTEMD_AUTO_ENABLE_${PN}-ad-dc = "disable"
68
69#cross_compile cannot use preforked process, since fork process earlier than point subproces.popen
70#to cross Popen
71export WAF_NO_PREFORK="yes"
72
73# Use krb5. Build active domain controller.
74#
75PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd zeroconf', d)} \
76 acl cups ad-dc gnutls ldap mitkrb5 \
77"
78
79RDEPENDS_${PN}-ctdb-tests += "bash util-linux-getopt"
80
81PACKAGECONFIG[acl] = "--with-acl-support,--without-acl-support,acl"
82PACKAGECONFIG[fam] = "--with-fam,--without-fam,gamin"
83PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,cups"
84PACKAGECONFIG[ldap] = "--with-ldap,--without-ldap,openldap"
85PACKAGECONFIG[sasl] = ",,cyrus-sasl"
86PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
87PACKAGECONFIG[dmapi] = "--with-dmapi,--without-dmapi,dmapi"
88PACKAGECONFIG[zeroconf] = "--enable-avahi,--disable-avahi,avahi"
89PACKAGECONFIG[valgrind] = ",--without-valgrind,valgrind,"
90PACKAGECONFIG[lttng] = "--with-lttng, --without-lttng,lttng-ust"
91PACKAGECONFIG[archive] = "--with-libarchive, --without-libarchive, libarchive"
92PACKAGECONFIG[libunwind] = ", , libunwind"
93PACKAGECONFIG[gpgme] = ",--without-gpgme,,"
94PACKAGECONFIG[lmdb] = ",--without-ldb-lmdb,lmdb,"
Andrew Geisslere231d582020-05-05 08:53:09 -050095PACKAGECONFIG[libbsd] = "--with-libbsd, --without-libbsd, libbsd"
Andrew Geissler82c905d2020-04-13 13:39:40 -050096
97# Building the AD (Active Directory) DC (Domain Controller) requires GnuTLS,
98# And ad-dc doesn't work with mitkrb5 for versions prior to 4.7.0 according to:
99# http://samba.2283325.n4.nabble.com/samba-4-6-6-Unknown-dependency-kdc-in-service-kdc-objlist-td4722096.html
100# So the working combination is:
101# 1) ad-dc: enable, gnutls: enable, mitkrb5: disable
102# 2) ad-dc: disable, gnutls: enable/disable, mitkrb5: enable
103#
104# We are now at 4.7.0, so take the above with a grain of salt. We do not need to know where
105# krb5kdc is unless ad-dc is enabled, but we tell configure anyhow.
106#
107PACKAGECONFIG[ad-dc] = "--with-experimental-mit-ad-dc,--without-ad-dc,,"
108PACKAGECONFIG[gnutls] = "--enable-gnutls,--disable-gnutls,gnutls,"
109PACKAGECONFIG[mitkrb5] = "--with-system-mitkrb5 --with-system-mitkdc=/usr/sbin/krb5kdc,,krb5,"
110
111SAMBA4_IDMAP_MODULES="idmap_ad,idmap_rid,idmap_adex,idmap_hash,idmap_tdb2"
112SAMBA4_PDB_MODULES="pdb_tdbsam,${@bb.utils.contains('PACKAGECONFIG', 'ldap', 'pdb_ldap,', '', d)}pdb_ads,pdb_smbpasswd,pdb_wbc_sam,pdb_samba4"
113SAMBA4_AUTH_MODULES="auth_unix,auth_wbc,auth_server,auth_netlogond,auth_script,auth_samba4"
114SAMBA4_MODULES="${SAMBA4_IDMAP_MODULES},${SAMBA4_PDB_MODULES},${SAMBA4_AUTH_MODULES}"
115
116# These libraries are supposed to replace others supplied by packages, but decorate the names of
117# .so files so there will not be a conflict. This is not done consistantly, so be very careful
118# when adding to this list.
119#
120SAMBA4_LIBS="heimdal,cmocka,NONE"
121
122EXTRA_OECONF += "--enable-fhs \
123 --with-piddir=/run \
124 --with-sockets-dir=/run/samba \
125 --with-modulesdir=${libdir}/samba \
126 --with-lockdir=${localstatedir}/lib/samba \
127 --with-cachedir=${localstatedir}/lib/samba \
128 --disable-rpath-install \
129 --with-shared-modules=${SAMBA4_MODULES} \
130 --bundled-libraries=${SAMBA4_LIBS} \
131 ${@oe.utils.conditional('TARGET_ARCH', 'x86_64', '', '--disable-glusterfs', d)} \
132 --with-cluster-support \
133 --with-profiling-data \
134 --with-libiconv=${STAGING_DIR_HOST}${prefix} \
135 --with-pam --with-pammodulesdir=${base_libdir}/security \
136 "
137
138LDFLAGS += "-Wl,-z,relro,-z,now ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
139
140do_install_append() {
141 for section in 1 5 7; do
142 install -d ${D}${mandir}/man$section
143 install -m 0644 ctdb/doc/*.$section ${D}${mandir}/man$section
144 done
145 for section in 1 5 7 8; do
146 install -d ${D}${mandir}/man$section
147 install -m 0644 docs/manpages/*.$section ${D}${mandir}/man$section
148 done
149
150 install -d ${D}${systemd_system_unitdir}
151 install -m 0644 ${S}/bin/default/packaging/systemd/*.service ${D}${systemd_system_unitdir}/
152 sed -e 's,\(ExecReload=\).*\(/kill\),\1${base_bindir}\2,' \
153 -e 's,/etc/sysconfig/samba,${sysconfdir}/default/samba,' \
154 -i ${D}${systemd_system_unitdir}/*.service
155
156 if [ "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'yes', 'no', d)}" = "no" ]; then
157 rm -f ${D}${systemd_system_unitdir}/samba.service
158 fi
159
160 install -d ${D}${sysconfdir}/tmpfiles.d
161 install -m644 packaging/systemd/samba.conf.tmp ${D}${sysconfdir}/tmpfiles.d/samba.conf
162 echo "d ${localstatedir}/log/samba 0755 root root -" \
163 >> ${D}${sysconfdir}/tmpfiles.d/samba.conf
164 install -d ${D}${sysconfdir}/init.d
165 install -m 0755 packaging/sysv/samba.init ${D}${sysconfdir}/init.d/samba
166 sed -e 's,/opt/samba/bin,${sbindir},g' \
167 -e 's,/opt/samba/smb.conf,${sysconfdir}/samba/smb.conf,g' \
168 -e 's,/opt/samba/log,${localstatedir}/log/samba,g' \
169 -e 's,/etc/init.d/samba.server,${sysconfdir}/init.d/samba,g' \
170 -e 's,/usr/bin,${base_bindir},g' \
171 -i ${D}${sysconfdir}/init.d/samba
172
173 install -d ${D}${sysconfdir}/samba
174 echo "127.0.0.1 localhost" > ${D}${sysconfdir}/samba/lmhosts
175 install -m644 ${WORKDIR}/smb.conf ${D}${sysconfdir}/samba/smb.conf
176 install -D -m 644 ${WORKDIR}/volatiles.03_samba ${D}${sysconfdir}/default/volatiles/03_samba
177
178 install -d ${D}${sysconfdir}/default
179 install -m644 packaging/systemd/samba.sysconfig ${D}${sysconfdir}/default/samba
180
181 # the items are from ctdb/tests/run_tests.sh
182 for d in onnode takeover tool eventscripts cunit simple complex; do
183 testdir=${D}${datadir}/ctdb-tests/$d
184 install -d $testdir
185 cp ${S}/ctdb/tests/$d/*.sh $testdir
186 cp -r ${S}/ctdb/tests/$d/scripts ${S}/ctdb/tests/$d/stubs $testdir || true
187 done
188
189 # fix file-rdeps qa warning
190 if [ -f ${D}${bindir}/onnode ]; then
191 sed -i 's:\(#!/bin/\)bash:\1sh:' ${D}${bindir}/onnode
192 fi
193
194 chmod 0750 ${D}${sysconfdir}/sudoers.d || true
195 rm -rf ${D}/run ${D}${localstatedir}/run ${D}${localstatedir}/log
196
197 for f in samba-gpupdate samba_upgradedns samba_spnupdate samba_kcc samba_dnsupdate; do
198 if [ -f "${D}${sbindir}/$f" ]; then
199 sed -i -e 's,${PYTHON},/usr/bin/env python3,g' ${D}${sbindir}/$f
200 fi
201 done
202 if [ -f "${D}${bindir}/samba-tool" ]; then
203 sed -i -e 's,${PYTHON},/usr/bin/env python3,g' ${D}${bindir}/samba-tool
204 fi
205
206}
207
208PACKAGES =+ "${PN}-python3 ${PN}-pidl \
209 ${PN}-dsdb-modules ${PN}-testsuite registry-tools \
210 winbind \
211 ${PN}-common ${PN}-base ${PN}-ad-dc ${PN}-ctdb-tests \
212 smbclient ${PN}-client ${PN}-server ${PN}-test"
213
214python samba_populate_packages() {
215 def module_hook(file, pkg, pattern, format, basename):
216 pn = d.getVar('PN')
217 d.appendVar('RRECOMMENDS_%s-base' % pn, ' %s' % pkg)
218
219 mlprefix = d.getVar('MLPREFIX') or ''
220 pam_libdir = d.expand('${base_libdir}/security')
221 pam_pkgname = mlprefix + 'pam-plugin%s'
222 do_split_packages(d, pam_libdir, '^pam_(.*)\.so$', pam_pkgname, 'PAM plugin for %s', extra_depends='', prepend=True)
223
224 libdir = d.getVar('libdir')
225 do_split_packages(d, libdir, '^lib(.*)\.so\..*$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True, allow_links=True)
226 pkglibdir = '%s/samba' % libdir
227 do_split_packages(d, pkglibdir, '^lib(.*)\.so$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True)
228 moduledir = '%s/samba/auth' % libdir
229 do_split_packages(d, moduledir, '^(.*)\.so$', 'samba-auth-%s', 'Samba %s authentication backend', hook=module_hook, extra_depends='', prepend=True)
230 moduledir = '%s/samba/pdb' % libdir
231 do_split_packages(d, moduledir, '^(.*)\.so$', 'samba-pdb-%s', 'Samba %s password backend', hook=module_hook, extra_depends='', prepend=True)
232}
233
234PACKAGESPLITFUNCS_prepend = "samba_populate_packages "
235PACKAGES_DYNAMIC = "samba-auth-.* samba-pdb-.*"
236
237RDEPENDS_${PN} += "${PN}-base ${PN}-python3 ${PN}-dsdb-modules python3"
238RDEPENDS_${PN}-python3 += "pytalloc python3-tdb"
239
240FILES_${PN}-base = "${sbindir}/nmbd \
241 ${sbindir}/smbd \
242 ${sysconfdir}/init.d \
243 ${systemd_system_unitdir}/nmb.service \
244 ${systemd_system_unitdir}/smb.service"
245
246FILES_${PN}-ad-dc = "${sbindir}/samba \
247 ${systemd_system_unitdir}/samba.service \
248 ${libdir}/krb5/plugins/kdb/samba.so \
249"
250RDEPENDS_${PN}-ad-dc = "krb5-kdc"
251
252FILES_${PN}-ctdb-tests = "${bindir}/ctdb_run_tests \
253 ${bindir}/ctdb_run_cluster_tests \
254 ${sysconfdir}/ctdb/nodes \
255 ${datadir}/ctdb-tests \
256 ${datadir}/ctdb/tests \
257 ${localstatedir}/lib/ctdb \
258 "
259
260FILES_${BPN}-common = "${sysconfdir}/default \
261 ${sysconfdir}/samba \
262 ${sysconfdir}/tmpfiles.d \
263 ${localstatedir}/lib/samba \
264 ${localstatedir}/spool/samba \
265"
266
267FILES_${PN} += "${libdir}/vfs/*.so \
268 ${libdir}/charset/*.so \
269 ${libdir}/*.dat \
270 ${libdir}/auth/*.so \
271 ${datadir}/ctdb/events/* \
272"
273
274FILES_${PN}-dsdb-modules = "${libdir}/samba/ldb"
275
276FILES_${PN}-testsuite = "${bindir}/gentest \
277 ${bindir}/locktest \
278 ${bindir}/masktest \
279 ${bindir}/ndrdump \
280 ${bindir}/smbtorture"
281
282FILES_registry-tools = "${bindir}/regdiff \
283 ${bindir}/regpatch \
284 ${bindir}/regshell \
285 ${bindir}/regtree"
286
287FILES_winbind = "${sbindir}/winbindd \
288 ${bindir}/wbinfo \
289 ${bindir}/ntlm_auth \
290 ${libdir}/samba/idmap \
291 ${libdir}/samba/nss_info \
292 ${libdir}/winbind_krb5_locator.so \
293 ${libdir}/winbind-krb5-localauth.so \
294 ${sysconfdir}/init.d/winbind \
295 ${systemd_system_unitdir}/winbind.service"
296
297FILES_${PN}-python3 = "${PYTHON_SITEPACKAGES_DIR}"
298
299FILES_smbclient = "${bindir}/cifsdd \
300 ${bindir}/rpcclient \
301 ${bindir}/smbcacls \
302 ${bindir}/smbclient \
303 ${bindir}/smbcquotas \
304 ${bindir}/smbget \
305 ${bindir}/smbspool \
306 ${bindir}/smbtar \
307 ${bindir}/smbtree \
308 ${libdir}/samba/smbspool_krb5_wrapper"
309
310RDEPENDS_${PN}-pidl_append = " perl"
311FILES_${PN}-pidl = "${bindir}/pidl ${datadir}/perl5/Parse"
312
313RDEPENDS_${PN}-client = "\
314 smbclient \
315 winbind \
316 registry-tools \
317 ${PN}-pidl \
318 "
319
320ALLOW_EMPTY_${PN}-client = "1"
321
322RDEPENDS_${PN}-server = "\
323 ${PN} \
324 winbind \
325 registry-tools \
326 "
327
328ALLOW_EMPTY_${PN}-server = "1"
329
330RDEPENDS_${PN}-test = "\
331 ${PN}-ctdb-tests \
332 ${PN}-testsuite \
333 "
334
335ALLOW_EMPTY_${PN}-test = "1"