blob: 5c5ce367050ce896a28c207c2f7fa85eed069f76 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001HOMEPAGE = "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 \
Andrew Geissler97771a32021-03-05 15:23:11 -06006 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"
Andrew Geissler82c905d2020-04-13 13:39:40 -05008
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 \
Andrew Geissler82c905d2020-04-13 13:39:40 -050017 file://volatiles.03_samba \
Andrew Geissler69721092021-07-23 12:57:00 -040018 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://0006-samba-defeat-iconv-test.patch \
24 file://0007-wscript_configure_system_gnutls-disable-check-gnutls.patch \
25 file://0008-source3-wscript-disable-check-fcntl-F_OWNER_EX.patch \
26 file://0009-source3-wscript-disable-check-fcntl-RW_HINTS.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050027 "
Andrew Geissler69721092021-07-23 12:57:00 -040028
Andrew Geissler82c905d2020-04-13 13:39:40 -050029SRC_URI_append_libc-musl = " \
Andrew Geissler69721092021-07-23 12:57:00 -040030 file://netdb_defines.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050031 file://samba-pam.patch \
32 file://samba-4.3.9-remove-getpwent_r.patch \
33 file://cmocka-uintptr_t.patch \
Andrew Geissler69721092021-07-23 12:57:00 -040034 file://samba-fix-musl-lib-without-innetgr.patch \
35 "
Andrew Geissler82c905d2020-04-13 13:39:40 -050036
Andrew Geissler69721092021-07-23 12:57:00 -040037SRC_URI[md5sum] = "96d275e31387e6c403d6c16465d15b7e"
38SRC_URI[sha256sum] = "bb6ef5d2f16b85288d823578abc453d9a80514c42e5a2ea2c4e3c60dc42335c3"
Andrew Geissler82c905d2020-04-13 13:39:40 -050039
Andrew Geissler69721092021-07-23 12:57:00 -040040UPSTREAM_CHECK_REGEX = "samba\-(?P<pver>4\.14(\.\d+)+).tar.gz"
Andrew Geissler82c905d2020-04-13 13:39:40 -050041
Andrew Geissler69721092021-07-23 12:57:00 -040042inherit systemd waf-samba cpan-base perlnative update-rc.d perl-version
43
44# CVE-2011-2411 is valnerble only on HP NonStop Servers.
45CVE_CHECK_WHITELIST += "CVE-2011-2411"
46
Andrew Geissler82c905d2020-04-13 13:39:40 -050047# remove default added RDEPENDS on perl
48RDEPENDS_${PN}_remove = "perl"
49
Andrew Geissler69721092021-07-23 12:57:00 -040050DEPENDS += "readline virtual/libiconv zlib popt libtalloc libtdb libtevent libldb libaio libpam libtasn1 jansson libparse-yapp-perl-native gnutls"
Andrew Geissler82c905d2020-04-13 13:39:40 -050051
52inherit features_check
53REQUIRED_DISTRO_FEATURES = "pam"
54
55DEPENDS_append_libc-musl = " libtirpc"
56CFLAGS_append_libc-musl = " -I${STAGING_INCDIR}/tirpc"
57LDFLAGS_append_libc-musl = " -ltirpc"
58
Andrew Geissler69721092021-07-23 12:57:00 -040059COMPATIBLE_HOST_riscv32 = "null"
60
Andrew Geissler82c905d2020-04-13 13:39:40 -050061INITSCRIPT_NAME = "samba"
62INITSCRIPT_PARAMS = "start 20 3 5 . stop 20 0 1 6 ."
63
64SYSTEMD_PACKAGES = "${PN}-base ${PN}-ad-dc winbind"
65SYSTEMD_SERVICE_${PN}-base = "nmb.service smb.service"
66SYSTEMD_SERVICE_${PN}-ad-dc = "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'samba.service', '', d)}"
67SYSTEMD_SERVICE_winbind = "winbind.service"
68
69# There are prerequisite settings to enable ad-dc, so disable the service by default.
70# Reference:
71# https://wiki.samba.org/index.php/Setting_up_Samba_as_an_Active_Directory_Domain_Controller
72SYSTEMD_AUTO_ENABLE_${PN}-ad-dc = "disable"
73
74#cross_compile cannot use preforked process, since fork process earlier than point subproces.popen
75#to cross Popen
76export WAF_NO_PREFORK="yes"
77
78# Use krb5. Build active domain controller.
79#
80PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd zeroconf', d)} \
Andrew Geissler69721092021-07-23 12:57:00 -040081 acl cups ad-dc ldap mitkrb5 \
Andrew Geissler82c905d2020-04-13 13:39:40 -050082"
83
84RDEPENDS_${PN}-ctdb-tests += "bash util-linux-getopt"
85
86PACKAGECONFIG[acl] = "--with-acl-support,--without-acl-support,acl"
87PACKAGECONFIG[fam] = "--with-fam,--without-fam,gamin"
88PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,cups"
89PACKAGECONFIG[ldap] = "--with-ldap,--without-ldap,openldap"
90PACKAGECONFIG[sasl] = ",,cyrus-sasl"
91PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
92PACKAGECONFIG[dmapi] = "--with-dmapi,--without-dmapi,dmapi"
93PACKAGECONFIG[zeroconf] = "--enable-avahi,--disable-avahi,avahi"
94PACKAGECONFIG[valgrind] = ",--without-valgrind,valgrind,"
95PACKAGECONFIG[lttng] = "--with-lttng, --without-lttng,lttng-ust"
96PACKAGECONFIG[archive] = "--with-libarchive, --without-libarchive, libarchive"
97PACKAGECONFIG[libunwind] = ", , libunwind"
98PACKAGECONFIG[gpgme] = ",--without-gpgme,,"
99PACKAGECONFIG[lmdb] = ",--without-ldb-lmdb,lmdb,"
Andrew Geisslere231d582020-05-05 08:53:09 -0500100PACKAGECONFIG[libbsd] = "--with-libbsd, --without-libbsd, libbsd"
Andrew Geissler69721092021-07-23 12:57:00 -0400101PACKAGECONFIG[ad-dc] = "--with-experimental-mit-ad-dc,--without-ad-dc,python3-markdown python3-dnspython,"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500102PACKAGECONFIG[mitkrb5] = "--with-system-mitkrb5 --with-system-mitkdc=/usr/sbin/krb5kdc,,krb5,"
103
104SAMBA4_IDMAP_MODULES="idmap_ad,idmap_rid,idmap_adex,idmap_hash,idmap_tdb2"
105SAMBA4_PDB_MODULES="pdb_tdbsam,${@bb.utils.contains('PACKAGECONFIG', 'ldap', 'pdb_ldap,', '', d)}pdb_ads,pdb_smbpasswd,pdb_wbc_sam,pdb_samba4"
106SAMBA4_AUTH_MODULES="auth_unix,auth_wbc,auth_server,auth_netlogond,auth_script,auth_samba4"
107SAMBA4_MODULES="${SAMBA4_IDMAP_MODULES},${SAMBA4_PDB_MODULES},${SAMBA4_AUTH_MODULES}"
108
109# These libraries are supposed to replace others supplied by packages, but decorate the names of
110# .so files so there will not be a conflict. This is not done consistantly, so be very careful
111# when adding to this list.
112#
113SAMBA4_LIBS="heimdal,cmocka,NONE"
114
115EXTRA_OECONF += "--enable-fhs \
116 --with-piddir=/run \
117 --with-sockets-dir=/run/samba \
118 --with-modulesdir=${libdir}/samba \
119 --with-lockdir=${localstatedir}/lib/samba \
120 --with-cachedir=${localstatedir}/lib/samba \
121 --disable-rpath-install \
122 --with-shared-modules=${SAMBA4_MODULES} \
123 --bundled-libraries=${SAMBA4_LIBS} \
124 ${@oe.utils.conditional('TARGET_ARCH', 'x86_64', '', '--disable-glusterfs', d)} \
125 --with-cluster-support \
126 --with-profiling-data \
127 --with-libiconv=${STAGING_DIR_HOST}${prefix} \
128 --with-pam --with-pammodulesdir=${base_libdir}/security \
129 "
130
131LDFLAGS += "-Wl,-z,relro,-z,now ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
132
Andrew Geissler69721092021-07-23 12:57:00 -0400133do_configure_append () {
134 cd ${S}/pidl/
135 perl Makefile.PL PREFIX=${prefix}
136 sed -e 's,VENDORPREFIX)/lib/perl,VENDORPREFIX)/${baselib}/perl,g' \
137 -e 's,PERLPREFIX)/lib/perl,PERLPREFIX)/${baselib}/perl,g' -i Makefile
138
139}
140
141do_compile_append () {
142 oe_runmake -C ${S}/pidl
143}
144
Andrew Geissler82c905d2020-04-13 13:39:40 -0500145do_install_append() {
146 for section in 1 5 7; do
147 install -d ${D}${mandir}/man$section
148 install -m 0644 ctdb/doc/*.$section ${D}${mandir}/man$section
149 done
150 for section in 1 5 7 8; do
151 install -d ${D}${mandir}/man$section
152 install -m 0644 docs/manpages/*.$section ${D}${mandir}/man$section
153 done
154
155 install -d ${D}${systemd_system_unitdir}
156 install -m 0644 ${S}/bin/default/packaging/systemd/*.service ${D}${systemd_system_unitdir}/
157 sed -e 's,\(ExecReload=\).*\(/kill\),\1${base_bindir}\2,' \
158 -e 's,/etc/sysconfig/samba,${sysconfdir}/default/samba,' \
159 -i ${D}${systemd_system_unitdir}/*.service
160
161 if [ "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'yes', 'no', d)}" = "no" ]; then
162 rm -f ${D}${systemd_system_unitdir}/samba.service
163 fi
164
165 install -d ${D}${sysconfdir}/tmpfiles.d
166 install -m644 packaging/systemd/samba.conf.tmp ${D}${sysconfdir}/tmpfiles.d/samba.conf
167 echo "d ${localstatedir}/log/samba 0755 root root -" \
168 >> ${D}${sysconfdir}/tmpfiles.d/samba.conf
169 install -d ${D}${sysconfdir}/init.d
170 install -m 0755 packaging/sysv/samba.init ${D}${sysconfdir}/init.d/samba
171 sed -e 's,/opt/samba/bin,${sbindir},g' \
172 -e 's,/opt/samba/smb.conf,${sysconfdir}/samba/smb.conf,g' \
173 -e 's,/opt/samba/log,${localstatedir}/log/samba,g' \
174 -e 's,/etc/init.d/samba.server,${sysconfdir}/init.d/samba,g' \
175 -e 's,/usr/bin,${base_bindir},g' \
176 -i ${D}${sysconfdir}/init.d/samba
177
178 install -d ${D}${sysconfdir}/samba
179 echo "127.0.0.1 localhost" > ${D}${sysconfdir}/samba/lmhosts
180 install -m644 ${WORKDIR}/smb.conf ${D}${sysconfdir}/samba/smb.conf
181 install -D -m 644 ${WORKDIR}/volatiles.03_samba ${D}${sysconfdir}/default/volatiles/03_samba
182
183 install -d ${D}${sysconfdir}/default
184 install -m644 packaging/systemd/samba.sysconfig ${D}${sysconfdir}/default/samba
185
186 # the items are from ctdb/tests/run_tests.sh
Andrew Geissler69721092021-07-23 12:57:00 -0400187 for d in cunit eventd eventscripts onnode shellcheck takeover takeover_helper tool; do
188 testdir=${D}${datadir}/ctdb-tests/UNIT/$d
Andrew Geissler82c905d2020-04-13 13:39:40 -0500189 install -d $testdir
Andrew Geissler69721092021-07-23 12:57:00 -0400190 cp ${S}/ctdb/tests/UNIT/$d/*.sh $testdir
191 cp -r ${S}/ctdb/tests/UNIT/$d/scripts ${S}/ctdb/tests/UNIT/$d/stubs $testdir || true
Andrew Geissler82c905d2020-04-13 13:39:40 -0500192 done
193
194 # fix file-rdeps qa warning
195 if [ -f ${D}${bindir}/onnode ]; then
196 sed -i 's:\(#!/bin/\)bash:\1sh:' ${D}${bindir}/onnode
197 fi
198
199 chmod 0750 ${D}${sysconfdir}/sudoers.d || true
200 rm -rf ${D}/run ${D}${localstatedir}/run ${D}${localstatedir}/log
201
Andrew Geissler69721092021-07-23 12:57:00 -0400202 for f in samba-gpupdate samba_upgradedns samba_spnupdate samba_kcc samba_dnsupdate samba_downgrade_db; do
Andrew Geissler82c905d2020-04-13 13:39:40 -0500203 if [ -f "${D}${sbindir}/$f" ]; then
204 sed -i -e 's,${PYTHON},/usr/bin/env python3,g' ${D}${sbindir}/$f
205 fi
206 done
207 if [ -f "${D}${bindir}/samba-tool" ]; then
208 sed -i -e 's,${PYTHON},/usr/bin/env python3,g' ${D}${bindir}/samba-tool
209 fi
Andrew Geissler69721092021-07-23 12:57:00 -0400210
211 oe_runmake -C ${S}/pidl DESTDIR=${D} install_vendor
212 find ${D}${libdir}/ -type f -name "perllocal.pod" | xargs rm -f
213 rm -rf ${D}${libdir}/perl5/vendor_perl/${PERLVERSION}/${BUILD_SYS}/auto/Parse/Pidl/.packlist
214 sed -i -e '1s,#!.*perl,#!${bindir}/env perl,' ${D}${bindir}/pidl
Andrew Geissler82c905d2020-04-13 13:39:40 -0500215}
216
217PACKAGES =+ "${PN}-python3 ${PN}-pidl \
218 ${PN}-dsdb-modules ${PN}-testsuite registry-tools \
219 winbind \
220 ${PN}-common ${PN}-base ${PN}-ad-dc ${PN}-ctdb-tests \
221 smbclient ${PN}-client ${PN}-server ${PN}-test"
222
223python samba_populate_packages() {
224 def module_hook(file, pkg, pattern, format, basename):
225 pn = d.getVar('PN')
226 d.appendVar('RRECOMMENDS_%s-base' % pn, ' %s' % pkg)
227
228 mlprefix = d.getVar('MLPREFIX') or ''
229 pam_libdir = d.expand('${base_libdir}/security')
230 pam_pkgname = mlprefix + 'pam-plugin%s'
231 do_split_packages(d, pam_libdir, '^pam_(.*)\.so$', pam_pkgname, 'PAM plugin for %s', extra_depends='', prepend=True)
232
233 libdir = d.getVar('libdir')
234 do_split_packages(d, libdir, '^lib(.*)\.so\..*$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True, allow_links=True)
235 pkglibdir = '%s/samba' % libdir
236 do_split_packages(d, pkglibdir, '^lib(.*)\.so$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True)
237 moduledir = '%s/samba/auth' % libdir
238 do_split_packages(d, moduledir, '^(.*)\.so$', 'samba-auth-%s', 'Samba %s authentication backend', hook=module_hook, extra_depends='', prepend=True)
239 moduledir = '%s/samba/pdb' % libdir
240 do_split_packages(d, moduledir, '^(.*)\.so$', 'samba-pdb-%s', 'Samba %s password backend', hook=module_hook, extra_depends='', prepend=True)
241}
242
243PACKAGESPLITFUNCS_prepend = "samba_populate_packages "
244PACKAGES_DYNAMIC = "samba-auth-.* samba-pdb-.*"
245
246RDEPENDS_${PN} += "${PN}-base ${PN}-python3 ${PN}-dsdb-modules python3"
247RDEPENDS_${PN}-python3 += "pytalloc python3-tdb"
248
249FILES_${PN}-base = "${sbindir}/nmbd \
250 ${sbindir}/smbd \
251 ${sysconfdir}/init.d \
252 ${systemd_system_unitdir}/nmb.service \
253 ${systemd_system_unitdir}/smb.service"
254
255FILES_${PN}-ad-dc = "${sbindir}/samba \
256 ${systemd_system_unitdir}/samba.service \
257 ${libdir}/krb5/plugins/kdb/samba.so \
258"
259RDEPENDS_${PN}-ad-dc = "krb5-kdc"
260
261FILES_${PN}-ctdb-tests = "${bindir}/ctdb_run_tests \
262 ${bindir}/ctdb_run_cluster_tests \
263 ${sysconfdir}/ctdb/nodes \
264 ${datadir}/ctdb-tests \
265 ${datadir}/ctdb/tests \
266 ${localstatedir}/lib/ctdb \
267 "
268
269FILES_${BPN}-common = "${sysconfdir}/default \
270 ${sysconfdir}/samba \
271 ${sysconfdir}/tmpfiles.d \
272 ${localstatedir}/lib/samba \
273 ${localstatedir}/spool/samba \
274"
275
276FILES_${PN} += "${libdir}/vfs/*.so \
277 ${libdir}/charset/*.so \
278 ${libdir}/*.dat \
279 ${libdir}/auth/*.so \
280 ${datadir}/ctdb/events/* \
281"
282
283FILES_${PN}-dsdb-modules = "${libdir}/samba/ldb"
284
285FILES_${PN}-testsuite = "${bindir}/gentest \
286 ${bindir}/locktest \
287 ${bindir}/masktest \
288 ${bindir}/ndrdump \
289 ${bindir}/smbtorture"
290
291FILES_registry-tools = "${bindir}/regdiff \
292 ${bindir}/regpatch \
293 ${bindir}/regshell \
294 ${bindir}/regtree"
295
296FILES_winbind = "${sbindir}/winbindd \
297 ${bindir}/wbinfo \
298 ${bindir}/ntlm_auth \
299 ${libdir}/samba/idmap \
300 ${libdir}/samba/nss_info \
301 ${libdir}/winbind_krb5_locator.so \
302 ${libdir}/winbind-krb5-localauth.so \
303 ${sysconfdir}/init.d/winbind \
304 ${systemd_system_unitdir}/winbind.service"
305
306FILES_${PN}-python3 = "${PYTHON_SITEPACKAGES_DIR}"
307
308FILES_smbclient = "${bindir}/cifsdd \
309 ${bindir}/rpcclient \
310 ${bindir}/smbcacls \
311 ${bindir}/smbclient \
312 ${bindir}/smbcquotas \
313 ${bindir}/smbget \
314 ${bindir}/smbspool \
315 ${bindir}/smbtar \
316 ${bindir}/smbtree \
317 ${libdir}/samba/smbspool_krb5_wrapper"
318
Andrew Geissler69721092021-07-23 12:57:00 -0400319RDEPENDS_${PN}-pidl_append = " perl libparse-yapp-perl"
320FILES_${PN}-pidl = "${bindir}/pidl \
321 ${libdir}/perl5 \
322 "
Andrew Geissler82c905d2020-04-13 13:39:40 -0500323
324RDEPENDS_${PN}-client = "\
325 smbclient \
326 winbind \
327 registry-tools \
328 ${PN}-pidl \
329 "
330
331ALLOW_EMPTY_${PN}-client = "1"
332
333RDEPENDS_${PN}-server = "\
334 ${PN} \
335 winbind \
336 registry-tools \
337 "
338
339ALLOW_EMPTY_${PN}-server = "1"
340
341RDEPENDS_${PN}-test = "\
342 ${PN}-ctdb-tests \
343 ${PN}-testsuite \
344 "
345
346ALLOW_EMPTY_${PN}-test = "1"