php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78788 ./configure generates invalid php_version.h
Submitted: 2019-11-06 12:39 UTC Modified: 2019-11-07 09:02 UTC
From: php at shyim dot de Assigned: cmb (profile)
Status: Closed Package: Compile Failure
PHP Version: 7.4.0RC5 OS: NixOs
Private report: No CVE-ID: None
 [2019-11-06 12:39 UTC] php at shyim dot de
Description:
------------
Before running ./configure
cat main/php_version.h 
/* automatically generated by configure */
/* edit configure.ac to change version number */
#define PHP_MAJOR_VERSION 7
#define PHP_MINOR_VERSION 4
#define PHP_RELEASE_VERSION 0
#define PHP_EXTRA_VERSION "RC5"
#define PHP_VERSION "7.4.0RC5"
#define PHP_VERSION_ID 70400

After running ./configure

cat main/php_version.h 
/* automatically generated by configure */
/* edit configure.ac to change version number */
#define PHP_MAJOR_VERSION linux
#define PHP_MINOR_VERSION gnu
#define PHP_RELEASE_VERSION 
#define PHP_EXTRA_VERSION ""
#define PHP_VERSION "linux.gnu."
#define PHP_VERSION_ID 

Should this file not readonly / fixed to version?

Test script:
---------------
cat main/php_version.h 
./configure
cat main/php_version.h 

Expected result:
----------------
./configure does not modify main/php_version.h


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-06 12:50 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2019-11-06 12:50 UTC] requinix@php.net
Did you make any changes to your configure.ac? What does the AC_INIT (line ~20) say?
 [2019-11-06 13:02 UTC] php at shyim dot de
I just did
wget https://downloads.php.net/~derick/php-7.4.0RC5.tar.bz2
tar xf php-7.4.0RC5.tar.bz2
cd php-7.4.0RC5
./configure

and that file is so wrong generated.

configure.ac content
AC_INIT([PHP],[7.4.0RC5],[https://bugs.php.net],[php],[https://www.php.net])
 [2019-11-06 14:03 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2019-11-06 14:03 UTC] cmb@php.net
What's you autoconf version?
 [2019-11-06 14:52 UTC] php at shyim dot de
autoconf --version
autoconf (GNU Autoconf) 2.69
 [2019-11-06 14:56 UTC] cmb@php.net
-Status: Feedback +Status: Open -Assigned To: cmb +Assigned To:
 [2019-11-06 14:56 UTC] cmb@php.net
2.69 should be good.
 [2019-11-06 15:04 UTC] php at shyim dot de
I guess I have found the issue

checking for a sed that does not truncate output... /nix/store/5bzp9gfa14j4a1rbxxf6d574a4qgmqi9-gnused-4.7/bin/sed
./configure: line 3832: /nix/store/5bzp9gfa14j4a1rbxxf6d574a4qgmqi9-gnused-4: No such file or directory

Line 3842: set $(echo 7.4.0RC5 | $SED 's/\([0-9\.]*\)\(.*\)/\1\.\2/')

I have outputted the $SED it contains "/nix/store/5bzp9gfa14j4a1rbxxf6d574a4qgmqi9-gnused-4 7/bin/sed"
The dot is missing in path
 [2019-11-06 17:05 UTC] max at swk-web dot com
The problem seems to be some missing escaping when using relative paths, and changing the IFS to ".":
$ cat tmp.sh
#!/bin/bash

executable_sed=$(which sed)
relative_sed_location=$(realpath --relative-to="." "${executable_sed}")
relative_executable_sed=./${relative_sed_location}
echo ${executable_sed}
echo ${relative_sed_location}
echo ${relative_executable_sed}

version=7.4.0RC5

echo ${version} | ${sed_location} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
echo ${version} | ./${relative_sed_location} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'

IFS="."
echo ${version} | ${sed_location} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
echo ${version} | ${relative_executable_sed} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'

echo "${relative_executable_sed}"
echo ${relative_executable_sed}

echo ${version} | "${executable_sed}" 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
echo ${version} | "${relative_executable_sed}" 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'


$ ./tmp.sh
/usr/bin/sed
../../usr/bin/sed
./../../usr/bin/sed
./tmp.sh: Zeile 12: s/\([[0-9\.]]*\)\(.*\)/\1\.\2/: Datei oder Verzeichnis nicht gefunden
7..4.0RC5
./tmp.sh: Zeile 16: s/\([[0-9\.]]*\)\(.*\)/\1\.\2/: Datei oder Verzeichnis nicht gefunden
./tmp.sh: Zeile 17: : Kommando nicht gefunden.
./../../usr/bin/sed
 /  /  /usr/bin/sed
7. 4 0RC5
7. 4 0RC5
version=7.4.0RC5

echo ${version} | ${sed_location} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
echo ${version} | ./${relative_sed_location} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'

IFS="."
echo ${version} | ${sed_location} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
echo ${version} | ${relative_executable_sed} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'

echo "${relative_executable_sed}"
echo ${relative_executable_sed}

echo ${version} | "${executable_sed}" 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
echo ${version} | "${relative_executable_sed}" 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
 [2019-11-06 17:11 UTC] max at swk-web dot com
Sorry I messed up the console output and sent the wrong output -.-

Here is the corrected one:
$ cat tmp.sh
#!/bin/bash

executable_sed=$(which sed)
relative_sed_location=$(realpath --relative-to="." "${executable_sed}")
relative_executable_sed=./${relative_sed_location}
echo ${executable_sed}
echo ${relative_sed_location}
echo ${relative_executable_sed}

version=7.4.0RC5

echo ${version} | ${executable_sed} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
echo ${version} | ./${relative_sed_location} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'

IFS="."
echo ${version} | ${executable_sed} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
echo ${version} | ${relative_executable_sed} 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'

echo "${relative_executable_sed}"
echo ${relative_executable_sed}

echo ${version} | "${executable_sed}" 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'
echo ${version} | "${relative_executable_sed}" 's/\([[0-9\.]]*\)\(.*\)/\1\.\2/'


$ ./tmp.sh  
/usr/bin/sed
../../usr/bin/sed
./../../usr/bin/sed
7..4.0RC5
7..4.0RC5
7. 4 0RC5
./tmp.sh: Zeile 17: : Kommando nicht gefunden.
./../../usr/bin/sed
 /  /  /usr/bin/sed
7. 4 0RC5
7. 4 0RC5
 [2019-11-07 07:15 UTC] max at swk-web dot com
The following pull request has been associated:

Patch Name: Escaping of $SED in the autotools configure script
On GitHub:  https://github.com/php/php-src/pull/4891
Patch:      https://github.com/php/php-src/pull/4891.patch
 [2019-11-07 09:02 UTC] cmb@php.net
Automatic comment on behalf of max@swk-web.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0988f6963420ab26b7804e080380b813ca79cfa8
Log: Fix #78788: ./configure generates invalid php_version.h
 [2019-11-07 09:02 UTC] cmb@php.net
-Status: Open +Status: Closed
 [2019-11-07 09:02 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC