signal-desktop/ts/updater/linux.ts

34 lines
779 B
TypeScript
Raw Normal View History

2023-01-18 23:31:10 +00:00
// Copyright 2023 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { version as osVersion } from 'os';
import type { LoggerType } from '../types/Logging';
2023-05-11 19:22:15 +00:00
const MIN_UBUNTU_VERSION = '20.04';
2023-01-18 23:31:10 +00:00
export function getUbuntuVersion(): string | undefined {
if (process.platform !== 'linux') {
return undefined;
}
const match = osVersion().match(/^#\d+~([\d.]+)-Ubuntu\s/);
if (!match) {
return undefined;
}
return match[1];
}
export function isLinuxVersionSupported(logger?: LoggerType): boolean {
const ubuntu = getUbuntuVersion();
if (ubuntu !== undefined && ubuntu < MIN_UBUNTU_VERSION) {
logger?.warn(
`updater/isLinuxVersionSupported: unsupported Ubuntu version ${ubuntu}`
);
return false;
}
return true;
}