blob: 84eee4419531a6201b43a0adc29bce0a4b265449 [file] [log] [blame]
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00001HOMEPAGE = "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-or-later;md5=c51d3eef3be114124d11349ca0d7e117 \
7 file://${COREBASE}/meta/files/common-licenses/GPL-2.0-or-later;md5=fed54355545ffd980b814dab4a3b312c"
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://volatiles.03_samba \
18 file://0001-Don-t-check-xsltproc-manpages.patch \
19 file://0002-do-not-import-target-module-while-cross-compile.patch \
20 file://0003-Add-config-option-without-valgrind.patch \
21 file://0004-Add-options-to-configure-the-use-of-libbsd.patch \
22 file://0005-samba-build-dnsserver_common-code.patch \
23 file://0001-Fix-pyext_PATTERN-for-cross-compilation.patch \
24 "
25
26SRC_URI:append:libc-musl = " \
27 file://netdb_defines.patch \
28 file://samba-pam.patch \
29 file://samba-4.3.9-remove-getpwent_r.patch \
30 file://cmocka-uintptr_t.patch \
31 file://samba-fix-musl-lib-without-innetgr.patch \
32 "
33
34SRC_URI[sha256sum] = "155d9c2dfb06a18104422987590858bfe5e9783ebebe63882e7e7f07eaaa512d"
35
36UPSTREAM_CHECK_REGEX = "samba\-(?P<pver>4\.14(\.\d+)+).tar.gz"
37
38inherit systemd waf-samba cpan-base perlnative update-rc.d perl-version pkgconfig
39
40# CVE-2011-2411 is valnerble only on HP NonStop Servers.
41CVE_CHECK_IGNORE += "CVE-2011-2411"
42
43# remove default added RDEPENDS on perl
44RDEPENDS:${PN}:remove = "perl"
45
46DEPENDS += "readline virtual/libiconv zlib popt libtalloc libtdb libtevent libldb libaio libpam libtasn1 jansson libparse-yapp-perl-native gnutls"
47
48inherit 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
55COMPATIBLE_HOST:riscv32 = "null"
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 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,"
96PACKAGECONFIG[libbsd] = "--with-libbsd, --without-libbsd, libbsd"
97PACKAGECONFIG[ad-dc] = "--with-experimental-mit-ad-dc,--without-ad-dc,python3-markdown python3-dnspython,"
98PACKAGECONFIG[mitkrb5] = "--with-system-mitkrb5 --with-system-mitkdc=/usr/sbin/krb5kdc,,krb5,"
99
100SAMBA4_IDMAP_MODULES="idmap_ad,idmap_rid,idmap_adex,idmap_hash,idmap_tdb2"
101SAMBA4_PDB_MODULES="pdb_tdbsam,${@bb.utils.contains('PACKAGECONFIG', 'ldap', 'pdb_ldap,', '', d)}pdb_ads,pdb_smbpasswd,pdb_wbc_sam,pdb_samba4"
102SAMBA4_AUTH_MODULES="auth_unix,auth_wbc,auth_server,auth_netlogond,auth_script,auth_samba4"
103SAMBA4_MODULES="${SAMBA4_IDMAP_MODULES},${SAMBA4_PDB_MODULES},${SAMBA4_AUTH_MODULES}"
104
105# These libraries are supposed to replace others supplied by packages, but decorate the names of
106# .so files so there will not be a conflict. This is not done consistantly, so be very careful
107# when adding to this list.
108#
109SAMBA4_LIBS="heimdal,cmocka,NONE"
110
111EXTRA_OECONF += "--enable-fhs \
112 --with-piddir=/run \
113 --with-sockets-dir=/run/samba \
114 --with-modulesdir=${libdir}/samba \
115 --with-lockdir=${localstatedir}/lib/samba \
116 --with-cachedir=${localstatedir}/lib/samba \
117 --disable-rpath-install \
118 --with-shared-modules=${SAMBA4_MODULES} \
119 --bundled-libraries=${SAMBA4_LIBS} \
120 ${@oe.utils.conditional('TARGET_ARCH', 'x86_64', '', '--disable-glusterfs', d)} \
121 --with-cluster-support \
122 --with-profiling-data \
123 --with-libiconv=${STAGING_DIR_HOST}${prefix} \
124 --with-pam --with-pammodulesdir=${base_libdir}/security \
125 "
126
127LDFLAGS += "-Wl,-z,relro,-z,now ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
128
129do_configure:append () {
130 cd ${S}/pidl/
131 perl Makefile.PL PREFIX=${prefix}
132 sed -e 's,VENDORPREFIX)/lib/perl,VENDORPREFIX)/${baselib}/perl,g' \
133 -e 's,PERLPREFIX)/lib/perl,PERLPREFIX)/${baselib}/perl,g' -i Makefile
134
135}
136
137do_compile:append () {
138 oe_runmake -C ${S}/pidl
139}
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 cunit eventd eventscripts onnode shellcheck takeover takeover_helper tool; do
184 testdir=${D}${datadir}/ctdb-tests/UNIT/$d
185 install -d $testdir
186 cp ${S}/ctdb/tests/UNIT/$d/*.sh $testdir
187 cp -r ${S}/ctdb/tests/UNIT/$d/scripts ${S}/ctdb/tests/UNIT/$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 samba_downgrade_db; 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 oe_runmake -C ${S}/pidl DESTDIR=${D} install_vendor
208 find ${D}${libdir}/ -type f -name "perllocal.pod" | xargs rm -f
209 rm -rf ${D}${libdir}/perl5/vendor_perl/${PERLVERSION}/${BUILD_SYS}/auto/Parse/Pidl/.packlist
210 sed -i -e '1s,#!.*perl,#!${bindir}/env perl,' ${D}${bindir}/pidl
211}
212
213PACKAGES =+ "${PN}-python3 ${PN}-pidl \
214 ${PN}-dsdb-modules ${PN}-testsuite registry-tools \
215 winbind \
216 ${PN}-common ${PN}-base ${PN}-ad-dc ${PN}-ctdb-tests \
217 smbclient ${PN}-client ${PN}-server ${PN}-test"
218
219python samba_populate_packages() {
220 def module_hook(file, pkg, pattern, format, basename):
221 pn = d.getVar('PN')
222 d.appendVar('RRECOMMENDS:%s-base' % pn, ' %s' % pkg)
223
224 mlprefix = d.getVar('MLPREFIX') or ''
225 pam_libdir = d.expand('${base_libdir}/security')
226 pam_pkgname = mlprefix + 'pam-plugin%s'
227 do_split_packages(d, pam_libdir, r'^pam_(.*)\.so$', pam_pkgname, 'PAM plugin for %s', extra_depends='', prepend=True)
228
229 libdir = d.getVar('libdir')
230 do_split_packages(d, libdir, r'^lib(.*)\.so\..*$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True, allow_links=True)
231 pkglibdir = '%s/samba' % libdir
232 do_split_packages(d, pkglibdir, r'^lib(.*)\.so$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True)
233 moduledir = '%s/samba/auth' % libdir
234 do_split_packages(d, moduledir, r'^(.*)\.so$', 'samba-auth-%s', 'Samba %s authentication backend', hook=module_hook, extra_depends='', prepend=True)
235 moduledir = '%s/samba/pdb' % libdir
236 do_split_packages(d, moduledir, r'^(.*)\.so$', 'samba-pdb-%s', 'Samba %s password backend', hook=module_hook, extra_depends='', prepend=True)
237}
238
239PACKAGESPLITFUNCS:prepend = "samba_populate_packages "
240PACKAGES_DYNAMIC = "samba-auth-.* samba-pdb-.*"
241
242RDEPENDS:${PN} += "${PN}-base ${PN}-python3 ${PN}-dsdb-modules python3"
243RDEPENDS:${PN}-python3 += "pytalloc python3-tdb pyldb"
244
245FILES:${PN}-base = "${sbindir}/nmbd \
246 ${sbindir}/smbd \
247 ${sysconfdir}/init.d \
248 ${systemd_system_unitdir}/nmb.service \
249 ${systemd_system_unitdir}/smb.service"
250
251FILES:${PN}-ad-dc = "${sbindir}/samba \
252 ${systemd_system_unitdir}/samba.service \
253 ${libdir}/krb5/plugins/kdb/samba.so \
254"
255RDEPENDS:${PN}-ad-dc = "krb5-kdc"
256
257FILES:${PN}-ctdb-tests = "${bindir}/ctdb_run_tests \
258 ${bindir}/ctdb_run_cluster_tests \
259 ${sysconfdir}/ctdb/nodes \
260 ${datadir}/ctdb-tests \
261 ${datadir}/ctdb/tests \
262 ${localstatedir}/lib/ctdb \
263 "
264
265FILES:${BPN}-common = "${sysconfdir}/default \
266 ${sysconfdir}/samba \
267 ${sysconfdir}/tmpfiles.d \
268 ${localstatedir}/lib/samba \
269 ${localstatedir}/spool/samba \
270"
271
272FILES:${PN} += "${libdir}/vfs/*.so \
273 ${libdir}/charset/*.so \
274 ${libdir}/*.dat \
275 ${libdir}/auth/*.so \
276 ${datadir}/ctdb/events/* \
277"
278
279FILES:${PN}-dsdb-modules = "${libdir}/samba/ldb"
280
281FILES:${PN}-testsuite = "${bindir}/gentest \
282 ${bindir}/locktest \
283 ${bindir}/masktest \
284 ${bindir}/ndrdump \
285 ${bindir}/smbtorture"
286
287FILES:registry-tools = "${bindir}/regdiff \
288 ${bindir}/regpatch \
289 ${bindir}/regshell \
290 ${bindir}/regtree"
291
292FILES:winbind = "${sbindir}/winbindd \
293 ${bindir}/wbinfo \
294 ${bindir}/ntlm_auth \
295 ${libdir}/samba/idmap \
296 ${libdir}/samba/nss_info \
297 ${libdir}/winbind_krb5_locator.so \
298 ${libdir}/winbind-krb5-localauth.so \
299 ${sysconfdir}/init.d/winbind \
300 ${systemd_system_unitdir}/winbind.service"
301
302FILES:${PN}-python3 = "${PYTHON_SITEPACKAGES_DIR}"
303
304FILES:smbclient = "${bindir}/cifsdd \
305 ${bindir}/rpcclient \
306 ${bindir}/smbcacls \
307 ${bindir}/smbclient \
308 ${bindir}/smbcquotas \
309 ${bindir}/smbget \
310 ${bindir}/smbspool \
311 ${bindir}/smbtar \
312 ${bindir}/smbtree \
313 ${libdir}/samba/smbspool_krb5_wrapper"
314
315RDEPENDS:${PN}-pidl:append = " perl libparse-yapp-perl"
316FILES:${PN}-pidl = "${bindir}/pidl \
317 ${libdir}/perl5 \
318 "
319
320RDEPENDS:${PN}-client = "\
321 smbclient \
322 winbind \
323 registry-tools \
324 ${PN}-pidl \
325 "
326
327ALLOW_EMPTY:${PN}-client = "1"
328
329RDEPENDS:${PN}-server = "\
330 ${PN} \
331 winbind \
332 registry-tools \
333 "
334
335ALLOW_EMPTY:${PN}-server = "1"
336
337RDEPENDS:${PN}-test = "\
338 ${PN}-ctdb-tests \
339 ${PN}-testsuite \
340 "
341
342ALLOW_EMPTY:${PN}-test = "1"