From 9b0aeeffae58802e3bd51bf98617e43f0712974c Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Thu, 13 May 2021 20:13:11 -0700 Subject: [PATCH] fix(install-deps): install deps on mint (#6569) --- src/utils/ubuntuVersion.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/utils/ubuntuVersion.ts b/src/utils/ubuntuVersion.ts index 4220f314cb..0c1e580920 100644 --- a/src/utils/ubuntuVersion.ts +++ b/src/utils/ubuntuVersion.ts @@ -24,7 +24,9 @@ const readFileAsync = util.promisify(fs.readFile.bind(fs)); export async function getUbuntuVersion(): Promise { if (os.platform() !== 'linux') return ''; - const osReleaseText = await readFileAsync('/etc/os-release', 'utf8').catch(e => ''); + let osReleaseText = await readFileAsync('/etc/upstream-release/lsb-release', 'utf8').catch(e => ''); + if (!osReleaseText) + osReleaseText = await readFileAsync('/etc/os-release', 'utf8').catch(e => ''); if (!osReleaseText) return ''; return getUbuntuVersionInternal(osReleaseText); @@ -34,7 +36,11 @@ export function getUbuntuVersionSync(): string { if (os.platform() !== 'linux') return ''; try { - const osReleaseText = fs.readFileSync('/etc/os-release', 'utf8'); + let osReleaseText: string; + if (fs.existsSync('/etc/upstream-release/lsb-release')) + osReleaseText = fs.readFileSync('/etc/upstream-release/lsb-release', 'utf8'); + else + osReleaseText = fs.readFileSync('/etc/os-release', 'utf8'); if (!osReleaseText) return ''; return getUbuntuVersionInternal(osReleaseText); @@ -55,6 +61,10 @@ function getUbuntuVersionInternal(osReleaseText: string): string { continue; fields.set(name.toLowerCase(), value); } + // For Linux mint + if (fields.get('distrib_id') && fields.get('distrib_id').toLowerCase() === 'ubuntu') + return fields.get('distrib_release') || ''; + if (!fields.get('name') || fields.get('name').toLowerCase() !== 'ubuntu') return ''; return fields.get('version_id') || '';