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