Skip to contentSkip to conversation

samba4: allow build of libsmbclient only

RFC New zooey at hirschkaefer.de 2 participants 5 messages Sep 27, 2014 – Feb 3, 2015

lore
Share & tools
lore
#0 lore raw

cover samba4: allow build of libsmbclient only

Hi,

this set of patches is a first draft of allowing a separate build of samba4's libsmbclient. Most of our devices don't need all of the other samba servers and tools, so it seems a bit of a waste having to build them all.

The first patch contains the naive attempt at implementing the separation.

However, it seems that samba4's build system gets confused when not all targets have been built, as it tries to install manpages along with libsmbclient which haven't been generated during the build phase. Patch 2 works around the problem by deactivating installation of manpages in general, but as that is hardly acceptable, I wonder if anyone here has a better idea?

Patch 3 appies --disable-rpath-private-install in order to work around another build problem, which is apparently caused by libsmbclient.inst.so (and additional install libraries) to not have been created during the build phase. Again, the solution proposed in the patch isn't a good one, as it basically means that samba4's private libraries are not being built with RPATH set, which is bound to cause problems at runtime (they won't be found by the runtime loader). As with patch 2, I'd be grateful for any hints at better solutions.

Thanks for any input.

cheers,
Oliver

#1 lore raw

RFC 1/3 samba4: allow separate build of libsmbclient

From: Oliver Tappe <[email protected]>

Introduce new config option BR2_PACKAGE_SAMBA4_CLIENT_LIB and adjust samba4.mk accordingly. Additionally, add patch that adds the required Makefile targets smbclient and install_smbclient.

---
 package/samba4/Config.in                           | 10 +++++++
 ...d-smbclient-and-install_smbclient-targets.patch | 35 ++++++++++++++++++++++
 package/samba4/samba4.mk                           | 16 ++++++++--
 3 files changed, 59 insertions(+), 2 deletions(-)
 create mode 100644 package/samba4/samba4-0010-build-add-smbclient-and-install_smbclient-targets.patch
package/samba4/Config.in +10 -0
index 60e0f55..308debd 100644
@@ -1,6 +1,16 @@
+config BR2_PACKAGE_SAMBA4_CLIENT_LIB
+	depends on !BR2_PACKAGE_SAMBA
+	bool "samba4 client library"
+	help
+	  libsmbclient is a library toolset that permits applications
+	  to manipulate CIFS/SMB network resources using many of the
+	  standards POSIX functions available for manipulating local
+	  files.
+
 config BR2_PACKAGE_SAMBA4
 	bool "samba4"
 	depends on !BR2_PACKAGE_SAMBA
+	depends on !BR2_PACKAGE_SAMBA4_CLIENT_LIB
 	depends on BR2_INET_IPV6
 	depends on BR2_USE_MMU # fork()
 	depends on BR2_USE_WCHAR # e2fsprogs
package/samba4/samba4-0010-build-add-smbclient-and-install_smbclient-targets.patch new file +35 -0
new file mode 100644
index 0000000..1f155c4
@@ -0,0 +1,35 @@
+From 255c0386275b64477801075b17edb3a647b01fd1 Mon Sep 17 00:00:00 2001
+From: Oliver Tappe <[email protected]>
+Date: Fri, 26 Sep 2014 18:37:17 +0200
+Subject: [PATCH] build: add smbclient and install_smbclient targets
+
+This (together with patches to buildroot's samba4.mk) makes it
+possible to build libsmbclient.so and all of its dependencies
+without needing to build all of samba.
+---
+ Makefile | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 5f220fa..bcc886c 100644
+--- a/Makefile
++++ b/Makefile
+@@ -7,9 +7,15 @@ WAF=WAF_MAKE=1 $(WAF_BINARY)
+ all:
+ 	$(WAF) build
+ 
++smbclient:
++	$(WAF) build --targets=smbclient
++
+ install:
+ 	$(WAF) install
+ 
++install_smbclient:
++	$(WAF) install --targets=smbclient
++
+ uninstall:
+ 	$(WAF) uninstall
+ 
+-- 
+1.8.4.5
+
package/samba4/samba4.mk +14 -2
index e1ee33f..1826c01 100644
@@ -69,6 +69,14 @@ else
 	SAMBA4_CONF_OPT += --without-regedit
 endif
 
+ifeq ($(BR2_PACKAGE_SAMBA4_CLIENT_LIB),y)
+	SAMBA4_WAF_BUILD_TARGET = smbclient
+	SAMBA4_WAF_INSTALL_TARGET = install_smbclient
+else
+	SAMBA4_WAF_BUILD_TARGET = all
+	SAMBA4_WAF_INSTALL_TARGET = install
+endif
+
 define SAMBA4_CONFIGURE_CMDS
 	cp package/samba4/samba4-cache.txt $(@D)/cache.txt;
 	echo 'Checking uname machine type: $(BR2_ARCH)' >>$(@D)/cache.txt;
@@ -102,13 +110,15 @@ define SAMBA4_CONFIGURE_CMDS
 endef
 
 define SAMBA4_BUILD_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(SAMBA4_WAF_BUILD_TARGET)
 endef
 
 define SAMBA4_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) $(SAMBA4_WAF_INSTALL_TARGET)
 endef
 
+ifneq ($(BR2_PACKAGE_SAMBA4_CLIENT_LIB),y)
+
 # Samba just installs .py files so the purge causes problems with some tools
 ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY),y)
 define SAMBA4_BUILD_PYC_FILES
@@ -133,4 +143,6 @@ endef
 SAMBA4_POST_INSTALL_TARGET_HOOKS += SAMBA4_MOVE_LIBS
 endif
 
+endif	# BR2_PACKAGE_SAMBA4_CLIENT_LIB
+
 $(eval $(generic-package))
Signature · 1 line
1.8.4.5
#2 lore raw

RFC 2/3 samba4: add hacky patch that avoids manpage creation

In reply to zooey at hirschkaefer.de

From: Oliver Tappe <[email protected]>

Otherwise, installation of smbclient fails.

---
 ...0011-build-avoid-installation-of-manpages.patch | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 package/samba4/samba4-0011-build-avoid-installation-of-manpages.patch
package/samba4/samba4-0011-build-avoid-installation-of-manpages.patch new file +40 -0
new file mode 100644
index 0000000..9a3f012
@@ -0,0 +1,40 @@
+From d39b348c3b8c210ba460f27ce50bc87f867f5705 Mon Sep 17 00:00:00 2001
+From: Oliver Tappe <[email protected]>
+Date: Fri, 26 Sep 2014 19:16:38 +0200
+Subject: [PATCH] build: avoid installation of manpages
+
+Somehow, telling waf to install the 'smbclient' target will also
+try to install manpages which have not been generated when during
+the build stage of 'smbclient'. Deactivate the installation of
+man pages as a (grossly hackish) workaround.
+---
+ buildtools/wafsamba/wafsamba.py | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
+index aaa0939..a5a476d 100644
+--- a/buildtools/wafsamba/wafsamba.py
++++ b/buildtools/wafsamba/wafsamba.py
+@@ -800,8 +800,8 @@ def MANPAGES(bld, manpages, install):
+                             group='final',
+                             rule='${XSLTPROC} --xinclude -o ${TGT} --nonet ${MAN_XSL} ${SRC}'
+                             )
+-        if install:
+-            bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
++        #if install:
++        #    bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
+ Build.BuildContext.MANPAGES = MANPAGES
+ 
+ def SAMBAMANPAGES(bld, manpages):
+@@ -821,7 +821,7 @@ def SAMBAMANPAGES(bld, manpages):
+                                     ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC}
+                                     ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
+                             )
+-        bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
++        #bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
+ Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
+ 
+ #############################################################
+-- 
+1.8.4.5
+
Signature · 1 line
1.8.4.5
#3 lore raw

RFC 3/3 samba4-HACK: apply --disable-rpath-private-install for smbclient

In reply to zooey at hirschkaefer.de

From: Oliver Tappe <[email protected]>

Otherwise, the installation of smbclient fails due to missing *.inst.so files.

---
 package/samba4/samba4.mk | 1 +
 1 file changed, 1 insertion(+)
package/samba4/samba4.mk +1 -0
index 1826c01..b6c8582 100644
@@ -72,6 +72,7 @@ endif
 ifeq ($(BR2_PACKAGE_SAMBA4_CLIENT_LIB),y)
 	SAMBA4_WAF_BUILD_TARGET = smbclient
 	SAMBA4_WAF_INSTALL_TARGET = install_smbclient
+	SAMBA4_CONF_OPT += --disable-rpath-private-install
 else
 	SAMBA4_WAF_BUILD_TARGET = all
 	SAMBA4_WAF_INSTALL_TARGET = install
Signature · 1 line
1.8.4.5
#4 lore raw

cover samba4: allow build of libsmbclient only

In reply to zooey at hirschkaefer.de

Hello,

Quoted 13 lines · zooey at hirschkaefer.de

this set of patches is a first draft of allowing a separate build of samba4's libsmbclient. Most of our devices don't need all of the other samba servers and tools, so it seems a bit of a waste having to build them all.

The first patch contains the naive attempt at implementing the separation.

However, it seems that samba4's build system gets confused when not all targets have been built, as it tries to install manpages along with libsmbclient which haven't been generated during the build phase. Patch 2 works around the problem by deactivating installation of manpages in general, but as that is hardly acceptable, I wonder if anyone here has a better idea?

Quoted 8 lines

Patch 3 appies --disable-rpath-private-install in order to work around another build problem, which is apparently caused by libsmbclient.inst.so (and additional install libraries) to not have been created during the build phase. Again, the solution proposed in the patch isn't a good one, as it basically means that samba4's private libraries are not being built with RPATH set, which is bound to cause problems at runtime (they won't be found by the runtime loader). As with patch 2, I'd be grateful for any hints at better solutions.

Thanks for those patches. However, as you point out in your cover letter, those patches are not really acceptable as is. Moreover, those are really "feature patches", and we generally try to avoid them if possible. Could you instead work with the upstream Samba developers a solution to build only smbclient, and see where that goes?

Thanks a lot,

Thomas Petazzoni

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com