Skip to content

Commit

Permalink
Merge pull request #7579 from jandubois/bump-socket_vmnet
Browse files Browse the repository at this point in the history
Install socket_vmnet 1.1.5 from upstream release
  • Loading branch information
mook-as authored Oct 4, 2024
2 parents 0fa0f9c + f856a69 commit c41f2d9
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ varnamelen
vcenter
vcpus
vcs
vde
ventura
VERSIONSTRING
vertificate
Expand Down
1 change: 1 addition & 0 deletions pkg/rancher-desktop/assets/dependencies.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
lima: 0.21.0.rd2
limaAndQemu: 1.31.3
socketVMNet: 1.1.5
alpineLimaISO:
isoVersion: 0.2.39.rd4
alpineVersion: 3.20.0
Expand Down
45 changes: 42 additions & 3 deletions scripts/dependencies/lima.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import path from 'path';

import semver from 'semver';

import { download, getResource } from '../lib/download';
import { download, downloadTarGZ, getResource } from '../lib/download';

import {
DownloadContext, Dependency, AlpineLimaISOVersion, getOctokit, GitHubDependency, getPublishedReleaseTagNames, GitHubRelease,
DownloadContext, Dependency, AlpineLimaISOVersion, findChecksum, getOctokit, GitHubDependency, getPublishedReleaseTagNames, GitHubRelease,
} from 'scripts/lib/dependencies';

/**
Expand Down Expand Up @@ -165,7 +165,8 @@ export class LimaAndQemu implements Dependency, GitHubDependency {
});
await fs.promises.mkdir(limaDir, { recursive: true });

const child = childProcess.spawn('/usr/bin/tar', ['-xf', tarPath, '--exclude', 'lima*'],
const child = childProcess.spawn('/usr/bin/tar',
['-xf', tarPath, '--exclude', 'lima*', '--exclude', 'vde/bin', '--exclude', 'vde/lib', '--exclude', 'socket_vmnet'],
{ cwd: limaDir, stdio: 'inherit' });

await new Promise<void>((resolve, reject) => {
Expand Down Expand Up @@ -201,6 +202,44 @@ export class LimaAndQemu implements Dependency, GitHubDependency {
}
}

export class SocketVMNet implements Dependency, GitHubDependency {
name = 'socketVMNet';
githubOwner = 'lima-vm';
githubRepo = 'socket_vmnet';

async download(context: DownloadContext): Promise<void> {
const arch = context.isM1 ? 'arm64' : 'x86_64';
const baseURL = `https://github.com/${ this.githubOwner }/${ this.githubRepo }/releases/download/v${ context.versions.socketVMNet }`;
const archiveName = `socket_vmnet-${ context.versions.socketVMNet }-${ arch }.tar.gz`;
const expectedChecksum = await findChecksum(`${ baseURL }/SHA256SUMS`, archiveName);

await downloadTarGZ(`${ baseURL }/${ archiveName }`,
path.join(context.resourcesDir, context.platform, 'lima', 'socket_vmnet', 'bin', 'socket_vmnet'),
{ expectedChecksum, entryName: './opt/socket_vmnet/bin/socket_vmnet' });
}

async getAvailableVersions(): Promise<string[]> {
const tagNames = await getPublishedReleaseTagNames(this.githubOwner, this.githubRepo);

return tagNames.map((tagName: string) => tagName.replace(/^v/, ''));
}

versionToTagName(version: string): string {
return `v${ version }`;
}

rcompareVersions(version1: string, version2: string): -1 | 0 | 1 {
const semver1 = semver.coerce(version1);
const semver2 = semver.coerce(version2);

if (semver1 === null || semver2 === null) {
throw new Error(`One of ${ version1 } and ${ version2 } failed to be coerced to semver`);
}

return semver.rcompare(semver1, semver2);
}
}

export class AlpineLimaISO implements Dependency, GitHubDependency {
name = 'alpineLimaISO';
githubOwner = 'rancher-sandbox';
Expand Down
22 changes: 1 addition & 21 deletions scripts/dependencies/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../lib/download';

import {
DownloadContext, Dependency, GitHubDependency, getPublishedReleaseTagNames, getPublishedVersions,
DownloadContext, Dependency, GitHubDependency, findChecksum, getPublishedReleaseTagNames, getPublishedVersions,
} from 'scripts/lib/dependencies';
import { simpleSpawn } from 'scripts/simple_process';

Expand All @@ -19,26 +19,6 @@ function exeName(context: DownloadContext, name: string) {
return `${ name }${ onWindows ? '.exe' : '' }`;
}

/**
* Download the given checksum file (which contains multiple checksums) and find
* the correct checksum for the given executable name.
* @param checksumURL The URL to download the checksum from.
* @param executableName The name of the executable expected.
* @returns The checksum.
*/
async function findChecksum(checksumURL: string, executableName: string): Promise<string> {
const allChecksums = await getResource(checksumURL);
const desiredChecksums = allChecksums.split(/\r?\n/).filter(line => line.endsWith(executableName));

if (desiredChecksums.length < 1) {
throw new Error(`Couldn't find a matching SHA for [${ executableName }] in [${ allChecksums }]`);
}
if (desiredChecksums.length === 1) {
return desiredChecksums[0].split(/\s+/, 1)[0];
}
throw new Error(`Matched ${ desiredChecksums.length } hits, not exactly 1, for ${ executableName } in [${ allChecksums }]`);
}

export class KuberlrAndKubectl implements Dependency {
name = 'kuberlr';
githubOwner = 'flavio';
Expand Down
23 changes: 23 additions & 0 deletions scripts/lib/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Octokit } from 'octokit';
import semver from 'semver';
import YAML from 'yaml';

import { getResource } from './download';

export type DependencyPlatform = 'wsl' | 'linux' | 'darwin' | 'win32';
export type Platform = 'linux' | 'darwin' | 'win32';
export type GoPlatform = 'linux' | 'darwin' | 'windows';
Expand Down Expand Up @@ -36,6 +38,7 @@ export type AlpineLimaISOVersion = {
export type DependencyVersions = {
lima: string;
limaAndQemu: string;
socketVMNet: string;
alpineLimaISO: AlpineLimaISOVersion;
WSLDistro: string;
kuberlr: string;
Expand All @@ -59,6 +62,26 @@ export type DependencyVersions = {
spinCLI: string;
};

/**
* Download the given checksum file (which contains multiple checksums) and find
* the correct checksum for the given executable name.
* @param checksumURL The URL to download the checksum from.
* @param executableName The name of the executable expected.
* @returns The checksum.
*/
export async function findChecksum(checksumURL: string, executableName: string): Promise<string> {
const allChecksums = await getResource(checksumURL);
const desiredChecksums = allChecksums.split(/\r?\n/).filter(line => line.endsWith(executableName));

if (desiredChecksums.length < 1) {
throw new Error(`Couldn't find a matching SHA for [${ executableName }] in [${ allChecksums }]`);
}
if (desiredChecksums.length === 1) {
return desiredChecksums[0].split(/\s+/, 1)[0];
}
throw new Error(`Matched ${ desiredChecksums.length } hits, not exactly 1, for ${ executableName } in [${ allChecksums }]`);
}

export async function readDependencyVersions(path: string): Promise<DependencyVersions> {
const rawContents = await fs.promises.readFile(path, 'utf-8');

Expand Down
3 changes: 2 additions & 1 deletion scripts/postinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import os from 'os';
import path from 'path';

import * as goUtils from 'scripts/dependencies/go-source';
import { Lima, LimaAndQemu, AlpineLimaISO } from 'scripts/dependencies/lima';
import { Lima, LimaAndQemu, SocketVMNet, AlpineLimaISO } from 'scripts/dependencies/lima';
import { MobyOpenAPISpec } from 'scripts/dependencies/moby-openapi';
import { SudoPrompt } from 'scripts/dependencies/sudo-prompt';
import { ExtensionProxyImage, WSLDistroImage } from 'scripts/dependencies/tar-archives';
Expand Down Expand Up @@ -49,6 +49,7 @@ const unixDependencies = [

// Dependencies that are specific to macOS hosts.
const macOSDependencies = [
new SocketVMNet(),
new SudoPrompt(),
];

Expand Down
3 changes: 2 additions & 1 deletion scripts/rddepman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path';

import { Octokit } from 'octokit';

import { Lima, LimaAndQemu, AlpineLimaISO } from 'scripts/dependencies/lima';
import { Lima, LimaAndQemu, SocketVMNet, AlpineLimaISO } from 'scripts/dependencies/lima';
import { MobyOpenAPISpec } from 'scripts/dependencies/moby-openapi';
import * as tools from 'scripts/dependencies/tools';
import { Wix } from 'scripts/dependencies/wix';
Expand Down Expand Up @@ -39,6 +39,7 @@ const dependencies: Dependency[] = [
new tools.ECRCredHelper(),
new Lima(),
new LimaAndQemu(),
new SocketVMNet(),
new AlpineLimaISO(),
new WSLDistro(),
new Wix(),
Expand Down

0 comments on commit c41f2d9

Please sign in to comment.