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