All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/4] core: add generic support for lz archives
@ 2017-02-10  5:52 Baruch Siach
  2017-02-10  5:52 ` [Buildroot] [PATCH 2/4] ed: use generic extract command Baruch Siach
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Baruch Siach @ 2017-02-10  5:52 UTC (permalink / raw)
  To: buildroot

This commit teaches the generic code how to extract .tar.lz archives. When
lzip is not installed on the host, host-lzip gets built automatically.

To avoid the dependency checker complain about missing host lzip (in addition
to xzcat) add a new host-extractor function that only returns extractors we
expect to be host installed. Use host-extractor output to feed the dependency
checker.

Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Cc: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
v2: add host-extractor to fix host lzip check
---
 Config.in                               |  7 +++++++
 Makefile                                |  1 +
 package/pkg-generic.mk                  |  6 +-----
 package/pkg-utils.mk                    |  5 +++++
 support/dependencies/check-host-lzip.mk |  4 ++++
 support/dependencies/check-host-lzip.sh | 14 ++++++++++++++
 6 files changed, 32 insertions(+), 5 deletions(-)
 create mode 100644 support/dependencies/check-host-lzip.mk
 create mode 100755 support/dependencies/check-host-lzip.sh

diff --git a/Config.in b/Config.in
index ccd777e8bb00..bd8f0d1a10ee 100644
--- a/Config.in
+++ b/Config.in
@@ -158,6 +158,13 @@ config BR2_XZCAT
 	  Command to be used to extract a xz'ed file to stdout.
 	  Default is "xzcat"
 
+config BR2_LZCAT
+	string "lzcat command"
+	default "lzip -d -c"
+	help
+	  Command to be used to extract a lzip'ed file to stdout.
+	  Default is "lzip -d -c"
+
 config BR2_TAR_OPTIONS
 	string "Tar options"
 	default ""
diff --git a/Makefile b/Makefile
index df3b64eb03ec..b4550e098958 100644
--- a/Makefile
+++ b/Makefile
@@ -431,6 +431,7 @@ KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
 ZCAT := $(call qstrip,$(BR2_ZCAT))
 BZCAT := $(call qstrip,$(BR2_BZCAT))
 XZCAT := $(call qstrip,$(BR2_XZCAT))
+LZCAT := $(call qstrip,$(BR2_LZCAT))
 TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
 
 # packages compiled for the host go here
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 3ca71b03b9df..b45d1109ca4f 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -928,11 +928,7 @@ 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
+DL_TOOLS_DEPENDENCIES += $$(firstword $$(call host-extractor,$$($(2)_SOURCE)))
 
 # Ensure all virtual targets are PHONY. Listed alphabetically.
 .PHONY:	$(1) \
diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index c5d4080c72f4..1c091a43d36c 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -36,6 +36,7 @@ pkgname = $(lastword $(subst /, ,$(pkgdir)))
 # Define extractors for different archive suffixes
 INFLATE.bz2  = $(BZCAT)
 INFLATE.gz   = $(ZCAT)
+INFLATE.lz   = $(LZCAT)
 INFLATE.lzma = $(XZCAT)
 INFLATE.tbz  = $(BZCAT)
 INFLATE.tbz2 = $(BZCAT)
@@ -45,6 +46,10 @@ INFLATE.tar  = cat
 # suitable-extractor(filename): returns extractor based on suffix
 suitable-extractor = $(INFLATE$(suffix $(1)))
 
+# host-extractor(filename): same as suitable-extractor, but filter out
+# extractors we build when the host lacks one.
+host-extractor = $(INFLATE$(filter-out .lz .lzma .xz,$(suffix $(1))))
+
 # check-deprecated-variable -- throw an error on deprecated variables
 # example:
 #   $(eval $(call check-deprecated-variable,FOO_MAKE_OPT,FOO_MAKE_OPTS))
diff --git a/support/dependencies/check-host-lzip.mk b/support/dependencies/check-host-lzip.mk
new file mode 100644
index 000000000000..32ab9f4daffe
--- /dev/null
+++ b/support/dependencies/check-host-lzip.mk
@@ -0,0 +1,4 @@
+ifeq (,$(call suitable-host-package,lzip,$(LZCAT)))
+DEPENDENCIES_HOST_PREREQ += host-lzip
+LZCAT = $(HOST_DIR)/usr/bin/lzip -d -c
+endif
diff --git a/support/dependencies/check-host-lzip.sh b/support/dependencies/check-host-lzip.sh
new file mode 100755
index 000000000000..4f8a2ba3de5b
--- /dev/null
+++ b/support/dependencies/check-host-lzip.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+candidate="$1"
+
+lzip=`which $candidate 2>/dev/null`
+if [ ! -x "$lzip" ]; then
+	lzip=`which lzip 2>/dev/null`
+	if [ ! -x "$lzip" ]; then
+		# echo nothing: no suitable lzip found
+		exit 1
+	fi
+fi
+
+echo $lzip
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/4] ed: use generic extract command
  2017-02-10  5:52 [Buildroot] [PATCH 1/4] core: add generic support for lz archives Baruch Siach
@ 2017-02-10  5:52 ` Baruch Siach
  2017-02-10 14:12   ` Peter Seiderer
  2017-02-10  5:52 ` [Buildroot] [PATCH 3/4] ddrescue: " Baruch Siach
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Baruch Siach @ 2017-02-10  5:52 UTC (permalink / raw)
  To: buildroot

The generic code now knows how to extract .tar.lz archives. Remove the local
extract code.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 package/ed/ed.mk | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/package/ed/ed.mk b/package/ed/ed.mk
index 50adeb4ec5b4..6b9f65ec5280 100644
--- a/package/ed/ed.mk
+++ b/package/ed/ed.mk
@@ -10,15 +10,9 @@ ED_SOURCE = ed-$(ED_VERSION).tar.lz
 ED_CONF_OPTS = \
 	CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)" \
 	LDFLAGS="$(TARGET_LDFLAGS)"
-ED_DEPENDENCIES = host-lzip
 ED_LICENSE = GPLv3+
 ED_LICENSE_FILES = COPYING
 
-define ED_EXTRACT_CMDS
-	$(HOST_DIR)/usr/bin/lzip -d -c $(DL_DIR)/$(ED_SOURCE) | \
-		tar --strip-components=1 -C $(@D) $(TAR_OPTIONS) -
-endef
-
 define ED_CONFIGURE_CMDS
 	(cd $(@D); \
 		$(TARGET_MAKE_ENV) ./configure \
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 3/4] ddrescue: use generic extract command
  2017-02-10  5:52 [Buildroot] [PATCH 1/4] core: add generic support for lz archives Baruch Siach
  2017-02-10  5:52 ` [Buildroot] [PATCH 2/4] ed: use generic extract command Baruch Siach
@ 2017-02-10  5:52 ` Baruch Siach
  2017-02-10 14:12   ` Peter Seiderer
  2017-02-10  5:52 ` [Buildroot] [PATCH 4/4] ocrad: " Baruch Siach
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Baruch Siach @ 2017-02-10  5:52 UTC (permalink / raw)
  To: buildroot

The generic code now knows how to extract .tar.lz archives. Remove the local
extract code

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 package/ddrescue/ddrescue.mk | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/package/ddrescue/ddrescue.mk b/package/ddrescue/ddrescue.mk
index 145d0520d66f..4e244e6bdaef 100644
--- a/package/ddrescue/ddrescue.mk
+++ b/package/ddrescue/ddrescue.mk
@@ -9,12 +9,6 @@ DDRESCUE_SOURCE = ddrescue-$(DDRESCUE_VERSION).tar.lz
 DDRESCUE_SITE = http://download.savannah.gnu.org/releases/ddrescue
 DDRESCUE_LICENSE = GPLv2+
 DDRESCUE_LICENSE_FILES = COPYING
-DDRESCUE_DEPENDENCIES = host-lzip
-
-define DDRESCUE_EXTRACT_CMDS
-	$(HOST_DIR)/usr/bin/lzip -d -c $(DL_DIR)/$(DDRESCUE_SOURCE) | \
-		tar --strip-components=1 -C $(@D) $(TAR_OPTIONS) -
-endef
 
 define DDRESCUE_CONFIGURE_CMDS
 	(cd $(@D); \
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 4/4] ocrad: use generic extract command
  2017-02-10  5:52 [Buildroot] [PATCH 1/4] core: add generic support for lz archives Baruch Siach
  2017-02-10  5:52 ` [Buildroot] [PATCH 2/4] ed: use generic extract command Baruch Siach
  2017-02-10  5:52 ` [Buildroot] [PATCH 3/4] ddrescue: " Baruch Siach
@ 2017-02-10  5:52 ` Baruch Siach
  2017-02-10 14:13   ` Peter Seiderer
  2017-02-10 14:11 ` [Buildroot] [PATCH 1/4] core: add generic support for lz archives Peter Seiderer
  2017-02-11 21:16 ` Thomas De Schampheleire
  4 siblings, 1 reply; 11+ messages in thread
From: Baruch Siach @ 2017-02-10  5:52 UTC (permalink / raw)
  To: buildroot

The generic code now knows how to extract .tar.lz archives. Remove the local
extract code

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 package/ocrad/ocrad.mk | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/package/ocrad/ocrad.mk b/package/ocrad/ocrad.mk
index d19e83ef4279..54b607c79193 100644
--- a/package/ocrad/ocrad.mk
+++ b/package/ocrad/ocrad.mk
@@ -10,12 +10,6 @@ OCRAD_SITE = $(BR2_GNU_MIRROR)/ocrad
 OCRAD_LICENSE = GPLv3+
 OCRAD_LICENSE_FILES = COPYING
 OCRAD_INSTALL_STAGING = YES
-OCRAD_DEPENDENCIES = host-lzip
-
-define OCRAD_EXTRACT_CMDS
-	$(HOST_DIR)/usr/bin/lzip -d -c $(DL_DIR)/$(OCRAD_SOURCE) | \
-		tar --strip-components=1 -C $(@D) $(TAR_OPTIONS) -
-endef
 
 # This is not a true autotools package.
 define OCRAD_CONFIGURE_CMDS
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/4] core: add generic support for lz archives
  2017-02-10  5:52 [Buildroot] [PATCH 1/4] core: add generic support for lz archives Baruch Siach
                   ` (2 preceding siblings ...)
  2017-02-10  5:52 ` [Buildroot] [PATCH 4/4] ocrad: " Baruch Siach
@ 2017-02-10 14:11 ` Peter Seiderer
  2017-02-11 21:16 ` Thomas De Schampheleire
  4 siblings, 0 replies; 11+ messages in thread
From: Peter Seiderer @ 2017-02-10 14:11 UTC (permalink / raw)
  To: buildroot

Hello Baruch,

On Fri, 10 Feb 2017 07:52:13 +0200, Baruch Siach <baruch@tkos.co.il> wrote:

> This commit teaches the generic code how to extract .tar.lz archives. When
> lzip is not installed on the host, host-lzip gets built automatically.
> 
> To avoid the dependency checker complain about missing host lzip (in addition
> to xzcat) add a new host-extractor function that only returns extractors we
> expect to be host installed. Use host-extractor output to feed the dependency
> checker.
> 
> Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> Cc: Peter Seiderer <ps.report@gmx.net>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> v2: add host-extractor to fix host lzip check
> ---
>  Config.in                               |  7 +++++++
>  Makefile                                |  1 +
>  package/pkg-generic.mk                  |  6 +-----
>  package/pkg-utils.mk                    |  5 +++++
>  support/dependencies/check-host-lzip.mk |  4 ++++
>  support/dependencies/check-host-lzip.sh | 14 ++++++++++++++
>  6 files changed, 32 insertions(+), 5 deletions(-)
>  create mode 100644 support/dependencies/check-host-lzip.mk
>  create mode 100755 support/dependencies/check-host-lzip.sh
> 
> diff --git a/Config.in b/Config.in
> index ccd777e8bb00..bd8f0d1a10ee 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -158,6 +158,13 @@ config BR2_XZCAT
>  	  Command to be used to extract a xz'ed file to stdout.
>  	  Default is "xzcat"
>  
> +config BR2_LZCAT
> +	string "lzcat command"
> +	default "lzip -d -c"
> +	help
> +	  Command to be used to extract a lzip'ed file to stdout.
> +	  Default is "lzip -d -c"
> +
>  config BR2_TAR_OPTIONS
>  	string "Tar options"
>  	default ""
> diff --git a/Makefile b/Makefile
> index df3b64eb03ec..b4550e098958 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -431,6 +431,7 @@ KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
>  ZCAT := $(call qstrip,$(BR2_ZCAT))
>  BZCAT := $(call qstrip,$(BR2_BZCAT))
>  XZCAT := $(call qstrip,$(BR2_XZCAT))
> +LZCAT := $(call qstrip,$(BR2_LZCAT))
>  TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
>  
>  # packages compiled for the host go here
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> index 3ca71b03b9df..b45d1109ca4f 100644
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -928,11 +928,7 @@ 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
> +DL_TOOLS_DEPENDENCIES += $$(firstword $$(call host-extractor,$$($(2)_SOURCE)))
>  
>  # Ensure all virtual targets are PHONY. Listed alphabetically.
>  .PHONY:	$(1) \
> diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
> index c5d4080c72f4..1c091a43d36c 100644
> --- a/package/pkg-utils.mk
> +++ b/package/pkg-utils.mk
> @@ -36,6 +36,7 @@ pkgname = $(lastword $(subst /, ,$(pkgdir)))
>  # Define extractors for different archive suffixes
>  INFLATE.bz2  = $(BZCAT)
>  INFLATE.gz   = $(ZCAT)
> +INFLATE.lz   = $(LZCAT)
>  INFLATE.lzma = $(XZCAT)
>  INFLATE.tbz  = $(BZCAT)
>  INFLATE.tbz2 = $(BZCAT)
> @@ -45,6 +46,10 @@ INFLATE.tar  = cat
>  # suitable-extractor(filename): returns extractor based on suffix
>  suitable-extractor = $(INFLATE$(suffix $(1)))
>  
> +# host-extractor(filename): same as suitable-extractor, but filter out
> +# extractors we build when the host lacks one.
> +host-extractor = $(INFLATE$(filter-out .lz .lzma .xz,$(suffix $(1))))
> +
>  # check-deprecated-variable -- throw an error on deprecated variables
>  # example:
>  #   $(eval $(call check-deprecated-variable,FOO_MAKE_OPT,FOO_MAKE_OPTS))
> diff --git a/support/dependencies/check-host-lzip.mk b/support/dependencies/check-host-lzip.mk
> new file mode 100644
> index 000000000000..32ab9f4daffe
> --- /dev/null
> +++ b/support/dependencies/check-host-lzip.mk
> @@ -0,0 +1,4 @@
> +ifeq (,$(call suitable-host-package,lzip,$(LZCAT)))
> +DEPENDENCIES_HOST_PREREQ += host-lzip
> +LZCAT = $(HOST_DIR)/usr/bin/lzip -d -c
> +endif
> diff --git a/support/dependencies/check-host-lzip.sh b/support/dependencies/check-host-lzip.sh
> new file mode 100755
> index 000000000000..4f8a2ba3de5b
> --- /dev/null
> +++ b/support/dependencies/check-host-lzip.sh
> @@ -0,0 +1,14 @@
> +#!/bin/sh
> +
> +candidate="$1"
> +
> +lzip=`which $candidate 2>/dev/null`
> +if [ ! -x "$lzip" ]; then
> +	lzip=`which lzip 2>/dev/null`
> +	if [ ! -x "$lzip" ]; then
> +		# echo nothing: no suitable lzip found
> +		exit 1
> +	fi
> +fi
> +
> +echo $lzip

Works for my testcase/ddrescue, you can add my

Tested-by: Peter Seiderer <ps.report@gmx.net>

Regards,
Peter

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/4] ed: use generic extract command
  2017-02-10  5:52 ` [Buildroot] [PATCH 2/4] ed: use generic extract command Baruch Siach
@ 2017-02-10 14:12   ` Peter Seiderer
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Seiderer @ 2017-02-10 14:12 UTC (permalink / raw)
  To: buildroot

On Fri, 10 Feb 2017 07:52:14 +0200, Baruch Siach <baruch@tkos.co.il> wrote:

> The generic code now knows how to extract .tar.lz archives. Remove the local
> extract code.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  package/ed/ed.mk | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/package/ed/ed.mk b/package/ed/ed.mk
> index 50adeb4ec5b4..6b9f65ec5280 100644
> --- a/package/ed/ed.mk
> +++ b/package/ed/ed.mk
> @@ -10,15 +10,9 @@ ED_SOURCE = ed-$(ED_VERSION).tar.lz
>  ED_CONF_OPTS = \
>  	CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)" \
>  	LDFLAGS="$(TARGET_LDFLAGS)"
> -ED_DEPENDENCIES = host-lzip
>  ED_LICENSE = GPLv3+
>  ED_LICENSE_FILES = COPYING
>  
> -define ED_EXTRACT_CMDS
> -	$(HOST_DIR)/usr/bin/lzip -d -c $(DL_DIR)/$(ED_SOURCE) | \
> -		tar --strip-components=1 -C $(@D) $(TAR_OPTIONS) -
> -endef
> -
>  define ED_CONFIGURE_CMDS
>  	(cd $(@D); \
>  		$(TARGET_MAKE_ENV) ./configure \

Reviewed-by: Peter Seiderer <ps.report@gmx.net>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 3/4] ddrescue: use generic extract command
  2017-02-10  5:52 ` [Buildroot] [PATCH 3/4] ddrescue: " Baruch Siach
@ 2017-02-10 14:12   ` Peter Seiderer
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Seiderer @ 2017-02-10 14:12 UTC (permalink / raw)
  To: buildroot

On Fri, 10 Feb 2017 07:52:15 +0200, Baruch Siach <baruch@tkos.co.il> wrote:

> The generic code now knows how to extract .tar.lz archives. Remove the local
> extract code
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  package/ddrescue/ddrescue.mk | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/package/ddrescue/ddrescue.mk b/package/ddrescue/ddrescue.mk
> index 145d0520d66f..4e244e6bdaef 100644
> --- a/package/ddrescue/ddrescue.mk
> +++ b/package/ddrescue/ddrescue.mk
> @@ -9,12 +9,6 @@ DDRESCUE_SOURCE = ddrescue-$(DDRESCUE_VERSION).tar.lz
>  DDRESCUE_SITE = http://download.savannah.gnu.org/releases/ddrescue
>  DDRESCUE_LICENSE = GPLv2+
>  DDRESCUE_LICENSE_FILES = COPYING
> -DDRESCUE_DEPENDENCIES = host-lzip
> -
> -define DDRESCUE_EXTRACT_CMDS
> -	$(HOST_DIR)/usr/bin/lzip -d -c $(DL_DIR)/$(DDRESCUE_SOURCE) | \
> -		tar --strip-components=1 -C $(@D) $(TAR_OPTIONS) -
> -endef
>  
>  define DDRESCUE_CONFIGURE_CMDS
>  	(cd $(@D); \

Tested-by: Peter Seiderer <ps.report@gmx.net>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 4/4] ocrad: use generic extract command
  2017-02-10  5:52 ` [Buildroot] [PATCH 4/4] ocrad: " Baruch Siach
@ 2017-02-10 14:13   ` Peter Seiderer
  0 siblings, 0 replies; 11+ messages in thread
From: Peter Seiderer @ 2017-02-10 14:13 UTC (permalink / raw)
  To: buildroot

On Fri, 10 Feb 2017 07:52:16 +0200, Baruch Siach <baruch@tkos.co.il> wrote:

> The generic code now knows how to extract .tar.lz archives. Remove the local
> extract code
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  package/ocrad/ocrad.mk | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/package/ocrad/ocrad.mk b/package/ocrad/ocrad.mk
> index d19e83ef4279..54b607c79193 100644
> --- a/package/ocrad/ocrad.mk
> +++ b/package/ocrad/ocrad.mk
> @@ -10,12 +10,6 @@ OCRAD_SITE = $(BR2_GNU_MIRROR)/ocrad
>  OCRAD_LICENSE = GPLv3+
>  OCRAD_LICENSE_FILES = COPYING
>  OCRAD_INSTALL_STAGING = YES
> -OCRAD_DEPENDENCIES = host-lzip
> -
> -define OCRAD_EXTRACT_CMDS
> -	$(HOST_DIR)/usr/bin/lzip -d -c $(DL_DIR)/$(OCRAD_SOURCE) | \
> -		tar --strip-components=1 -C $(@D) $(TAR_OPTIONS) -
> -endef
>  
>  # This is not a true autotools package.
>  define OCRAD_CONFIGURE_CMDS

Reviewed-by: Peter Seiderer <ps.report@gmx.net>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/4] core: add generic support for lz archives
  2017-02-10  5:52 [Buildroot] [PATCH 1/4] core: add generic support for lz archives Baruch Siach
                   ` (3 preceding siblings ...)
  2017-02-10 14:11 ` [Buildroot] [PATCH 1/4] core: add generic support for lz archives Peter Seiderer
@ 2017-02-11 21:16 ` Thomas De Schampheleire
       [not found]   ` <CAAXf6LXmYoo0mSdf6-uvMQtLwv0nP2D0WO8t7omkyy4CkeiStg@mail.gmail.com>
  2017-02-12 20:07   ` Baruch Siach
  4 siblings, 2 replies; 11+ messages in thread
From: Thomas De Schampheleire @ 2017-02-11 21:16 UTC (permalink / raw)
  To: buildroot

Hi Baruch,

On Fri, Feb 10, 2017 at 6:52 AM, Baruch Siach <baruch@tkos.co.il> wrote:
> This commit teaches the generic code how to extract .tar.lz archives. When
> lzip is not installed on the host, host-lzip gets built automatically.
>
> To avoid the dependency checker complain about missing host lzip (in addition
> to xzcat) add a new host-extractor function that only returns extractors we
> expect to be host installed. Use host-extractor output to feed the dependency
> checker.
>
> Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> Cc: Peter Seiderer <ps.report@gmx.net>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> v2: add host-extractor to fix host lzip check
> ---
>  Config.in                               |  7 +++++++
>  Makefile                                |  1 +
>  package/pkg-generic.mk                  |  6 +-----
>  package/pkg-utils.mk                    |  5 +++++
>  support/dependencies/check-host-lzip.mk |  4 ++++
>  support/dependencies/check-host-lzip.sh | 14 ++++++++++++++
>  6 files changed, 32 insertions(+), 5 deletions(-)
>  create mode 100644 support/dependencies/check-host-lzip.mk
>  create mode 100755 support/dependencies/check-host-lzip.sh
>
> diff --git a/Config.in b/Config.in
> index ccd777e8bb00..bd8f0d1a10ee 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -158,6 +158,13 @@ config BR2_XZCAT
>           Command to be used to extract a xz'ed file to stdout.
>           Default is "xzcat"
>
> +config BR2_LZCAT
> +       string "lzcat command"
> +       default "lzip -d -c"
> +       help
> +         Command to be used to extract a lzip'ed file to stdout.
> +         Default is "lzip -d -c"
> +
>  config BR2_TAR_OPTIONS
>         string "Tar options"
>         default ""
> diff --git a/Makefile b/Makefile
> index df3b64eb03ec..b4550e098958 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -431,6 +431,7 @@ KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
>  ZCAT := $(call qstrip,$(BR2_ZCAT))
>  BZCAT := $(call qstrip,$(BR2_BZCAT))
>  XZCAT := $(call qstrip,$(BR2_XZCAT))
> +LZCAT := $(call qstrip,$(BR2_LZCAT))
>  TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
>
>  # packages compiled for the host go here
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> index 3ca71b03b9df..b45d1109ca4f 100644
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -928,11 +928,7 @@ 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
> +DL_TOOLS_DEPENDENCIES += $$(firstword $$(call host-extractor,$$($(2)_SOURCE)))
>
>  # Ensure all virtual targets are PHONY. Listed alphabetically.
>  .PHONY:        $(1) \
> diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
> index c5d4080c72f4..1c091a43d36c 100644
> --- a/package/pkg-utils.mk
> +++ b/package/pkg-utils.mk
> @@ -36,6 +36,7 @@ pkgname = $(lastword $(subst /, ,$(pkgdir)))
>  # Define extractors for different archive suffixes
>  INFLATE.bz2  = $(BZCAT)
>  INFLATE.gz   = $(ZCAT)
> +INFLATE.lz   = $(LZCAT)
>  INFLATE.lzma = $(XZCAT)
>  INFLATE.tbz  = $(BZCAT)
>  INFLATE.tbz2 = $(BZCAT)
> @@ -45,6 +46,10 @@ INFLATE.tar  = cat
>  # suitable-extractor(filename): returns extractor based on suffix
>  suitable-extractor = $(INFLATE$(suffix $(1)))
>
> +# host-extractor(filename): same as suitable-extractor, but filter out
> +# extractors we build when the host lacks one.
> +host-extractor = $(INFLATE$(filter-out .lz .lzma .xz,$(suffix $(1))))

suitable-extractor and host-extractor now render different output for
a given file which makes no sense in general for functions named like
this. You only need the different output to decide whether extra
dependency checks need to be done, not to determine what the extractor
is.

Also, the list of extensions is kind of 'magic' and not immediately
linked with the changes in support/dependencies (this was already true
with the original situation, true). It would be great if the
exceptions could be steered from the check-host-foo.mk files directly,
which is the conceptually right place: when that file exists it will
take over all checking, if it does not then the checking is done in
the standard DL_TOOLS_DEPENDENCIES.

I thought hard on a way to attack the problem without needing to know
the extensions and more in line with the original change, but it is
not easy due to the fact that XZCAT and such can contain spaces which
does not fit well with make.
For clarity, I wanted to let check-host-xz.mk append to a new variable, e.g.
    DL_TOOLS_DEPENDENCIES_PRECHECKED_VARS += $(XZCAT)
and in pkg-generic.mk use this list to drive the exceptions:
    ifeq (,$$(filter $$(call
suitable-extractor,$$($(2)_SOURCE)),$$(DL_TOOLS_DEPENDENCIES_PRECHECKED_VARS)))
    DL_TOOLS_DEPENDENCIES += $$(firstword $$(call
suitable-extractor,$$($(2)_SOURCE)))
    endif
This could work if we first replace all spaces with another character,
both when appending to DL_TOOLS_DEPENDENCIES_PRECHECKED_VARS as in the
first argument of the filter function.
But perhaps it makes things too complex.

An alternative is to stick closer to your proposal, but with some changes:
- let check-host-foo.mk define the list of extensions that it handles
instead of the magic list, e.g.
  EXTRACTOR_DEPENDENCY_PRECHECKED_EXTENSIONS += .xz
- rename host-extractor to something else, e.g. extractor-dependency
- perhaps it makes sense to let extractor-dependency handle the
$(firstword) call

Given my input, what do you think?

Separate note: it could make sense to split this patch in two: one to
refactor the handing of the dependencies, and a second one to cover
lz7.

Best regards,
Thomas

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/4] core: add generic support for lz archives
       [not found]   ` <CAAXf6LXmYoo0mSdf6-uvMQtLwv0nP2D0WO8t7omkyy4CkeiStg@mail.gmail.com>
@ 2017-02-12  6:48     ` Thomas De Schampheleire
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas De Schampheleire @ 2017-02-12  6:48 UTC (permalink / raw)
  To: buildroot

On Feb 11, 2017 22:16, "Thomas De Schampheleire" <patrickdepinguin@gmail.com>
wrote:

Hi Baruch,

On Fri, Feb 10, 2017 at 6:52 AM, Baruch Siach <baruch@tkos.co.il> wrote:
> This commit teaches the generic code how to extract .tar.lz archives. When
> lzip is not installed on the host, host-lzip gets built automatically.
>
> To avoid the dependency checker complain about missing host lzip (in
addition
> to xzcat) add a new host-extractor function that only returns extractors
we
> expect to be host installed. Use host-extractor output to feed the
dependency
> checker.
>
> Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> Cc: Peter Seiderer <ps.report@gmx.net>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
> v2: add host-extractor to fix host lzip check
> ---
>  Config.in                               |  7 +++++++
>  Makefile                                |  1 +
>  package/pkg-generic.mk                  |  6 +-----
>  package/pkg-utils.mk                    |  5 +++++
>  support/dependencies/check-host-lzip.mk |  4 ++++
>  support/dependencies/check-host-lzip.sh | 14 ++++++++++++++
>  6 files changed, 32 insertions(+), 5 deletions(-)
>  create mode 100644 support/dependencies/check-host-lzip.mk
>  create mode 100755 support/dependencies/check-host-lzip.sh
>
> diff --git a/Config.in b/Config.in
> index ccd777e8bb00..bd8f0d1a10ee 100644
> --- a/Config.in
> +++ b/Config.in
> @@ -158,6 +158,13 @@ config BR2_XZCAT
>           Command to be used to extract a xz'ed file to stdout.
>           Default is "xzcat"
>
> +config BR2_LZCAT
> +       string "lzcat command"
> +       default "lzip -d -c"
> +       help
> +         Command to be used to extract a lzip'ed file to stdout.
> +         Default is "lzip -d -c"
> +
>  config BR2_TAR_OPTIONS
>         string "Tar options"
>         default ""
> diff --git a/Makefile b/Makefile
> index df3b64eb03ec..b4550e098958 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -431,6 +431,7 @@ KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e
"s/-.*//" \
>  ZCAT := $(call qstrip,$(BR2_ZCAT))
>  BZCAT := $(call qstrip,$(BR2_BZCAT))
>  XZCAT := $(call qstrip,$(BR2_XZCAT))
> +LZCAT := $(call qstrip,$(BR2_LZCAT))
>  TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
>
>  # packages compiled for the host go here
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> index 3ca71b03b9df..b45d1109ca4f 100644
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -928,11 +928,7 @@ 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
> +DL_TOOLS_DEPENDENCIES += $$(firstword $$(call
host-extractor,$$($(2)_SOURCE)))
>
>  # Ensure all virtual targets are PHONY. Listed alphabetically.
>  .PHONY:        $(1) \
> diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
> index c5d4080c72f4..1c091a43d36c 100644
> --- a/package/pkg-utils.mk
> +++ b/package/pkg-utils.mk
> @@ -36,6 +36,7 @@ pkgname = $(lastword $(subst /, ,$(pkgdir)))
>  # Define extractors for different archive suffixes
>  INFLATE.bz2  = $(BZCAT)
>  INFLATE.gz   = $(ZCAT)
> +INFLATE.lz   = $(LZCAT)
>  INFLATE.lzma = $(XZCAT)
>  INFLATE.tbz  = $(BZCAT)
>  INFLATE.tbz2 = $(BZCAT)
> @@ -45,6 +46,10 @@ INFLATE.tar  = cat
>  # suitable-extractor(filename): returns extractor based on suffix
>  suitable-extractor = $(INFLATE$(suffix $(1)))
>
> +# host-extractor(filename): same as suitable-extractor, but filter out
> +# extractors we build when the host lacks one.
> +host-extractor = $(INFLATE$(filter-out .lz .lzma .xz,$(suffix $(1))))

suitable-extractor and host-extractor now render different output for
a given file which makes no sense in general for functions named like
this. You only need the different output to decide whether extra
dependency checks need to be done, not to determine what the extractor
is.

Also, the list of extensions is kind of 'magic' and not immediately
linked with the changes in support/dependencies (this was already true
with the original situation, true). It would be great if the
exceptions could be steered from the check-host-foo.mk files directly,
which is the conceptually right place: when that file exists it will
take over all checking, if it does not then the checking is done in
the standard DL_TOOLS_DEPENDENCIES.

I thought hard on a way to attack the problem without needing to know
the extensions and more in line with the original change, but it is
not easy due to the fact that XZCAT and such can contain spaces which
does not fit well with make.
For clarity, I wanted to let check-host-xz.mk append to a new variable, e.g.
    DL_TOOLS_DEPENDENCIES_PRECHECKED_VARS += $(XZCAT)
and in pkg-generic.mk use this list to drive the exceptions:
    ifeq (,$$(filter $$(call
suitable-extractor,$$($(2)_SOURCE)),$$(DL_TOOLS_
DEPENDENCIES_PRECHECKED_VARS)))
    DL_TOOLS_DEPENDENCIES += $$(firstword $$(call
suitable-extractor,$$($(2)_SOURCE)))
    endif
This could work if we first replace all spaces with another character,
both when appending to DL_TOOLS_DEPENDENCIES_PRECHECKED_VARS as in the
first argument of the filter function.
But perhaps it makes things too complex.


Second thought: by reducing XZCAT to its firstword before appending to some
variable, the complexity is gone.
In that case, we can use filter-out to remove these prechecked tools from
DL_TOOLS_DEPENDENCIES.
Perhaps then it doesn't need to be done from pkg-generic anymore but could
be done from dependencies.mk where DL_TOOLS_DEPENDENCIES is actually used.


An alternative is to stick closer to your proposal, but with some changes:
- let check-host-foo.mk define the list of extensions that it handles
instead of the magic list, e.g.
  EXTRACTOR_DEPENDENCY_PRECHECKED_EXTENSIONS += .xz
- rename host-extractor to something else, e.g. extractor-dependency
- perhaps it makes sense to let extractor-dependency handle the
$(firstword) call

Given my input, what do you think?

Separate note: it could make sense to split this patch in two: one to
refactor the handing of the dependencies, and a second one to cover
lz7.

Best regards,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170212/f34e1401/attachment.html>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/4] core: add generic support for lz archives
  2017-02-11 21:16 ` Thomas De Schampheleire
       [not found]   ` <CAAXf6LXmYoo0mSdf6-uvMQtLwv0nP2D0WO8t7omkyy4CkeiStg@mail.gmail.com>
@ 2017-02-12 20:07   ` Baruch Siach
  1 sibling, 0 replies; 11+ messages in thread
From: Baruch Siach @ 2017-02-12 20:07 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

On Sat, Feb 11, 2017 at 10:16:20PM +0100, Thomas De Schampheleire wrote:
> On Fri, Feb 10, 2017 at 6:52 AM, Baruch Siach <baruch@tkos.co.il> wrote:
> > +# host-extractor(filename): same as suitable-extractor, but filter out
> > +# extractors we build when the host lacks one.
> > +host-extractor = $(INFLATE$(filter-out .lz .lzma .xz,$(suffix $(1))))
> 
> suitable-extractor and host-extractor now render different output for
> a given file which makes no sense in general for functions named like
> this. You only need the different output to decide whether extra
> dependency checks need to be done, not to determine what the extractor
> is.
> 
> Also, the list of extensions is kind of 'magic' and not immediately
> linked with the changes in support/dependencies (this was already true
> with the original situation, true). It would be great if the
> exceptions could be steered from the check-host-foo.mk files directly,
> which is the conceptually right place: when that file exists it will
> take over all checking, if it does not then the checking is done in
> the standard DL_TOOLS_DEPENDENCIES.
> 
> I thought hard on a way to attack the problem without needing to know
> the extensions and more in line with the original change, but it is
> not easy due to the fact that XZCAT and such can contain spaces which
> does not fit well with make.
> For clarity, I wanted to let check-host-xz.mk append to a new variable, e.g.
>     DL_TOOLS_DEPENDENCIES_PRECHECKED_VARS += $(XZCAT)
> and in pkg-generic.mk use this list to drive the exceptions:
>     ifeq (,$$(filter $$(call
> suitable-extractor,$$($(2)_SOURCE)),$$(DL_TOOLS_DEPENDENCIES_PRECHECKED_VARS)))
>     DL_TOOLS_DEPENDENCIES += $$(firstword $$(call
> suitable-extractor,$$($(2)_SOURCE)))
>     endif
> This could work if we first replace all spaces with another character,
> both when appending to DL_TOOLS_DEPENDENCIES_PRECHECKED_VARS as in the
> first argument of the filter function.
> But perhaps it makes things too complex.

Indeed.

> An alternative is to stick closer to your proposal, but with some changes:
> - let check-host-foo.mk define the list of extensions that it handles
> instead of the magic list, e.g.
>   EXTRACTOR_DEPENDENCY_PRECHECKED_EXTENSIONS += .xz
> - rename host-extractor to something else, e.g. extractor-dependency
> - perhaps it makes sense to let extractor-dependency handle the
> $(firstword) call
> 
> Given my input, what do you think?

I like your second suggestion better. Patches follow.

> Separate note: it could make sense to split this patch in two: one to
> refactor the handing of the dependencies, and a second one to cover
> lz7.

I agree.

Thanks for reviewing,
baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-02-12 20:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10  5:52 [Buildroot] [PATCH 1/4] core: add generic support for lz archives Baruch Siach
2017-02-10  5:52 ` [Buildroot] [PATCH 2/4] ed: use generic extract command Baruch Siach
2017-02-10 14:12   ` Peter Seiderer
2017-02-10  5:52 ` [Buildroot] [PATCH 3/4] ddrescue: " Baruch Siach
2017-02-10 14:12   ` Peter Seiderer
2017-02-10  5:52 ` [Buildroot] [PATCH 4/4] ocrad: " Baruch Siach
2017-02-10 14:13   ` Peter Seiderer
2017-02-10 14:11 ` [Buildroot] [PATCH 1/4] core: add generic support for lz archives Peter Seiderer
2017-02-11 21:16 ` Thomas De Schampheleire
     [not found]   ` <CAAXf6LXmYoo0mSdf6-uvMQtLwv0nP2D0WO8t7omkyy4CkeiStg@mail.gmail.com>
2017-02-12  6:48     ` Thomas De Schampheleire
2017-02-12 20:07   ` Baruch Siach

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.