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