[MacPorts] #64758: php* +universal: php-config* differs and cannot be merged (was: php74/php80/php81: php-config differs and cannot be merged)

MacPorts noreply at macports.org
Sat Aug 12 08:33:05 UTC 2023


#64758: php* +universal: php-config* differs and cannot be merged
-----------------------+------------------------
  Reporter:  claviola  |      Owner:  ryandesign
      Type:  defect    |     Status:  assigned
  Priority:  Normal    |  Milestone:
 Component:  ports     |    Version:  2.7.1
Resolution:            |   Keywords:
      Port:  php       |
-----------------------+------------------------
Changes (by ryandesign):

 * cc: kencu (added)
 * port:  php74 php80 php81 => php


Comment:

 Ken, I see that you [changeset:c9a6e03fc195486bbc91148a44393ae9f333f109
 /macports-ports added code to the muniversal portgroups] to automatically
 strip these differences from scripts. Your code adds rules that:

 1. remove all characters starting from `--host=` until the next space or
 end of line,
 2. remove all characters starting from `host_alias=` until the next space
 or end of line, and
 3. collapse all runs of two or more spaces into a single space.

 Unfortunately this does not take into account two peculiarities of the way
 these flags are put into the php-config scripts:

 * They are enclosed in single quotation marks
 * One of them is at the end of the string right before the closing
 quotation mark

 See above where the line that begins with `configure_options="` ends with
 `'--with-libedit' '--host=aarch64-apple-darwin21.3.0' 'host_alias=aarch64
 -apple-darwin21.3.0'"`.

 If we apply your first rule, that replaces `--host=aarch64-apple-
 darwin21.3.0'` with nothing, leaving us with `'--with-libedit' '
 'host_alias=aarch64-apple-darwin21.3.0'"`. If we apply your second rule,
 that replaces `host_alias=aarch64-apple-darwin21.3.0'"` with nothing
 leaving us with `'--with-libedit' ' '`. There is now no closing quotation
 mark on this string, resulting in a syntax error when we try to run the
 script. However since the same processing was applied to the files of both
 architectures, the resulting files are the same, and muniversal allows the
 merge to proceed. The user has now successfully installed a php with the
 universal variant but the php-config script is broken. All the php module
 ports that depend on php use the php-config script, so they all now fail
 to install with a confusing error. This is what happened in #67898.

 I was unable to reproduce the issue on my own system because I have an
 Intel Mac. On my Intel Mac, only the php-config file for the cross-
 compiled architecture (arm64) got the `--host` and `host_alias` flags, so
 there was still a difference between the files after processing and the
 merge failed. Only users on Apple Silicon Macs will get a successful
 erroneous install of php +universal because
 [changeset:151f7c48a55d61bb821376dc8a461e9efdba9c93/macports-ports in an
 attempt to help broken pre-Apple Silicon config.guess scripts bundled with
 old software] muniversal uses the `--host` and `host_alias` flags even for
 the non-cross-compiled architecture on arm64.

 I am also concerned about your third rule. I don't think we should be
 indiscriminately collapsing multiple spaces into one throughout these
 merged files. It's true that for shell scripts there's no syntactical
 difference between one space and multiple spaces, but this replacement
 happens not only for shell scripts but for any file whose first two
 characters are `#!`. This could include python scripts; whitespace is very
 significant in python. Also, multiple spaces might have been used in user-
 facing messages for alignment purposes. Taking php-config82 as an example,
 here is what a properly-working script outputs when you run it:

 {{{
 % php-config82
 Usage: /opt/local/bin/php-config82 [OPTION]
 Options:
   --prefix            [/opt/local]
   --includes          [-I/opt/local/include/php82/php
 -I/opt/local/include/php82/php/main -I/opt/local/include/php82/php/TSRM
 -I/opt/local/include/php82/php/Zend -I/opt/local/include/php82/php/ext
 -I/opt/local/include/php82/php/ext/date/lib -I/opt/local/include]
   --ldflags           [ -L/opt/local/lib]
   --libs              [  -lresolv -lncurses -lbz2 -lnetwork -lm  -lxml2
 -lpcre2-8 -lz -lxml2 -ledit -lxml2 -largon2 -lxml2 -lxml2 -lxml2 -lz ]
   --extension-dir     [/opt/local/lib/php82/extensions/no-debug-non-
 zts-20220829]
   --include-dir       [/opt/local/include/php82/php]
   --man-dir           [/opt/local/share/man]
   --php-binary        [/opt/local/bin/php82]
   --php-sapis         [ cli phpdbg]
   --ini-path          [/opt/local/etc/php82]
   --ini-dir           [/opt/local/var/db/php82]
   --configure-options [--prefix=/opt/local --mandir=/opt/local/share/man
 --infodir=/opt/local/share/info --program-suffix=82
 --includedir=/opt/local/include/php82 --libdir=/opt/local/lib/php82
 --with-config-file-path=/opt/local/etc/php82 --with-config-file-scan-
 dir=/opt/local/var/db/php82 --disable-all --enable-bcmath --enable-ctype
 --enable-dom --enable-filter --enable-json --enable-pdo --enable-session
 --enable-simplexml --enable-tokenizer --enable-xml --enable-xmlreader
 --enable-xmlwriter --with-bz2=/opt/local --with-mhash=/opt/local --with-
 zlib=/opt/local --disable-cgi --enable-cli --with-libxml --with-external-
 pcre=/opt/local --enable-fileinfo --enable-phar --disable-fpm --with-
 password-argon2=/opt/local --without-valgrind --with-libedit]
   --version           [8.2.8]
   --vernum            [80208]
 }}}

 If I fix the closing quotation mark issue in a php-config82 that has gone
 through the merging procedure, its output is clearly less desirable:

 {{{
 % sh ./php-config82-broken2
 Usage: ./php-config82-broken2 [OPTION]
 Options:
  --prefix [/opt/local]
  --includes [-I/opt/local/include/php82/php
 -I/opt/local/include/php82/php/main -I/opt/local/include/php82/php/TSRM
 -I/opt/local/include/php82/php/Zend -I/opt/local/include/php82/php/ext
 -I/opt/local/include/php82/php/ext/date/lib -I/opt/local/include]
  --ldflags [ -L/opt/local/lib]
  --libs [ -lresolv -lncurses -lbz2 -lnetwork -lm -lxml2 -lpcre2-8 -lz
 -lxml2 -ledit -lxml2 -largon2 -lxml2 -lxml2 -lxml2 -lz ]
  --extension-dir [/opt/local/lib/php82/extensions/no-debug-non-
 zts-20220829]
  --include-dir [/opt/local/include/php82/php]
  --man-dir [/opt/local/share/man]
  --php-binary [/opt/local/bin/php82]
  --php-sapis [ cli phpdbg]
  --ini-path [/opt/local/etc/php82]
  --ini-dir [/opt/local/var/db/php82]
  --configure-options [--prefix=/opt/local --mandir=/opt/local/share/man
 --infodir=/opt/local/share/info --program-suffix=82
 --includedir=/opt/local/include/php82 --libdir=/opt/local/lib/php82
 --with-config-file-path=/opt/local/etc/php82 --with-config-file-scan-
 dir=/opt/local/var/db/php82 --disable-all --enable-bcmath --enable-ctype
 --enable-dom --enable-filter --enable-json --enable-pdo --enable-session
 --enable-simplexml --enable-tokenizer --enable-xml --enable-xmlreader
 --enable-xmlwriter --with-bz2=/opt/local --with-mhash=/opt/local --with-
 zlib=/opt/local --disable-cgi --enable-cli --with-libxml --with-external-
 pcre=/opt/local --enable-fileinfo --enable-phar --disable-fpm --with-
 password-argon2=/opt/local --without-valgrind --with-libedit]
  --version [8.2.8]
  --vernum [80208]
 }}}

-- 
Ticket URL: <https://trac.macports.org/ticket/64758#comment:6>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list