mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-22 19:06:09 +08:00
docker(install): check qemu is installed
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
05607289aa
commit
1362d80447
@ -279,9 +279,14 @@ export class Install {
|
|||||||
core.info(limaCfg);
|
core.info(limaCfg);
|
||||||
});
|
});
|
||||||
|
|
||||||
const qemuArch = await Install.qemuArch();
|
if (!(await Install.qemuInstalled())) {
|
||||||
|
await core.group('Installing QEMU', async () => {
|
||||||
|
await Exec.exec('brew', ['install', 'qemu'], {env: envs});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const qemuBin = await Install.qemuBin();
|
||||||
await core.group('QEMU version', async () => {
|
await core.group('QEMU version', async () => {
|
||||||
await Exec.exec(`qemu-system-${qemuArch} --version`);
|
await Exec.exec(qemuBin, ['--version']);
|
||||||
});
|
});
|
||||||
|
|
||||||
// lima might already be started on the runner so env var added in download
|
// lima might already be started on the runner so env var added in download
|
||||||
@ -617,29 +622,42 @@ EOF`,
|
|||||||
return await io
|
return await io
|
||||||
.which('lima', true)
|
.which('lima', true)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
core.debug(`docker.Install.limaAvailable ok: ${res}`);
|
core.debug(`docker.Install.limaInstalled ok: ${res}`);
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
core.debug(`docker.Install.limaAvailable error: ${error}`);
|
core.debug(`docker.Install.limaInstalled error: ${error}`);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async qemuArch(): Promise<string> {
|
private static async qemuBin(): Promise<string> {
|
||||||
switch (os.arch()) {
|
switch (os.arch()) {
|
||||||
case 'x64': {
|
case 'x64': {
|
||||||
return 'x86_64';
|
return `qemu-system-x86_64`;
|
||||||
}
|
}
|
||||||
case 'arm64': {
|
case 'arm64': {
|
||||||
return 'aarch64';
|
return `qemu-system-aarch64`;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return os.arch();
|
return `qemu-system-${os.arch()}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async qemuInstalled(): Promise<boolean> {
|
||||||
|
return await io
|
||||||
|
.which(await Install.qemuBin(), true)
|
||||||
|
.then(res => {
|
||||||
|
core.debug(`docker.Install.qemuInstalled ok: ${res}`);
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
core.debug(`docker.Install.qemuInstalled error: ${error}`);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static async getRelease(version: string): Promise<GitHubRelease> {
|
public static async getRelease(version: string): Promise<GitHubRelease> {
|
||||||
const url = `https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json`;
|
const url = `https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/docker-releases.json`;
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
|
const http: httpm.HttpClient = new httpm.HttpClient('docker-actions-toolkit');
|
||||||
|
Loading…
Reference in New Issue
Block a user