Merge pull request #12567 from Grommish/master
[feed/packages.git] / net / samba4 / Makefile
1 # Based partially on (wongsyrone/hbl0307106015) versions
2 include $(TOPDIR)/rules.mk
3
4 PKG_NAME:=samba
5 PKG_VERSION:=4.12.3
6 PKG_RELEASE:=4
7
8 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
9 PKG_SOURCE_URL:= \
10 https://ftp.gwdg.de/pub/samba/stable/ \
11 https://ftp.heanet.ie/mirrors/ftp.samba.org/stable/ \
12 https://ftp.riken.jp/net/samba/samba/stable/ \
13 http://www.nic.funet.fi/index/samba/pub/samba/stable/ \
14 http://samba.mirror.bit.nl/samba/ftp/stable/ \
15 https://download.samba.org/pub/samba/stable/
16 PKG_HASH:=3fadbca4504937820d0d8a34e500a1efdcc35e0c554f05bd0a844916ae528727
17
18 PKG_MAINTAINER:=Andy Walsh <andy.walsh44+github@gmail.com>
19 PKG_LICENSE:=GPL-3.0-only
20 PKG_LICENSE_FILES:=COPYING
21 PKG_CPE_ID:=cpe:/a:samba:samba
22
23 # samba4=(asn1_compile,compile_et) rpcsvc-proto=(rpcgen)
24 HOST_BUILD_DEPENDS:=python3/host rpcsvc-proto/host perl/host perl-parse-yapp/host
25 PKG_BUILD_DEPENDS:=samba4/host libtasn1/host
26
27 PKG_CONFIG_DEPENDS:= \
28 CONFIG_SAMBA4_SERVER_NETBIOS \
29 CONFIG_SAMBA4_SERVER_AVAHI \
30 CONFIG_SAMBA4_SERVER_VFS \
31 CONFIG_SAMBA4_SERVER_VFSX \
32 CONFIG_SAMBA4_SERVER_AD_DC \
33 CONFIG_PACKAGE_kmod-fs-btrfs \
34 CONFIG_PACKAGE_kmod-fs-xfs
35
36 PYTHON3_PKG_BUILD:=0
37
38 include $(INCLUDE_DIR)/package.mk
39 include $(INCLUDE_DIR)/host-build.mk
40 include $(INCLUDE_DIR)/kernel.mk
41 include $(INCLUDE_DIR)/version.mk
42 include ../../lang/python/python3-host.mk
43 include ../../lang/python/python3-package.mk
44 include ../../lang/perl/perlver.mk
45
46 define Package/samba4/Default
47 SECTION:=net
48 CATEGORY:=Network
49 TITLE:=Samba $(PKG_VERSION)
50 URL:=https://www.samba.org/
51 endef
52
53 define Package/samba4/Default/description
54 The Samba software suite is a collection of programs that implements the
55 SMB/CIFS protocol for UNIX systems, allowing you to serve files and printers.
56
57 Samba 4 implements up-to protocol version SMB v3.1.1 (Win10), supports mDNS via AVAHI and a AD-DC setup via krb5.
58 NOTE: No cluster and printer support.
59 endef
60
61 define Package/samba4-libs
62 $(call Package/samba4/Default)
63 TITLE+= libs
64 DEPENDS:= +libtirpc +libreadline +libpopt +libcap +zlib +libgnutls +libtasn1 +libuuid +libopenssl +USE_GLIBC:libpthread \
65 +PACKAGE_libpam:libpam \
66 +SAMBA4_SERVER_VFS:attr \
67 +SAMBA4_SERVER_VFSX:libaio \
68 +SAMBA4_SERVER_AVAHI:libavahi-client \
69 +SAMBA4_SERVER_AD_DC:python3-cryptodome +SAMBA4_SERVER_AD_DC:libopenldap +SAMBA4_SERVER_AD_DC:jansson +SAMBA4_SERVER_AD_DC:libarchive +SAMBA4_SERVER_AD_DC:acl +SAMBA4_SERVER_AD_DC:attr
70 endef
71
72 define Package/samba4-server
73 $(call Package/samba4/Default)
74 TITLE+= server
75 DEPENDS:= +samba4-libs
76 CONFLICTS:=samba36-server
77 endef
78
79 define Package/samba4-server/description
80 installs: smbd (nmbd) smbpasswd pdbedit testparm (nmblookup) (smbcacls sharesec)
81 (samba samba-tool ntlm_auth samba-gpupdate samba_dnsupdate samba_kcc samba_spnupdate samba_upgradedns samba_downgrade_db)
82
83 This provides the basic fileserver service and is the minimum needed to serve file shares.
84 HINT: https://fitzcarraldoblog.wordpress.com/2016/10/17/a-correct-method-of-configuring-samba-for-browsing-smb-shares-in-a-home-network/
85 endef
86
87 define Package/samba4-server/config
88 select PACKAGE_wsdd2
89 source "$(SOURCE)/Config.in"
90 endef
91
92 define Package/samba4-client
93 $(call Package/samba4/Default)
94 TITLE+= client
95 DEPENDS:= +samba4-libs
96 endef
97
98 define Package/samba4-client/description
99 installs: cifsdd smbclient smbget
100
101 The smbclient program implements a simple ftp-like client for accessing SMB shares
102 endef
103
104 define Package/samba4-admin
105 $(call Package/samba4/Default)
106 TITLE+= admin tools
107 DEPENDS:= +samba4-libs
108 endef
109
110 define Package/samba4-admin/description
111 installs: net smbcontrol profiles rpcclient dbwrap_tool eventlogadm
112 ldbadd ldbdel ldbedit ldbmodify ldbrename ldbsearch
113 tdbbackup tdbdump tdbrestore tdbtool
114
115 Administration tools collection
116 endef
117
118 define Package/samba4-utils
119 $(call Package/samba4/Default)
120 TITLE+= utils
121 DEPENDS:= +samba4-libs
122 endef
123
124 define Package/samba4-utils/description
125 installs: smbstatus smbtree mvxattr smbtar smbcquotas
126
127 Utilities collection
128 endef
129
130 TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections -I$(STAGING_DIR)/usr/include/tirpc
131 TARGET_LDFLAGS += -Wl,--gc-sections,--as-needed
132 # dont mess with sambas private rpath!
133 RSTRIP:=:
134
135 CONFIGURE_VARS += \
136 CPP="$(TARGET_CROSS)cpp"
137
138 CONFIGURE_CMD = ./buildtools/bin/waf
139 HOST_CONFIGURE_CMD = ./buildtools/bin/waf
140
141 # Strip options that WAF configure script does not recognize
142 CONFIGURE_ARGS:=$(filter-out \
143 --target=% \
144 --host=% \
145 --build=% \
146 --program-prefix=% \
147 --program-suffix=% \
148 --disable-nls \
149 --disable-ipv6 \
150 , $(CONFIGURE_ARGS))
151
152 HOST_CONFIGURE_ARGS:=$(filter-out \
153 --target=% \
154 --host=% \
155 --build=% \
156 --program-prefix=% \
157 --program-suffix=% \
158 --disable-nls \
159 --disable-ipv6 \
160 , $(HOST_CONFIGURE_ARGS))
161
162 # Waf needs the "configure" argument
163 CONFIGURE_ARGS:=configure $(CONFIGURE_ARGS)
164 HOST_CONFIGURE_ARGS:=configure $(HOST_CONFIGURE_ARGS)
165
166 CONFIGURE_ARGS += \
167 --hostcc="$(HOSTCC)" \
168 --cross-compile \
169 --cross-answers=cross-answers.txt \
170 --disable-cups \
171 --disable-iprint \
172 --disable-cephfs \
173 --disable-fault-handling \
174 --disable-glusterfs \
175 --disable-spotlight \
176 --enable-fhs \
177 --without-automount \
178 --without-iconv \
179 --without-lttng \
180 --without-ntvfs-fileserver \
181 --without-pam \
182 --without-systemd \
183 --without-utmp \
184 --without-dmapi \
185 --without-fam \
186 --without-gettext \
187 --without-regedit \
188 --without-gpgme
189
190 HOST_CONFIGURE_ARGS += \
191 --hostcc="$(HOSTCC)" \
192 --disable-cups \
193 --disable-iprint \
194 --disable-cephfs \
195 --disable-fault-handling \
196 --disable-glusterfs \
197 --disable-spotlight \
198 --disable-rpath \
199 --disable-rpath-install \
200 --disable-rpath-private-install \
201 --enable-fhs \
202 --without-automount \
203 --without-iconv \
204 --without-lttng \
205 --without-ntvfs-fileserver \
206 --without-pam \
207 --without-systemd \
208 --without-utmp \
209 --without-dmapi \
210 --without-fam \
211 --without-gettext \
212 --without-regedit \
213 --without-gpgme
214
215 HOST_CONFIGURE_ARGS += --disable-avahi --without-quotas --without-acl-support --without-winbind \
216 --without-ad-dc --without-json --without-libarchive --disable-python --nopyc --nopyo \
217 --without-dnsupdate --without-ads --without-ldap --without-ldb-lmdb
218
219 # Optional AES-NI support - https://lists.samba.org/archive/samba-technical/2017-September/122738.html
220 # Support for Nettle wasn't comitted
221 ifdef CONFIG_TARGET_x86_64
222 CONFIGURE_ARGS += --accel-aes=intelaesni
223 else
224 CONFIGURE_ARGS += --accel-aes=none
225 endif
226
227 CONFIGURE_ARGS += \
228 --with-lockdir=/var/lock \
229 --with-logfilebase=/var/log \
230 --with-piddir=/var/run \
231 --with-privatedir=/etc/samba
232
233 # features
234 ifeq ($(CONFIG_SAMBA4_SERVER_VFS),y)
235 CONFIGURE_ARGS += --with-quotas
236 else
237 CONFIGURE_ARGS += --without-quotas
238 endif
239 ifeq ($(CONFIG_SAMBA4_SERVER_AVAHI),y)
240 CONFIGURE_ARGS += --enable-avahi
241 else
242 CONFIGURE_ARGS += --disable-avahi
243 endif
244
245 ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
246 CONFIGURE_ARGS += --without-winbind --without-ldb-lmdb --with-acl-support
247 else
248 CONFIGURE_ARGS += --without-winbind --without-ads --without-ldap --without-ldb-lmdb --without-ad-dc \
249 --without-json --without-libarchive --disable-python --nopyc --nopyo --without-dnsupdate --without-acl-support
250 endif
251
252 SAMBA4_PDB_MODULES :=pdb_smbpasswd,pdb_tdbsam,
253 SAMBA4_AUTH_MODULES :=auth_builtin,auth_sam,auth_unix,
254 SAMBA4_VFS_MODULES :=vfs_default,
255 SAMBA4_VFS_MODULES_SHARED :=auth_script,
256 ifeq ($(CONFIG_SAMBA4_SERVER_VFS),y)
257 SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_fruit,vfs_shadow_copy2,vfs_recycle,vfs_fake_perms,vfs_readonly,vfs_cap,vfs_offline,vfs_crossrename,vfs_catia,vfs_streams_xattr,vfs_xattr_tdb,vfs_default_quota,
258 ifeq ($(CONFIG_PACKAGE_kmod-fs-btrfs),y)
259 SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_btrfs,
260 endif
261 endif
262 ifeq ($(CONFIG_SAMBA4_SERVER_VFSX),y)
263 SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_virusfilter,vfs_shell_snap,vfs_commit,vfs_worm,vfs_aio_fork,vfs_aio_pthread,vfs_netatalk,vfs_dirsort,vfs_fileid,
264 ifeq ($(CONFIG_PACKAGE_kmod-fs-xfs),y)
265 SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_linux_xfs_sgid,
266 endif
267 endif
268 ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
269 SAMBA4_PDB_MODULES :=$(SAMBA4_PDB_MODULES)pdb_samba_dsdb,pdb_ldapsam,
270 SAMBA4_AUTH_MODULES :=$(SAMBA4_AUTH_MODULES)auth_samba4,
271 SAMBA4_VFS_MODULES :=$(SAMBA4_VFS_MODULES)vfs_posixacl,
272 SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_audit,vfs_extd_audit,vfs_full_audit,vfs_acl_xattr,vfs_acl_tdb,
273 # vfs_zfsacl needs https://github.com/zfsonlinux/zfs/tree/master/include/sys/zfs_acl.h
274 # vfs_nfs4acl_xattr needs https://github.com/notriddle/libdrpc/blob/master/rpc/xdr.h
275 endif
276
277 SAMBA4_MODULES :=${SAMBA4_VFS_MODULES}${SAMBA4_AUTH_MODULES}${SAMBA4_PDB_MODULES}
278 SAMBA4_MODULES_SHARDED :=${SAMBA4_VFS_MODULES_SHARED}
279
280 CONFIGURE_ARGS += \
281 --with-static-modules=$(SAMBA4_MODULES)!DEFAULT,!FORCED \
282 --with-shared-modules=$(SAMBA4_MODULES_SHARDED)!DEFAULT,!FORCED
283
284 HOST_CONFIGURE_ARGS += \
285 --with-static-modules=!DEFAULT,!FORCED \
286 --with-shared-modules=!DEFAULT,!FORCED
287
288 # lib bundling
289 PY_VER:=$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR)
290 # NOTE: bundle + make private, we want to avoid version configuration (build, link) conflicts
291 HOST_CONFIGURE_ARGS += --builtin-libraries=replace --nonshared-binary=asn1_compile,compile_et
292 SYSTEM_BUNDLED_LIBS:=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,replace,com_err
293 PYTHON_BUNDLED_LIBS:=pytalloc-util.cpython-$(PY_VER),pyldb-util.cpython-$(PY_VER)
294 # CONFIGURE_ARGS += --builtin-libraries=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,com_err
295 ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
296 CONFIGURE_ARGS += --bundled-libraries=NONE,$(SYSTEM_BUNDLED_LIBS),$(PYTHON_BUNDLED_LIBS)
297 else
298 CONFIGURE_ARGS += --bundled-libraries=NONE,$(SYSTEM_BUNDLED_LIBS)
299 endif
300 CONFIGURE_ARGS += --private-libraries=$(SYSTEM_BUNDLED_LIBS)
301
302 export COMPILE_ET=$(STAGING_DIR_HOSTPKG)/bin/compile_et_samba
303 export ASN1_COMPILE=$(STAGING_DIR_HOSTPKG)/bin/asn1_compile_samba
304
305 # make sure we use the hostpkg build toolset and we need to find host 'yapp'
306 HOST_CONFIGURE_VARS+= \
307 PATH="$(STAGING_DIR_HOSTPKG)/bin:$(STAGING_DIR_HOSTPKG)/usr/bin:$(PATH)"
308 CONFIGURE_VARS += \
309 PATH="$(STAGING_DIR_HOSTPKG)/bin:$(STAGING_DIR_HOSTPKG)/usr/bin:$(PATH)"
310
311 # we need hostpkg bin and target config
312 ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
313 CONFIGURE_VARS += \
314 PYTHON_CONFIG="$(STAGING_DIR)/host/bin/$(PYTHON3)-config"
315 endif
316
317 # we dont need GnuTLS for the host helpers
318 define Host/Prepare
319 $(call Host/Prepare/Default)
320 $(SED) 's,mandatory=True,mandatory=False,g' $(HOST_BUILD_DIR)/wscript_configure_system_gnutls
321 $(SED) 's,gnutls_version =.*,gnutls_version = gnutls_min_required_version,g' $(HOST_BUILD_DIR)/wscript_configure_system_gnutls
322 endef
323 define Host/Compile
324 (cd $(HOST_BUILD_DIR); \
325 ./buildtools/bin/waf build \
326 --targets=asn1_compile,compile_et \
327 )
328 endef
329
330 define Host/Install
331 $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin/
332 # add host tools suffix, prevent conflicts with krb5
333 $(INSTALL_BIN) $(HOST_BUILD_DIR)/bin/asn1_compile $(STAGING_DIR_HOSTPKG)/bin/asn1_compile_samba
334 $(INSTALL_BIN) $(HOST_BUILD_DIR)/bin/compile_et $(STAGING_DIR_HOSTPKG)/bin/compile_et_samba
335 endef
336
337 define Build/Prepare
338 $(Build/Prepare/Default)
339 ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),)
340 # un-bundle dnspython
341 $(SED) '/"dns.resolver":/d' $(PKG_BUILD_DIR)/third_party/wscript
342 # unbundle iso8601
343 $(SED) '/"iso8601":/d' $(PKG_BUILD_DIR)/third_party/wscript
344 endif
345 endef
346
347 define Build/Configure
348 $(CP) ./waf-cross-answers/$(ARCH).txt $(PKG_BUILD_DIR)/cross-answers.txt
349 echo 'Checking uname sysname type: "$(VERSION_DIST)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
350 echo 'Checking uname machine type: "$(ARCH)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
351 echo 'Checking uname release type: "$(LINUX_VERSION)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
352 echo 'Checking uname version type: "$(VERSION_DIST) Linux-$(LINUX_VERSION) $(shell date +%Y-%m-%d)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
353 # NOTE: special answers for freeBSD/CircleCI
354 echo 'checking for clnt_create(): OK' >> $(PKG_BUILD_DIR)/cross-answers.txt
355 $(call Build/Configure/Default)
356 endef
357
358 # Build via "waf install", avoid the make wrapper. (Samba logic is 'waf install' = build + install)
359 define Build/Compile
360 (cd $(PKG_BUILD_DIR); \
361 ./buildtools/bin/waf install \
362 --jobs=$(shell nproc) \
363 --destdir="$(PKG_INSTALL_DIR)" \
364 )
365 endef
366
367 # No default install see above
368 define Build/Install
369 endef
370
371 define Package/samba4-libs/install
372 $(INSTALL_DIR) $(1)/usr/lib
373 $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/
374 # rpath-install
375 $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba $(1)/usr/lib/
376 endef
377
378 define Package/samba4-client/install
379 $(INSTALL_DIR) $(1)/usr/bin
380 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{cifsdd,smbclient,smbget} $(1)/usr/bin/
381 endef
382
383 define Package/samba4-admin/install
384 $(INSTALL_DIR) $(1)/usr/bin
385 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{net,smbcontrol,profiles,rpcclient,dbwrap_tool} $(1)/usr/bin/
386 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{ldbadd,ldbdel,ldbedit,ldbmodify,ldbrename,ldbsearch} $(1)/usr/bin/
387 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{tdbbackup,tdbdump,tdbrestore,tdbtool} $(1)/usr/bin/
388 $(INSTALL_DIR) $(1)/usr/sbin
389 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/eventlogadm $(1)/usr/sbin/
390 endef
391
392 define Package/samba4-utils/install
393 $(INSTALL_DIR) $(1)/usr/bin
394 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbstatus,smbtree,mvxattr,smbtar} $(1)/usr/bin/
395 ifeq ($(CONFIG_SAMBA4_SERVER_VFS),y)
396 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/smbcquotas $(1)/usr/bin/
397 endif
398 endef
399
400 define Package/samba4-server/install
401 $(INSTALL_DIR) $(1)/usr/bin
402 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbpasswd,pdbedit,testparm} $(1)/usr/bin/
403 $(INSTALL_DIR) $(1)/usr/sbin
404 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/smbd $(1)/usr/sbin/
405 ifeq ($(CONFIG_SAMBA4_SERVER_NETBIOS),y)
406 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nmbd $(1)/usr/sbin/
407 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/nmblookup $(1)/usr/bin/
408 endif
409 ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
410 $(INSTALL_DIR) $(1)/usr/lib
411 $(CP) $(PKG_INSTALL_DIR)/usr/lib/$(PYTHON3) $(1)/usr/lib/
412 $(INSTALL_DIR) $(1)/usr/share/
413 $(CP) $(PKG_INSTALL_DIR)/usr/share/samba $(1)/usr/share/
414 # fix wrong hardcoded python3 location
415 $(SED) '1s,^#!/.*python3.*,#!/usr/bin/python3,' $(PKG_INSTALL_DIR)/usr/bin/samba-tool
416 $(SED) '1s,^#!/.*python3.*,#!/usr/bin/python3,' $(PKG_INSTALL_DIR)/usr/sbin/{samba-gpupdate,samba_dnsupdate,samba_kcc,samba_spnupdate,samba_upgradedns,samba_downgrade_db}
417 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{samba-tool,ntlm_auth,oLschema2ldif} $(1)/usr/bin/
418 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{sharesec,smbcacls} $(1)/usr/bin/
419 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{samba,samba-gpupdate,samba_dnsupdate,samba_kcc,samba_spnupdate,samba_upgradedns,samba_downgrade_db} $(1)/usr/sbin/
420 endif
421 $(INSTALL_DIR) $(1)/etc/config $(1)/etc/samba $(1)/etc/init.d
422 $(INSTALL_CONF) ./files/samba.config $(1)/etc/config/samba4
423 $(INSTALL_DATA) ./files/smb.conf.template $(1)/etc/samba
424 $(INSTALL_BIN) ./files/samba.init $(1)/etc/init.d/samba4
425 endef
426
427 define Package/samba4-server/conffiles
428 /etc/config/samba4
429 /etc/samba/smb.conf.template
430 /etc/samba/smb.conf
431 /etc/samba/smbpasswd
432 /etc/samba/secrets.tdb
433 /etc/samba/passdb.tdb
434 /etc/samba/lmhosts
435 /etc/nsswitch.conf
436 /etc/krb5.conf
437 endef
438
439 $(eval $(call HostBuild))
440 $(eval $(call BuildPackage,samba4-libs))
441 $(eval $(call BuildPackage,samba4-server))
442 $(eval $(call BuildPackage,samba4-client))
443 $(eval $(call BuildPackage,samba4-admin))
444 $(eval $(call BuildPackage,samba4-utils))