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.

385 lines
13 KiB

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