Skip to content

Commit

Permalink
changes for v1.10.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ashnazg committed Nov 19, 2019
1 parent 742be8d commit 625a3c4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
24 changes: 15 additions & 9 deletions src/OS/Guess.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,22 @@ function _detectGlibcVersion()
}
$major = $minor = 0;
include_once "System.php";

if (@is_link('/lib64/libc.so.6')) {
// Let's try reading the libc.so.6 symlink
if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib64/libc.so.6')), $matches)) {
list($major, $minor) = explode('.', $matches[1]);
}
} else if (@is_link('/lib/libc.so.6')) {
// Let's try reading the libc.so.6 symlink
if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
list($major, $minor) = explode('.', $matches[1]);
}
}
// Use glibc's <features.h> header file to
// get major and minor version number:
if (@file_exists('/usr/include/features.h') &&
if (!($major && $minor) &&
@file_exists('/usr/include/features.h') &&
@is_readable('/usr/include/features.h')) {
if (!@file_exists('/usr/bin/cpp') || !@is_executable('/usr/bin/cpp')) {
$features_file = fopen('/usr/include/features.h', 'rb');
Expand Down Expand Up @@ -240,7 +253,7 @@ function _detectGlibcVersion()
fclose($fp);
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
while ($line = fgets($cpp, 1024)) {
if ($line{0} == '#' || trim($line) == '') {
if ($line[0] == '#' || trim($line) == '') {
continue;
}

Expand All @@ -252,13 +265,6 @@ function _detectGlibcVersion()
unlink($tmpfile);
} // features.h

if (!($major && $minor) && @is_link('/lib/libc.so.6')) {
// Let's try reading the libc.so.6 symlink
if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
list($major, $minor) = explode('.', $matches[1]);
}
}

if (!($major && $minor)) {
return $glibc = '';
}
Expand Down
22 changes: 22 additions & 0 deletions src/PEAR.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,28 @@ function_exists('dl') === false ||

return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
}

/**
* Get SOURCE_DATE_EPOCH environment variable
* See https://reproducible-builds.org/specs/source-date-epoch/
*
* @return int
* @access public
*/
static function getSourceDateEpoch()
{
if ($source_date_epoch = getenv('SOURCE_DATE_EPOCH')) {
if (preg_match('/^\d+$/', $source_date_epoch)) {
return (int) $source_date_epoch;
} else {
// "If the value is malformed, the build process SHOULD exit with a non-zero error code."
self::raiseError("Invalid SOURCE_DATE_EPOCH: $source_date_epoch");
exit(1);
}
} else {
return time();
}
}
}

function _PEAR_call_destructors()
Expand Down
6 changes: 3 additions & 3 deletions src/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function _parseArgs($argv, $short_options, $long_options = null)
$offset = 0;
foreach ($av as $a) {
$b = trim($a[0]);
if ($b{0} == '"' || $b{0} == "'") {
if ($b[0] == '"' || $b[0] == "'") {
continue;
}
Expand Down Expand Up @@ -265,7 +265,7 @@ public static function mkDir($args)
} elseif ($opt[0] == 'm') {
// if the mode is clearly an octal number (starts with 0)
// convert it to decimal
if (strlen($opt[1]) && $opt[1]{0} == '0') {
if (strlen($opt[1]) && $opt[1][0] == '0') {
$opt[1] = octdec($opt[1]);
} else {
// convert to int
Expand Down Expand Up @@ -480,7 +480,7 @@ public static function tmpdir()
if ($var = isset($_ENV['TMPDIR']) ? $_ENV['TMPDIR'] : getenv('TMPDIR')) {
return $var;
}
return realpath('/tmp');
return realpath(function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : '/tmp');
}

/**
Expand Down

0 comments on commit 625a3c4

Please sign in to comment.