Skip to content

Commit

Permalink
Use runtime version 2023.1 by default, extend download runtime script
Browse files Browse the repository at this point in the history
  • Loading branch information
vishniakov-nikolai committed Sep 18, 2023
1 parent 95a2397 commit 87d48e4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/bindings/js/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
},
"gypfile": true,
"binary": {
"version": "2023.1.0.dev20230811",
"version": "2023.1.0.12185.47b736f63ed",
"module_path": "./ov_runtime/",
"package_name": "{letter}_openvino_toolkit_{os}_{version}_{arch}.{extension}",
"host": "https://storage.openvinotoolkit.org/",
"remote_path": "repositories/openvino/packages/master/2023.1.0.dev20230811/"
"remote_path": "repositories/openvino/packages/2023.1/"
}
}
80 changes: 55 additions & 25 deletions src/bindings/js/node/scripts/download_runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function main() {
packageName = packageName.replace('{version}', packageJson.binary.version);

const binaryUrl = packageJson.binary.host + packageJson.binary['remote_path']
+ packageName;
+ `${osInfo.dir}/` + packageName;

try {
await fetchRuntime(binaryUrl);
Expand All @@ -57,59 +57,89 @@ async function main() {
async function detectOS() {
const platform = os.platform();

if (!['win32', 'linux'].includes(platform)) {
if (!['win32', 'linux', 'darwin'].includes(platform)) {
console.error(`Platform '${platform}' doesn't support`);
process.exit(1);
}

const platformMapping = {
win32: {
os: 'windows',
dir: 'windows',
letter: 'w',
extension: 'zip',
},
linux: {
letter: 'l',
dir: 'linux',
extension: 'tgz',
}
},
darwin: {
letter: 'm',
dir: 'macos',
extension: 'tgz',
},
};

const arch = os.arch();

if (!['arm64', 'x64'].includes(arch)) {
if (!['arm64', 'armhf', 'x64'].includes(arch)) {
console.error(`Architecture '${arch}' doesn't support`);
process.exit(1);
}

const archMapping = {
arm64: 'arm64',
armhf: 'armhf',
x64: 'x86_64',
};

platformMapping.arch = archMapping[arch];

if (platform === 'linux') {
const osReleaseData = await fs.readFile('/etc/os-release', 'utf8');
const os = osReleaseData.includes('Ubuntu 22')
? 'ubuntu22'
: osReleaseData.includes('Ubuntu 20')
? 'ubuntu20'
: osReleaseData.includes('Ubuntu 18')
? 'ubuntu18'
: ['arm64', 'armhf'].includes(platformMapping.arch)
&& osReleaseData.includes('ID=debian')
? 'debian9'
: null;

if (!os) {
console.error('Cannot detect your OS');
process.exit(1);
}
let osVersion = null;
switch(platform) {
case 'linux':
const osReleaseData = await fs.readFile('/etc/os-release', 'utf8');

osVersion = osReleaseData.includes('Ubuntu 22')
? 'ubuntu22'
: osReleaseData.includes('Ubuntu 20')
? 'ubuntu20'
: osReleaseData.includes('Ubuntu 18')
? 'ubuntu18'
: ['arm64', 'armhf'].includes(arch)
&& osReleaseData.includes('ID=debian')
? 'debian9'
: null;

break;

case 'darwin':
const [major, minor] = os.release().split('.');

platformMapping.linux.os = os;
osVersion = (major === 10 && minor >= 15)
? 'macos_10_15'
: major === 11
? 'macos_11_0'
: null;

break;

case 'win32':
osVersion = true;

break;
}

return { platform, arch: archMapping[arch], ...platformMapping[platform] };
if (!osVersion) {
console.error('Cannot detect your OS');
process.exit(1);
}

return {
platform,
os: osVersion,
arch: archMapping[arch],
...platformMapping[platform]
};
}

async function checkDirExistence(pathToDir) {
Expand Down

0 comments on commit 87d48e4

Please sign in to comment.