You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

417 lines
14 KiB

  1. # Based partially on (wongsyrone/hbl0307106015) versions
  2. include $(TOPDIR)/rules.mk
  3. PKG_NAME:=samba
  4. PKG_VERSION:=4.9.16
  5. PKG_RELEASE:=1
  6. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  7. PKG_SOURCE_URL:=https://ftp.heanet.ie/mirrors/ftp.samba.org/stable/ \
  8. https://ftp.gwdg.de/pub/samba/stable/ \
  9. https://ftp.riken.jp/net/samba/samba/stable/ \
  10. http://www.nic.funet.fi/index/samba/pub/samba/stable/ \
  11. http://samba.mirror.bit.nl/samba/ftp/stable/ \
  12. https://download.samba.org/pub/samba/stable/
  13. PKG_HASH:=613987fac719ed90f3daad6ca12517329f0754dd51c573f6b3623e6b03cb3916
  14. PKG_MAINTAINER:=Andy Walsh <andy.walsh44+github@gmail.com>
  15. PKG_LICENSE:=GPL-3.0-only
  16. PKG_LICENSE_FILES:=COPYING
  17. PKG_CPE_ID:=cpe:/a:samba:samba
  18. # samba4=(asn1_compile,compile_et) nfs-kernel-server=(rpcgen)
  19. HOST_BUILD_DEPENDS:=python/host nfs-kernel-server/host
  20. PKG_BUILD_DEPENDS:=samba4/host
  21. PKG_CONFIG_DEPENDS:= \
  22. CONFIG_SAMBA4_SERVER_NETBIOS \
  23. CONFIG_SAMBA4_SERVER_AVAHI \
  24. CONFIG_SAMBA4_SERVER_VFS \
  25. CONFIG_SAMBA4_SERVER_VFSX \
  26. CONFIG_SAMBA4_SERVER_QUOTAS \
  27. CONFIG_SAMBA4_SERVER_ACL \
  28. CONFIG_PACKAGE_kmod-fs-btrfs \
  29. CONFIG_PACKAGE_kmod-fs-xfs
  30. include $(INCLUDE_DIR)/package.mk
  31. include $(INCLUDE_DIR)/host-build.mk
  32. include $(INCLUDE_DIR)/kernel.mk
  33. include $(INCLUDE_DIR)/version.mk
  34. define Package/samba4/Default
  35. SECTION:=net
  36. CATEGORY:=Network
  37. TITLE:=Samba $(PKG_VERSION)
  38. URL:=https://www.samba.org/
  39. endef
  40. define Package/samba4/Default/description
  41. The Samba software suite is a collection of programs that implements the
  42. SMB/CIFS protocol for UNIX systems, allowing you to serve files and printers.
  43. Samba 4 implements up-to protocol version SMB v3.1.1 (Win10), supports mDNS via AVAHI and a AD-DC setup via krb5.
  44. NOTE: No cluster and printer support.
  45. endef
  46. define Package/samba4-libs
  47. $(call Package/samba4/Default)
  48. TITLE+= libs
  49. DEPENDS:= +zlib +libtirpc +libpopt +libreadline +libcap \
  50. +PACKAGE_libpthread:libpthread +PACKAGE_libnettle:libnettle +PACKAGE_libgcrypt:libgcrypt +PACKAGE_libpam:libpam +PACKAGE_dbus:dbus +PACKAGE_libavahi-client:libavahi-client \
  51. +SAMBA4_SERVER_VFS:attr \
  52. +SAMBA4_SERVER_ACL:acl +SAMBA4_SERVER_ACL:attr \
  53. +SAMBA4_SERVER_AVAHI:libavahi-client
  54. endef
  55. define Package/samba4-server
  56. $(call Package/samba4/Default)
  57. TITLE+= server
  58. DEPENDS:= +samba4-libs
  59. endef
  60. define Package/samba4-server/description
  61. installs: smbd, nmbd (daemon) smbpasswd pdbedit testparm
  62. This provides the basic fileserver service and is the minimum needed to serve file shares.
  63. HINT: https://fitzcarraldoblog.wordpress.com/2016/10/17/a-correct-method-of-configuring-samba-for-browsing-smb-shares-in-a-home-network/
  64. endef
  65. define Package/samba4-server/config
  66. select PACKAGE_wsdd2
  67. source "$(SOURCE)/Config.in"
  68. endef
  69. define Package/samba4-client
  70. $(call Package/samba4/Default)
  71. TITLE+= client
  72. DEPENDS:= +samba4-libs
  73. endef
  74. define Package/samba4-client/description
  75. installs: smbclient cifsdd
  76. The smbclient program implements a simple ftp-like client for accessing SMB shares
  77. endef
  78. define Package/samba4-admin
  79. $(call Package/samba4/Default)
  80. TITLE+= admin tools
  81. DEPENDS:= +samba4-libs
  82. endef
  83. define Package/samba4-admin/description
  84. installs: net smbcontrol profiles rpcclient smbcacls smbcquotas
  85. Administration tools collection
  86. endef
  87. define Package/samba4-utils
  88. $(call Package/samba4/Default)
  89. TITLE+= utils
  90. DEPENDS:= +samba4-libs
  91. endef
  92. define Package/samba4-utils/description
  93. installs: smbstatus smbtree smbget nmblookup mvxattr
  94. Utilities collection
  95. endef
  96. TARGET_CFLAGS += -ffunction-sections -fdata-sections
  97. TARGET_LDFLAGS += -Wl,--gc-sections
  98. CONFIGURE_VARS += \
  99. CPP="$(TARGET_CROSS)cpp"
  100. CONFIGURE_CMD = ./buildtools/bin/waf
  101. HOST_CONFIGURE_CMD = ./buildtools/bin/waf
  102. # Strip options that WAF configure script does not recognize
  103. CONFIGURE_ARGS:=$(filter-out \
  104. --target=% \
  105. --host=% \
  106. --build=% \
  107. --program-prefix=% \
  108. --program-suffix=% \
  109. --disable-nls \
  110. --disable-ipv6 \
  111. , $(CONFIGURE_ARGS))
  112. HOST_CONFIGURE_ARGS:=$(filter-out \
  113. --target=% \
  114. --host=% \
  115. --build=% \
  116. --program-prefix=% \
  117. --program-suffix=% \
  118. --disable-nls \
  119. --disable-ipv6 \
  120. , $(HOST_CONFIGURE_ARGS))
  121. # Waf needs the "configure" argument
  122. CONFIGURE_ARGS:=configure $(CONFIGURE_ARGS)
  123. HOST_CONFIGURE_ARGS:=configure $(HOST_CONFIGURE_ARGS)
  124. CONFIGURE_ARGS += \
  125. --hostcc="$(HOSTCC)" \
  126. --cross-compile \
  127. --cross-answers=cross-answers.txt \
  128. --disable-cups \
  129. --disable-iprint \
  130. --disable-cephfs \
  131. --disable-fault-handling \
  132. --disable-glusterfs \
  133. --disable-rpath \
  134. --disable-rpath-install \
  135. --disable-rpath-private-install \
  136. --enable-fhs \
  137. --without-automount \
  138. --without-iconv \
  139. --without-lttng \
  140. --without-ntvfs-fileserver \
  141. --without-pam \
  142. --without-systemd \
  143. --without-utmp \
  144. --without-dmapi \
  145. --without-fam \
  146. --without-gettext \
  147. --without-regedit \
  148. --without-gpgme
  149. HOST_CONFIGURE_ARGS += \
  150. --hostcc="$(HOSTCC)" \
  151. --disable-cups \
  152. --disable-iprint \
  153. --disable-cephfs \
  154. --disable-fault-handling \
  155. --disable-glusterfs \
  156. --disable-rpath \
  157. --disable-rpath-install \
  158. --disable-rpath-private-install \
  159. --enable-fhs \
  160. --without-automount \
  161. --without-iconv \
  162. --without-lttng \
  163. --without-ntvfs-fileserver \
  164. --without-pam \
  165. --without-systemd \
  166. --without-utmp \
  167. --without-dmapi \
  168. --without-fam \
  169. --without-gettext \
  170. --without-regedit \
  171. --without-gpgme
  172. HOST_CONFIGURE_ARGS += --disable-avahi --without-quotas --without-acl-support --without-winbind \
  173. --without-ad-dc --without-json-audit --without-libarchive --disable-python --nopyc --nopyo \
  174. --disable-gnutls --without-dnsupdate --without-ads --without-ldap
  175. HOST_CONFIGURE_VARS += python_LDFLAGS="" python_LIBDIR=""
  176. # Optional AES-NI support - https://lists.samba.org/archive/samba-technical/2017-September/122738.html
  177. # Support for Nettle wasn't comitted
  178. ifdef CONFIG_TARGET_x86_64
  179. CONFIGURE_ARGS += --accel-aes=intelaesni
  180. else
  181. CONFIGURE_ARGS += --accel-aes=none
  182. endif
  183. CONFIGURE_ARGS += \
  184. --with-lockdir=/var/lock \
  185. --with-logfilebase=/var/log \
  186. --with-piddir=/var/run \
  187. --with-privatedir=/etc/samba
  188. ifeq ($(CONFIG_SAMBA4_SERVER_AVAHI),y)
  189. CONFIGURE_ARGS += --enable-avahi
  190. else
  191. CONFIGURE_ARGS += --disable-avahi
  192. endif
  193. ifeq ($(CONFIG_SAMBA4_SERVER_QUOTAS),y)
  194. CONFIGURE_ARGS += --with-quotas
  195. else
  196. CONFIGURE_ARGS += --without-quotas
  197. endif
  198. ifeq ($(CONFIG_SAMBA4_SERVER_ACL),y)
  199. CONFIGURE_ARGS += --with-acl-support
  200. else
  201. CONFIGURE_ARGS += --without-acl-support
  202. endif
  203. # features
  204. CONFIGURE_ARGS += --without-ad-dc --without-json-audit --without-libarchive --disable-python --nopyc --nopyo \
  205. --disable-gnutls --without-dnsupdate --without-ads --without-ldap
  206. CONFIGURE_VARS += \
  207. python_LDFLAGS="" \
  208. python_LIBDIR=""
  209. SAMBA4_PDB_MODULES :=pdb_smbpasswd,pdb_tdbsam,
  210. SAMBA4_AUTH_MODULES :=auth_builtin,auth_sam,auth_unix,auth_script,
  211. SAMBA4_VFS_MODULES :=vfs_default,
  212. SAMBA4_VFS_MODULES_SHARED :=
  213. ifeq ($(CONFIG_SAMBA4_SERVER_VFS),y)
  214. 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,
  215. ifeq ($(CONFIG_PACKAGE_kmod-fs-btrfs),y)
  216. SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_btrfs,
  217. endif
  218. endif
  219. ifeq ($(CONFIG_SAMBA4_SERVER_VFSX),y)
  220. 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,
  221. ifeq ($(CONFIG_PACKAGE_kmod-fs-xfs),y)
  222. SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_linux_xfs_sgid,
  223. endif
  224. endif
  225. ifeq ($(CONFIG_SAMBA4_SERVER_QUOTAS),y)
  226. SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_default_quota,
  227. endif
  228. ifeq ($(CONFIG_SAMBA4_SERVER_ACL),y)
  229. SAMBA4_VFS_MODULES :=$(SAMBA4_VFS_MODULES)vfs_posixacl,
  230. SAMBA4_VFS_MODULES_SHARED :=$(SAMBA4_VFS_MODULES_SHARED)vfs_acl_xattr,vfs_acl_tdb,
  231. # vfs_zfsacl needs https://github.com/zfsonlinux/zfs/tree/master/include/sys/zfs_acl.h
  232. # vfs_nfs4acl_xattr needs https://github.com/notriddle/libdrpc/blob/master/rpc/xdr.h
  233. endif
  234. SAMBA4_MODULES :=${SAMBA4_VFS_MODULES}${SAMBA4_AUTH_MODULES}${SAMBA4_PDB_MODULES}
  235. SAMBA4_MODULES_SHARDED :=${SAMBA4_VFS_MODULES_SHARED}
  236. CONFIGURE_ARGS += \
  237. --with-static-modules=$(SAMBA4_MODULES)!DEFAULT,!FORCED \
  238. --with-shared-modules=$(SAMBA4_MODULES_SHARDED)!DEFAULT,!FORCED
  239. HOST_CONFIGURE_ARGS += \
  240. --with-static-modules=!DEFAULT,!FORCED \
  241. --with-shared-modules=!DEFAULT,!FORCED
  242. # Setup build/install targets
  243. # CONFIG_PACKAGE_samba4-server
  244. BUILD_TARGETS_SERVER :=smbd/smbd,smbpasswd,pdbedit,testparm
  245. # Optional server targets
  246. ifeq ($(CONFIG_SAMBA4_SERVER_ACL),y)
  247. BUILD_TARGETS_SERVER :=$(BUILD_TARGETS_SERVER),sharesec
  248. endif
  249. ifeq ($(CONFIG_SAMBA4_SERVER_NETBIOS),y)
  250. BUILD_TARGETS_SERVER :=$(BUILD_TARGETS_SERVER),nmbd
  251. endif
  252. # CONFIG_PACKAGE_samba4-client
  253. BUILD_TARGETS_CLIENT :=client/smbclient,client/cifsdd
  254. # CONFIG_PACKAGE_samba4-admin
  255. BUILD_TARGETS_ADMIN :=net,smbcontrol,profiles,rpcclient,smbcacls,smbcquotas,eventlogadm
  256. # CONFIG_PACKAGE_samba4-utils
  257. BUILD_TARGETS_UTILS :=smbstatus,smbtree,smbget,mvxattr,nmblookup
  258. # lib bundling
  259. # NOTE: bundle + make private, we want to avoid version configuration (build, link) conflicts
  260. CONFIGURE_ARGS += --builtin-libraries=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,com_err
  261. HOST_CONFIGURE_ARGS += --builtin-libraries=replace --nonshared-binary=asn1_compile,compile_et
  262. #CONFIGURE_ARGS += --bundled-libraries=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,replace,!asn1_compile,!compile_et,!popt
  263. CONFIGURE_ARGS += --bundled-libraries=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,replace,com_err,roken,wind,hx509,asn1,heimbase,hcrypto,krb5,gssapi,heimntlm,hdb,kdc,NONE
  264. # BUG: --private-libraries, Does not work for System possible libs, will not get "samba4" suffix!
  265. CONFIGURE_ARGS += --private-libraries=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,replace,com_err
  266. # CONFIGURE_ARGS += --disable-symbol-versions
  267. define Host/Compile
  268. (cd $(HOST_BUILD_DIR); \
  269. ./buildtools/bin/waf build \
  270. --targets=asn1_compile,compile_et \
  271. )
  272. endef
  273. define Host/Install
  274. $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin/
  275. # add host tools suffix, prevent conflicts with krb5
  276. $(INSTALL_BIN) $(HOST_BUILD_DIR)/bin/asn1_compile $(STAGING_DIR_HOSTPKG)/bin/asn1_compile_samba
  277. $(INSTALL_BIN) $(HOST_BUILD_DIR)/bin/compile_et $(STAGING_DIR_HOSTPKG)/bin/compile_et_samba
  278. endef
  279. define Build/Prepare
  280. $(Build/Prepare/Default)
  281. # un-bundle dnspython
  282. $(SED) '/"dns.resolver":/d' $(PKG_BUILD_DIR)/third_party/wscript
  283. # unbundle iso8601
  284. $(SED) '/"iso8601":/d' $(PKG_BUILD_DIR)/third_party/wscript
  285. endef
  286. define Build/Configure
  287. $(CP) ./waf-cross-answers/$(ARCH).txt $(PKG_BUILD_DIR)/cross-answers.txt
  288. echo 'Checking uname machine type: "$(ARCH)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
  289. echo 'Checking uname release type: "$(LINUX_VERSION)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
  290. echo 'Checking uname version type: "$(VERSION_DIST) Linux-$(LINUX_VERSION) $(shell date +%Y-%m-%d)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
  291. # NOTE: For some unknown reason this answer is not needed on some hosts/distros, yet needed on others?
  292. echo 'Checking whether POSIX capabilities are available: OK' >> $(PKG_BUILD_DIR)/cross-answers.txt
  293. $(call Build/Configure/Default)
  294. endef
  295. # Note: We need to build via "waf install --targets=". Why do we also need to add the modules as targets here?
  296. define Build/Compile
  297. (cd $(PKG_BUILD_DIR); \
  298. ./buildtools/bin/waf install \
  299. --jobs=$(shell nproc) \
  300. --destdir="$(PKG_INSTALL_DIR)" \
  301. --targets=$(SAMBA4_MODULES)$(SAMBA4_MODULES_SHARDED)$(BUILD_TARGETS_SERVER),$(BUILD_TARGETS_UTILS),$(BUILD_TARGETS_ADMIN),$(BUILD_TARGETS_CLIENT) \
  302. )
  303. endef
  304. # No default install see above
  305. define Build/Install
  306. endef
  307. define Package/samba4-libs/install
  308. $(INSTALL_DIR) $(1)/usr/lib
  309. $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/
  310. $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba/*.so* $(1)/usr/lib/
  311. $(INSTALL_DIR) $(1)/usr/lib/samba/vfs $(1)/usr/lib/samba/ldb $(1)/usr/lib/samba/krb5
  312. if [ -d $(PKG_INSTALL_DIR)/usr/lib/samba/vfs ]; then \
  313. $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba/vfs $(1)/usr/lib/samba/; \
  314. fi
  315. if [ -d $(PKG_INSTALL_DIR)/usr/lib/samba/krb5 ]; then \
  316. $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba/krb5 $(1)/usr/lib/samba/; \
  317. fi
  318. endef
  319. define Package/samba4-client/install
  320. $(INSTALL_DIR) $(1)/usr/bin
  321. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbclient,cifsdd} $(1)/usr/bin/
  322. endef
  323. define Package/samba4-admin/install
  324. $(INSTALL_DIR) $(1)/usr/bin
  325. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{net,smbcontrol,profiles,rpcclient,smbcacls,smbcquotas} $(1)/usr/bin/
  326. $(INSTALL_DIR) $(1)/usr/sbin
  327. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/eventlogadm $(1)/usr/sbin/
  328. endef
  329. define Package/samba4-utils/install
  330. $(INSTALL_DIR) $(1)/usr/bin
  331. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbstatus,smbtree,smbget,mvxattr,nmblookup} $(1)/usr/bin/
  332. endef
  333. define Package/samba4-server/install
  334. $(INSTALL_DIR) $(1)/usr/bin
  335. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbpasswd,pdbedit,testparm} $(1)/usr/bin/
  336. $(INSTALL_DIR) $(1)/usr/sbin
  337. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/smbd $(1)/usr/sbin/
  338. ifeq ($(CONFIG_SAMBA4_SERVER_NETBIOS),y)
  339. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nmbd $(1)/usr/sbin/
  340. endif
  341. ifeq ($(CONFIG_SAMBA4_SERVER_ACL),y)
  342. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sharesec $(1)/usr/bin/
  343. endif
  344. $(INSTALL_DIR) $(1)/etc/config $(1)/etc/samba $(1)/etc/init.d
  345. $(INSTALL_CONF) ./files/samba.config $(1)/etc/config/samba4
  346. $(INSTALL_DATA) ./files/smb.conf.template $(1)/etc/samba
  347. $(INSTALL_BIN) ./files/samba.init $(1)/etc/init.d/samba4
  348. endef
  349. define Package/samba4-server/conffiles
  350. /etc/config/samba4
  351. /etc/samba/smb.conf.template
  352. /etc/samba/smb.conf
  353. /etc/samba/smbpasswd
  354. /etc/samba/secrets.tdb
  355. /etc/samba/passdb.tdb
  356. endef
  357. $(eval $(call HostBuild))
  358. $(eval $(call BuildPackage,samba4-libs))
  359. $(eval $(call BuildPackage,samba4-server))
  360. $(eval $(call BuildPackage,samba4-client))
  361. $(eval $(call BuildPackage,samba4-admin))
  362. $(eval $(call BuildPackage,samba4-utils))