Skip to content

Commit b53451b

Browse files
committed
Fix nfpm package building by using relative paths and running from working directory
- Changed nfpm configuration to use relative paths for content sources - Run nfpm from the working directory to resolve relative paths correctly - Place nfpm.yaml in the working directory instead of out directory - Fix cleanup to remove config file from correct location This fixes the issue where nfpm couldn't find the files to package.
1 parent e67c644 commit b53451b

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

package/src/linux/installer.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ async function createNfpmConfig(
2828
workingDir: string,
2929
) {
3030
const arch = mapArchitecture(configuration.arch, format);
31+
// Use relative paths for nfpm configuration
3132
const workingBinPath = join(
32-
workingDir,
3333
"opt",
3434
configuration.productName.toLowerCase(),
3535
"bin",
3636
);
3737
const workingSharePath = join(
38-
workingDir,
3938
"opt",
4039
configuration.productName.toLowerCase(),
4140
"share",
@@ -142,24 +141,32 @@ async function buildPackageWithNfpm(
142141

143142
// Create nfpm configuration
144143
const nfpmConfig = await createNfpmConfig(configuration, format, workingDir);
145-
const configPath = join(configuration.directoryInfo.out, "nfpm.yaml");
144+
const configPath = join(workingDir, "nfpm.yaml");
146145

147146
info("Creating nfpm configuration file");
148147
Deno.writeTextFileSync(configPath, yaml.dump(nfpmConfig));
149148

150149
// Build package using nfpm (assumes nfpm is installed in PATH)
150+
// Run nfpm from the working directory so relative paths work
151151
const outputPath = join(configuration.directoryInfo.out, packageName);
152-
await runCmd("nfpm", [
153-
"package",
154-
"--config", configPath,
155-
"--target", outputPath,
156-
"--packager", format,
157-
]);
152+
const originalCwd = Deno.cwd();
153+
Deno.chdir(workingDir);
154+
155+
try {
156+
await runCmd("nfpm", [
157+
"package",
158+
"--config", "nfpm.yaml",
159+
"--target", outputPath,
160+
"--packager", format,
161+
]);
162+
} finally {
163+
Deno.chdir(originalCwd);
164+
}
158165

159166
info(`Package created: ${outputPath}`);
160167

161-
// Clean up
162-
Deno.removeSync(configPath);
168+
// Clean up - config file is now in the working directory
169+
Deno.removeSync(join(workingDir, "nfpm.yaml"));
163170
// Optionally remove working directory
164171
// Deno.removeSync(workingDir, { recursive: true });
165172
}

0 commit comments

Comments
 (0)