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