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