xzcat: treat as host prerequisite and build if needed
authorThomas De Schampheleire <patrickdepinguin+buildroot@gmail.com>
Fri, 2 Aug 2013 09:05:15 +0000 (11:05 +0200)
committerPeter Korsgaard <jacmet@sunsite.dk>
Fri, 6 Sep 2013 21:30:36 +0000 (23:30 +0200)
If xzcat is not present on the host system, buildroot bails out early asking
the developer to install it (xzcat is now a DL_TOOLS_DEPENDENCY)
Conversely, when BR2_TARGET_ROOTFS_CPIO_XZ is enabled, then host-xz is a
build dependency, and no manual action is required from the developer.

Because the second approach is nicer, also build host-xz when xzcat is not
available, using the host-prerequisite and suitable-host-pkg mechanisms,
already used for tar.

Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
package/pkg-generic.mk
support/dependencies/check-host-xzcat.mk [new file with mode: 0644]
support/dependencies/check-host-xzcat.sh [new file with mode: 0755]

index 65ab8c63da59f18b57643e2c8bf99dc1d0bb42c6..00f1cb31d2e5f3b8008495e36f9e190dd30ae6b8 100644 (file)
@@ -541,7 +541,11 @@ endif # SITE_METHOD
 
 # $(firstword) is used here because the extractor can have arguments, like
 # ZCAT="gzip -d -c", and to check for the dependency we only want 'gzip'.
+# Do not add xzcat to the list of required dependencies, as it gets built
+# automatically if it isn't found.
+ifneq ($(call suitable-extractor,$($(2)_SOURCE)),$(XZCAT))
 DL_TOOLS_DEPENDENCIES += $(firstword $(call suitable-extractor,$($(2)_SOURCE)))
+endif
 
 endif # $(2)_KCONFIG_VAR
 endef # inner-generic-package
diff --git a/support/dependencies/check-host-xzcat.mk b/support/dependencies/check-host-xzcat.mk
new file mode 100644 (file)
index 0000000..24286ef
--- /dev/null
@@ -0,0 +1,7 @@
+# XZCAT is taken from BR2_XZCAT (defaults to 'xzcat') (see Makefile)
+# If it is not present, build our own host-xzcat
+
+ifeq (,$(call suitable-host-package,xzcat,$(XZCAT)))
+  DEPENDENCIES_HOST_PREREQ += host-xz
+  XZCAT = $(HOST_DIR)/usr/bin/xzcat
+endif
diff --git a/support/dependencies/check-host-xzcat.sh b/support/dependencies/check-host-xzcat.sh
new file mode 100755 (executable)
index 0000000..10f1c45
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+candidate="$1"
+
+xzcat=`which $candidate 2>/dev/null`
+if [ ! -x "$xzcat" ]; then
+       xzcat=`which xzcat 2>/dev/null`
+       if [ ! -x "$xzcat" ]; then
+               # echo nothing: no suitable xzcat found
+               exit 1
+       fi
+fi
+
+echo $xzcat