53 lines
1.8 KiB
TypeScript
53 lines
1.8 KiB
TypeScript
import fs from "fs";
|
|
import fse from "fs-extra";
|
|
import gulp from "gulp";
|
|
import deb from "gulp-debian";
|
|
import os from "os";
|
|
import path from "path";
|
|
import template from "../../../../common/template";
|
|
import { type Config, Platform } from "../../../../core/type";
|
|
import { Packer } from "../../../core/packer";
|
|
|
|
export class LinuxDEBPacker extends Packer {
|
|
static NAME = "deb";
|
|
|
|
constructor(config: Config) {
|
|
super(config, Platform.LINUX);
|
|
}
|
|
|
|
call() {
|
|
const target = this.targetPath;
|
|
const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian");
|
|
const icon = this.config.meta.icon!;
|
|
const iconfile = `${this.config.meta.filename}${path.extname(icon)}`;
|
|
const desktop = template.render("linux/app.desktop", { iconfile: iconfile, ...this.config });
|
|
fse.ensureDirSync(`${buildDir}/usr/share/applications`);
|
|
fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop);
|
|
fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`);
|
|
fse.copySync(icon, `${buildDir}/usr/share/${this.config.meta.filename}/${iconfile}`);
|
|
return gulp.src(`${buildDir}/*`).pipe(
|
|
deb({
|
|
package: this.config.meta.filename!,
|
|
version: this.config.meta.version!,
|
|
section: "base",
|
|
priority: "optional",
|
|
architecture: "all",
|
|
maintainer: this.config.meta.author,
|
|
description: this.config.meta.title,
|
|
changelog: [],
|
|
postinst: [
|
|
'if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ] ; then\n' +
|
|
" update-menus\n" +
|
|
"fi",
|
|
],
|
|
_target: "/",
|
|
_out: this.resolveTargetPath("debian"),
|
|
_clean: true,
|
|
_verbose: false,
|
|
}),
|
|
);
|
|
}
|
|
}
|
|
|
|
Packer.register(Platform.LINUX, LinuxDEBPacker.NAME, LinuxDEBPacker);
|