Skip to content

Commit f7f5780

Browse files
committed
Add kexts support
1 parent dd8aa12 commit f7f5780

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

build.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"local_bootloader_not_found": `File "bootloader-local.bin" not found.`,
7171
"downloading_bootloader": "Downloading bootloader...",
7272
"downloading_kernel": "Downloading kernel...",
73+
"downloading_kexts": "Downloading kernel extensions...",
7374
"applying_fixes": "Applying fixes...",
7475
"unable_to_find": "Unable to find",
7576
"did_you_compile_first": "Did you compile first?",
@@ -114,6 +115,7 @@
114115
"local_bootloader_not_found": `Файл "bootloader-local.bin" не найден.`,
115116
"downloading_bootloader": "Скачивание загрузчика...",
116117
"downloading_kernel": "Скачивание ядра...",
118+
"downloading_kexts": "Скачивание расширений ядра...",
117119
"applying_fixes": "Принятие исправлений...",
118120
"unable_to_find": "Не удалось найти",
119121
"did_you_compile_first": "Вы скомпилировали перед этим?",
@@ -278,7 +280,7 @@
278280
versions.unshift("./kernel-local");
279281
}
280282
if (config.dev && fs.existsSync("../kernel/dist")) {
281-
versions.unshift(...fs.readdirSync("../kernel/dist").map(version => `../kernel/dist/${version}`));
283+
versions.unshift(...fs.readdirSync("../kernel/dist").filter(version => version != "kexts").map(version => `../kernel/dist/${version}`));
282284
}
283285
document.querySelector("#kernels").innerHTML = versions.map(version => `<option value="${version}">${version}</option>`).join("");
284286
if (versions.includes(config.kernel)) {
@@ -711,7 +713,31 @@
711713
fs.writeFileSync("kernel-cache", Buffer.from(await fetch(`https://github.com/CatCoreV/catcore/releases/download/${config.kernel}/kernel-${config.kernel.replace("v", "")}${targetMappings[config.target]}-${config.arch}`).then(res => res.arrayBuffer())));
712714
fs.writeFileSync("catcore.d.ts", Buffer.from(await fetch(`https://github.com/CatCoreV/catcore/releases/download/${config.kernel}/catcore.d.ts`).then(res => res.arrayBuffer())));
713715
} catch {}
714-
fs.copyFileSync("kernel-cache", path.join(process.cwd(), "dist", "fs", "boot", "kernel"));
716+
fs.copyFileSync("kernel-cache", path.join(process.cwd(), "dist", "fs", "boot", `kernel-${config.kernel.replace("v", "")}${targetMappings[config.target]}-${config.arch}`));
717+
fs.linkSync(path.join(process.cwd(), "dist", "fs", "boot", `kernel-${config.kernel.replace("v", "")}${targetMappings[config.target]}-${config.arch}`), path.join(process.cwd(), "dist", "fs", "boot", "kernel"));
718+
}
719+
fs.mkdirSync(path.join(process.cwd(), "dist", "fs", "boot", "kexts"));
720+
if (config.kernel.startsWith(".")) {
721+
fs.readdirSync(path.join(path.dirname(config.kernel), "kexts")).forEach(kext => {
722+
fs.copyFileSync(path.join(path.dirname(config.kernel), "kexts", kext), path.join(process.cwd(), "dist", "fs", "boot", "kexts", kext));
723+
});
724+
} else {
725+
document.querySelector("#status").innerText = text("downloading_kexts");
726+
document.querySelector("#status").style.color = "yellow";
727+
try {
728+
if (quick) {
729+
throw "";
730+
}
731+
fs.writeFileSync("kexts-cache.zip", Buffer.from(await fetch(`https://github.com/CatCoreV/catcore/releases/download/${config.kernel}/kexts-${targetMappings[config.target]}-${config.arch}.zip`).then(res => res.arrayBuffer())));
732+
} catch {}
733+
await new Promise(res => {
734+
child_process.exec(`${(process.platform == "win32") ? "tar -xf" : "unzip"} ../../../../kexts-cache.zip`, {
735+
"cwd": path.join(process.cwd(), "dist", "fs", "boot", "kexts")
736+
}, res);
737+
});
738+
}
739+
for (var excludedKext of (system.excludeKexts || [])) {
740+
fs.unlinkSync(path.join(process.cwd(), "dist", "fs", "boot", "kexts", excludedKext));
715741
}
716742
if (!quick && config.target == "macos-app") {
717743
document.querySelector("#status").innerText = text("applying_fixes");

0 commit comments

Comments
 (0)