Skip to content

Commit 4bc97ee

Browse files
committed
fix: installing Lame on Linux with required libs
1 parent 36fc62f commit 4bc97ee

File tree

3 files changed

+144
-11
lines changed

3 files changed

+144
-11
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
postinstall:
6161
name: LAME install on ${{ matrix.os }}
6262
runs-on: ${{ matrix.os }}
63+
needs: quality
6364
strategy:
6465
fail-fast: false
6566
matrix:

scripts/diagnose-lame.mjs

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { existsSync, readdirSync, statSync } from "node:fs";
44
import { spawnSync } from "node:child_process";
55
import { platform } from "node:os";
6+
import { delimiter } from "node:path";
67

78
const {
89
resolveLameBinary,
@@ -13,21 +14,39 @@ function logSection(title) {
1314
console.log(`[lame-diagnostics] ${title}`);
1415
}
1516

16-
const binaryPath = resolveLameBinary();
17-
logSection(`Resolved binary: ${binaryPath}`);
17+
const resolveLibraryDir = () => {
18+
if (typeof resolveBundledLibraryDirectory === "function") {
19+
return resolveBundledLibraryDirectory();
20+
}
1821

19-
try {
20-
const stats = statSync(binaryPath);
21-
logSection(
22-
`File stats -> size=${stats.size} mode=${stats.mode.toString(8)} mtime=${stats.mtime.toISOString()}`,
23-
);
24-
} catch (error) {
25-
logSection(`stat() failed: ${error instanceof Error ? error.message : error}`);
26-
}
22+
return null;
23+
};
24+
25+
const libraryDir = resolveLibraryDir();
26+
const libraryEnvVar =
27+
platform() === "linux"
28+
? "LD_LIBRARY_PATH"
29+
: platform() === "darwin"
30+
? "DYLD_LIBRARY_PATH"
31+
: platform() === "win32"
32+
? "PATH"
33+
: null;
34+
35+
const withLibraryEnv = () => {
36+
const env = { ...process.env };
37+
if (libraryDir && libraryEnvVar) {
38+
env[libraryEnvVar] = env[libraryEnvVar]
39+
? `${libraryDir}${delimiter}${env[libraryEnvVar]}`
40+
: libraryDir;
41+
}
42+
43+
return env;
44+
};
2745

2846
const runCommand = (cmd, args) => {
2947
const result = spawnSync(cmd, args, {
3048
encoding: "utf-8",
49+
env: withLibraryEnv(),
3150
});
3251

3352
logSection(
@@ -43,13 +62,30 @@ const runCommand = (cmd, args) => {
4362
}
4463
};
4564

65+
const binaryPath = resolveLameBinary();
66+
logSection(`Resolved binary: ${binaryPath}`);
67+
68+
try {
69+
const stats = statSync(binaryPath);
70+
logSection(
71+
`File stats -> size=${stats.size} mode=${stats.mode.toString(8)} mtime=${stats.mtime.toISOString()}`,
72+
);
73+
} catch (error) {
74+
logSection(`stat() failed: ${error instanceof Error ? error.message : error}`);
75+
}
76+
77+
if (libraryDir && libraryEnvVar) {
78+
logSection(
79+
`Using ${libraryEnvVar}=${libraryDir} when running diagnostics`,
80+
);
81+
}
82+
4683
runCommand(binaryPath, ["--version"]);
4784

4885
if (platform() === "linux") {
4986
runCommand("ldd", [binaryPath]);
5087
}
5188

52-
const libraryDir = resolveBundledLibraryDirectory();
5389
logSection(
5490
`Bundled library directory: ${libraryDir ?? "not found (not expected on this platform?)"}`,
5591
);

scripts/install-lame.mjs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ const TARGET_BINARY = join(INSTALL_BASE, `lame${EXECUTABLE_SUFFIX}`);
3535
const LIB_DIRECTORY = join(INSTALL_BASE, "lib");
3636
const LIB_DIRECTORY_MARKER = join(LIB_DIRECTORY, ".installed");
3737
const LIBSNDFILE_VERSION = "1.2.0-1+deb12u1";
38+
const LIBFLAC_VERSION = "1.4.2+ds-2";
39+
const LIBOGG_VERSION = "1.3.5-3";
40+
const LIBVORBIS_VERSION = "1.3.7-1";
41+
const LIBOPUS_VERSION = "1.3.1-3";
42+
const LIBMPG123_VERSION = "1.31.2-1+deb12u1";
3843

3944
const DOWNLOAD_SOURCES = {
4045
"linux-x64": [
@@ -115,6 +120,36 @@ const LINUX_SHARED_LIBRARY_PACKAGES = {
115120
url: `https://deb.debian.org/debian/pool/main/libs/libsndfile/libsndfile1_${LIBSNDFILE_VERSION}_amd64.deb`,
116121
libraryRoot: "usr/lib/x86_64-linux-gnu",
117122
},
123+
{
124+
name: "libflac12",
125+
url: `https://deb.debian.org/debian/pool/main/f/flac/libflac12_${LIBFLAC_VERSION}_amd64.deb`,
126+
libraryRoot: "usr/lib/x86_64-linux-gnu",
127+
},
128+
{
129+
name: "libogg0",
130+
url: `https://deb.debian.org/debian/pool/main/libo/libogg/libogg0_${LIBOGG_VERSION}_amd64.deb`,
131+
libraryRoot: "usr/lib/x86_64-linux-gnu",
132+
},
133+
{
134+
name: "libvorbis0a",
135+
url: `https://deb.debian.org/debian/pool/main/libv/libvorbis/libvorbis0a_${LIBVORBIS_VERSION}_amd64.deb`,
136+
libraryRoot: "usr/lib/x86_64-linux-gnu",
137+
},
138+
{
139+
name: "libvorbisenc2",
140+
url: `https://deb.debian.org/debian/pool/main/libv/libvorbis/libvorbisenc2_${LIBVORBIS_VERSION}_amd64.deb`,
141+
libraryRoot: "usr/lib/x86_64-linux-gnu",
142+
},
143+
{
144+
name: "libopus0",
145+
url: `https://deb.debian.org/debian/pool/main/o/opus/libopus0_${LIBOPUS_VERSION}_amd64.deb`,
146+
libraryRoot: "usr/lib/x86_64-linux-gnu",
147+
},
148+
{
149+
name: "libmpg123-0",
150+
url: `https://deb.debian.org/debian/pool/main/m/mpg123/libmpg123-0_${LIBMPG123_VERSION}_amd64.deb`,
151+
libraryRoot: "usr/lib/x86_64-linux-gnu",
152+
},
118153
],
119154
"linux-arm64": [
120155
{
@@ -127,6 +162,36 @@ const LINUX_SHARED_LIBRARY_PACKAGES = {
127162
url: `https://deb.debian.org/debian/pool/main/libs/libsndfile/libsndfile1_${LIBSNDFILE_VERSION}_arm64.deb`,
128163
libraryRoot: "usr/lib/aarch64-linux-gnu",
129164
},
165+
{
166+
name: "libflac12",
167+
url: `https://deb.debian.org/debian/pool/main/f/flac/libflac12_${LIBFLAC_VERSION}_arm64.deb`,
168+
libraryRoot: "usr/lib/aarch64-linux-gnu",
169+
},
170+
{
171+
name: "libogg0",
172+
url: `https://deb.debian.org/debian/pool/main/libo/libogg/libogg0_${LIBOGG_VERSION}_arm64.deb`,
173+
libraryRoot: "usr/lib/aarch64-linux-gnu",
174+
},
175+
{
176+
name: "libvorbis0a",
177+
url: `https://deb.debian.org/debian/pool/main/libv/libvorbis/libvorbis0a_${LIBVORBIS_VERSION}_arm64.deb`,
178+
libraryRoot: "usr/lib/aarch64-linux-gnu",
179+
},
180+
{
181+
name: "libvorbisenc2",
182+
url: `https://deb.debian.org/debian/pool/main/libv/libvorbis/libvorbisenc2_${LIBVORBIS_VERSION}_arm64.deb`,
183+
libraryRoot: "usr/lib/aarch64-linux-gnu",
184+
},
185+
{
186+
name: "libopus0",
187+
url: `https://deb.debian.org/debian/pool/main/o/opus/libopus0_${LIBOPUS_VERSION}_arm64.deb`,
188+
libraryRoot: "usr/lib/aarch64-linux-gnu",
189+
},
190+
{
191+
name: "libmpg123-0",
192+
url: `https://deb.debian.org/debian/pool/main/m/mpg123/libmpg123-0_${LIBMPG123_VERSION}_arm64.deb`,
193+
libraryRoot: "usr/lib/aarch64-linux-gnu",
194+
},
130195
],
131196
"linux-arm": [
132197
{
@@ -139,6 +204,36 @@ const LINUX_SHARED_LIBRARY_PACKAGES = {
139204
url: `https://deb.debian.org/debian/pool/main/libs/libsndfile/libsndfile1_${LIBSNDFILE_VERSION}_armhf.deb`,
140205
libraryRoot: "usr/lib/arm-linux-gnueabihf",
141206
},
207+
{
208+
name: "libflac12",
209+
url: `https://deb.debian.org/debian/pool/main/f/flac/libflac12_${LIBFLAC_VERSION}_armhf.deb`,
210+
libraryRoot: "usr/lib/arm-linux-gnueabihf",
211+
},
212+
{
213+
name: "libogg0",
214+
url: `https://deb.debian.org/debian/pool/main/libo/libogg/libogg0_${LIBOGG_VERSION}_armhf.deb`,
215+
libraryRoot: "usr/lib/arm-linux-gnueabihf",
216+
},
217+
{
218+
name: "libvorbis0a",
219+
url: `https://deb.debian.org/debian/pool/main/libv/libvorbis/libvorbis0a_${LIBVORBIS_VERSION}_armhf.deb`,
220+
libraryRoot: "usr/lib/arm-linux-gnueabihf",
221+
},
222+
{
223+
name: "libvorbisenc2",
224+
url: `https://deb.debian.org/debian/pool/main/libv/libvorbis/libvorbisenc2_${LIBVORBIS_VERSION}_armhf.deb`,
225+
libraryRoot: "usr/lib/arm-linux-gnueabihf",
226+
},
227+
{
228+
name: "libopus0",
229+
url: `https://deb.debian.org/debian/pool/main/o/opus/libopus0_${LIBOPUS_VERSION}_armhf.deb`,
230+
libraryRoot: "usr/lib/arm-linux-gnueabihf",
231+
},
232+
{
233+
name: "libmpg123-0",
234+
url: `https://deb.debian.org/debian/pool/main/m/mpg123/libmpg123-0_${LIBMPG123_VERSION}_armhf.deb`,
235+
libraryRoot: "usr/lib/arm-linux-gnueabihf",
236+
},
142237
],
143238
};
144239

@@ -439,6 +534,7 @@ function copyLibrariesIntoTarget(sourceDir) {
439534
recursive: true,
440535
force: true,
441536
errorOnExist: false,
537+
dereference: true,
442538
});
443539
}
444540
}

0 commit comments

Comments
 (0)