From 05baad598e1f69fabfa78558632d9481e67ca369 Mon Sep 17 00:00:00 2001 From: develar Date: Sun, 15 May 2016 17:06:42 +0200 Subject: [PATCH] feat(linux): Install libappindicator1 and libnotify as a dependency of the linux package --- .idea/dictionaries/develar.xml | 2 ++ docs/Options.md | 1 + package.json | 4 ++-- src/linuxPackager.ts | 17 +++++++++++++++++ src/metadata.ts | 5 +++++ test/src/helpers/packTester.ts | 7 +++++-- test/src/linuxPackagerTest.ts | 22 ++++++++++++++++++---- 7 files changed, 50 insertions(+), 8 deletions(-) diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml index b1c442d8da3..d5b950c11cf 100644 --- a/.idea/dictionaries/develar.xml +++ b/.idea/dictionaries/develar.xml @@ -20,7 +20,9 @@ globaldots globby hicolor + libappindicator libgcrypt + libnotify lzma makedeb mkdirp diff --git a/docs/Options.md b/docs/Options.md index ec953e67324..e19a0508a67 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -105,6 +105,7 @@ MAS (Mac Application Store) specific options (in addition to `build.osx`). | maintainer | The maintainer. Defaults to [author](#AppMetadata-author). | vendor | The vendor. Defaults to [author](#AppMetadata-author). | compression | *deb-only.* The compression type, one of `gz`, `bzip2`, `xz` (default: `xz`). +| depends | Package dependencies. Defaults to `["libappindicator1", "libnotify"]`. ## `.directories` diff --git a/package.json b/package.json index 41a595fb0ac..1017cc7b678 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "debug": "^2.2.0", "deep-assign": "^2.0.0", "electron-osx-sign-tf": "0.4.0-beta.0", - "electron-packager-tf": "^7.0.2-beta.0", + "electron-packager-tf": "~7.1.0", "electron-winstaller-fixed": "~2.8.2", "fs-extra-p": "^1.0.1", "globby": "^4.0.0", @@ -107,7 +107,7 @@ "ts-babel": "^0.8.6", "tsconfig-glob": "^0.4.3", "tslint": "3.10.0-dev.1", - "typescript": "1.9.0-dev.20160513", + "typescript": "1.9.0-dev.20160515", "whitespace": "^2.0.0" }, "babel": { diff --git a/src/linuxPackager.ts b/src/linuxPackager.ts index bc968461272..518701102d6 100755 --- a/src/linuxPackager.ts +++ b/src/linuxPackager.ts @@ -214,6 +214,23 @@ Icon=${this.metadata.name} "--url", projectUrl, ] + let depends = options.depends + if (depends == null) { + depends = ["libappindicator1", "libnotify"] + } + else if (!Array.isArray(depends)) { + if (typeof depends === "string") { + depends = [depends] + } + else { + throw new Error(`depends must be Array or String, but specified as: ${depends}`) + } + } + + for (let dep of depends) { + args.push("--depends", dep) + } + use(this.metadata.license || this.devMetadata.license, it => args.push("--license", it!)) use(this.computeBuildNumber(), it => args.push("--iteration", it!)) diff --git a/src/metadata.ts b/src/metadata.ts index eb0cb011202..ab6f8d609b8 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -283,6 +283,11 @@ export interface LinuxBuildOptions { *deb-only.* The compression type, one of `gz`, `bzip2`, `xz` (default: `xz`). */ readonly compression?: string | null + + /* + Package dependencies. Defaults to `["libappindicator1", "libnotify"]`. + */ + readonly depends?: string[] | null } /* diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index 0d2835ccc01..e01b02a6b74 100755 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -28,6 +28,8 @@ interface AssertPackOptions { readonly packed?: (projectDir: string) => Promise readonly expectedContents?: Array readonly expectedArtifacts?: Array + + readonly expectedDepends?: string } export async function assertPack(fixtureName: string, packagerOptions: PackagerOptions, checkOptions?: AssertPackOptions): Promise { @@ -104,7 +106,7 @@ async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions await checkOsXResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.OSX)) } else if (platform === Platform.LINUX) { - await checkLinuxResult(projectDir, packager, packagerOptions) + await checkLinuxResult(projectDir, packager, packagerOptions, checkOptions) } else if (platform === Platform.WINDOWS) { await checkWindowsResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.WINDOWS)) @@ -112,7 +114,7 @@ async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions } } -async function checkLinuxResult(projectDir: string, packager: Packager, packagerOptions: PackagerOptions) { +async function checkLinuxResult(projectDir: string, packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions) { const productName = getProductName(packager.metadata, packager.devMetadata) const expectedContents = expectedLinuxContents.map(it => { if (it === "/opt/TestApp/TestApp") { @@ -142,6 +144,7 @@ async function checkLinuxResult(projectDir: string, packager: Packager, packager Vendor: "Foo Bar ", Package: "testapp", Description: " \n Test Application (test quite \" #378)", + Depends: checkOptions == null || checkOptions.expectedDepends == null ? "libappindicator1, libnotify" : checkOptions.expectedDepends, }) } diff --git a/test/src/linuxPackagerTest.ts b/test/src/linuxPackagerTest.ts index b17221f0e60..1d853c86880 100755 --- a/test/src/linuxPackagerTest.ts +++ b/test/src/linuxPackagerTest.ts @@ -9,11 +9,25 @@ const __awaiter = require("out/awaiter") test.ifNotWindows("linux", () => assertPack("test-app-one", platform(Platform.LINUX))) -test.ifNotWindows("linux - icons from ICNS", async () => { - await assertPack("test-app-one", { +test.ifNotWindows("icons from ICNS", () => assertPack("test-app-one", { + platform: [Platform.LINUX], +}, { + tempDirCreated: it => remove(path.join(it, "build", "icons")) +})) + +test.ifNotWindows("custom configuration", () => assertPack("test-app-one", { platform: [Platform.LINUX], - }, {tempDirCreated: (projectDir) => remove(path.join(projectDir, "build", "icons"))}) -}) + devMetadata: { + build: { + linux: { + depends: ["foo"], + } + } + } + }, + { + expectedDepends: "foo" + })) test.ifNotWindows("no-author-email", t => { t.throws(assertPack("test-app-one", platform(Platform.LINUX), {