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.

398 lines
14 KiB

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