Skip to content

Commit

Permalink
feat(manifest): support more sidecar archs
Browse files Browse the repository at this point in the history
support linux armhf armel i386
support window i386
  • Loading branch information
greenhat616 committed Sep 11, 2024
1 parent 7546547 commit 0fe1046
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 100 deletions.
28 changes: 22 additions & 6 deletions manifest/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,55 @@
"manifest_version": 1,
"latest": {
"mihomo": "v1.18.8",
"mihomo_alpha": "alpha-417d709",
"mihomo_alpha": "alpha-8230bc8",
"clash_rs": "v0.3.1",
"clash_premium": "2023-09-05-gdcc8d87"
},
"arch_template": {
"mihomo": {
"windows-i386": "mihomo-windows-386-{}.zip",
"windows-x86_64": "mihomo-windows-amd64-compatible-{}.zip",
"linux-aarch64": "mihomo-linux-arm64-{}.gz",
"linux-amd64": "mihomo-linux-amd64-compatible-{}.gz",
"linux-i386": "mihomo-linux-386-{}.gz",
"darwin-arm64": "mihomo-darwin-arm64-{}.gz",
"darwin-x64": "mihomo-darwin-amd64-compatible-{}.gz"
"darwin-x64": "mihomo-darwin-amd64-compatible-{}.gz",
"linux-armv7": "mihomo-linux-armv5-{}.gz",
"linux-armv7hf": "mihomo-linux-armv7-{}.gz"
},
"mihomo_alpha": {
"windows-i386": "mihomo-windows-386-{}.zip",
"windows-x86_64": "mihomo-windows-amd64-compatible-{}.zip",
"linux-aarch64": "mihomo-linux-arm64-{}.gz",
"linux-amd64": "mihomo-linux-amd64-compatible-{}.gz",
"linux-i386": "mihomo-linux-i386-{}.gz",
"darwin-arm64": "mihomo-darwin-arm64-{}.gz",
"darwin-x64": "mihomo-darwin-amd64-compatible-{}.gz"
"darwin-x64": "mihomo-darwin-amd64-compatible-{}.gz",
"linux-armv7": "mihomo-linux-armv5-{}.gz",
"linux-armv7hf": "mihomo-linux-armv7-{}.gz"
},
"clash_rs": {
"windows-i386": "clash-i686-pc-windows-msvc-static-crt.exe",
"windows-x86_64": "clash-x86_64-pc-windows-msvc.exe",
"linux-aarch64": "clash-aarch64-unknown-linux-gnu-static-crt",
"linux-amd64": "clash-x86_64-unknown-linux-gnu-static-crt",
"linux-i386": "clash-i686-unknown-linux-gnu-static-crt",
"darwin-arm64": "clash-aarch64-apple-darwin",
"darwin-x64": "clash-x86_64-apple-darwin"
"darwin-x64": "clash-x86_64-apple-darwin",
"linux-armv7": "clash-armv7-unknown-linux-gnueabi-static-crt",
"linux-armv7hf": "clash-armv7-unknown-linux-gnueabihf"
},
"clash_premium": {
"windows-i386": "clash-windows-386-n{}.zip",
"windows-x86_64": "clash-windows-amd64-n{}.zip",
"linux-aarch64": "clash-linux-arm64-n{}.gz",
"linux-amd64": "clash-linux-amd64-n{}.gz",
"linux-i386": "clash-linux-386-n{}.gz",
"darwin-arm64": "clash-darwin-arm64-n{}.gz",
"darwin-x64": "clash-darwin-amd64-n{}.gz"
"darwin-x64": "clash-darwin-amd64-n{}.gz",
"linux-armv7": "clash-linux-armv5-n{}.gz",
"linux-armv7hf": "clash-linux-armv7-n{}.gz"
}
},
"updated_at": "2024-09-10T22:20:30.913Z"
"updated_at": "2024-09-11T06:21:25.794Z"
}
2 changes: 1 addition & 1 deletion scripts/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (!SIDECAR_HOST) {

const platform = process.platform;

const arch = ARCH ? ARCH : process.arch;
const arch = (ARCH ? ARCH : process.arch) as NodeJS.Architecture | "armel";

archCheck(platform, arch);

Expand Down
16 changes: 2 additions & 14 deletions scripts/manifest/clash-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import versionManifest from "../../manifest/version.json";
export const CLASH_META_MANIFEST: ClashManifest = {
URL_PREFIX: `https://github.com/MetaCubeX/mihomo/releases/download/${versionManifest.latest.mihomo}`,
VERSION: versionManifest.latest.mihomo,
BIN_MAP: {
"win32-x64": "mihomo-windows-amd64-compatible",
"darwin-x64": "mihomo-darwin-amd64-compatible",
"darwin-arm64": "mihomo-darwin-arm64",
"linux-x64": "mihomo-linux-amd64-compatible",
"linux-arm64": "mihomo-linux-arm64",
},
ARCH_MAPPING: versionManifest.arch_template.mihomo,
};

export const CLASH_META_ALPHA_MANIFEST: ClashManifest = {
Expand All @@ -19,11 +13,5 @@ export const CLASH_META_ALPHA_MANIFEST: ClashManifest = {
URL_PREFIX:
"https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha",
VERSION: versionManifest.latest.mihomo_alpha,
BIN_MAP: {
"win32-x64": "mihomo-windows-amd64-compatible",
"darwin-x64": "mihomo-darwin-amd64-compatible",
"darwin-arm64": "mihomo-darwin-arm64",
"linux-x64": "mihomo-linux-amd64-compatible",
"linux-arm64": "mihomo-linux-arm64",
},
ARCH_MAPPING: versionManifest.arch_template.mihomo_alpha,
};
9 changes: 2 additions & 7 deletions scripts/manifest/clash-premium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ export const CLASH_MANIFEST: ClashManifest = {
BACKUP_URL_PREFIX:
"https://github.com/zhongfly/Clash-premium-backup/releases/download/",
BACKUP_LATEST_DATE: versionManifest.latest.clash_premium,
BIN_MAP: {
"win32-x64": "clash-windows-amd64",
"darwin-x64": "clash-darwin-amd64",
"darwin-arm64": "clash-darwin-arm64",
"linux-x64": "clash-linux-amd64",
"linux-arm64": "clash-linux-arm64",
},
VERSION: versionManifest.latest.clash_premium,
ARCH_MAPPING: versionManifest.arch_template.clash_premium,
};
8 changes: 1 addition & 7 deletions scripts/manifest/clash-rs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@ import versionManifest from "../../manifest/version.json";
export const CLASH_RS_MANIFEST: ClashManifest = {
URL_PREFIX: "https://github.com/Watfaq/clash-rs/releases/download/",
VERSION: versionManifest.latest.clash_rs,
BIN_MAP: {
"win32-x64": "clash-x86_64-pc-windows-msvc",
"darwin-x64": "clash-x86_64-apple-darwin",
"darwin-arm64": "clash-aarch64-apple-darwin",
"linux-x64": "clash-x86_64-unknown-linux-gnu-static-crt",
"linux-arm64": "clash-aarch64-unknown-linux-gnu-static-crt",
},
ARCH_MAPPING: versionManifest.arch_template.clash_rs,
};
7 changes: 5 additions & 2 deletions scripts/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ClashManifest {
BACKUP_LATEST_DATE?: string;
VERSION?: string;
VERSION_URL?: string;
BIN_MAP: { [key: string]: string };
ARCH_MAPPING: ArchMapping;
}

export interface BinInfo {
Expand All @@ -21,12 +21,15 @@ export interface BinInfo {

export enum SupportedArch {
// blocked by clash-rs
// WindowsX86 = "windows-x86",
WindowsX86_32 = "windows-i386",
WindowsX86_64 = "windows-x86_64",
// blocked by clash-rs#212
// WindowsArm64 = "windows-arm64",
LinuxAarch64 = "linux-aarch64",
LinuxAmd64 = "linux-amd64",
LinuxI386 = "linux-i386",
LinuxArmv7 = "linux-armv7",
LinuxArmv7hf = "linux-armv7hf",
DarwinArm64 = "darwin-arm64",
DarwinX64 = "darwin-x64",
}
Expand Down
10 changes: 0 additions & 10 deletions scripts/utils/arch-check.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import { CLASH_META_MANIFEST } from "../manifest/clash-meta";
import { CLASH_MANIFEST } from "../manifest/clash-premium";
import { colorize, consola } from "./logger";

export const archCheck = (platform: string, arch: string) => {
consola.debug(colorize`platform {yellow ${platform}}`);

consola.debug(colorize`arch {yellow ${arch}}`);

if (!CLASH_MANIFEST.BIN_MAP[`${platform}-${arch}`]) {
throw new Error(`clash unsupported platform "${platform}-${arch}"`);
}

if (!CLASH_META_MANIFEST.BIN_MAP[`${platform}-${arch}`]) {
throw new Error(`clash meta unsupported platform "${platform}-${arch}"`);
}
};
22 changes: 18 additions & 4 deletions scripts/utils/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { applyProxy, octokit } from "./octokit";

export type ArchMapping = { [key in SupportedArch]: string };

export type NodeArch = NodeJS.Architecture | "armel";

// resolvers block
export type LatestVersionResolver = Promise<{
name: string;
Expand All @@ -22,13 +24,16 @@ export const resolveMihomo = async (): LatestVersionResolver => {
consola.debug(`mihomo latest release: ${latestRelease.data.tag_name}`);

const archMapping: ArchMapping = {
// [SupportedArch.WindowsX86]: "mihomo-windows-386-{}.zip",
[SupportedArch.WindowsX86_32]: "mihomo-windows-386-{}.zip",
[SupportedArch.WindowsX86_64]: "mihomo-windows-amd64-compatible-{}.zip",
// [SupportedArch.WindowsAarch64]: "mihomo-windows-arm64-{}.zip",
[SupportedArch.LinuxAarch64]: "mihomo-linux-arm64-{}.gz",
[SupportedArch.LinuxAmd64]: "mihomo-linux-amd64-compatible-{}.gz",
[SupportedArch.LinuxI386]: "mihomo-linux-386-{}.gz",
[SupportedArch.DarwinArm64]: "mihomo-darwin-arm64-{}.gz",
[SupportedArch.DarwinX64]: "mihomo-darwin-amd64-compatible-{}.gz",
[SupportedArch.LinuxArmv7]: "mihomo-linux-armv5-{}.gz",
[SupportedArch.LinuxArmv7hf]: "mihomo-linux-armv7-{}.gz",
} satisfies ArchMapping;

return {
Expand All @@ -48,13 +53,16 @@ export const resolveMihomoAlpha = async (): LatestVersionResolver => {
consola.debug(`mihomo alpha release: ${alphaReleaseHash}`);

const archMapping: ArchMapping = {
// [SupportedArch.WindowsX86]: "mihomo-windows-386-{}.zip",
[SupportedArch.WindowsX86_32]: "mihomo-windows-386-{}.zip",
[SupportedArch.WindowsX86_64]: "mihomo-windows-amd64-compatible-{}.zip",
// [SupportedArch.WindowsAarch64]: "mihomo-windows-arm64-{}.zip",
[SupportedArch.LinuxAarch64]: "mihomo-linux-arm64-{}.gz",
[SupportedArch.LinuxAmd64]: "mihomo-linux-amd64-compatible-{}.gz",
[SupportedArch.LinuxI386]: "mihomo-linux-i386-{}.gz",
[SupportedArch.DarwinArm64]: "mihomo-darwin-arm64-{}.gz",
[SupportedArch.DarwinX64]: "mihomo-darwin-amd64-compatible-{}.gz",
[SupportedArch.LinuxArmv7]: "mihomo-linux-armv5-{}.gz",
[SupportedArch.LinuxArmv7hf]: "mihomo-linux-armv7-{}.gz",
} satisfies ArchMapping;

return {
Expand All @@ -75,13 +83,16 @@ export const resolveClashRs = async (): LatestVersionResolver => {
consola.debug(`clash-rs latest release: ${latestRelease.data.tag_name}`);

const archMapping: ArchMapping = {
// [SupportedArch.WindowsX86]: "mihomo-windows-386-alpha-{}.zip",
[SupportedArch.WindowsX86_32]: "clash-i686-pc-windows-msvc-static-crt.exe",
[SupportedArch.WindowsX86_64]: "clash-x86_64-pc-windows-msvc.exe",
// [SupportedArch.WindowsAarch64]: "mihomo-windows-arm64-alpha-{}.zip",
[SupportedArch.LinuxAarch64]: "clash-aarch64-unknown-linux-gnu-static-crt",
[SupportedArch.LinuxAmd64]: "clash-x86_64-unknown-linux-gnu-static-crt",
[SupportedArch.LinuxI386]: "clash-i686-unknown-linux-gnu-static-crt",
[SupportedArch.DarwinArm64]: "clash-aarch64-apple-darwin",
[SupportedArch.DarwinX64]: "clash-x86_64-apple-darwin",
[SupportedArch.LinuxArmv7]: "clash-armv7-unknown-linux-gnueabi-static-crt",
[SupportedArch.LinuxArmv7hf]: "clash-armv7-unknown-linux-gnueabihf",
} satisfies ArchMapping;

return {
Expand All @@ -102,13 +113,16 @@ export const resolveClashPremium = async (): LatestVersionResolver => {
consola.debug(`clash-premium latest release: ${latestRelease.data.tag_name}`);

const archMapping: ArchMapping = {
// [SupportedArch.WindowsX86]: "clash-windows-386-n{}.zip",
[SupportedArch.WindowsX86_32]: "clash-windows-386-n{}.zip",
[SupportedArch.WindowsX86_64]: "clash-windows-amd64-n{}.zip",
// [SupportedArch.WindowsAarch64]: "clash-windows-arm64-n{}.zip",
[SupportedArch.LinuxAarch64]: "clash-linux-arm64-n{}.gz",
[SupportedArch.LinuxAmd64]: "clash-linux-amd64-n{}.gz",
[SupportedArch.LinuxI386]: "clash-linux-386-n{}.gz",
[SupportedArch.DarwinArm64]: "clash-darwin-arm64-n{}.gz",
[SupportedArch.DarwinX64]: "clash-darwin-amd64-n{}.gz",
[SupportedArch.LinuxArmv7]: "clash-linux-armv5-n{}.gz",
[SupportedArch.LinuxArmv7hf]: "clash-linux-armv7-n{}.gz",
} satisfies ArchMapping;

return {
Expand Down
13 changes: 7 additions & 6 deletions scripts/utils/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import crypto from "node:crypto";
import path from "path";
import AdmZip from "adm-zip";
import fs from "fs-extra";
import { BinInfo } from "types";
import { BinInfo } from "../types";
import { downloadFile, resolveSidecar } from "./download";
import { TAURI_APP_DIR, TEMP_DIR } from "./env";
import { colorize, consola } from "./logger";
import { NodeArch } from "./manifest";
import {
getClashBackupInfo,
getClashMetaAlphaInfo,
Expand Down Expand Up @@ -38,16 +39,16 @@ export const resolveResource = async (

export class Resolve {
private infoOption: {
platform: string;
arch: string;
platform: NodeJS.Platform;
arch: NodeArch;
sidecarHost: string;
};

constructor(
private readonly options: {
force?: boolean;
platform: string;
arch: string;
platform: NodeJS.Platform;
arch: NodeArch;
sidecarHost: string;
},
) {
Expand All @@ -64,7 +65,7 @@ export class Resolve {
*/
public async wintun() {
const { platform } = process;
let arch = this.options.arch || "x64";
let arch: string = this.options.arch || "x64";
if (platform !== "win32") return;

switch (arch) {
Expand Down
Loading

0 comments on commit 0fe1046

Please sign in to comment.