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.

394 lines
14 KiB

  1. # Based partially on (wongsyrone/hbl0307106015) versions
  2. include $(TOPDIR)/rules.mk
  3. PKG_NAME:=samba
  4. PKG_VERSION:=4.8.4
  5. PKG_RELEASE:=1
  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:=f5044d149e01894a08b1d114b8b69aed78171a7bb19608bd1fd771453b9a5406
  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_jansson:jansson +PACKAGE_libpthread:libpthread +PACKAGE_libnettle:libnettle \
  45. +PACKAGE_libarchive:libarchive +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
  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. CONFIGURE_ARGS += --accel-aes=none
  133. CONFIGURE_ARGS += \
  134. --with-lockdir=/var/lock \
  135. --with-logfilebase=/var/log \
  136. --with-piddir=/var/run \
  137. --with-privatedir=/etc/samba
  138. CONFIGURE_ARGS += \
  139. --with-system-mitkrb5 "$(STAGING_DIR)/usr" \
  140. --with-system-mitkdc=/usr/sbin/krb5kdc
  141. ## embedded-heimdal
  142. # --bundled-libraries=talloc,tevent,tdb,ldb,com_err,cmocka,roken,wind,hx509,asn1,heimbase,hcrypto,krb5,gssapi,heimntlm,hdb,kdc,NONE
  143. ifeq ($(CONFIG_SAMBA4_SERVER_AVAHI),y)
  144. CONFIGURE_ARGS += --enable-avahi
  145. else
  146. CONFIGURE_ARGS += --disable-avahi
  147. endif
  148. ifeq ($(CONFIG_SAMBA4_SERVER_QUOTAS),y)
  149. CONFIGURE_ARGS += --with-quotas
  150. else
  151. CONFIGURE_ARGS += --without-quotas
  152. endif
  153. ifeq ($(CONFIG_SAMBA4_SERVER_ACL),y)
  154. CONFIGURE_ARGS += --with-acl-support
  155. else
  156. CONFIGURE_ARGS += --without-acl-support
  157. endif
  158. ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
  159. CONFIGURE_ARGS += --enable-gnutls --with-dnsupdate --with-ads --with-ldap
  160. TARGET_CFLAGS := -I$(STAGING_DIR)/usr/include/python2.7 $(TARGET_CFLAGS)
  161. else
  162. CONFIGURE_ARGS += --without-ad-dc --disable-python --nopyc --nopyo --disable-gnutls --without-dnsupdate --without-ads --without-ldap
  163. CONFIGURE_VARS += \
  164. python_LDFLAGS="" \
  165. python_LIBDIR=""
  166. endif
  167. ifeq ($(CONFIG_SAMBA4_SERVER_WINBIND),y)
  168. CONFIGURE_ARGS += --with-winbind
  169. else
  170. CONFIGURE_ARGS += --without-winbind
  171. endif
  172. SAMBA4_IDMAP_MODULES :=
  173. SAMBA4_IDMAP_MODULES_SHARED :=
  174. SAMBA4_PDB_MODULES :=pdb_smbpasswd,pdb_tdbsam,
  175. SAMBA4_AUTH_MODULES :=auth_builtin,auth_sam,auth_unix,auth_script,
  176. SAMBA4_VFS_MODULES :=vfs_default,
  177. ifeq ($(CONFIG_SAMBA4_SERVER_VFS),y)
  178. 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,
  179. ifeq ($(CONFIG_PACKAGE_kmod-fs-btrfs),y)
  180. SAMBA4_VFS_MODULES :=$(SAMBA4_VFS_MODULES)vfs_btrfs,
  181. endif
  182. endif
  183. ifeq ($(CONFIG_SAMBA4_SERVER_VFSX),y)
  184. SAMBA4_VFS_MODULES :=$(SAMBA4_VFS_MODULES)vfs_virusfilter,vfs_shell_snap,vfs_commit,vfs_worm,vfs_xattr_tdb,vfs_aio_fork,vfs_aio_pthread,vfs_netatalk,vfs_dirsort,vfs_fileid,
  185. ifeq ($(CONFIG_PACKAGE_kmod-fs-xfs),y)
  186. SAMBA4_VFS_MODULES :=$(SAMBA4_VFS_MODULES)vfs_linux_xfs_sgid,
  187. endif
  188. endif
  189. ifeq ($(CONFIG_SAMBA4_SERVER_QUOTAS),y)
  190. SAMBA4_VFS_MODULES :=$(SAMBA4_VFS_MODULES)vfs_default_quota,
  191. endif
  192. ifeq ($(CONFIG_SAMBA4_SERVER_ACL),y)
  193. SAMBA4_VFS_MODULES :=$(SAMBA4_VFS_MODULES)vfs_posixacl,vfs_acl_xattr,vfs_acl_tdb,
  194. # vfs_zfsacl needs https://github.com/zfsonlinux/zfs/tree/master/include/sys/zfs_acl.h
  195. # vfs_nfs4acl_xattr needs https://github.com/notriddle/libdrpc/blob/master/rpc/xdr.h
  196. endif
  197. ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
  198. SAMBA4_PDB_MODULES :=$(SAMBA4_PDB_MODULES)pdb_samba_dsdb,
  199. SAMBA4_AUTH_MODULES :=$(SAMBA4_AUTH_MODULES)auth_samba4,
  200. endif
  201. ifeq ($(CONFIG_SAMBA4_SERVER_WINBIND),y)
  202. SAMBA4_IDMAP_MODULES :=$(SAMBA4_IDMAP_MODULES)idmap_passdb,idmap_nss,idmap_tdb,idmap_tdb2,idmap_script,nss_info_template,
  203. SAMBA4_IDMAP_MODULES_SHARED :=$(SAMBA4_IDMAP_MODULES_SHARED)idmap_autorid,idmap_rid,idmap_ad,idmap_rfc2307,
  204. # idmap_ad needs --with-ads
  205. # idmap_rfc2307 needs ldap headers
  206. SAMBA4_AUTH_MODULES :=$(SAMBA4_AUTH_MODULES)auth_winbind,
  207. endif
  208. SAMBA4_MODULES :=${SAMBA4_AUTH_MODULES}${SAMBA4_PDB_MODULES}${SAMBA4_IDMAP_MODULES}${SAMBA4_VFS_MODULES}
  209. SAMBA4_MODULES_SHARDED :=${SAMBA4_IDMAP_MODULES_SHARED}
  210. CONFIGURE_ARGS += \
  211. --with-static-modules=$(SAMBA4_MODULES)!DEFAULT,!FORCED \
  212. --with-shared-modules=$(SAMBA4_MODULES_SHARDED)!DEFAULT,!FORCED
  213. # Setup build/install targets
  214. # CONFIG_PACKAGE_samba4-server
  215. BUILD_TARGETS_SERVER :=smbd/smbd,smbpasswd,pdbedit,testparm
  216. # Optional server targets
  217. ifeq ($(CONFIG_SAMBA4_SERVER_ACL),y)
  218. BUILD_TARGETS_SERVER :=$(BUILD_TARGETS_SERVER),sharesec
  219. endif
  220. ifeq ($(CONFIG_SAMBA4_SERVER_NETBIOS),y)
  221. BUILD_TARGETS_SERVER :=$(BUILD_TARGETS_SERVER),nmbd
  222. endif
  223. ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
  224. BUILD_TARGETS_SERVER :=$(BUILD_TARGETS_SERVER),samba,nsstest,ntlm_auth
  225. endif
  226. ifeq ($(CONFIG_SAMBA4_SERVER_WINBIND),y)
  227. BUILD_TARGETS_SERVER :=$(BUILD_TARGETS_SERVER),winbindd,wbinfo,winbind_krb5_locator
  228. endif
  229. # CONFIG_PACKAGE_samba4-client
  230. BUILD_TARGETS_CLIENT :=client/smbclient,client/cifsdd
  231. # CONFIG_PACKAGE_samba4-admin
  232. BUILD_TARGETS_ADMIN :=net,smbcontrol,profiles,rpcclient,smbcacls,smbcquotas
  233. # CONFIG_PACKAGE_samba4-utils
  234. BUILD_TARGETS_UTILS :=smbstatus,smbtree,smbget,mvxattr,nmblookup
  235. # lib bundling
  236. # NOTE: Compile some unique libs into related bins, so we end-up with a unified samba4-libs base, mainly to allow package separation (server, client, admin, utils)
  237. CONFIGURE_ARGS += --builtin-libraries=smbclient,netapi,samba-passdb,ads,auth,cli-spoolss,libcli-lsa3,gpext,talloc,tevent,texpect,tdb,ldb,tdr,cmocka,replace
  238. #CONFIGURE_ARGS += --nonshared-binary=$(BUILD_TARGETS_SERVER)
  239. # NOTE: bundle + make private, we want to avoid version configuration (build, link) conflicts
  240. ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
  241. CONFIGURE_ARGS += --bundled-libraries=talloc,tevent,texpect,tdb,ldb,tdr,cmocka,replace,pytalloc-util,pyldb-util,NONE
  242. else
  243. CONFIGURE_ARGS += --bundled-libraries=talloc,tevent,texpect,tdb,ldb,tdr,cmocka,replace,NONE
  244. endif
  245. CONFIGURE_ARGS += --private-libraries=talloc,tevent,texpect,tdb,ldb,tdr,cmocka,replace
  246. define Build/Prepare
  247. $(Build/Prepare/Default)
  248. ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),)
  249. # un-bundle dnspython
  250. $(SED) '/"dns.resolver":/d' $(PKG_BUILD_DIR)/third_party/wscript
  251. # unbundle iso8601
  252. $(SED) '/"iso8601":/d' $(PKG_BUILD_DIR)/third_party/wscript
  253. endif
  254. endef
  255. define Build/Configure
  256. $(CP) ./waf-cross-answers/$(ARCH).txt $(PKG_BUILD_DIR)/cross-answers.txt
  257. echo 'Checking uname machine type: "$(ARCH)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
  258. echo 'Checking uname release type: "$(LINUX_VERSION)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
  259. echo 'Checking uname version type: "$(VERSION_DIST) Linux-$(LINUX_VERSION) $(shell date +%Y-%m-%d)"' >> $(PKG_BUILD_DIR)/cross-answers.txt
  260. # NOTE: For some unknown reason this answer is not needed on some hosts/distros, yet needed on others?
  261. echo 'Checking whether POSIX capabilities are available: OK' >> $(PKG_BUILD_DIR)/cross-answers.txt
  262. $(call Build/Configure/Default,configure)
  263. endef
  264. # BUG: We need to use "waf install --targets=" otherwise a "make install" or "waf install" will retrigger a full recompile of all possible targets!
  265. define Build/Compile
  266. (cd $(PKG_BUILD_DIR); \
  267. ./buildtools/bin/waf install -j$(shell nproc) \
  268. --targets=$(SAMBA4_MODULES)$(SAMBA4_MODULES_SHARDED)$(BUILD_TARGETS_SERVER),$(BUILD_TARGETS_UTILS),$(BUILD_TARGETS_ADMIN),$(BUILD_TARGETS_CLIENT) \
  269. --destdir="$(PKG_INSTALL_DIR)" \
  270. )
  271. endef
  272. # No default install see above
  273. define Build/Install
  274. endef
  275. define Package/samba4-libs/install
  276. $(INSTALL_DIR) $(1)/usr/lib
  277. $(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/
  278. $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba/*.so* $(1)/usr/lib/
  279. endef
  280. define Package/samba4-client/install
  281. $(INSTALL_DIR) $(1)/usr/bin
  282. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbclient,cifsdd} $(1)/usr/bin/
  283. endef
  284. define Package/samba4-admin/install
  285. $(INSTALL_DIR) $(1)/usr/bin
  286. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{net,smbcontrol,profiles,rpcclient,smbcacls,smbcquotas} $(1)/usr/bin/
  287. endef
  288. define Package/samba4-utils/install
  289. $(INSTALL_DIR) $(1)/usr/bin
  290. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbstatus,smbtree,smbget,mvxattr,nmblookup} $(1)/usr/bin/
  291. endef
  292. define Package/samba4-server/install
  293. $(INSTALL_DIR) $(1)/usr/lib/samba
  294. if [ -d $(PKG_INSTALL_DIR)/usr/lib/samba/idmap ]; then \
  295. $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba/idmap $(1)/usr/lib/samba/; \
  296. fi
  297. if [ -d $(PKG_INSTALL_DIR)/usr/lib/samba/auth ]; then \
  298. $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba/auth $(1)/usr/lib/samba/; \
  299. fi
  300. if [ -d $(PKG_INSTALL_DIR)/usr/lib/samba/vfs ]; then \
  301. $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba/vfs $(1)/usr/lib/samba/; \
  302. fi
  303. if [ -d $(PKG_INSTALL_DIR)/usr/lib/samba/pdb ]; then \
  304. $(CP) $(PKG_INSTALL_DIR)/usr/lib/samba/pdb $(1)/usr/lib/samba/; \
  305. fi
  306. $(INSTALL_DIR) $(1)/usr/bin
  307. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{smbpasswd,pdbedit,testparm} $(1)/usr/bin/
  308. $(INSTALL_DIR) $(1)/usr/sbin
  309. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/smbd $(1)/usr/sbin/
  310. ifeq ($(CONFIG_SAMBA4_SERVER_AD_DC),y)
  311. $(CP) $(PKG_INSTALL_DIR)/usr/lib/python2.7 $(1)/usr/lib/
  312. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{samba-tool,ntlm_auth} $(1)/usr/bin
  313. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{samba,samba_gpoupdate,samba_dnsupdate,samba_kcc,samba_spnupdate,samba_upgradedns} $(1)/usr/sbin/
  314. endif
  315. ifeq ($(CONFIG_SAMBA4_SERVER_NETBIOS),y)
  316. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nmbd $(1)/usr/sbin/
  317. endif
  318. ifeq ($(CONFIG_SAMBA4_SERVER_WINBIND),y)
  319. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/wbinfo $(1)/usr/bin/
  320. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/winbindd $(1)/usr/sbin/
  321. endif
  322. ifeq ($(CONFIG_SAMBA4_SERVER_ACL),y)
  323. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sharesec $(1)/usr/bin/
  324. endif
  325. $(INSTALL_DIR) $(1)/etc/config $(1)/etc/samba $(1)/etc/init.d
  326. $(INSTALL_DATA) ./files/samba.config $(1)/etc/config/samba4
  327. $(INSTALL_DATA) ./files/smb.conf.template $(1)/etc/samba
  328. $(INSTALL_BIN) ./files/samba.init $(1)/etc/init.d/samba4
  329. endef
  330. define Package/samba4-server/conffiles
  331. /etc/config/samba4
  332. /etc/samba/smb.conf.template
  333. /etc/samba/smb.conf
  334. /etc/samba/smbpasswd
  335. /etc/samba/secrets.tdb
  336. /etc/samba/passdb.tdb
  337. /etc/samba/idmap.ldb
  338. /etc/samba/lmhosts
  339. /etc/nsswitch.conf
  340. endef
  341. $(eval $(call BuildPackage,samba4-libs))
  342. $(eval $(call BuildPackage,samba4-server))
  343. $(eval $(call BuildPackage,samba4-client))
  344. $(eval $(call BuildPackage,samba4-admin))
  345. $(eval $(call BuildPackage,samba4-utils))