Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deb package description according to spec #328

Merged
merged 1 commit into from
Apr 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ install:
- node -v
- npm -v
- npm prune
- npm install Microsoft/TypeScript
- npm install

build: off
Expand Down
15 changes: 10 additions & 5 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,24 @@ Here documented only `electron-builder` specific options:
| --- | ---
| **name** | <a name="AppMetadata-name"></a>The application name.
| productName | <a name="AppMetadata-productName"></a><p>As [name](#AppMetadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name}).</p>
| **description** | <a name="AppMetadata-description"></a>The application description.

<a name="DevMetadata"></a>
# Development `package.json`
| Name | Description
| --- | ---
| homepage | <a name="DevMetadata-homepage"></a><p>The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package <code>projectUrl</code> (optional) or Linux Package URL (required)).</p> <p>If not specified and your project repository is public on GitHub, it will be <code>https://github.com/${user}/${project}</code> by default.</p>
| license | <a name="DevMetadata-license"></a>*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name for this package.
| **build** | <a name="DevMetadata-build"></a>See [.build](#BuildMetadata).
| homepage | <a name="DevMetadata-homepage"></a><p>The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package <code>projectUrl</code> (optional) or Linux Package URL (required)).</p> <p>If not specified and your project repository is public on GitHub, it will be <code>https://github.com/${user}/${project}</code> by default.</p>
| license | <a name="DevMetadata-license"></a>*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
| directories | <a name="DevMetadata-directories"></a>See [.directories](#MetadataDirectories)

<a name="BuildMetadata"></a>
## `.build`
| Name | Description
| --- | ---
| **app-bundle-id** | <a name="BuildMetadata-app-bundle-id"></a>The bundle identifier to use in the application's plist.
| **app-category-type** | <a name="BuildMetadata-app-category-type"></a><p>The application category type, as shown in the Finder via *View -&gt; Arrange by Application Category* when viewing the Applications directory.</p> <p>For example, <code>app-category-type=public.app-category.developer-tools</code> will set the application category to *Developer Tools*.</p> <p>Valid values are listed in [Apple’s documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8).</p>
| **iconUrl** | <a name="BuildMetadata-iconUrl"></a><p>*windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel &gt; Programs and Features). Defaults to the Electron icon.</p> <p>Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.</p> <ul> <li>If you don’t plan to build windows installer, you can omit it.</li> <li>If your project repository is public on GitHub, it will be <code>https://raw.githubusercontent.com/${user}/${project}/master/build/icon.ico</code> by default.</li> </ul>
| app-bundle-id | <a name="BuildMetadata-app-bundle-id"></a>*OS X-only.* The bundle identifier to use in the application's plist.
| app-category-type | <a name="BuildMetadata-app-category-type"></a><p>*OS X-only.* The application category type, as shown in the Finder via *View -&gt; Arrange by Application Category* when viewing the Applications directory.</p> <p>For example, <code>app-category-type=public.app-category.developer-tools</code> will set the application category to *Developer Tools*.</p> <p>Valid values are listed in [Apple’s documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8).</p>
| iconUrl | <a name="BuildMetadata-iconUrl"></a><p>*windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel &gt; Programs and Features). Defaults to the Electron icon.</p> <p>Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.</p> <ul> <li>If you don’t plan to build windows installer, you can omit it.</li> <li>If your project repository is public on GitHub, it will be <code>https://raw.githubusercontent.com/${user}/${project}/master/build/icon.ico</code> by default.</li> </ul>
| productName | <a name="BuildMetadata-productName"></a>See [AppMetadata.productName](#AppMetadata-productName).
| extraResources | <a name="BuildMetadata-extraResources"></a><p>A [glob expression](https://www.npmjs.com/package/glob#glob-primer), when specified, copy the file or directory with matching names directly into the app’s directory (<code>Contents/Resources</code> for OS X).</p> <p>You can use <code>${os}</code> (expanded to osx, linux or win according to current platform) and <code>${arch}</code> in the pattern.</p> <p>If directory matched, all contents are copied. So, you can just specify <code>foo</code> to copy <code>&lt;project_dir&gt;/foo</code> directory.</p> <p>May be specified in the platform options (i.e. in the <code>build.osx</code>).</p>
| osx | <a name="BuildMetadata-osx"></a>See [.build.osx](#OsXBuildOptions).
Expand Down Expand Up @@ -83,6 +84,10 @@ See all [windows-installer options](https://github.com/electron/windows-installe
### `.build.linux`
| Name | Description
| --- | ---
| description | <a name="LinuxBuildOptions-description"></a>As [description](#AppMetadata-description) from application package.json, but allows you to specify different for Linux.
| synopsis | <a name="LinuxBuildOptions-synopsis"></a>*deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description).
| 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`).

<a name="MetadataDirectories"></a>
Expand Down
12 changes: 8 additions & 4 deletions src/linuxPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class LinuxPackager extends PlatformPackager<LinuxBuildOptions> {

this.debOptions = Object.assign({
name: this.metadata.name,
comment: this.metadata.description,
description: this.metadata.description,
}, this.customBuildOptions)

if (this.options.dist) {
Expand Down Expand Up @@ -57,7 +57,7 @@ export class LinuxPackager extends PlatformPackager<LinuxBuildOptions> {
const tempFile = path.join(tempDir, this.appName + ".desktop")
await outputFile(tempFile, this.debOptions.desktop || `[Desktop Entry]
Name=${this.appName}
Comment=${this.debOptions.comment}
Comment=${this.debOptions.description}
Exec="${this.appName}"
Terminal=false
Type=Application
Expand Down Expand Up @@ -172,6 +172,7 @@ Icon=${this.metadata.name}
throw new Error("Please specify project homepage")
}

const author = options.maintainer || `${this.metadata.author.name} <${this.metadata.author.email}>`
const args = [
"-s", "dir",
"-t", target,
Expand All @@ -181,8 +182,9 @@ Icon=${this.metadata.name}
"--force",
"--after-install", scripts[0],
"--after-remove", scripts[1],
"--description", options.comment,
"--maintainer", options.maintainer || `${this.metadata.author.name} <${this.metadata.author.email}>`,
"--description", `${options.synopsis || ""}\n ${this.debOptions.description}`,
"--maintainer", author,
"--vendor", options.vendor || author,
"--version", this.metadata.version,
"--package", destination,
"--deb-compression", options.compression || (this.devMetadata.build.compression === "store" ? "gz" : "xz"),
Expand All @@ -192,6 +194,8 @@ Icon=${this.metadata.name}
use(this.devMetadata.license, it => args.push("--license", it))
use(this.computeBuildNumber(), it => args.push("--iteration", it))

use(options.fpm, it => args.push(...it))

args.push(`${appOutDir}/=/opt/${this.appName}`)
args.push(...(await this.packageFiles))
await exec("fpm", args)
Expand Down
51 changes: 37 additions & 14 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export interface AppMetadata extends Metadata {
*/
readonly productName?: string

/*
The application description.
*/
readonly description: string

readonly author: AuthorMetadata
Expand All @@ -28,6 +31,11 @@ export interface AppMetadata extends Metadata {
# Development `package.json`
*/
export interface DevMetadata extends Metadata {
/*
See [.build](#BuildMetadata).
*/
readonly build: BuildMetadata

/*
The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package `projectUrl` (optional) or Linux Package URL (required)).

Expand All @@ -36,15 +44,10 @@ export interface DevMetadata extends Metadata {
readonly homepage?: string

/*
*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name for this package.
*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
*/
readonly license?: string

/*
See [.build](#BuildMetadata).
*/
readonly build: BuildMetadata

/*
See [.directories](#MetadataDirectories)
*/
Expand All @@ -65,17 +68,17 @@ export interface AuthorMetadata {
*/
export interface BuildMetadata {
/*
The bundle identifier to use in the application's plist.
*OS X-only.* The bundle identifier to use in the application's plist.
*/
readonly "app-bundle-id": string
readonly "app-bundle-id"?: string
/*
The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory.
*OS X-only.* The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory.

For example, `app-category-type=public.app-category.developer-tools` will set the application category to *Developer Tools*.

Valid values are listed in [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8).
*/
readonly "app-category-type": string
readonly "app-category-type"?: string

/*
*windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Electron icon.
Expand All @@ -85,7 +88,7 @@ export interface BuildMetadata {
* If you don't plan to build windows installer, you can omit it.
* If your project repository is public on GitHub, it will be `https://raw.githubusercontent.com/${user}/${project}/master/build/icon.ico` by default.
*/
readonly iconUrl: string
readonly iconUrl?: string

/*
See [AppMetadata.productName](#AppMetadata-productName).
Expand Down Expand Up @@ -122,6 +125,8 @@ export interface BuildMetadata {
The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly.
*/
readonly compression?: "store" | "normal" | "maximum"

readonly "build-version": string
}

/*
Expand Down Expand Up @@ -169,10 +174,28 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions {
### `.build.linux`
*/
export interface LinuxBuildOptions {
name: string
comment: string
/*
As [description](#AppMetadata-description) from application package.json, but allows you to specify different for Linux.
*/
description?: string

/*
*deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description).
*/
synopsis?: string

/*
The maintainer. Defaults to [author](#AppMetadata-author).
*/
maintainer?: string

/*
The vendor. Defaults to [author](#AppMetadata-author).
*/
vendor?: string

maintainer: string
// should be not documented, only to experiment
fpm?: string[]

//.desktop file template
desktop?: string
Expand Down
3 changes: 1 addition & 2 deletions src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
return null
}

//noinspection JSMethodCanBeStatic
protected computeBuildNumber(): string {
return process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM
return this.devMetadata.build["build-version"] || process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM
}
}

Expand Down
31 changes: 22 additions & 9 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,35 @@ async function checkLinuxResult(projectDir: string, packager: Packager, packager
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-1.1.0-i386.deb`, productName)).deepEqual(expectedContents)
}

const regexp = /^ *(\w+): *(.+)$/gm
const info = (await exec("dpkg", ["--info", packageFile])).toString()
let match: Array<string>
const metadata: any = {}
while ((match = regexp.exec(info)) !== null) {
metadata[match[1]] = match[2]
}
assertThat(metadata).has.properties({
assertThat(parseDebControl((await exec("dpkg", ["--info", packageFile])).toString())).has.properties({
License: "MIT",
Homepage: "http://foo.example.com",
Maintainer: "Foo Bar <[email protected]>",
Vendor: "Foo Bar <[email protected]>",
Package: "testapp",
Description: "Test Application",
Description: " \n Test Application",
})
}

function parseDebControl(info: string): any {
const regexp = /([\w]+): *(.+\n)([^:\n]+\n)?/g
let match: Array<string>
const metadata: any = {}
info = info.substring(info.indexOf("Package:"))
while ((match = regexp.exec(info)) !== null) {
let value = match[2]
if (match[3] != null) {
value += match[3]
}

if (value[value.length - 1] == "\n") {
value = value.substring(0, value.length - 1)
}
metadata[match[1]] = value
}
return metadata
}

async function checkOsXResult(packager: Packager, artifacts: Array<ArtifactCreated>) {
const productName = getProductName(packager.metadata, packager.devMetadata)
const packedAppDir = path.join(path.dirname(artifacts[0].file), (productName || packager.metadata.name) + ".app")
Expand Down
1 change: 1 addition & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
],
"no-use-before-declare": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-var-keyword": true,
"one-line": [
true,
Expand Down