blob: d824eacf9e576e36f9805c220a058571b09e36c4 [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 Bishopb809eb92019-09-18 06:27:43 -040037SRC_URI[md5sum] = "f3c722bbcd903479008fa1b529f56365"
38SRC_URI[sha256sum] = "c41f05fb567f7359998b451543501c7690a2bf6551d658a76bd6916316a410f4"
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 Bishopc342db32019-05-15 21:57:59 -040048inherit distro_features_check
49REQUIRED_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
192 chmod 0750 ${D}${sysconfdir}/sudoers.d
193 rm -rf ${D}/run ${D}${localstatedir}/run ${D}${localstatedir}/log
Brad Bishop26bdd442019-08-16 17:08:17 -0400194
195 sed -i -e 's,${PYTHON},/usr/bin/env python3/,g' ${D}${sbindir}/samba-gpupdate
196 sed -i -e 's,${PYTHON},/usr/bin/env python3/,g' ${D}${sbindir}/samba_upgradedns
197 sed -i -e 's,${PYTHON},/usr/bin/env python3/,g' ${D}${sbindir}/samba_spnupdate
198 sed -i -e 's,${PYTHON},/usr/bin/env python3/,g' ${D}${sbindir}/samba_kcc
199 sed -i -e 's,${PYTHON},/usr/bin/env python3/,g' ${D}${sbindir}/samba_dnsupdate
200 sed -i -e 's,${PYTHON},/usr/bin/env python3/,g' ${D}${bindir}/samba-tool
201
Brad Bishopc342db32019-05-15 21:57:59 -0400202}
203
Brad Bishop26bdd442019-08-16 17:08:17 -0400204PACKAGES =+ "${PN}-python3 ${PN}-pidl \
Brad Bishopc342db32019-05-15 21:57:59 -0400205 ${PN}-dsdb-modules ${PN}-testsuite registry-tools \
206 winbind \
207 ${PN}-common ${PN}-base ${PN}-ad-dc ${PN}-ctdb-tests \
208 smbclient ${PN}-client ${PN}-server ${PN}-test"
209
210python samba_populate_packages() {
211 def module_hook(file, pkg, pattern, format, basename):
212 pn = d.getVar('PN')
213 d.appendVar('RRECOMMENDS_%s-base' % pn, ' %s' % pkg)
214
215 mlprefix = d.getVar('MLPREFIX') or ''
216 pam_libdir = d.expand('${base_libdir}/security')
217 pam_pkgname = mlprefix + 'pam-plugin%s'
218 do_split_packages(d, pam_libdir, '^pam_(.*)\.so$', pam_pkgname, 'PAM plugin for %s', extra_depends='', prepend=True)
219
220 libdir = d.getVar('libdir')
221 do_split_packages(d, libdir, '^lib(.*)\.so\..*$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True, allow_links=True)
222 pkglibdir = '%s/samba' % libdir
223 do_split_packages(d, pkglibdir, '^lib(.*)\.so$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True)
224 moduledir = '%s/samba/auth' % libdir
225 do_split_packages(d, moduledir, '^(.*)\.so$', 'samba-auth-%s', 'Samba %s authentication backend', hook=module_hook, extra_depends='', prepend=True)
226 moduledir = '%s/samba/pdb' % libdir
227 do_split_packages(d, moduledir, '^(.*)\.so$', 'samba-pdb-%s', 'Samba %s password backend', hook=module_hook, extra_depends='', prepend=True)
228}
229
230PACKAGESPLITFUNCS_prepend = "samba_populate_packages "
231PACKAGES_DYNAMIC = "samba-auth-.* samba-pdb-.*"
232
Brad Bishop26bdd442019-08-16 17:08:17 -0400233RDEPENDS_${PN} += "${PN}-base ${PN}-python3 ${PN}-dsdb-modules python3"
234RDEPENDS_${PN}-python3 += "pytalloc python3-tdb"
Brad Bishopc342db32019-05-15 21:57:59 -0400235
236FILES_${PN}-base = "${sbindir}/nmbd \
237 ${sbindir}/smbd \
238 ${sysconfdir}/init.d \
239 ${systemd_system_unitdir}/nmb.service \
240 ${systemd_system_unitdir}/smb.service"
241
242FILES_${PN}-ad-dc = "${sbindir}/samba \
243 ${systemd_system_unitdir}/samba.service \
244 ${libdir}/krb5/plugins/kdb/samba.so \
245"
246RDEPENDS_${PN}-ad-dc = "krb5-kdc"
247
248FILES_${PN}-ctdb-tests = "${bindir}/ctdb_run_tests \
249 ${bindir}/ctdb_run_cluster_tests \
250 ${sysconfdir}/ctdb/nodes \
251 ${datadir}/ctdb-tests \
252 ${datadir}/ctdb/tests \
253 ${localstatedir}/lib/ctdb \
254 "
255
256FILES_${BPN}-common = "${sysconfdir}/default \
257 ${sysconfdir}/samba \
258 ${sysconfdir}/tmpfiles.d \
259 ${localstatedir}/lib/samba \
260 ${localstatedir}/spool/samba \
261"
262
263FILES_${PN} += "${libdir}/vfs/*.so \
264 ${libdir}/charset/*.so \
265 ${libdir}/*.dat \
266 ${libdir}/auth/*.so \
Brad Bishop26bdd442019-08-16 17:08:17 -0400267 ${datadir}/ctdb/events/* \
Brad Bishopc342db32019-05-15 21:57:59 -0400268"
269
270FILES_${PN}-dsdb-modules = "${libdir}/samba/ldb"
271
272FILES_${PN}-testsuite = "${bindir}/gentest \
273 ${bindir}/locktest \
274 ${bindir}/masktest \
275 ${bindir}/ndrdump \
276 ${bindir}/smbtorture"
277
278FILES_registry-tools = "${bindir}/regdiff \
279 ${bindir}/regpatch \
280 ${bindir}/regshell \
281 ${bindir}/regtree"
282
283FILES_winbind = "${sbindir}/winbindd \
284 ${bindir}/wbinfo \
285 ${bindir}/ntlm_auth \
286 ${libdir}/samba/idmap \
287 ${libdir}/samba/nss_info \
288 ${libdir}/winbind_krb5_locator.so \
289 ${libdir}/winbind-krb5-localauth.so \
290 ${sysconfdir}/init.d/winbind \
291 ${systemd_system_unitdir}/winbind.service"
292
Brad Bishop26bdd442019-08-16 17:08:17 -0400293FILES_${PN}-python3 = "${PYTHON_SITEPACKAGES_DIR}"
Brad Bishopc342db32019-05-15 21:57:59 -0400294
295FILES_smbclient = "${bindir}/cifsdd \
296 ${bindir}/rpcclient \
297 ${bindir}/smbcacls \
298 ${bindir}/smbclient \
299 ${bindir}/smbcquotas \
300 ${bindir}/smbget \
301 ${bindir}/smbspool \
302 ${bindir}/smbtar \
303 ${bindir}/smbtree \
304 ${libdir}/samba/smbspool_krb5_wrapper"
305
306RDEPENDS_${PN}-pidl_append = " perl"
307FILES_${PN}-pidl = "${bindir}/pidl ${datadir}/perl5/Parse"
308
309RDEPENDS_${PN}-client = "\
310 smbclient \
311 winbind \
312 registry-tools \
313 ${PN}-pidl \
Brad Bishop26bdd442019-08-16 17:08:17 -0400314 "
Brad Bishopc342db32019-05-15 21:57:59 -0400315
316ALLOW_EMPTY_${PN}-client = "1"
317
318RDEPENDS_${PN}-server = "\
319 ${PN} \
320 winbind \
321 registry-tools \
Brad Bishop26bdd442019-08-16 17:08:17 -0400322 "
Brad Bishopc342db32019-05-15 21:57:59 -0400323
324ALLOW_EMPTY_${PN}-server = "1"
325
326RDEPENDS_${PN}-test = "\
327 ${PN}-ctdb-tests \
328 ${PN}-testsuite \
329 "
330
331ALLOW_EMPTY_${PN}-test = "1"