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