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