Skip to content

Commit 53c03d7

Browse files
committed
revert
1 parent 57a7f91 commit 53c03d7

File tree

1 file changed

+15
-44
lines changed

1 file changed

+15
-44
lines changed

package/src/linux/installer.ts

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ async function createNfpmConfig(
2828
workingDir: string,
2929
) {
3030
const arch = mapArchitecture(configuration.arch, format);
31-
// Use relative paths for nfpm configuration
3231
const workingBinPath = join(
32+
workingDir,
3333
"opt",
3434
configuration.productName.toLowerCase(),
3535
"bin",
3636
);
3737
const workingSharePath = join(
38+
workingDir,
3839
"opt",
3940
configuration.productName.toLowerCase(),
4041
"share",
@@ -71,16 +72,14 @@ async function createNfpmConfig(
7172
},
7273
],
7374

75+
scripts: {
76+
postinstall: join(configuration.directoryInfo.pkg, "scripts", "linux", format, "postinst"),
77+
postremove: join(configuration.directoryInfo.pkg, "scripts", "linux", format, "postrm"),
78+
},
7479

7580
overrides: {},
7681
};
7782

78-
// Use relative paths for scripts (relative to working directory where nfpm runs)
79-
config.scripts = {
80-
postinstall: `./postinst`,
81-
postremove: `./postrm`,
82-
};
83-
8483
// Format-specific configuration
8584
if (format === 'deb') {
8685
config.overrides.deb = {
@@ -141,54 +140,26 @@ async function buildPackageWithNfpm(
141140
overwrite: true,
142141
});
143142

144-
// Copy scripts to working directory for nfpm to find them
145-
const scriptSourceDir = join(configuration.directoryInfo.pkg, "scripts", "linux", format);
146-
const postinstScript = join(scriptSourceDir, "postinst");
147-
const postrmScript = join(scriptSourceDir, "postrm");
148-
149-
if (existsSync(postinstScript)) {
150-
copySync(postinstScript, join(workingDir, "postinst"));
151-
}
152-
if (existsSync(postrmScript)) {
153-
copySync(postrmScript, join(workingDir, "postrm"));
154-
}
155-
156143
// Create nfpm configuration
157144
const nfpmConfig = await createNfpmConfig(configuration, format, workingDir);
158-
const configPath = join(workingDir, "nfpm.yaml");
145+
const configPath = join(configuration.directoryInfo.out, "nfpm.yaml");
159146

160147
info("Creating nfpm configuration file");
161148
Deno.writeTextFileSync(configPath, yaml.dump(nfpmConfig));
162149

163150
// Build package using nfpm (assumes nfpm is installed in PATH)
164-
// Run nfpm from the working directory so relative paths work
165151
const outputPath = join(configuration.directoryInfo.out, packageName);
166-
const originalCwd = Deno.cwd();
167-
Deno.chdir(workingDir);
168-
169-
try {
170-
await runCmd("nfpm", [
171-
"package",
172-
"--config", "nfpm.yaml",
173-
"--target", outputPath,
174-
"--packager", format,
175-
]);
176-
} finally {
177-
Deno.chdir(originalCwd);
178-
}
152+
await runCmd("nfpm", [
153+
"package",
154+
"--config", configPath,
155+
"--target", outputPath,
156+
"--packager", format,
157+
]);
179158

180159
info(`Package created: ${outputPath}`);
181160

182-
// Clean up - config file and scripts are in the working directory
183-
Deno.removeSync(join(workingDir, "nfpm.yaml"));
184-
const postinstPath = join(workingDir, "postinst");
185-
const postrmPath = join(workingDir, "postrm");
186-
if (existsSync(postinstPath)) {
187-
Deno.removeSync(postinstPath);
188-
}
189-
if (existsSync(postrmPath)) {
190-
Deno.removeSync(postrmPath);
191-
}
161+
// Clean up
162+
Deno.removeSync(configPath);
192163
// Optionally remove working directory
193164
// Deno.removeSync(workingDir, { recursive: true });
194165
}

0 commit comments

Comments
 (0)