new host-composer package patches series
cover new host-composer package patches series
From: Nicolas Carrier <[email protected]>
This patch series introduces a new host package for composer. This package requires the creation of a host-php package, which in turn, needs a host-oniguruma package.
Composer is a tool used to deploy and handle dependencies of php web sites and is used in particular, by the CakePHP framework.
In order to test this patch series up to the creation of a working minimal system, able to serve a test CakePHP website, a hello-world can be created this way:
################################################################################
#
# hello-world # ################################################################################
HELLO_WORLD_DEPENDENCIES += \ php \ host-php \ host-composer
define HELLO_WORLD_INSTALL_TARGET_CMDS
cd $(@D) && rm -rf hello-world && \ $(HOST_DIR)/bin/php $(HOST_DIR)/bin/composer create-project \ --ignore-platform-reqs \ --no-interaction \ --no-dev \ --prefer-dist cakephp/app:4.* hello-world mkdir -p $(TARGET_DIR)/srv/www2/ rsync --exclude resources \ --exclude composer.json \ --exclude composer.lock \ -a $(@D)/hello-world/ \ $(TARGET_DIR)/srv/www2/hello-world/ # we disable the loading of DebugKit which isn't available and disabling the # debug instead just won't work with such a minimal application sed -i "s/.*'DebugKit');//g" \ $(TARGET_DIR)/srv/www2/hello-world/src/Application.php endef
$(eval $(generic-package))
Then select the qemu_x86 default config:
make qemu_x86_defconfig
And the following configurations must be set:
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_PACKAGE_HELLO_WORLD=y
BR2_PACKAGE_PHP_SAPI_CGI=y
BR2_PACKAGE_PHP_EXT_PDO=y
BR2_PACKAGE_PHP_EXT_INTL=y
BR2_PACKAGE_PHP_EXT_MBSTRING=y
BR2_PACKAGE_PHP_EXT_FILTER=y
BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
Then build the image, execute it with:
qemu-system-i386 -M pc -kernel output/images/bzImage \ -drive file=output/images/rootfs.ext2,if=virtio,format=raw \ -append "rootwait root=/dev/vda console=tty1 console=ttyS0" \ -serial stdio -net nic,model=virtio -net user
Once booted in the system, enter 'root' as the password and then:
cd /srv/www2/hello-world/
bin/cake server &
wget -O - http://localhost:8765
wget should be able to dump the landing page of the test web site.
Nicolas Carrier (3):
package/oniguruma/oniguruma.mk: add a host package package/php/php.mk: add host-php package/composer: new package
package/composer/composer.hash | 3 +++ package/composer/composer.mk | 31 +++++++++++++++++++++++++++++++ package/oniguruma/oniguruma.mk | 1 + package/php/php.mk | 19 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 package/composer/composer.hash create mode 100644 package/composer/composer.mk
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 1/3 package/oniguruma/oniguruma.mk: add a host package
From: Nicolas Carrier <[email protected]>
This is needed for the creation of an host-php package
--- package/oniguruma/oniguruma.mk | 1 + 1 file changed, 1 insertion(+)
package/oniguruma/oniguruma.mk +1 -0
@@ -14,3 +14,4 @@ ONIGURUMA_CPE_ID_VENDOR = oniguruma_project ONIGURUMA_INSTALL_STAGING = YES $(eval $(autotools-package)) +$(eval $(host-autotools-package))
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 1/3] package/oniguruma/oniguruma.mk: add a host package
Quoted 5 lines · On Thu, 19 Jan 2023 14:28:54 +0100 [email protected] wrote:
From: Nicolas Carrier <[email protected]>
This is needed for the creation of an host-php package
Signed-off-by Nicolas Carrier <[email protected]>
Tweaked commit title as:
package/oniguruma: add a host variant
and applied. Thanks!
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
PATCH 2/3 package/php/php.mk: add host-php
In reply to [email protected]From: Nicolas Carrier <[email protected]>
having a working PHP with the correct version, is mandatory for executing some PHP tools, such as composer, when building packages.
--- package/php/php.mk | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
package/php/php.mk +19 -0
@@ -14,6 +14,24 @@ PHP_DEPENDENCIES = host-pkgconf pcre2 PHP_LICENSE = PHP-3.01 PHP_LICENSE_FILES = LICENSE PHP_CPE_ID_VENDOR = php + +# This host php is installed in $(HOST_DIR), as it is needed +# to use composer. + +HOST_PHP_CONF_OPTS += \ + --disable-all \ + --without-pear \ + --with-config-file-path=/etc \ + --disable-phpdbg \ + --enable-phar \ + --enable-json \ + --enable-filter \ + --enable-mbstring \ + --enable-tokenizer \ + --with-openssl=$(HOST_DIR)/usr + +HOST_PHP_DEPENDENCIES += host-oniguruma host-openssl host-pkgconf + PHP_CONF_OPTS = \ --mandir=/usr/share/man \ --infodir=/usr/share/info \
@@ -344,3 +362,4 @@ PHP_POST_INSTALL_TARGET_HOOKS += PHP_INSTALL_FIXUP PHP_CONF_ENV += CFLAGS="$(PHP_CFLAGS)" CXXFLAGS="$(PHP_CXXFLAGS)" $(eval $(autotools-package)) +$(eval $(host-autotools-package))
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 2/3] package/php/php.mk: add host-php
Hello,
Quoted 6 lines · On Thu, 19 Jan 2023 14:28:55 +0100 [email protected] wrote:
From: Nicolas Carrier <[email protected]>
having a working PHP with the correct version, is mandatory for executing some PHP tools, such as composer, when building packages.
Signed-off-by Nicolas Carrier <[email protected]>
Tweaked commit title as:
package/php/php: add a host variant
and it should have been:
package/php: add a host variant
but I messed up.
package/php/php.mk PHP_DEPENDENCIES = host-pkgconf pcre2 · line 19
Quoted 11 lines
package/php/php.mk +3
-0@@ -14,6 +14,24 @@ PHP_DEPENDENCIES = host-pkgconf pcre2 PHP_LICENSE = PHP-3.01 PHP_LICENSE_FILES = LICENSE PHP_CPE_ID_VENDOR = php + +# This host php is installed in $(HOST_DIR), as it is needed +# to use composer.
This comment was not really useful: all host packages are installed in $(HOST_DIR). So I dropped this comment.
Quoted 4 lines
package/php/php.mk +4
-0+ +HOST_PHP_CONF_OPTS += \ + --disable-all \ + --without-pear \
package/php/php.mk PHP_DEPENDENCIES = host-pkgconf pcre2 · line 33
Quoted 10 lines
package/php/php.mk +10
-0+ --with-config-file-path=/etc \ + --disable-phpdbg \ + --enable-phar \ + --enable-json \ + --enable-filter \ + --enable-mbstring \ + --enable-tokenizer \ + --with-openssl=$(HOST_DIR)/usr + +HOST_PHP_DEPENDENCIES += host-oniguruma host-openssl host-pkgconf
I moved both of these to the bottom of the file, to have first all the stuff related to target PHP, and the all the stuff related to host PHP.
I replaced the += by = signs, since these assignments are not within conditions.
I was also puzzled by the discrepancy in dependencies between target and host PHP:
- target PHP depends on host-pkgconf and pcre2
- your host PHP proposal depends on host-onigurama host-openssl and host-pkgconf
So I added host-pcre2 in the dependencies, and added the option --with-external-pcre to be on par with what we're doing for the target PHP. host-onigurama is needed for --enable-mbstring, and host-openssl for --with-openssl.
--with-openssl=$(HOST_DIR)/usr had to be changed to --with-openssl=$(HOST_DIR) (we no longer used a usr/ subdir, and this line was causing a check-package warning).
--with-config-file-path=/etc was changed to
--with-config-file-path=$(HOST_DIR)/etc.
Applied with those changes. Thanks!
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
PATCH 3/3 package/composer: new package
In reply to [email protected]From: Nicolas Carrier <[email protected]>
composer describes itself as a dependency manager for PHP, it is used by projects such as CakePHP.
--- package/composer/composer.hash | 3 +++ package/composer/composer.mk | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 package/composer/composer.hash create mode 100644 package/composer/composer.mk
package/composer/composer.hash new file +3 -0
@@ -0,0 +1,3 @@ +# Locally computed hashes, not provided by upstream +sha256 2021f0d52b446e0efe3c548cc058ab5671fa38cdbcf814e7911c7e9d71d61538 composer-2.0.8.phar +sha256 c8cce4b6b9729f264ffdf9296d505d63432497feeed1f586d1902b942197e024 LICENSE
package/composer/composer.mk new file +31 -0
@@ -0,0 +1,31 @@ +################################################################################ +# +# composer +# +################################################################################ + +COMPOSER_VERSION = 2.0.8 +COMPOSER_SOURCE = composer-$(COMPOSER_VERSION).phar +# Here, we pass a dummy URL parameter in order to control the name the file +# will have once downloaded. +# Otherwise, the names will clash ifever we update the version. +BASE_SITE = https://getcomposer.org/download/$(COMPOSER_VERSION)/composer.phar +COMPOSER_SITE = $(BASE_SITE)?n=f/$(COMPOSER_SOURCE) +COMPOSER_LICENSE = MIT +COMPOSER_LICENSE_FILES = LICENSE + +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 \ + $$p = new Phar("$(COMPOSER_SOURCE)"); \ + $$p->extractTo(".", "LICENSE");' +endef + +define HOST_COMPOSER_INSTALL_CMDS + mv $(@D)/$(COMPOSER_SOURCE) $(HOST_DIR)/bin/composer + chmod +x $(HOST_DIR)/bin/composer +endef + +$(eval $(host-generic-package))
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH 3/3] package/composer: new package
Hello Nicolas,
Quoted 19 lines · On Thu, 19 Jan 2023 14:28:56 +0100 [email protected] wrote:
From: Nicolas Carrier <[email protected]>
composer describes itself as a dependency manager for PHP, it is used by projects such as CakePHP.
Signed-off-by Nicolas Carrier <[email protected]>--- package/composer/composer.hash | 3 +++ package/composer/composer.mk | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 package/composer/composer.hash create mode 100644 package/composer/composer.mkpackage/composer/composer.hash new file +0
-0
package/composer/composer.hash line 1
Quoted 1 line
package/composer/composer.hash new file +1
-0@@ -0,0 +1,3 @@ +# Locally computed hashes, not provided by upstream
Actually hashes are available at https://getcomposer.org/download/.
Quoted 8 lines
package/composer/composer.hash new file +2
-0+sha256 2021f0d52b446e0efe3c548cc058ab5671fa38cdbcf814e7911c7e9d71d61538 composer-2.0.8.phar +sha256 c8cce4b6b9729f264ffdf9296d505d63432497feeed1f586d1902b942197e024 LICENSEpackage/composer/composer.mk new file +0
-0
package/composer/composer.mk line 7
Quoted 7 lines
package/composer/composer.mk new file +7
-0@@ -0,0 +1,31 @@ +################################################################################ +# +# composer +# +################################################################################ + +COMPOSER_VERSION = 2.0.8
I have bumped to 2.5.8, because at runtime 2.0.8 was spitting out a few warnings about usage of PHP features that are deprecated/obsolete.
I've added a Config.in.host file so that this package can be enabled as a host package from menuconfig.
And I now realize that I forgot to add a DEVELOPERS entry, so I will do that now.
Applied with those changes!
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