Skip to content

Commit 09517c5

Browse files
authored
Merge pull request elizaOS#1875 from odilitime/fix-postinstall-script
chore: support more debians distros
2 parents 2724555 + 9689bc2 commit 09517c5

File tree

1 file changed

+55
-9
lines changed

1 file changed

+55
-9
lines changed
+55-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,64 @@
11
import os from "os";
2+
import fs from "fs";
3+
import { execSync } from "child_process";
4+
25
const platform = os.platform();
6+
const rel = os.release();
7+
8+
if (platform !== "linux") {
9+
console.log("Skipping playwright installation: non-Linux platform detected:", platform);
10+
process.exit(0);
11+
}
12+
13+
function getDistroName() {
14+
try {
15+
const osReleaseContent = fs.readFileSync("/etc/os-release", "utf8");
16+
const lines = osReleaseContent.split("\n");
17+
const info = {};
18+
for (const line of lines) {
19+
const [key, value] = line.split("=");
20+
if (key && value) {
21+
info[key.toLowerCase()] = value.replace(/"/g, "").toLowerCase().trim();
22+
}
23+
}
24+
return info["id"] || info["id_like"] || null;
25+
} catch (err) {
26+
console.error("Error reading /etc/os-release:", err.message);
27+
}
28+
return null;
29+
}
330

4-
if (
5-
platform === "linux" &&
6-
!(os.release().includes("ubuntu") || os.release().includes("debian"))
7-
) {
8-
// DO NOT CHANGE THIS TO ELIZALOGGER, this file cannot depends on any workspace otherwise we can't build the workspace
31+
const distro = getDistroName();
32+
console.log("Detected Linux distribution:", distro || "unknown");
33+
34+
const supportedDistros = [
35+
"ubuntu",
36+
"debian",
37+
"pve",
38+
"raspbian",
39+
"pop",
40+
"zorin",
41+
"linuxmint",
42+
"elementary",
43+
"pureos",
44+
"kali"
45+
];
46+
47+
if (!distro || !supportedDistros.some((name) => distro.includes(name))) {
948
console.log(
1049
"Skipping playwright installation on unsupported platform:",
11-
platform
50+
platform,
51+
rel,
52+
distro || "unknown distro"
1253
);
13-
} else {
14-
const { execSync } = await import("child_process");
54+
process.exit(0);
55+
}
56+
57+
try {
1558
execSync("npx playwright install-deps && npx playwright install", {
16-
stdio: "inherit",
59+
stdio: "inherit"
1760
});
61+
} catch (err) {
62+
console.error("Failed to install Playwright dependencies:", err.message);
63+
process.exit(1);
1864
}

0 commit comments

Comments
 (0)