tech-pkg archive

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

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



> Date: Thu, 27 Mar 2025 16:59:30 +0000
> From: Jonathan Perkin <jperkin%pkgsrc.org@localhost>
> 
> I'm not a fan of the php change, I'm very worried that it's going to 
> silently break many of my users if I ever update to it.  Would be nice 
> if it could be made optional.

The attached draft patch adds an mk.conf option PHP_MULTIVERSION,
default off.  This is work in progress -- limited to php82 for now.

With PHP_MULTIVERSION=yes, all the files are versioned so php81 and
php82 can be installed side by side -- this enables the new feature
taca@ implemented.

With PHP_MULTIVERSION=no (default), the status quo of 2024Q4 is
preserved for include/lib/etc/share paths and rcvars, so config files
don't need to change -- no regression from 2024Q4.

I have only build-tested this for lang/php82 and www/php-fpm -- it
needs to be tested by someone who knows anything about deploying PHP
applications.

Perhaps it is a cheaper path to avoiding gratuitous incompatibility in
2025Q1 than reverting the multiversion changes altogether.  Later, for
2025Q2 or beyond, we can prepare and test a migration plan for
flipping PHP_MULTIVERSION on by default.
From 08f380f496ada9030821aa5ccff5f0d99cf7128f 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/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 +-
 13 files changed, 50 insertions(+), 23 deletions(-)

diff --git a/lang/php/phpversion.mk b/lang/php/phpversion.mk
index 34ecb91aa211..300fadfbbd8c 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: no
+#
 # === 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.
 #
@@ -122,6 +132,8 @@ _SYS_VARS.php=	PHP_VERSION_PHP PHPPKGSRCDIR PHP_PKG_PREFIX PHP_VER PHP_MAJOR_VER
 
 .include "../../mk/bsd.prefs.mk"
 
+PHP_MULTIVERSION?=		no
+
 PHP_VERSION_DEFAULT?=		82
 PHP_VERSIONS_ACCEPTED?=		82 81 83 84 74 56
 .for pv in ${PHP_VERSIONS_ACCEPTED}
@@ -211,33 +223,48 @@ 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}
 
+.if ${PHP_MULTIVERSION:tl} == "yes"
 PKG_SYSCONFSUBDIR?=	php/${PHP_API_VERS}
+.endif
 
 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 178f959e02b7..0803e183f6fb 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