mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-21 06:33:28 +00:00
Convert qemu.js to typescript
Change-type: patch
This commit is contained in:
parent
4f6550e7eb
commit
52bece7f17
@ -20,16 +20,16 @@ import { getBalenaSdk } from './lazy';
|
|||||||
export const QEMU_VERSION = 'v4.0.0+balena2';
|
export const QEMU_VERSION = 'v4.0.0+balena2';
|
||||||
export const QEMU_BIN_NAME = 'qemu-execve';
|
export const QEMU_BIN_NAME = 'qemu-execve';
|
||||||
|
|
||||||
export function qemuPathInContext(context) {
|
export function qemuPathInContext(context: string) {
|
||||||
const path = require('path');
|
const path = require('path') as typeof import('path');
|
||||||
const binDir = path.join(context, '.balena');
|
const binDir = path.join(context, '.balena');
|
||||||
const binPath = path.join(binDir, QEMU_BIN_NAME);
|
const binPath = path.join(binDir, QEMU_BIN_NAME);
|
||||||
return path.relative(context, binPath);
|
return path.relative(context, binPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function copyQemu(context, arch) {
|
export function copyQemu(context: string, arch: string) {
|
||||||
const path = require('path');
|
const path = require('path') as typeof import('path');
|
||||||
const fs = require('mz/fs');
|
const fs = require('mz/fs') as typeof import('mz/fs');
|
||||||
// Create a hidden directory in the build context, containing qemu
|
// Create a hidden directory in the build context, containing qemu
|
||||||
const binDir = path.join(context, '.balena');
|
const binDir = path.join(context, '.balena');
|
||||||
const binPath = path.join(binDir, QEMU_BIN_NAME);
|
const binPath = path.join(binDir, QEMU_BIN_NAME);
|
||||||
@ -56,10 +56,10 @@ export function copyQemu(context, arch) {
|
|||||||
.then(() => path.relative(context, binPath));
|
.then(() => path.relative(context, binPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getQemuPath = function(arch) {
|
export const getQemuPath = function(arch: string) {
|
||||||
const balena = getBalenaSdk();
|
const balena = getBalenaSdk();
|
||||||
const path = require('path');
|
const path = require('path') as typeof import('path');
|
||||||
const fs = require('mz/fs');
|
const fs = require('mz/fs') as typeof import('mz/fs');
|
||||||
|
|
||||||
return balena.settings.get('binDirectory').then(binDir =>
|
return balena.settings.get('binDirectory').then(binDir =>
|
||||||
Promise.resolve(fs.mkdir(binDir))
|
Promise.resolve(fs.mkdir(binDir))
|
||||||
@ -72,11 +72,11 @@ export const getQemuPath = function(arch) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export function installQemu(arch) {
|
export function installQemu(arch: string) {
|
||||||
const request = require('request');
|
const request = require('request') as typeof import('request');
|
||||||
const fs = require('fs');
|
const fs = require('fs') as typeof import('fs');
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib') as typeof import('zlib');
|
||||||
const tar = require('tar-stream');
|
const tar = require('tar-stream') as typeof import('tar-stream');
|
||||||
|
|
||||||
return getQemuPath(arch).then(
|
return getQemuPath(arch).then(
|
||||||
qemuPath =>
|
qemuPath =>
|
||||||
@ -115,7 +115,7 @@ export function installQemu(arch) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var balenaArchToQemuArch = function(arch) {
|
const balenaArchToQemuArch = function(arch: string) {
|
||||||
switch (arch) {
|
switch (arch) {
|
||||||
case 'armv7hf':
|
case 'armv7hf':
|
||||||
case 'rpi':
|
case 'rpi':
|
Loading…
Reference in New Issue
Block a user