blob: 9d8802ff5495ba515bc529ae38b4206e2aa7d94b [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001HOMEPAGE = "https://www.samba.org/"
2SECTION = "console/network"
3
4LICENSE = "GPL-3.0-or-later & LGPL-3.0-or-later & GPL-2.0-or-later"
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
15export PYTHONHASHSEED="1"
16
17SRC_URI = "${SAMBA_MIRROR}/stable/samba-${PV}.tar.gz \
18 file://smb.conf \
19 file://volatiles.03_samba \
20 file://0001-Don-t-check-xsltproc-manpages.patch \
21 file://0002-do-not-import-target-module-while-cross-compile.patch \
22 file://0003-Add-config-option-without-valgrind.patch \
23 file://0004-Add-options-to-configure-the-use-of-libbsd.patch \
24 file://0005-Fix-pyext_PATTERN-for-cross-compilation.patch \
25 file://0006-smbtorture-skip-test-case-tfork_cmd_send.patch \
Patrick Williams864cc432023-02-09 14:54:44 -060026 file://0007-Deleted-settiong-of-python-to-fix-the-install-confli.patch \
Andrew Geissler517393d2023-01-13 08:55:19 -060027 "
28
29SRC_URI:append:libc-musl = " \
30 file://samba-pam.patch \
31 file://samba-4.3.9-remove-getpwent_r.patch \
32 file://cmocka-uintptr_t.patch \
33 "
34
Patrick Williams2a254922023-08-11 09:48:11 -050035SRC_URI[sha256sum] = "095256ac332e1d9fbf9b7ff7823f92a3233d3ed658ce7fc9b33905c2243f447f"
Andrew Geissler517393d2023-01-13 08:55:19 -060036
Andrew Geisslerfc113ea2023-03-31 09:59:46 -050037UPSTREAM_CHECK_REGEX = "samba\-(?P<pver>4\.18(\.\d+)+).tar.gz"
Andrew Geissler517393d2023-01-13 08:55:19 -060038
39inherit systemd waf-samba cpan-base perlnative update-rc.d perl-version pkgconfig
40
Patrick Williams2a254922023-08-11 09:48:11 -050041CVE_STATUS[CVE-2011-2411] = "not-applicable-platform: vulnerable only on HP NonStop Servers"
Andrew Geissler517393d2023-01-13 08:55:19 -060042
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 ctdb"
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"
64SYSTEMD_SERVICE:ctdb = "ctdb.service"
65
66# There are prerequisite settings to enable ad-dc, so disable the service by default.
67# Reference:
68# https://wiki.samba.org/index.php/Setting_up_Samba_as_an_Active_Directory_Domain_Controller
69SYSTEMD_AUTO_ENABLE:${PN}-ad-dc = "disable"
70
71#cross_compile cannot use preforked process, since fork process earlier than point subproces.popen
72#to cross Popen
73export WAF_NO_PREFORK="yes"
74
75# Use krb5. Build active domain controller.
76#
77PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd zeroconf', d)} \
78 acl cups ad-dc ldap mitkrb5 \
79"
80
81PACKAGECONFIG[acl] = "--with-acl-support,--without-acl-support,acl"
82PACKAGECONFIG[fam] = "--with-fam,--without-fam,gamin"
83PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,cups"
84PACKAGECONFIG[ldap] = "--with-ldap,--without-ldap,openldap"
85PACKAGECONFIG[sasl] = ",,cyrus-sasl"
86PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
87PACKAGECONFIG[dmapi] = "--with-dmapi,--without-dmapi,dmapi"
88PACKAGECONFIG[zeroconf] = "--enable-avahi,--disable-avahi,avahi"
89PACKAGECONFIG[valgrind] = ",--without-valgrind,valgrind,"
90PACKAGECONFIG[lttng] = "--with-lttng,--without-lttng,lttng-ust"
91PACKAGECONFIG[archive] = "--with-libarchive,--without-libarchive,libarchive"
92PACKAGECONFIG[libunwind] = "--with-libunwind,--without-libunwind,libunwind"
93PACKAGECONFIG[gpgme] = "--with-gpgme,--without-gpgme,gpgme"
94PACKAGECONFIG[lmdb] = ",--without-ldb-lmdb,lmdb"
95PACKAGECONFIG[libbsd] = "--with-libbsd,--without-libbsd,libbsd"
96PACKAGECONFIG[ad-dc] = "--with-experimental-mit-ad-dc,--without-ad-dc,python3-markdown python3-dnspython,"
97PACKAGECONFIG[mitkrb5] = "--with-system-mitkrb5 --with-system-mitkdc=/usr/sbin/krb5kdc,,krb5,"
98
99SAMBA4_IDMAP_MODULES="idmap_ad,idmap_rid,idmap_adex,idmap_hash,idmap_tdb2"
100SAMBA4_PDB_MODULES="pdb_tdbsam,${@bb.utils.contains('PACKAGECONFIG', 'ldap', 'pdb_ldap,', '', d)}pdb_ads,pdb_smbpasswd,pdb_wbc_sam,pdb_samba4"
101SAMBA4_AUTH_MODULES="auth_unix,auth_wbc,auth_server,auth_netlogond,auth_script,auth_samba4"
102SAMBA4_MODULES="${SAMBA4_IDMAP_MODULES},${SAMBA4_PDB_MODULES},${SAMBA4_AUTH_MODULES}"
103
104# These libraries are supposed to replace others supplied by packages, but decorate the names of
105# .so files so there will not be a conflict. This is not done consistantly, so be very careful
106# when adding to this list.
107#
108SAMBA4_LIBS="heimdal,cmocka,NONE"
109
110EXTRA_OECONF += "--enable-fhs \
111 --with-piddir=/run \
112 --with-sockets-dir=/run/samba \
113 --with-modulesdir=${libdir}/samba \
114 --with-privatelibdir=${libdir}/samba \
115 --with-lockdir=${localstatedir}/lib/samba \
116 --with-cachedir=${localstatedir}/lib/samba \
117 --disable-rpath-install \
118 --disable-rpath \
119 --with-shared-modules=${SAMBA4_MODULES} \
120 --bundled-libraries=${SAMBA4_LIBS} \
121 ${@oe.utils.conditional('TARGET_ARCH', 'x86_64', '', '--disable-glusterfs', d)} \
122 --with-cluster-support \
123 --with-profiling-data \
124 --with-libiconv=${STAGING_DIR_HOST}${prefix} \
125 --with-pam --with-pammodulesdir=${base_libdir}/security \
126 "
127
128LDFLAGS += "-Wl,-z,relro,-z,now ${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', ' -fuse-ld=bfd ', '', d)}"
129
130do_configure:append() {
131 cd ${S}/pidl/
132 perl Makefile.PL PREFIX=${prefix}
133 sed -e 's,VENDORPREFIX)/lib/perl,VENDORPREFIX)/${baselib}/perl,g' \
134 -e 's,PERLPREFIX)/lib/perl,PERLPREFIX)/${baselib}/perl,g' -i Makefile
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
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500208 find ${D}${libdir}/perl5/ -type f -name "perllocal.pod" -delete
209 find ${D}${libdir}/perl5/ -type f -name ".packlist" -delete
Andrew Geissler517393d2023-01-13 08:55:19 -0600210 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 ctdb ctdb-tests \
216 ${PN}-common ${PN}-base ${PN}-ad-dc \
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"
255
256RDEPENDS:${PN}-ad-dc = "krb5-kdc"
257
258FILES:ctdb = "${bindir}/ctdb \
259 ${bindir}/ctdb_diagnostics \
260 ${bindir}/ltdbtool \
261 ${bindir}/onnode \
262 ${bindir}/ping_pong \
263 ${sbindir}/ctdbd \
264 ${datadir}/ctdb \
265 ${libexecdir}/ctdb \
266 ${localstatedir}/lib/ctdb \
267 ${sysconfdir}/ctdb \
268 ${sysconfdir}/sudoers.d/ctdb \
269 ${systemd_system_unitdir}/ctdb.service \
270"
271
272FILES:ctdb-tests = "${bindir}/ctdb_run_tests \
273 ${bindir}/ctdb_run_cluster_tests \
274 ${datadir}/ctdb-tests \
275 ${datadir}/ctdb/tests \
276"
277
278RDEPENDS:ctdb-tests += "bash util-linux-getopt ctdb"
279
280FILES:${BPN}-common = "${sysconfdir}/default \
281 ${sysconfdir}/samba \
282 ${sysconfdir}/tmpfiles.d \
283 ${localstatedir}/lib/samba \
284 ${localstatedir}/spool/samba \
285"
286
287FILES:${PN} += "${libdir}/vfs/*.so \
288 ${libdir}/charset/*.so \
289 ${libdir}/*.dat \
290 ${libdir}/auth/*.so \
291"
292
293FILES:${PN}-dsdb-modules = "${libdir}/samba/ldb"
294
295FILES:${PN}-testsuite = "${bindir}/gentest \
296 ${bindir}/locktest \
297 ${bindir}/masktest \
298 ${bindir}/ndrdump \
299 ${bindir}/smbtorture"
300
301FILES:registry-tools = "${bindir}/regdiff \
302 ${bindir}/regpatch \
303 ${bindir}/regshell \
304 ${bindir}/regtree"
305
306FILES:winbind = "${sbindir}/winbindd \
307 ${bindir}/wbinfo \
308 ${bindir}/ntlm_auth \
309 ${libdir}/samba/idmap \
310 ${libdir}/samba/nss_info \
311 ${libdir}/winbind_krb5_locator.so \
312 ${libdir}/winbind-krb5-localauth.so \
313 ${sysconfdir}/init.d/winbind \
314 ${systemd_system_unitdir}/winbind.service"
315
316FILES:${PN}-python3 = "${PYTHON_SITEPACKAGES_DIR}"
317
318FILES:smbclient = "${bindir}/cifsdd \
319 ${bindir}/rpcclient \
320 ${bindir}/smbcacls \
321 ${bindir}/smbclient \
322 ${bindir}/smbcquotas \
323 ${bindir}/smbget \
324 ${bindir}/smbspool \
325 ${bindir}/smbtar \
326 ${bindir}/smbtree \
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500327 ${libexecdir}/samba/smbspool_krb5_wrapper"
Andrew Geissler517393d2023-01-13 08:55:19 -0600328
329FILES:${PN}-pidl = "${bindir}/pidl \
330 ${libdir}/perl5 \
331 "
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500332RDEPENDS:${PN}-pidl += "perl perl-modules libparse-yapp-perl"
Andrew Geissler517393d2023-01-13 08:55:19 -0600333
334RDEPENDS:${PN}-client = "\
335 smbclient \
336 winbind \
337 registry-tools \
338 ${PN}-pidl \
339 "
340
341ALLOW_EMPTY:${PN}-client = "1"
342
343RDEPENDS:${PN}-server = "\
344 ${PN} \
345 winbind \
346 registry-tools \
347 "
348
349ALLOW_EMPTY:${PN}-server = "1"
350
351RDEPENDS:${PN}-test = "\
352 ctdb-tests \
353 ${PN}-testsuite \
354 "
355
356ALLOW_EMPTY:${PN}-test = "1"