tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] PHP_MULTIVERSION option [was Re: upgrade glitches with php, maybe]



> Date: Thu, 24 Apr 2025 18:01:23 +0100
> From: Jonathan Perkin <jperkin%pkgsrc.org@localhost>
> 
> * On 2025-03-28 at 15:36 GMT, Taylor R Campbell wrote:
> 
> >The attached draft patch adds an mk.conf option PHP_MULTIVERSION,
> >default off.  This is work in progress -- limited to php82 for now.
> 
> What's the status of this?  While discussing with some of my users why I 
> haven't updated SmartOS trunk packages for a while, in part due to the 
> php issues, one of them said that the changes would affect over 400 of 
> their servers, so I'm keen to find a way forward that doesn't 
> immediately break them on "pkgin upgrade".

Here's the latest version of the patch (possibly not changed since I
first posted it, don't remember).

I tested it enough to verify the packages would build and have
plausible paths but I didn't try running any PHP scripts.  I haven't
pursued the patch further myself because I don't use PHP and it was
determined not to be a blocker for the branch.

Needs review and testing by someone who actually uses PHP.

Needs extension to versions other than lang/php82 -- should be easy in
principle, just a one-line change to lang/phpNN/Makefile.php and a few
changes to patches to replace php/${PHP_API_VERS} by ${PHP_API_VERS}
or lib/php@PHP_VER@ by @PHP_LIBDIR@, but it's work I haven't done.


Another issue is that pkgin will not automatically upgrade php82-8.2.*
to php-8.2.*, because the SUPERSEDES logic only considers dependencies
of packages that are already chosen to be upgraded -- it does not look
for supersedes of packages that aren't being upgraded.

So if you installed php82-8.2.1, and the repo now has php-8.2.2, pkgin
won't notice that -- you'll be stuck with php82-8.2.1.

(But if you installed php-foo-1.2.3 that depends on php82-8.2.1, and
the repo now has php-foo-1.2.3nb1 which depends on php-8.2.2, pkgin
will decide to replace php82-8.2.1 by php-8.2.2.)
From 34b35be025288e5e9872840f38157e30a63983bf Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
Date: Fri, 28 Mar 2025 15:26:19 +0000
Subject: [PATCH] WIP: New PHP_MULTIVERSION option, default off.

When this option is enabled, PHP include, lib, share, and config
paths are all versioned:

lib/php/8.2/...
include/php/8.2/...
share/php/8.2/...
etc/php/8.2/php.ini

When this option is disabled, they are not versioned, as before:

lib/php/...
include/php/...
share/php/...
etc/php.ini

PHP_MULTIVERSION is required for simultaneous installations of
multiple PHP versions.  Leaving the option disabled means we don't
break any existing installations and configurations.

XXX Only done for lang/php82 so far -- TBD: other php versions.
---
 lang/php/common.mk                            |  2 ++
 lang/php/phpversion.mk                        | 35 ++++++++++++++++---
 lang/php82/Makefile.php                       |  2 +-
 lang/php82/distinfo                           | 10 +++---
 lang/php82/patches/patch-configure.ac         |  4 +--
 lang/php82/patches/patch-php.ini-development  |  2 +-
 lang/php82/patches/patch-php.ini-production   |  2 +-
 .../php82/patches/patch-scripts_Makefile.frag |  2 +-
 .../php82/patches/patch-scripts_php-config.in |  2 +-
 www/php-concrete-cms/files/README             |  2 +-
 www/php-fpm/Makefile                          |  6 ++--
 www/php-fpm/files/php_fpm.sh                  |  2 +-
 www/php-owncloud/MESSAGE                      |  2 +-
 www/php-tt-rss/MESSAGE                        |  2 +-
 14 files changed, 51 insertions(+), 24 deletions(-)

diff --git a/lang/php/common.mk b/lang/php/common.mk
index b08d371ec865..e5596a116579 100644
--- a/lang/php/common.mk
+++ b/lang/php/common.mk
@@ -19,6 +19,8 @@ HOMEPAGE?=		https://www.php.net/
 
 .include "../../lang/php/phpversion.mk"
 
+.if ${PHP_MULTIVERSION:tl} == "yes"
 PKG_SYSCONFSUBDIR?=	php/${PHP_API_VERS}
+.endif
 
 .endif	# PHPCOMMON_MK
diff --git a/lang/php/phpversion.mk b/lang/php/phpversion.mk
index d2a7d4b7d680..26df9ece3807 100644
--- a/lang/php/phpversion.mk
+++ b/lang/php/phpversion.mk
@@ -13,6 +13,12 @@
 #	Possible: 56 74 81 82 83 84
 #	Default: 82
 #
+# PHP_MULTIVERSION
+#	Whether to version the paths of config and library files.
+#
+#	Possible: yes, no
+#	Default: yes
+#
 # === Infrastructure variables ===
 #
 # PHP_VERSION_REQD
@@ -47,6 +53,10 @@
 #	Possible: 56 74 81 82 83 84
 #	Default: ${PHP_VERSION_DEFAULT}
 #
+# PHP_VERSUFFIX
+#	Alias for PHP_VER if PHP_MULTIVERSION is enabled, empty if it
+#	is disabled.
+#
 # PHP_VERSION
 #	The selected PHP's full version.
 #
@@ -116,12 +126,14 @@ PHP83_VERSION=	8.3.19
 PHP84_VERSION=	8.4.5
 
 _VARGROUPS+=	php
-_USER_VARS.php=	PHP_VERSION_DEFAULT
+_USER_VARS.php=	PHP_VERSION_DEFAULT PHP_MULTIVERSION
 _PKG_VARS.php=	PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
 _SYS_VARS.php=	PHP_VERSION_PHP PHPPKGSRCDIR PHP_PKG_PREFIX PHP_VER PHP_MAJOR_VERS
 
 .include "../../mk/bsd.prefs.mk"
 
+PHP_MULTIVERSION?=		yes
+
 PHP_VERSION_DEFAULT?=		82
 PHP_VERSIONS_ACCEPTED?=		82 81 83 84 74 56
 .for pv in ${PHP_VERSIONS_ACCEPTED}
@@ -211,31 +223,44 @@ PHP_CONFIG?=		${PREFIX}/bin/php-config${PHP_VER}
 # force the selected PHP version for recursive builds
 PHP_VERSION_REQD:=	${PHP_VER}
 
-PHP_INCDIR=		include/php/${PHP_API_VERS}
-PHP_LIBDIR=		lib/php/${PHP_API_VERS}
-PHP_EGDIR=		share/examples/php/${PHP_API_VERS}
-PHP_SHAREDIR=		share/php/${PHP_API_VERS}
+.if ${PHP_MULTIVERSION:tl} == "yes"
+PHP_VERSUFFIX=		${PHP_VER}
+PHP_API_DIR=		php/${PHP_API_VERS}
+.else
+PHP_VERSUFFIX=		# empty
+PHP_API_DIR=		php
+.endif
+
+PHP_INCDIR=		include/${PHP_API_DIR}
+PHP_LIBDIR=		lib/${PHP_API_DIR}
+PHP_EGDIR=		share/examples/${PHP_API_DIR}
+PHP_SHAREDIR=		share/${PHP_API_DIR}
 
 PHP_EXTENSION_DIR=	${PHP_LIBDIR}/${MACHINE_GNU_ARCH}
 
 MAKE_ENV+=		PHP_VERSION_REQD="${PHP_VER}" \
+			PHP_API_DIR="${PHP_API_DIR}" \
 			PHP_VER="${PHP_VER}" PHP_API_VERS="${PHP_API_VERS}" \
+			PHP_VERSUFFIX="${PHP_VERSUFFIX}" \
 			PHP_INCDIR="${PHP_INCDIR}" \
 			PHP_LIBDIR="${PHP_LIBDIR}" PHP_EGDIR="${PHP_EGDIR}" \
 			PHP_SHAREDIR="${PHP_SHAREDIR}" \
 			PHP_EXTENSION_DIR="${PHP_EXTENSION_DIR}"
 MAKEFLAGS+=		PHP_VERSION_REQD="${PHP_VER}"
 FILES_SUBST+=		PHP_VER="${PHP_VER}" PHP_API_VERS="${PHP_API_VERS}" \
+			PHP_VERSUFFIX="${PHP_VERSUFFIX}" \
 			PHP_INCDIR="${PHP_INCDIR}" \
 			PHP_LIBDIR="${PHP_LIBDIR}" PHP_EGDIR="${PHP_EGDIR}" \
 			PHP_SHAREDIR="${PHP_SHAREDIR}" \
 			PHP_EXTENSION_DIR="${PHP_EXTENSION_DIR}"
 MESSAGE_SUBST+=		PHP_VER=${PHP_VER} PHP_API_VERS="${PHP_API_VERS}" \
+			PHP_VERSUFFIX="${PHP_VERSUFFIX}" \
 			PHP_INCDIR="${PHP_INCDIR}" \
 			PHP_LIBDIR="${PHP_LIBDIR}" PHP_EGDIR="${PHP_EGDIR}" \
 			PHP_SHAREDIR="${PHP_SHAREDIR}" \
 			PHP_EXTENSION_DIR="${PHP_EXTENSION_DIR}"
 PLIST_SUBST+=		PHP_PKG_PREFIX="${PHP_PKG_PREFIX}" \
+			PHP_VERSUFFIX="${PHP_VERSUFFIX}" \
 			PHP_VER="${PHP_VER}" \
 			PHP_MAJOR_VERS="${PHP_MAJOR_VERS}" \
 			PHP_INCDIR="${PHP_INCDIR}" \
diff --git a/lang/php82/Makefile.php b/lang/php82/Makefile.php
index 46344dfda67f..79ada107f76c 100644
--- a/lang/php82/Makefile.php
+++ b/lang/php82/Makefile.php
@@ -68,7 +68,7 @@ SUBST_FILES.path+=	sapi/cgi/Makefile.frag
 SUBST_FILES.path+=	sapi/fpm/php-fpm.conf.in sapi/fpm/www.conf.in
 SUBST_FILES.path+=	sapi/fpm/fpm/fpm_conf.c
 SUBST_FILES.path+=	scripts/php-config.in scripts/phpize.in
-SUBST_VARS.path=	PREFIX CGIDIR PHP_VER PHP_API_VERS
+SUBST_VARS.path=	PREFIX CGIDIR PHP_VER PHP_API_VERS PHP_API_DIR
 SUBST_VARS.path+=	PHP_EGDIR PHP_INCDIR PHP_LIBDIR
 SUBST_VARS.path+=	TOOLS_PATH.pkg-config PHP_PKGCONFIG_PATH
 
diff --git a/lang/php82/distinfo b/lang/php82/distinfo
index f80cd68bae18..4b1e91eec1d4 100644
--- a/lang/php82/distinfo
+++ b/lang/php82/distinfo
@@ -5,15 +5,15 @@ SHA512 (php-8.2.28.tar.xz) = af2a4f43da756a78f762dbd2b9e589e52864c7069fd55a6a2b9
 Size (php-8.2.28.tar.xz) = 12147756 bytes
 SHA1 (patch-build_Makefile.global) = 87c533087a536649b5f51108ef4f4b72c8efc5b2
 SHA1 (patch-build_php.m4) = 465d2896c8c4d88c325414caf221e1f2aec27fc3
-SHA1 (patch-configure.ac) = d3bb35c423250d1124e2ada0974fc93448634abb
+SHA1 (patch-configure.ac) = e0563fec00931fb1d0647d3729bc922538472e73
 SHA1 (patch-ext_enchant_enchant.c) = 7d999de1b2fde2ea11e4a6e16e7b59c085924b9b
 SHA1 (patch-ext_phar_Makefile.frag) = 53ea5c58b0bc27d236118d5750a74b1cba43e5dd
 SHA1 (patch-ext_standard_php__fopen__wrapper.c) = 0a2c19c18f089448a8d842e99738b292ab9e5640
 SHA1 (patch-ext_tidy_config.m4) = 380f4e8927582b2781faf58b17ad81b6dc967ba7
 SHA1 (patch-ext_xsl_php__xsl.h) = cf930c5d6d9dab29b12558d265c67d3534a006fd
 SHA1 (patch-main_streams_streams.c) = d699ce7d3a300ffb39494b3f1fa5e0958f714483
-SHA1 (patch-php.ini-development) = 039c0b316ac1a65b66c9e36f6aff17e9c9cd2a90
-SHA1 (patch-php.ini-production) = cd127bcbd4c0f16e2136e84dfcf1c0c3d6107705
+SHA1 (patch-php.ini-development) = 6b328cf7210469131a9362cc3d32793e8d331919
+SHA1 (patch-php.ini-production) = 8ee06c7c4c94edbb98a31b5c77ae9f07567cb399
 SHA1 (patch-sapi_apache2handler_config.m4) = c669235e4890a3a56c02760c451b40d97c651c34
 SHA1 (patch-sapi_cgi_Makefile.frag) = f4cd64d334884c49787d8854115c8cd69cc79bb8
 SHA1 (patch-sapi_cgi_config9.m4) = 080a809291984540aa426d14eb9b9c34225828a4
@@ -21,6 +21,6 @@ SHA1 (patch-sapi_cli_Makefile.frag) = 1cd29d09042863acbf5330e406410fdcf75d06b3
 SHA1 (patch-sapi_fpm_fpm_fpm__conf.c) = 32f391847009dd00e3ab304e40e172ca46c3613c
 SHA1 (patch-sapi_fpm_php-fpm.conf.in) = 67ac024688ece4c771f0aefbd999923f73b06eef
 SHA1 (patch-sapi_fpm_www.conf.in) = 0a1587e67c6e141a169f23692420de67368172c3
-SHA1 (patch-scripts_Makefile.frag) = a2519d5329bd7860cea58f4999c2a24769cc5416
-SHA1 (patch-scripts_php-config.in) = ce621fc3086fd8f2249cfe3b680256bd08a143ad
+SHA1 (patch-scripts_Makefile.frag) = 655e98a303de2bce5dcd3bfa453e56da3eeb6dec
+SHA1 (patch-scripts_php-config.in) = 6841f4cfdd4909553afea889c4892d71d50f69eb
 SHA1 (patch-scripts_phpize.in) = 7c2f49aebbabb5a1510d856243dc8f159695c9f2
diff --git a/lang/php82/patches/patch-configure.ac b/lang/php82/patches/patch-configure.ac
index b7cb67ccee5d..eca82f1ce50e 100644
--- a/lang/php82/patches/patch-configure.ac
+++ b/lang/php82/patches/patch-configure.ac
@@ -24,13 +24,13 @@ $NetBSD: patch-configure.ac,v 1.1 2025/02/08 02:59:45 taca Exp $
  case $libdir in
    '${exec_prefix}/lib')
 -    libdir=$libdir/php
-+    libdir=$libdir/php/${PHP_API_VERS}
++    libdir=$libdir/${PHP_API_DIR}
      ;;
  esac
  case `eval echo $datadir` in
    '${prefix}/share')
 -    datadir=$datadir/php
-+    datadir=$datadir/php/${PHP_API_VERS}
++    datadir=$datadir/${PHP_API_DIR}
      ;;
  esac
  
diff --git a/lang/php82/patches/patch-php.ini-development b/lang/php82/patches/patch-php.ini-development
index 99aaaaf1889d..839d04a0cef6 100644
--- a/lang/php82/patches/patch-php.ini-development
+++ b/lang/php82/patches/patch-php.ini-development
@@ -9,7 +9,7 @@ Set proper default configuration values.
  
  ; UNIX: "/path1:/path2"
 -;include_path = ".:/php/includes"
-+include_path = ".:@PREFIX@/lib/php@PHP_VER@"
++include_path = ".:@PREFIX@/@PHP_LIBDIR@"
  ;
  ; Windows: "\path1;\path2"
  ;include_path = ".;c:\php\includes"
diff --git a/lang/php82/patches/patch-php.ini-production b/lang/php82/patches/patch-php.ini-production
index 2b86d5e5e403..c714b5ab2e91 100644
--- a/lang/php82/patches/patch-php.ini-production
+++ b/lang/php82/patches/patch-php.ini-production
@@ -9,7 +9,7 @@ Set proper default configuration values.
  
  ; UNIX: "/path1:/path2"
 -;include_path = ".:/php/includes"
-+include_path = ".:@PREFIX@/lib/php@PHP_VER@"
++include_path = ".:@PREFIX@/@PHP_LIBDIR@"
  ;
  ; Windows: "\path1;\path2"
  ;include_path = ".;c:\php\includes"
diff --git a/lang/php82/patches/patch-scripts_Makefile.frag b/lang/php82/patches/patch-scripts_Makefile.frag
index 091f6aaaf8ce..c9cb0acbe0c9 100644
--- a/lang/php82/patches/patch-scripts_Makefile.frag
+++ b/lang/php82/patches/patch-scripts_Makefile.frag
@@ -10,7 +10,7 @@ $NetBSD: patch-scripts_Makefile.frag,v 1.1 2025/02/08 02:59:45 taca Exp $
  
 -phpincludedir = $(includedir)/php
 -phpbuilddir = $(libdir)/build
-+phpincludedir = $(includedir)/php/$(PHP_API_VERS)
++phpincludedir = $(includedir)/$(PHP_API_DIR)
 +phpbuilddir = $(prefix)/$(PHP_LIBDIR)/build
  
  BUILD_FILES = \
diff --git a/lang/php82/patches/patch-scripts_php-config.in b/lang/php82/patches/patch-scripts_php-config.in
index 67bb5e0df0e4..6f1a57534d5f 100644
--- a/lang/php82/patches/patch-scripts_php-config.in
+++ b/lang/php82/patches/patch-scripts_php-config.in
@@ -9,7 +9,7 @@ $NetBSD: patch-scripts_php-config.in,v 1.1 2025/02/08 02:59:45 taca Exp $
  version="@PHP_VERSION@"
  vernum="@PHP_VERSION_ID@"
 -include_dir="@includedir@/php"
-+include_dir="@includedir@/php/@PHP_API_VERS@"
++include_dir="@includedir@/@PHP_API_DIR@"
  includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"
  ldflags="@PHP_LDFLAGS@"
  libs="@EXTRA_LIBS@"
diff --git a/www/php-concrete-cms/files/README b/www/php-concrete-cms/files/README
index a22b7d5cdf55..3ef14f5315e4 100644
--- a/www/php-concrete-cms/files/README
+++ b/www/php-concrete-cms/files/README
@@ -96,7 +96,7 @@ To use Concrete CMS with nginx, you will need to perform the following steps.
 
 10. Start php-fpm and nginx.
 
-	# ${RCD_SCRIPTS_DIR}/php_fpm start
+	# ${RCD_SCRIPTS_DIR}/php_fpm${PHP_VERSUFFIX} start
 	# ${RCD_SCRIPTS_DIR}/nginx start
 
 11. Access http://localhost/
diff --git a/www/php-fpm/Makefile b/www/php-fpm/Makefile
index b61a73e49719..9c0ea7da4f63 100644
--- a/www/php-fpm/Makefile
+++ b/www/php-fpm/Makefile
@@ -50,9 +50,9 @@ CONFIGURE_ARGS+=	--with-fpm-user=${FPM_USER}
 CONFIGURE_ARGS+=	--with-fpm-group=${FPM_GROUP}
 CONFIGURE_ARGS+=	--sysconfdir=${PKG_SYSCONFDIR}
 
-SMF_NAME=				php-fpm${PHP_VER}
-RCD_SCRIPTS=				php_fpm${PHP_VER}
-RCD_SCRIPT_SRC.php_fpm${PHP_VER}=	${FILESDIR}/php_fpm.sh
+SMF_NAME=				php-fpm${PHP_VERSUFFIX}
+RCD_SCRIPTS=				php_fpm${PHP_VERSUFFIX}
+RCD_SCRIPT_SRC.php_fpm${PHP_VERSUFFIX}=	${FILESDIR}/php_fpm.sh
 
 MESSAGE_SUBST+=		CGIDIR=${CGIDIR} VARBASE=${VARBASE}
 INSTALLATION_DIRS+=	${PREFIX}/${PHP_EGDIR} ${PKGMANDIR}/man8 sbin
diff --git a/www/php-fpm/files/php_fpm.sh b/www/php-fpm/files/php_fpm.sh
index 3abfc5b18949..29f6653c5b2d 100755
--- a/www/php-fpm/files/php_fpm.sh
+++ b/www/php-fpm/files/php_fpm.sh
@@ -13,7 +13,7 @@
 
 $_rc_subr_loaded . @SYSCONFBASE@/rc.subr
 
-name="php_fpm@PHP_VER@"
+name="php_fpm@PHP_VERSUFFIX@"
 rcvar=${name}
 command="@PREFIX@/sbin/php-fpm@PHP_VER@"
 required_files="@PKG_SYSCONFDIR@/php-fpm.conf"
diff --git a/www/php-owncloud/MESSAGE b/www/php-owncloud/MESSAGE
index 833ab5848f42..d8a6e1d00c6a 100644
--- a/www/php-owncloud/MESSAGE
+++ b/www/php-owncloud/MESSAGE
@@ -102,7 +102,7 @@ server {
 
 7. Start PHP-FPM daemon.
 
-	${RCD_SCRIPTS_DIR}/php_fpm start
+	${RCD_SCRIPTS_DIR}/php_fpm${PHP_VERSUFFIX} start
 
 8. Start nginx httpd server.
 
diff --git a/www/php-tt-rss/MESSAGE b/www/php-tt-rss/MESSAGE
index 9da319c9beda..8d6ddc2363f8 100644
--- a/www/php-tt-rss/MESSAGE
+++ b/www/php-tt-rss/MESSAGE
@@ -96,7 +96,7 @@ the following steps.
 
 13. Start PHP-FPM daemon.
 
-	${RCD_SCRIPTS_DIR}/php_fpm start
+	${RCD_SCRIPTS_DIR}/php_fpm${PHP_VERSUFFIX} start
 
 14. Start nginx httpd server.
 


Home | Main Index | Thread Index | Old Index