[OpenWrt-Devel] [PATCH 1/1] [buildroot] Fix for liblzma breaks redhat-like systems

Daniel Dickinson openwrt at daniel.thecshore.com
Sat Aug 8 23:50:43 EDT 2015


On RedHat/Fedora and derivatives we must use the system liblzma
from xz-devel because the liblzma in tools/xz breaks these
systems due to system tools (which use liblzma) having
missing symbols when staging_dir/host/lib has liblzma
(because buildroot puts staging_dir/host/lib first in
library load path and therefore all binaries not just
buildroot's binaries use liblzma from staging_dir/host/lib, at
least while building OpenWrt).

Closes: 20134
Signed-off-by: Daniel Dickinson <openwrt at daniel.thecshore.com>
---
 include/host.mk          |  7 ++++++-
 include/prereq-build.mk  |  7 +++++++
 tools/Makefile           | 11 ++++++++---
 tools/squashfs4/Makefile |  2 +-
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/include/host.mk b/include/host.mk
index ec3ae27..fc55b63 100644
--- a/include/host.mk
+++ b/include/host.mk
@@ -45,7 +45,12 @@ $(TMP_DIR)/.host.mk: $(TOPDIR)/include/host.mk
 			echo "FIND_L=find -L \$$(1)" >> $@; \
 		else \
 			echo "FIND_L=find \$$(1) -follow" >> $@; \
-		fi \
+		fi ; \
+		[ -r /etc/os-release ] && \
+			eval "$$(cat /etc/os-release)" && \
+				echo "$$ID_LIKE" | grep -qE '(rhel|fedora)' && \
+					[ "$$VERSION_ID" -ge 7 ] && \
+						echo "USE_HOST_LZMA:=1" >> $@ \
 	) >/dev/null 2>/dev/null
 
 endif
diff --git a/include/prereq-build.mk b/include/prereq-build.mk
index 211201a..312eabf 100644
--- a/include/prereq-build.mk
+++ b/include/prereq-build.mk
@@ -70,6 +70,13 @@ $(eval $(call TestHostCommand,libssl, \
 	echo 'int main(int argc, char **argv) { SSL_library_init(); return 0; }' | \
 		gcc -include openssl/ssl.h -x c -o $(TMP_DIR)/a.out - -lcrypto -lssl))
 
+ifeq ($(USE_HOST_LZMA),1)
+$(eval $(call TestHostCommand,liblzma, \
+	Please install xz development package.  (Missing liblzma.so or lzma.h), \
+	echo 'int main(int argc, char **argv) { lzma_stream strm = LZMA_STREAM_INIT; lzma_ret ret = lzma_easy_encoder(&strm, 1, LZMA_CHECK_CRC64); if (ret == LZMA_OK) { lzma_end(&strm); return 0; } else { return -1; } }' | \
+		gcc -include lzma.h -x c -o $(TMP_DIR)/a.out - -llzma))
+endif
+
 
 $(eval $(call SetupHostCommand,tar,Please install GNU 'tar', \
 	gtar --version 2>&1 | grep GNU, \
diff --git a/tools/Makefile b/tools/Makefile
index 60041dd..a4bc127 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -27,7 +27,10 @@ tools-$(BUILD_TOOLCHAIN) += gmp mpfr mpc libelf expat
 tools-y += m4 libtool autoconf automake flex bison pkg-config sed mklibs
 tools-y += sstrip make-ext4fs e2fsprogs mtd-utils mkimage
 tools-y += firmware-utils patch-image patch quilt yaffs2 flock padjffs2
-tools-y += mm-macros missing-macros xz cmake scons bc findutils gengetopt patchelf
+tools-y += mm-macros missing-macros cmake scons bc findutils gengetopt patchelf
+ifneq ($(USE_HOST_LZMA),1)
+tools-y += xz
+endif
 tools-$(CONFIG_TARGET_orion_generic) += wrt350nv2-builder upslug2
 tools-$(CONFIG_powerpc) += upx
 tools-$(CONFIG_TARGET_x86) += qemu
@@ -45,16 +48,18 @@ $(curdir)/flex/compile := $(curdir)/libtool/install
 $(curdir)/pkg-config/compile := $(curdir)/sed/install
 $(curdir)/libtool/compile := $(curdir)/sed/install $(curdir)/m4/install $(curdir)/autoconf/install $(curdir)/automake/install $(curdir)/missing-macros/install
 $(curdir)/squashfs/compile := $(curdir)/lzma-old/install
+ifneq ($(USE_HOST_LZMA),1)
 $(curdir)/squashfs4/compile := $(curdir)/xz/install
+endif
 $(curdir)/quilt/compile := $(curdir)/sed/install $(curdir)/autoconf/install $(curdir)/findutils/install
 $(curdir)/autoconf/compile := $(curdir)/m4/install
-$(curdir)/automake/compile := $(curdir)/m4/install $(curdir)/autoconf/install $(curdir)/pkg-config/install $(curdir)/xz/install
+$(curdir)/automake/compile := $(curdir)/m4/install $(curdir)/autoconf/install $(curdir)/pkg-config/install $(if $(filter 1,$(USE_HOST_LZMA)),,$(curdir)/xz/install)
 $(curdir)/gmp/compile := $(curdir)/libtool/install
 $(curdir)/mpc/compile := $(curdir)/mpfr/install $(curdir)/gmp/install
 $(curdir)/mpfr/compile := $(curdir)/gmp/install
 $(curdir)/ppl/compile := $(curdir)/gmp/install
 $(curdir)/cloog/compile := $(curdir)/ppl/install
-$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/install $(curdir)/xz/install
+$(curdir)/mtd-utils/compile := $(curdir)/e2fsprogs/install $(if $(filter 1,$(USE_HOST_LZMA)),,$(curdir)/xz/install)
 $(curdir)/mkimage/compile := $(curdir)/sed/install
 $(curdir)/mklibs/compile := $(curdir)/libtool/install
 $(curdir)/qemu/compile := $(curdir)/e2fsprogs/install
diff --git a/tools/squashfs4/Makefile b/tools/squashfs4/Makefile
index 50b70fb..2c0ee0d 100644
--- a/tools/squashfs4/Makefile
+++ b/tools/squashfs4/Makefile
@@ -24,7 +24,7 @@ define Host/Compile
 		XZ_SUPPORT=1 \
 		LZMA_XZ_SUPPORT=1 \
 		XATTR_SUPPORT= \
-		LZMA_LIB="$(STAGING_DIR_HOST)/lib/liblzma.a" \
+		$(if $(filter 1,$(USE_HOST_LZMA)),,LZMA_LIB="$(STAGING_DIR_HOST)/lib/liblzma.a") \
 		EXTRA_CFLAGS="-I$(STAGING_DIR_HOST)/include" \
 		mksquashfs unsquashfs
 endef
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list