diff --git a/src/platformPackager.ts b/src/platformPackager.ts index d34ddb61d65..1e96aef01ca 100644 --- a/src/platformPackager.ts +++ b/src/platformPackager.ts @@ -635,4 +635,8 @@ export async function getResolvedPublishConfig(packager: BuildInfo, publishConfi else { return null } +} + +export function toDebArch(arch: Arch) { + return arch === Arch.ia32 ? "i386" : "amd64" } \ No newline at end of file diff --git a/src/targets/LinuxTargetHelper.ts b/src/targets/LinuxTargetHelper.ts index e05d0af87c7..7656e7a5668 100644 --- a/src/targets/LinuxTargetHelper.ts +++ b/src/targets/LinuxTargetHelper.ts @@ -67,11 +67,10 @@ export class LinuxTargetHelper { return options.description || this.packager.appInfo.description } - async computeDesktopEntry(platformSpecificBuildOptions: LinuxBuildOptions, exec?: string, extra?: { [key: string]: string; }): Promise { + async computeDesktopEntry(platformSpecificBuildOptions: LinuxBuildOptions, exec?: string, destination?: string | null, extra?: { [key: string]: string; }): Promise { const appInfo = this.packager.appInfo const productFilename = appInfo.productFilename - const tempFile = await this.packager.getTempFile(`${productFilename}.desktop`) const desktopMeta: any = Object.assign({ Name: appInfo.productName, @@ -80,6 +79,7 @@ export class LinuxTargetHelper { Terminal: "false", Type: "Application", Icon: appInfo.name, + StartupWMClass: `"${productFilename}"`, }, extra, platformSpecificBuildOptions.desktop) const category = platformSpecificBuildOptions.category @@ -94,6 +94,7 @@ export class LinuxTargetHelper { } data += "\n" + const tempFile = destination || await this.packager.getTempFile(`${productFilename}.desktop`) await outputFile(tempFile, data) return tempFile } diff --git a/src/targets/appImage.ts b/src/targets/appImage.ts index 6b2bc167795..814e52a782b 100644 --- a/src/targets/appImage.ts +++ b/src/targets/appImage.ts @@ -25,7 +25,7 @@ export default class AppImageTarget extends Target { // we add X-AppImage-BuildId to ensure that new desktop file will be installed this.desktopEntry = BluebirdPromise.promisify(uuid1)({mac: false}) - .then(uuid => helper.computeDesktopEntry(this.options, "AppRun", { + .then(uuid => helper.computeDesktopEntry(this.options, "AppRun", null, { "X-AppImage-Version": `${packager.appInfo.buildVersion}`, "X-AppImage-BuildId": uuid, })) @@ -65,7 +65,7 @@ export default class AppImageTarget extends Target { args.push("-zisofs", `level=${packager.devMetadata.build.compression === "store" ? "0" : "9"}:block_size=128k:by_magic=off`) args.push("set_filter_r", "--zisofs", "/") - await exec(process.env.USE_SYSTEM_FPM === "true" || process.arch !== "x64" ? "xorriso" : path.join(appImagePath, "xorriso"), args) + await exec(process.arch === "x64" ? path.join(appImagePath, "xorriso") : "xorriso", args) await new BluebirdPromise((resolve, reject) => { const rd = createReadStream(path.join(appImagePath, arch === Arch.ia32 ? "32" : "64", "runtime")) @@ -87,6 +87,6 @@ export default class AppImageTarget extends Target { await chmod(resultFile, "0755") - packager.dispatchArtifactCreated(resultFile, packager.generateName("AppImage", arch, true)) + packager.dispatchArtifactCreated(resultFile) } } \ No newline at end of file diff --git a/src/targets/snap.ts b/src/targets/snap.ts index 6b8bb6b54a8..8588f867c07 100644 --- a/src/targets/snap.ts +++ b/src/targets/snap.ts @@ -1,24 +1,20 @@ -import { Target } from "../platformPackager" +import { Target, toDebArch } from "../platformPackager" import { Arch } from "../metadata" import { LinuxTargetHelper } from "./LinuxTargetHelper" import { LinuxPackager } from "../linuxPackager" import { log } from "../util/log" import { SnapOptions } from "../options/linuxOptions" -import { emptyDir, writeFile } from "fs-extra-p" +import { emptyDir, writeFile, rename, copy } from "fs-extra-p" import * as path from "path" import { safeDump } from "js-yaml" -import { spawn, unlinkIfExists } from "../util/util" +import { spawn } from "../util/util" import { homedir } from "os" export default class SnapTarget extends Target { private readonly options: SnapOptions = Object.assign({}, this.packager.platformSpecificBuildOptions, (this.packager.devMetadata.build)[this.name]) - private readonly desktopEntry: Promise constructor(private packager: LinuxPackager, private helper: LinuxTargetHelper, private outDir: string) { super("snap") - - // we add X-AppImage-BuildId to ensure that new desktop file will be installed - this.desktopEntry = helper.computeDesktopEntry(this.options, "AppRun") } async build(appOutDir: string, arch: Arch): Promise { @@ -28,8 +24,8 @@ export default class SnapTarget extends Target { const appInfo = packager.appInfo const options = this.options - const resultFile = path.join(this.outDir, packager.generateName("snap", arch, true)) - await unlinkIfExists(resultFile) + const snapDir = `${appOutDir}-snap` + await emptyDir(snapDir) const snap: any = {} snap.name = packager.executableName @@ -39,6 +35,12 @@ export default class SnapTarget extends Target { snap.confinement = options.confinement || "strict" snap.grade = options.grade || "stable" + await this.helper.icons + if (this.helper.maxIconPath != null) { + snap.icon = "setup/gui/icon.png" + await copy(this.helper.maxIconPath, path.join(snapDir, "setup", "gui", "icon.png")) + } + if (options.assumes != null) { if (!Array.isArray(options.assumes)) { throw new Error("snap.assumes must be an array of strings") @@ -46,8 +48,6 @@ export default class SnapTarget extends Target { snap.assumes = options.assumes } - const snapDir = `${appOutDir}-snap` - snap.apps = { [snap.name]: { command: `desktop-launch $SNAP/${packager.executableName}`, @@ -57,6 +57,10 @@ export default class SnapTarget extends Target { } } + await this.helper.computeDesktopEntry(this.options, "$snap.$app", path.join(snapDir, "setup", "gui", `${snap.name}.desktop`), { + "Icon": "${SNAP}/meta/gui/icon.png" + }) + const isUseDocker = process.platform !== "linux" snap.parts = { app: { @@ -64,22 +68,15 @@ export default class SnapTarget extends Target { "stage-packages": ["libappindicator1", "libdbusmenu-glib4", "libnotify4", "libunity9", "libgconf-2-4", "libnss3", "libxss1", "fontconfig-config", "libnotify-bin"], source: isUseDocker ? `/out/${path.basename(snapDir)}` : appOutDir, filesets: { - app: [`${appOutDir}/*`] + app: [`${appOutDir}/*`], }, after: ["desktop-glib-only"] } } const snapcraft = path.join(snapDir, "snapcraft.yaml") - await emptyDir(snapDir) await writeFile(snapcraft, safeDump(snap)) -// await writeFile(path.join(snapDir, "wrapper"), ` -// #!/bin/bash -// unset XDG_CONFIG_DIRS -// exec $SNAP/${packager.executableName} -// `) - // const args = ["snapcraft", path.relative(snapDir)] // snap /out/${path.basename(snapDir)} --output /out/${path.basename(resultFile)} if (isUseDocker) { @@ -100,6 +97,9 @@ export default class SnapTarget extends Target { }) } - packager.dispatchArtifactCreated(resultFile, packager.generateName("snap", arch, true)) + const snapName = `${snap.name}_${snap.version}_${toDebArch(arch)}.snap` + const resultFile = path.join(this.outDir, snapName) + await rename(path.join(snapDir, snapName), resultFile) + packager.dispatchArtifactCreated(resultFile) } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 0277d1cd96e..3fd5fccf9c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1155,9 +1155,9 @@ electron-download-tf@3.1.0: semver "^5.3.0" sumchecker "^1.2.0" -electron-macos-sign@1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/electron-macos-sign/-/electron-macos-sign-1.3.2.tgz#e7b6d0721fb3f4365f69c04d59f74d30354a5b47" +electron-macos-sign@^1.3.4: + version "1.3.4" + resolved "https://registry.yarnpkg.com/electron-macos-sign/-/electron-macos-sign-1.3.4.tgz#641e011f974b26879f05ac505dde94b86481376a" dependencies: bluebird "^3.4.6" compare-version "^0.1.2"