Skip to content

Commit

Permalink
feat(linux): Install libappindicator1 and libnotify as a dependency o…
Browse files Browse the repository at this point in the history
…f the linux package
  • Loading branch information
develar committed May 15, 2016
1 parent 153e857 commit 05baad5
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ MAS (Mac Application Store) specific options (in addition to `build.osx`).
| maintainer | <a name="LinuxBuildOptions-maintainer"></a>The maintainer. Defaults to [author](#AppMetadata-author).
| vendor | <a name="LinuxBuildOptions-vendor"></a>The vendor. Defaults to [author](#AppMetadata-author).
| compression | <a name="LinuxBuildOptions-compression"></a>*deb-only.* The compression type, one of `gz`, `bzip2`, `xz` (default: `xz`).
| depends | <a name="LinuxBuildOptions-depends"></a>Package dependencies. Defaults to `["libappindicator1", "libnotify"]`.

<a name="MetadataDirectories"></a>
## `.directories`
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
17 changes: 17 additions & 0 deletions src/linuxPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [<string>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!))

Expand Down
5 changes: 5 additions & 0 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/*
Expand Down
7 changes: 5 additions & 2 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ interface AssertPackOptions {
readonly packed?: (projectDir: string) => Promise<any>
readonly expectedContents?: Array<string>
readonly expectedArtifacts?: Array<string>

readonly expectedDepends?: string
}

export async function assertPack(fixtureName: string, packagerOptions: PackagerOptions, checkOptions?: AssertPackOptions): Promise<void> {
Expand Down Expand Up @@ -104,15 +106,15 @@ 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))
}
}
}

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") {
Expand Down Expand Up @@ -142,6 +144,7 @@ async function checkLinuxResult(projectDir: string, packager: Packager, packager
Vendor: "Foo Bar <foo@example.com>",
Package: "testapp",
Description: " \n Test Application (test quite \" #378)",
Depends: checkOptions == null || checkOptions.expectedDepends == null ? "libappindicator1, libnotify" : checkOptions.expectedDepends,
})
}

Expand Down
22 changes: 18 additions & 4 deletions test/src/linuxPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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), {
Expand Down

0 comments on commit 05baad5

Please sign in to comment.