Repository navigation
Expand file tree
/
Copy pathskopeo.ts
More file actions
57 lines (49 loc) · 1.86 KB
/
Copy pathskopeo.ts
File metadata and controls
57 lines (49 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { join } from 'node:path';
import { injectFromHierarchy, injectable } from 'inversify';
import { BaseInstallService } from '../install-tool/base-install.service.ts';
@injectable()
@injectFromHierarchy()
export class SkopeoInstallService extends BaseInstallService {
readonly name = 'skopeo';
/** Older prebuilds exist for focal only. */
override readonly minVersion = '1.14.0';
/** The architecture name used by the skopeo prebuilds. */
private get ghArch(): string {
switch (this.envSvc.arch) {
case 'arm64':
return 'aarch64';
case 'amd64':
return 'x86_64';
}
}
/**
* Downloads the containerbase skopeo prebuild, verified against its
* `.sha512`, and extracts it into the tool path.
*/
override async install(version: string): Promise<void> {
const name = this.name;
const filename = `${name}-${version}-${this.ghArch}.tar.xz`;
const url = `https://github.com/containerbase/${name}-prebuild/releases/download/${version}/${filename}`;
const checksumFileUrl = `${url}.sha512`;
const expectedChecksum = await this.getChecksum(checksumFileUrl);
const file = await this.http.download({
url,
checksumType: 'sha512',
expectedChecksum,
});
await this.compress.extract({ file, cwd: await this.getToolPath() });
}
/** Links the `skopeo` binary into the global bin folder. */
override async link(version: string): Promise<void> {
const src = join(this.pathSvc.versionedToolPath(this.name, version), 'bin');
await this.shellwrapper({ srcDir: src });
}
/** Checks that `skopeo --version` runs. */
override async test(_version: string): Promise<void> {
await this._spawn('skopeo', ['--version']);
}
/** Returns the tool path, creating it when missing. */
private async getToolPath(): Promise<string> {
return await this.pathSvc.ensureToolPath(this.name);
}
}