cc74d7
From 5ec93aff2ad01f269669a12f45aeb8abaa853062 Mon Sep 17 00:00:00 2001
cc74d7
From: Remi Collet <remi@remirepo.net>
cc74d7
Date: Fri, 19 Jul 2019 10:33:01 +0200
cc74d7
Subject: [PATCH] handle "lib64" case for glibc detection
cc74d7
cc74d7
Also move the "simple" way first
cc74d7
to avoid file parsing or shell call
cc74d7
cc74d7
Notice: it seems that this information if not really used anywhere
cc74d7
and I'm not aware of any pear/pecl package with constraint on glibc version
cc74d7
---
cc74d7
 OS/Guess.php | 22 ++++++++++++++--------
cc74d7
 1 file changed, 14 insertions(+), 8 deletions(-)
cc74d7
cc74d7
diff --git a/OS/Guess.php b/OS/Guess.php
cc74d7
index c45e84f15..79d5cfe36 100644
cc74d7
--- a/OS/Guess.php
cc74d7
+++ b/OS/Guess.php
cc74d7
@@ -195,9 +195,22 @@ function _detectGlibcVersion()
cc74d7
         }
cc74d7
         $major = $minor = 0;
cc74d7
         include_once "System.php";
cc74d7
+
cc74d7
+        if (@is_link('/lib64/libc.so.6')) {
cc74d7
+            // Let's try reading the libc.so.6 symlink
cc74d7
+            if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib64/libc.so.6')), $matches)) {
cc74d7
+                list($major, $minor) = explode('.', $matches[1]);
cc74d7
+            }
cc74d7
+        } else if (@is_link('/lib/libc.so.6')) {
cc74d7
+            // Let's try reading the libc.so.6 symlink
cc74d7
+            if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
cc74d7
+                list($major, $minor) = explode('.', $matches[1]);
cc74d7
+            }
cc74d7
+        }
cc74d7
         // Use glibc's <features.h> header file to
cc74d7
         // get major and minor version number:
cc74d7
-        if (@file_exists('/usr/include/features.h') &&
cc74d7
+        if (!($major && $minor) &&
cc74d7
+              @file_exists('/usr/include/features.h') &&
cc74d7
               @is_readable('/usr/include/features.h')) {
cc74d7
             if (!@file_exists('/usr/bin/cpp') || !@is_executable('/usr/bin/cpp')) {
cc74d7
                 $features_file = fopen('/usr/include/features.h', 'rb');
cc74d7
@@ -252,13 +265,6 @@ function _detectGlibcVersion()
cc74d7
             unlink($tmpfile);
cc74d7
         } // features.h
cc74d7
 
cc74d7
-        if (!($major && $minor) && @is_link('/lib/libc.so.6')) {
cc74d7
-            // Let's try reading the libc.so.6 symlink
cc74d7
-            if (preg_match('/^libc-(.*)\.so$/', basename(readlink('/lib/libc.so.6')), $matches)) {
cc74d7
-                list($major, $minor) = explode('.', $matches[1]);
cc74d7
-            }
cc74d7
-        }
cc74d7
-
cc74d7
         if (!($major && $minor)) {
cc74d7
             return $glibc = '';
cc74d7
         }