blob: 4828526edfa9f1c25035adaa42a33ccad8b1ce92 [file] [log] [blame]
Patrick Williamsac13d5f2023-11-24 18:59:46 -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 \
26 file://0007-Deleted-settiong-of-python-to-fix-the-install-confli.patch \
27 "
28
29SRC_URI:append:libc-musl = " \
30 file://samba-pam.patch \
31 file://samba-4.3.9-remove-getpwent_r.patch \
32 "
33
Patrick Williams705982a2024-01-12 09:51:57 -060034SRC_URI[sha256sum] = "280553b90f131b1940580df293653c9e9bd8906201f5def6e5e8c160f0bfac96"
Patrick Williamsac13d5f2023-11-24 18:59:46 -060035
Patrick Williams705982a2024-01-12 09:51:57 -060036UPSTREAM_CHECK_REGEX = "samba\-(?P<pver>4\.19(\.\d+)+).tar.gz"
Patrick Williamsac13d5f2023-11-24 18:59:46 -060037
38inherit systemd waf-samba cpan-base perlnative update-rc.d perl-version pkgconfig
39
40CVE_STATUS[CVE-2011-2411] = "not-applicable-platform: vulnerable only on HP NonStop Servers"
41
42# remove default added RDEPENDS on perl
43RDEPENDS:${PN}:remove = "perl"
44
45DEPENDS += "readline virtual/libiconv zlib popt libtalloc libtdb libtevent libldb libaio libpam libtasn1 libtasn1-native jansson libparse-yapp-perl-native gnutls cmocka"
46
47inherit features_check
48REQUIRED_DISTRO_FEATURES = "pam"
49
50DEPENDS:append:libc-musl = " libtirpc"
51CFLAGS:append:libc-musl = " -I${STAGING_INCDIR}/tirpc"
52LDFLAGS:append:libc-musl = " -ltirpc"
53
54COMPATIBLE_HOST:riscv32 = "null"
55
56INITSCRIPT_NAME = "samba"
57INITSCRIPT_PARAMS = "start 20 3 5 . stop 20 0 1 6 ."
58
59SYSTEMD_PACKAGES = "${PN}-base ${PN}-ad-dc winbind ctdb"
60SYSTEMD_SERVICE:${PN}-base = "nmb.service smb.service"
61SYSTEMD_SERVICE:${PN}-ad-dc = "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'samba.service', '', d)}"
62SYSTEMD_SERVICE:winbind = "winbind.service"
63SYSTEMD_SERVICE:ctdb = "ctdb.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 ldap mitkrb5 \
78"
79
80PACKAGECONFIG[acl] = "--with-acl-support,--without-acl-support,acl"
81PACKAGECONFIG[fam] = "--with-fam,--without-fam,gamin"
82PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,cups"
83PACKAGECONFIG[ldap] = "--with-ldap,--without-ldap,openldap"
84PACKAGECONFIG[sasl] = ",,cyrus-sasl"
85PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
86PACKAGECONFIG[dmapi] = "--with-dmapi,--without-dmapi,dmapi"
87PACKAGECONFIG[zeroconf] = "--enable-avahi,--disable-avahi,avahi"
Patrick Williams705982a2024-01-12 09:51:57 -060088PACKAGECONFIG[valgrind] = "--with-valgrind,--without-valgrind,valgrind"
Patrick Williamsac13d5f2023-11-24 18:59:46 -060089PACKAGECONFIG[lttng] = "--with-lttng,--without-lttng,lttng-ust"
90PACKAGECONFIG[archive] = "--with-libarchive,--without-libarchive,libarchive"
91PACKAGECONFIG[libunwind] = "--with-libunwind,--without-libunwind,libunwind"
92PACKAGECONFIG[gpgme] = "--with-gpgme,--without-gpgme,gpgme"
93PACKAGECONFIG[lmdb] = ",--without-ldb-lmdb,lmdb"
94PACKAGECONFIG[libbsd] = "--with-libbsd,--without-libbsd,libbsd"
95PACKAGECONFIG[ad-dc] = "--with-experimental-mit-ad-dc,--without-ad-dc,python3-markdown python3-dnspython,"
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,NONE"
108
109EXTRA_OECONF += "--enable-fhs \
110 --with-piddir=/run \
111 --with-sockets-dir=/run/samba \
112 --with-modulesdir=${libdir}/samba \
113 --with-privatelibdir=${libdir}/samba \
114 --with-lockdir=${localstatedir}/lib/samba \
115 --with-cachedir=${localstatedir}/lib/samba \
116 --disable-rpath-install \
117 --disable-rpath \
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
136do_compile:append() {
137 oe_runmake -C ${S}/pidl
138}
139
140do_install:append() {
141 for section in 1 5 7; do
142 install -d ${D}${mandir}/man$section
143 install -m 0644 ctdb/doc/*.$section ${D}${mandir}/man$section
144 done
145 for section in 1 5 7 8; do
146 install -d ${D}${mandir}/man$section
147 install -m 0644 docs/manpages/*.$section ${D}${mandir}/man$section
148 done
149
150 install -d ${D}${systemd_system_unitdir}
151 install -m 0644 ${S}/bin/default/packaging/systemd/*.service ${D}${systemd_system_unitdir}/
152 sed -e 's,\(ExecReload=\).*\(/kill\),\1${base_bindir}\2,' \
153 -e 's,/etc/sysconfig/samba,${sysconfdir}/default/samba,' \
154 -i ${D}${systemd_system_unitdir}/*.service
155
156 if [ "${@bb.utils.contains('PACKAGECONFIG', 'ad-dc', 'yes', 'no', d)}" = "no" ]; then
157 rm -f ${D}${systemd_system_unitdir}/samba.service
158 fi
159
160 install -d ${D}${sysconfdir}/tmpfiles.d
161 install -m644 packaging/systemd/samba.conf.tmp ${D}${sysconfdir}/tmpfiles.d/samba.conf
162 echo "d ${localstatedir}/log/samba 0755 root root -" \
163 >> ${D}${sysconfdir}/tmpfiles.d/samba.conf
164 install -d ${D}${sysconfdir}/init.d
165 install -m 0755 packaging/sysv/samba.init ${D}${sysconfdir}/init.d/samba
166 sed -e 's,/opt/samba/bin,${sbindir},g' \
167 -e 's,/opt/samba/smb.conf,${sysconfdir}/samba/smb.conf,g' \
168 -e 's,/opt/samba/log,${localstatedir}/log/samba,g' \
169 -e 's,/etc/init.d/samba.server,${sysconfdir}/init.d/samba,g' \
170 -e 's,/usr/bin,${base_bindir},g' \
171 -i ${D}${sysconfdir}/init.d/samba
172
173 install -d ${D}${sysconfdir}/samba
174 echo "127.0.0.1 localhost" > ${D}${sysconfdir}/samba/lmhosts
175 install -m644 ${WORKDIR}/smb.conf ${D}${sysconfdir}/samba/smb.conf
176 install -D -m 644 ${WORKDIR}/volatiles.03_samba ${D}${sysconfdir}/default/volatiles/03_samba
177
178 install -d ${D}${sysconfdir}/default
179 install -m644 packaging/systemd/samba.sysconfig ${D}${sysconfdir}/default/samba
180
181 # the items are from ctdb/tests/run_tests.sh
182 for d in cunit eventd eventscripts onnode shellcheck takeover takeover_helper tool; do
183 testdir=${D}${datadir}/ctdb-tests/UNIT/$d
184 install -d $testdir
185 cp ${S}/ctdb/tests/UNIT/$d/*.sh $testdir
186 cp -r ${S}/ctdb/tests/UNIT/$d/scripts ${S}/ctdb/tests/UNIT/$d/stubs $testdir || true
187 done
188
189 # fix file-rdeps qa warning
190 if [ -f ${D}${bindir}/onnode ]; then
191 sed -i 's:\(#!/bin/\)bash:\1sh:' ${D}${bindir}/onnode
192 fi
193
194 chmod 0750 ${D}${sysconfdir}/sudoers.d || true
195 rm -rf ${D}/run ${D}${localstatedir}/run ${D}${localstatedir}/log
196
197 for f in samba-gpupdate samba_upgradedns samba_spnupdate samba_kcc samba_dnsupdate samba_downgrade_db; do
198 if [ -f "${D}${sbindir}/$f" ]; then
199 sed -i -e 's,${PYTHON},/usr/bin/env python3,g' ${D}${sbindir}/$f
200 fi
201 done
202 if [ -f "${D}${bindir}/samba-tool" ]; then
203 sed -i -e 's,${PYTHON},/usr/bin/env python3,g' ${D}${bindir}/samba-tool
204 fi
205
206 oe_runmake -C ${S}/pidl DESTDIR=${D} install_vendor
207 find ${D}${libdir}/perl5/ -type f -name "perllocal.pod" -delete
208 find ${D}${libdir}/perl5/ -type f -name ".packlist" -delete
209 sed -i -e '1s,#!.*perl,#!${bindir}/env perl,' ${D}${bindir}/pidl
210}
211
212PACKAGES =+ "${PN}-python3 ${PN}-pidl \
213 ${PN}-dsdb-modules ${PN}-testsuite registry-tools \
214 winbind ctdb ctdb-tests \
215 ${PN}-common ${PN}-base ${PN}-ad-dc \
216 smbclient ${PN}-client ${PN}-server ${PN}-test"
217
218python samba_populate_packages() {
219 def module_hook(file, pkg, pattern, format, basename):
220 pn = d.getVar('PN')
221 d.appendVar('RRECOMMENDS:%s-base' % pn, ' %s' % pkg)
222
223 mlprefix = d.getVar('MLPREFIX') or ''
224 pam_libdir = d.expand('${base_libdir}/security')
225 pam_pkgname = mlprefix + 'pam-plugin%s'
226 do_split_packages(d, pam_libdir, r'^pam_(.*)\.so$', pam_pkgname, 'PAM plugin for %s', extra_depends='', prepend=True)
227
228 libdir = d.getVar('libdir')
229 do_split_packages(d, libdir, r'^lib(.*)\.so\..*$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True, allow_links=True)
230 pkglibdir = '%s/samba' % libdir
231 do_split_packages(d, pkglibdir, r'^lib(.*)\.so$', 'lib%s', 'Samba %s library', extra_depends='${PN}-common', prepend=True)
232 moduledir = '%s/samba/auth' % libdir
233 do_split_packages(d, moduledir, r'^(.*)\.so$', 'samba-auth-%s', 'Samba %s authentication backend', hook=module_hook, extra_depends='', prepend=True)
234 moduledir = '%s/samba/pdb' % libdir
235 do_split_packages(d, moduledir, r'^(.*)\.so$', 'samba-pdb-%s', 'Samba %s password backend', hook=module_hook, extra_depends='', prepend=True)
236}
237
238PACKAGESPLITFUNCS:prepend = "samba_populate_packages "
239PACKAGES_DYNAMIC = "samba-auth-.* samba-pdb-.*"
240
241RDEPENDS:${PN} += "${PN}-base ${PN}-python3 ${PN}-dsdb-modules python3"
242RDEPENDS:${PN}-python3 += "pytalloc python3-tdb pyldb"
243
244FILES:${PN}-base = "${sbindir}/nmbd \
245 ${sbindir}/smbd \
246 ${sysconfdir}/init.d \
247 ${systemd_system_unitdir}/nmb.service \
248 ${systemd_system_unitdir}/smb.service"
249
250FILES:${PN}-ad-dc = "${sbindir}/samba \
251 ${systemd_system_unitdir}/samba.service \
252 ${libdir}/krb5/plugins/kdb/samba.so \
253"
254
255RDEPENDS:${PN}-ad-dc = "krb5-kdc"
256
257FILES:ctdb = "${bindir}/ctdb \
258 ${bindir}/ctdb_diagnostics \
259 ${bindir}/ltdbtool \
260 ${bindir}/onnode \
261 ${bindir}/ping_pong \
262 ${sbindir}/ctdbd \
263 ${datadir}/ctdb \
264 ${libexecdir}/ctdb \
265 ${localstatedir}/lib/ctdb \
266 ${sysconfdir}/ctdb \
267 ${sysconfdir}/sudoers.d/ctdb \
268 ${systemd_system_unitdir}/ctdb.service \
269"
270
271FILES:ctdb-tests = "${bindir}/ctdb_run_tests \
272 ${bindir}/ctdb_run_cluster_tests \
273 ${datadir}/ctdb-tests \
274 ${datadir}/ctdb/tests \
275"
276
277RDEPENDS:ctdb-tests += "bash util-linux-getopt ctdb"
278
279FILES:${BPN}-common = "${sysconfdir}/default \
280 ${sysconfdir}/samba \
281 ${sysconfdir}/tmpfiles.d \
282 ${localstatedir}/lib/samba \
283 ${localstatedir}/spool/samba \
284"
285
286FILES:${PN} += "${libdir}/vfs/*.so \
287 ${libdir}/charset/*.so \
288 ${libdir}/*.dat \
289 ${libdir}/auth/*.so \
290"
291
292FILES:${PN}-dsdb-modules = "${libdir}/samba/ldb"
293
294FILES:${PN}-testsuite = "${bindir}/gentest \
295 ${bindir}/locktest \
296 ${bindir}/masktest \
297 ${bindir}/ndrdump \
298 ${bindir}/smbtorture"
299
300FILES:registry-tools = "${bindir}/regdiff \
301 ${bindir}/regpatch \
302 ${bindir}/regshell \
303 ${bindir}/regtree"
304
305FILES:winbind = "${sbindir}/winbindd \
306 ${bindir}/wbinfo \
307 ${bindir}/ntlm_auth \
308 ${libdir}/samba/idmap \
309 ${libdir}/samba/nss_info \
310 ${libdir}/winbind_krb5_locator.so \
311 ${libdir}/winbind-krb5-localauth.so \
312 ${sysconfdir}/init.d/winbind \
313 ${systemd_system_unitdir}/winbind.service"
314
315FILES:${PN}-python3 = "${PYTHON_SITEPACKAGES_DIR}"
316
317FILES:smbclient = "${bindir}/cifsdd \
318 ${bindir}/rpcclient \
319 ${bindir}/smbcacls \
320 ${bindir}/smbclient \
321 ${bindir}/smbcquotas \
322 ${bindir}/smbget \
323 ${bindir}/smbspool \
324 ${bindir}/smbtar \
325 ${bindir}/smbtree \
326 ${libexecdir}/samba/smbspool_krb5_wrapper"
327
328FILES:${PN}-pidl = "${bindir}/pidl \
329 ${libdir}/perl5 \
330 "
331RDEPENDS:${PN}-pidl += "perl perl-modules libparse-yapp-perl"
332
333RDEPENDS:${PN}-client = "\
334 smbclient \
335 winbind \
336 registry-tools \
337 ${PN}-pidl \
338 "
339
340ALLOW_EMPTY:${PN}-client = "1"
341
342RDEPENDS:${PN}-server = "\
343 ${PN} \
344 winbind \
345 registry-tools \
346 "
347
348ALLOW_EMPTY:${PN}-server = "1"
349
350RDEPENDS:${PN}-test = "\
351 ctdb-tests \
352 ${PN}-testsuite \
353 "
354
355ALLOW_EMPTY:${PN}-test = "1"