@@ -13,8 +13,11 @@ export enum SupportedPlatform {
1313 OSX ,
1414 CentOS ,
1515 Debian ,
16+ Fedora ,
17+ OpenSUSE ,
1618 RHEL ,
17- Ubuntu
19+ Ubuntu14 ,
20+ Ubuntu16
1821}
1922
2023export function getSupportedPlatform ( ) {
@@ -25,24 +28,57 @@ export function getSupportedPlatform() {
2528 return SupportedPlatform . OSX ;
2629 }
2730 else if ( process . platform === 'linux' ) {
28- // Get the text of /etc/*-release to discover which Linux distribution we're running on.
29- let release = child_process . execSync ( 'cat /etc/os-release' ) . toString ( ) . toLowerCase ( ) ;
31+ // Get the text of /etc/os-release to discover which Linux distribution we're running on.
32+ // For details: https://www.freedesktop.org/software/systemd/man/os-release.html
33+ const text = child_process . execSync ( 'cat /etc/os-release' ) . toString ( ) ;
34+ const lines = text . split ( '\n' ) ;
3035
31- if ( release . indexOf ( 'ubuntu' ) >= 0 ) {
32- return SupportedPlatform . Ubuntu ;
33- }
34- else if ( release . indexOf ( 'centos' ) >= 0 ) {
35- return SupportedPlatform . CentOS ;
36- }
37- else if ( release . indexOf ( 'rhel' ) >= 0 ) {
38- return SupportedPlatform . RHEL ;
39- }
40- else if ( release . indexOf ( 'debian' ) >= 0 ) {
41- return SupportedPlatform . Debian ;
36+ function getValue ( name : string ) {
37+ for ( let line of lines ) {
38+ if ( line . startsWith ( name ) ) {
39+ const equalsIndex = line . indexOf ( '=' ) ;
40+ if ( equalsIndex >= 0 ) {
41+ let value = line . substring ( equalsIndex + 1 ) ;
42+
43+ // Strip double quotes if necessary
44+ if ( value . length > 1 && value . startsWith ( '"' ) && value . endsWith ( '"' ) ) {
45+ value = value . substring ( 1 , value . length - 2 ) ;
46+ }
47+
48+ return value ;
49+ }
50+ }
51+ }
52+
53+ return undefined ;
4254 }
43- else if ( release . indexOf ( 'oracle' ) >= 0 ) {
44- // Oracle Linux is binary compatible with CentOS
45- return SupportedPlatform . CentOS ;
55+
56+ const id = getValue ( "ID" ) ;
57+
58+ switch ( id )
59+ {
60+ case 'ubuntu' :
61+ const versionId = getValue ( "VERSION_ID" ) ;
62+ if ( versionId . startsWith ( "14" ) ) {
63+ // This also works for Linux Mint
64+ return SupportedPlatform . Ubuntu14 ;
65+ }
66+ else if ( versionId . startsWith ( "16" ) ) {
67+ return SupportedPlatform . Ubuntu16 ;
68+ }
69+ case 'centos' :
70+ return SupportedPlatform . CentOS ;
71+ case 'fedora' :
72+ return SupportedPlatform . Fedora ;
73+ case 'opensuse' :
74+ return SupportedPlatform . OpenSUSE ;
75+ case 'rehl' :
76+ return SupportedPlatform . RHEL ;
77+ case 'debian' :
78+ return SupportedPlatform . Debian ;
79+ case 'ol' :
80+ // Oracle Linux is binary compatible with CentOS
81+ return SupportedPlatform . CentOS ;
4682 }
4783 }
4884
0 commit comments