Skip to content

Commit 734b81f

Browse files
Merge pull request #500 from DustinCampbell/update-linux-distros
Update linux distros for OmniSharp
2 parents d381c25 + 524397b commit 734b81f

File tree

2 files changed

+62
-20
lines changed

2 files changed

+62
-20
lines changed

src/omnisharpDownload.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const decompress = require('decompress');
1818

1919
const BaseDownloadUrl = 'https://omnisharpdownload.blob.core.windows.net/ext';
2020
const DefaultInstallLocation = path.join(__dirname, '../.omnisharp');
21-
export const OmniSharpVersion = '1.9-beta10';
21+
export const OmniSharpVersion = '1.9-beta11';
2222

2323
tmp.setGracefulCleanup();
2424

@@ -32,10 +32,16 @@ export function getOmnisharpAssetName(): string {
3232
return `omnisharp-${OmniSharpVersion}-centos-x64-netcoreapp1.0.tar.gz`;
3333
case SupportedPlatform.Debian:
3434
return `omnisharp-${OmniSharpVersion}-debian-x64-netcoreapp1.0.tar.gz`;
35+
case SupportedPlatform.Fedora:
36+
return `omnisharp-${OmniSharpVersion}-fedora-x64-netcoreapp1.0.tar.gz`;
37+
case SupportedPlatform.OpenSUSE:
38+
return `omnisharp-${OmniSharpVersion}-opensuse-x64-netcoreapp1.0.tar.gz`;
3539
case SupportedPlatform.RHEL:
3640
return `omnisharp-${OmniSharpVersion}-rhel-x64-netcoreapp1.0.tar.gz`;
37-
case SupportedPlatform.Ubuntu:
38-
return `omnisharp-${OmniSharpVersion}-ubuntu-x64-netcoreapp1.0.tar.gz`;
41+
case SupportedPlatform.Ubuntu14:
42+
return `omnisharp-${OmniSharpVersion}-ubuntu14-x64-netcoreapp1.0.tar.gz`;
43+
case SupportedPlatform.Ubuntu16:
44+
return `omnisharp-${OmniSharpVersion}-ubuntu16-x64-netcoreapp1.0.tar.gz`;
3945

4046
default:
4147
if (process.platform === 'linux') {

src/utils.ts

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2023
export 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

Comments
 (0)