Skip to contentSkip to conversation

package/pkg-generic: handle host-php as an extract dependency

PATCH In review Bernd Kuhls 3 participants 4 messages Aug 4, 2023 – Aug 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/pkg-generic: handle host-php as an extract dependency

Fixes:
http://autobuild.buildroot.net/results/506/50658c50fde8145fac320e3b17004e98c78c6c4d/

Although composer has host-php as build dependency, in the case of BR2_PER_PACKAGE_DIRECTORIES=y host-php was not built during extract stage of the composer package.

---
 package/composer/composer.mk           |  2 +-
 package/pkg-utils.mk                   |  2 ++
 support/dependencies/check-host-php.mk |  4 ++++
 support/dependencies/check-host-php.sh | 14 ++++++++++++++
 4 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 support/dependencies/check-host-php.mk
 create mode 100755 support/dependencies/check-host-php.sh
package/composer/composer.mk +1 -1
index a24c020796..ad1785cba6 100644
@@ -18,7 +18,7 @@ HOST_COMPOSER_DEPENDENCIES = host-php
 
 define HOST_COMPOSER_EXTRACT_CMDS
 	cp $(HOST_COMPOSER_DL_DIR)/$(COMPOSER_SOURCE) $(@D)
-	cd $(@D); $(HOST_DIR)/bin/php <<< '<?php \
+	cd $(@D); $(PHP) <<< '<?php \
 		$$p = new Phar("$(COMPOSER_SOURCE)"); \
 		$$p->extractTo(".", "LICENSE");'
 endef
package/pkg-utils.mk +2 -0
index 530638566c..353190c334 100644
@@ -55,6 +55,7 @@ INFLATE.bz2  = $(BZCAT)
 INFLATE.gz   = $(ZCAT)
 INFLATE.lz   = $(LZCAT)
 INFLATE.lzma = $(XZCAT)
+INFLATE.phar = $(PHP)
 INFLATE.tbz  = $(BZCAT)
 INFLATE.tbz2 = $(BZCAT)
 INFLATE.tgz  = $(ZCAT)
@@ -64,6 +65,7 @@ INFLATE.tar  = cat
 suitable-extractor = $(INFLATE$(suffix $(1)))
 
 EXTRACTOR_PKG_DEPENDENCY.lzma = $(BR2_XZCAT_HOST_DEPENDENCY)
+EXTRACTOR_PKG_DEPENDENCY.phar = $(BR2_PHP_HOST_DEPENDENCY)
 EXTRACTOR_PKG_DEPENDENCY.xz   = $(BR2_XZCAT_HOST_DEPENDENCY)
 EXTRACTOR_PKG_DEPENDENCY.lz   = $(BR2_LZIP_HOST_DEPENDENCY)
 
support/dependencies/check-host-php.mk new file +4 -0
new file mode 100644
index 0000000000..eac98e73d9
@@ -0,0 +1,4 @@
+ifeq (,$(call suitable-host-package,php,$(PHP)))
+BR2_PHP_HOST_DEPENDENCY = host-php
+PHP = $(HOST_DIR)/bin/php
+endif
support/dependencies/check-host-php.sh new file +14 -0
new file mode 100755
index 0000000000..d049a89455
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+candidate="$1"
+
+php=`which $candidate 2>/dev/null`
+if [ ! -x "$php" ]; then
+	php=`which php 2>/dev/null`
+	if [ ! -x "$php" ]; then
+		# echo nothing: no suitable php found
+		exit 1
+	fi
+fi
+
+echo $php
Signature · 6 lines
2.39.2

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hello Bernd,

Quoted 8 lines · On Fri, 4 Aug 2023 08:23:07 +0200 Bernd Kuhls <[email protected]> wrote:

Fixes:
http://autobuild.buildroot.net/results/506/50658c50fde8145fac320e3b17004e98c78c6c4d/

Although composer has host-php as build dependency, in the case of BR2_PER_PACKAGE_DIRECTORIES=y host-php was not built during extract stage of the composer package.

Thanks for noticing this. I indeed completely overlooked that when reviewing/merging the composer patch. However, there is one thing that I believe isn't ideal in your proposal, indeed it's kind of "half-way" through.

You handle part of the problem in package/pkg-utils.mk, as if .phar extraction was supported in the generic way in the package infrastructure, but that isn't the case: it only works with the special _EXTRACT_CMDS defined in composer.mk. So this .phar extraction would not work for any other package.

So instead of your change in package/pkg-utils.mk, can you do:

HOST_COMPOSER_EXTRACT_DEPENDENCIES = $(BR2_PHP_HOST_DEPENDENCY)

in composer.mk ? This would make the entire handling of .phar extraction a problem of composer.mk.

Of course, should we progressively have more and more of these, we could look at making this generic. But right now, let's handle this as a composer.mk specific concern.

What do you think?

Thanks a lot!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Bernd, All,

On 2023-08-04 14:35 +0200, Thomas Petazzoni via buildroot spake thusly:

Quoted 26 lines
Quoted 8 lines · On Fri, 4 Aug 2023 08:23:07 +0200 Bernd Kuhls <[email protected]> wrote:

Fixes:
http://autobuild.buildroot.net/results/506/50658c50fde8145fac320e3b17004e98c78c6c4d/

Although composer has host-php as build dependency, in the case of BR2_PER_PACKAGE_DIRECTORIES=y host-php was not built during extract stage of the composer package.

Thanks for noticing this. I indeed completely overlooked that when reviewing/merging the composer patch. However, there is one thing that I believe isn't ideal in your proposal, indeed it's kind of "half-way" through.

You handle part of the problem in package/pkg-utils.mk, as if .phar extraction was supported in the generic way in the package infrastructure, but that isn't the case: it only works with the special _EXTRACT_CMDS defined in composer.mk. So this .phar extraction would not work for any other package.

So instead of your change in package/pkg-utils.mk, can you do:

HOST_COMPOSER_EXTRACT_DEPENDENCIES = $(BR2_PHP_HOST_DEPENDENCY)

Quoted 8 lines

in composer.mk ? This would make the entire handling of .phar extraction a problem of composer.mk.

Of course, should we progressively have more and more of these, we could look at making this generic. But right now, let's handle this as a composer.mk specific concern.

What do you think?

I agree that we do not want to introduce it in the generic infra for now, until we have at least a few packages that need it.

Regards,
Yann E. MORIN.

Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw
Quoted 4 lines · On Fri, 4 Aug 2023 19:22:13 +0200 "Yann E. MORIN" <[email protected]>…
Quoted 1 line

What do you think?

I agree that we do not want to introduce it in the generic infra for now, until we have at least a few packages that need it.

Agreed, but to me the issue was not so much that it was made generic
here: my concern was that the proposed solution was half generic, half in the composer package.

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot