@@ -261,8 +261,8 @@ function get_distname() {
261261 $ distbaseid = 'opensuse ' ;
262262 } elseif (stristr (file_get_contents ('/etc/os-release ' ), 'opensuse ' )) {
263263 $ content = file_get_contents ('/etc/os-release ' );
264- preg_match_all ('/NAME=\"([\w ]+)\"/m ' , $ content , $ name );
265- preg_match_all ('/VERSION_ID=\"([0-9]{1,2})\.?([0-9]{0,2})\.?([0-9]*).$/m ' , $ content , $ version );
264+ preg_match_all ('/NAME=\"([\w ]+)\"/m ' , $ content , $ name );
265+ preg_match_all ('/VERSION_ID=\"([0-9]{1,2})\.?([0-9]{0,2})\.?([0-9]*).$/m ' , $ content , $ version );
266266 $ distname = is_array ($ name ) ? $ name [1 ][0 ] : 'openSUSE ' ;
267267 $ distver = is_array ($ version ) ? implode ('. ' , array_filter (array ($ version [1 ][0 ],$ version [2 ][0 ],$ version [3 ][0 ]),'strlen ' )) : 'Unknown ' ;
268268 $ distid = 'opensuse112 ' ;
@@ -276,84 +276,81 @@ function get_distname() {
276276 }
277277
278278
279- //** Redhat
280- elseif (file_exists ('/etc/redhat-release ' )) {
279+ //** RHEL (including compatible clones) & Fedora
280+ elseif (file_exists ('/etc/redhat-release ' ) && file_exists ( ' /etc/os-release ' ) ) {
281281
282- $ content = file_get_contents ('/etc/redhat -release ' );
282+ $ content = file_get_contents ('/etc/os -release ' );
283283
284- if (stristr ($ content , 'Fedora release 9 (Sulphur) ' )) {
285- $ distname = 'Fedora ' ;
286- $ distver = '9 ' ;
287- $ distid = 'fedora9 ' ;
288- $ distbaseid = 'fedora ' ;
289- } elseif (stristr ($ content , 'Fedora release 10 (Cambridge) ' )) {
290- $ distname = 'Fedora ' ;
291- $ distver = '10 ' ;
292- $ distid = 'fedora9 ' ;
293- $ distbaseid = 'fedora ' ;
294- } elseif (stristr ($ content , 'Fedora release 10 ' )) {
295- $ distname = 'Fedora ' ;
296- $ distver = '11 ' ;
297- $ distid = 'fedora9 ' ;
298- $ distbaseid = 'fedora ' ;
299- } elseif (stristr ($ content , 'Fedora release 32 (Thirty Two) ' )) {
284+ preg_match ('/(?<=PRETTY_NAME=\").+?(?=\")/ ' , $ content , $ prettyname );
285+ preg_match ('/(?<=NAME=\").+?(?=\")/ ' , $ content , $ name );
286+ preg_match ('/(?<=VERSION=\").+?(?=\")/ ' , $ content , $ version );
287+ preg_match ('/(?<=VERSION_ID=\").+?(?=\")/ ' , $ content , $ versionid );
288+
289+ if (stristr ($ prettyname [0 ], 'Fedora 32 (Thirty Two) ' )) {
300290 $ distname = 'Fedora ' ;
301291 $ distver = '32 ' ;
302292 $ distid = 'fedora32 ' ;
303293 $ distbaseid = 'fedora ' ;
304- } elseif (stristr ($ content , 'Fedora release 33 (Thirty Three) ' )) {
294+ } elseif (stristr ($ prettyname [ 0 ] , 'Fedora 33 (Thirty Three) ' )) {
305295 $ distname = 'Fedora ' ;
306296 $ distver = '33 ' ;
307297 $ distid = 'fedora33 ' ;
308298 $ distbaseid = 'fedora ' ;
309- } elseif (stristr ($ content , 'CentOS release 5.2 (Final) ' )) {
310- $ distname = 'CentOS ' ;
311- $ distver = '5.2 ' ;
312- $ distid = 'centos52 ' ;
299+ //** RHEL 7 and compatible clones
300+ } elseif (preg_match ('/^(?:7|7\.[0-9]{1,2})$/ ' , $ versionid [0 ])) {
301+ preg_match_all ('/([0-9]{1,2})\.?([0-9]{0,2})\.?([0-9]*)/ ' , file_get_contents ('/etc/redhat-release ' ), $ centos7_version );
302+ $ distname = $ name [0 ];
303+ $ distver = is_array ($ centos7_version )? implode ('. ' , array_filter (array ($ centos7_version [1 ][0 ],$ centos7_version [2 ][0 ],$ centos7_version [3 ][0 ]),'strlen ' )) : $ version [0 ];
304+ $ distid = 'centos72 ' ;
313305 $ distbaseid = 'fedora ' ;
314- } elseif (stristr ($ content , 'CentOS release 5.3 (Final) ' )) {
315- $ distname = 'CentOS ' ;
316- $ distver = '5.3 ' ;
317- $ distid = 'centos53 ' ;
306+ //** RHEL 8 and compatible clones
307+ } elseif (preg_match ('/^(?:8|8\.[0-9]{1,2})$/ ' , $ versionid [0 ])) {
308+ $ distname = $ name [0 ];
309+ $ distver = $ version [0 ];
310+ $ distid = 'centos80 ' ;
318311 $ distbaseid = 'fedora ' ;
319- } elseif (stristr ($ content , 'CentOS release 5 ' )) {
320- $ distname = 'CentOS ' ;
321- $ distver = 'Unknown ' ;
322- $ distid = 'centos53 ' ;
323- $ distbaseid = 'fedora ' ;
324- } elseif (stristr ($ content , 'CentOS Linux release 6 ' ) || stristr ($ content , 'CentOS release 6 ' )) {
325- $ distname = 'CentOS ' ;
326- $ distver = 'Unknown ' ;
327- $ distid = 'centos53 ' ;
328- $ distbaseid = 'fedora ' ;
329- } elseif (stristr ($ content , 'CentOS Linux release 7 ' )) {
330- preg_match_all ('/([0-9]{1,2})\.?([0-9]{0,2})\.?([0-9]*)/ ' , $ content , $ version );
331- $ distname = 'CentOS ' ;
332- $ distver = is_array ($ version )? implode ('. ' , array_filter (array ($ version [1 ][0 ],$ version [2 ][0 ],$ version [3 ][0 ]),'strlen ' )) :'Unknown ' ;
333- $ distbaseid = 'fedora ' ;
334- $ var =explode (" " , $ content );
335- $ var =explode (". " , $ var [3 ]);
336- $ var =$ var [0 ].". " .$ var [1 ];
337- if ($ var =='7.0 ' || $ var =='7.1 ' ) {
338- $ distid = 'centos70 ' ;
339- } else {
340- $ distid = 'centos72 ' ;
341- }
342- } elseif (stristr ($ content , 'CentOS Linux release 8 ' )) {
343- preg_match_all ('/([0-9]{1,2})\.?([0-9]{0,2})\.?([0-9]*)/ ' , $ content , $ version );
344- $ distname = 'CentOS ' ;
345- $ distver = is_array ($ version )? implode ('. ' , array_filter (array ($ version [1 ][0 ],$ version [2 ][0 ],$ version [3 ][0 ]),'strlen ' )) :'Unknown ' ;
346- $ distbaseid = 'fedora ' ;
347- $ var =explode (" " , $ content );
348- $ var =explode (". " , $ var [3 ]);
349- $ var =$ var [0 ].". " .$ var [1 ];
350312 } else {
351313 $ distname = 'Redhat ' ;
352314 $ distver = 'Unknown ' ;
353315 $ distid = 'fedora9 ' ;
354316 $ distbaseid = 'fedora ' ;
355317 }
356- }
318+ //** CentOS 6
319+ } elseif (file_exists ('/etc/redhat-release ' ) && !file_exists ('/etc/os-release ' ) && !file_exists ('/etc/els-release ' )) {
320+
321+ $ content = file_get_contents ('/etc/redhat-release ' );
322+
323+ if (stristr ($ content , 'CentOS Linux release 6 ' ) || stristr ($ content , 'CentOS release 6 ' )) {
324+ preg_match_all ('/(6\.?([0-9]{0,2})\.?(\s)?([a-zA-Z()]+))$/ ' , $ content , $ centos6_version );
325+ $ distname = 'CentOS Linux ' ;
326+ $ distver = $ centos6_version [0 ][0 ] ? $ centos6_version [0 ][0 ] : '6 ' ;
327+ $ distid = 'centos53 ' ;
328+ $ distbaseid = 'fedora ' ;
329+ } else {
330+ $ distname = 'Redhat ' ;
331+ $ distver = 'Unknown ' ;
332+ $ distid = 'fedora9 ' ;
333+ $ distbaseid = 'fedora ' ;
334+ }
335+ //** CentOS 6 Extended Lifecycle Support by CloudLinux
336+ } elseif (file_exists ('/etc/redhat-release ' ) && file_exists ('/etc/els-release ' ) && !file_exists ('/etc/os-release ' )) {
337+
338+ $ content = file_get_contents ('/etc/els-release ' );
339+
340+ if (stristr ($ content , 'CentOS Linux release 6 ' ) || stristr ($ content , 'CentOS release 6 ' )) {
341+ preg_match_all ('/(6)\.?([0-9]{0,2})?\.?\s([a-zA-Z(), ]+)?$/ ' , $ content , $ centos6_version );
342+ $ distname = 'CentOS Linux ' ;
343+ $ distver = $ centos6_version [0 ][0 ] ? $ centos6_version [0 ][0 ] : '6 ' ;
344+ $ distid = 'centos53 ' ;
345+ $ distbaseid = 'fedora ' ;
346+ } else {
347+ $ distname = 'Redhat ' ;
348+ $ distver = 'Unknown ' ;
349+ $ distid = 'fedora9 ' ;
350+ $ distbaseid = 'fedora ' ;
351+ }
352+ }
353+
357354
358355 //** Gentoo
359356 elseif (file_exists ('/etc/gentoo-release ' )) {
0 commit comments