Skip to content

Commit 3c6ec3f

Browse files
committed
fix: deb package description according to spec
Closes #327
1 parent c866084 commit 3c6ec3f

File tree

7 files changed

+79
-35
lines changed

7 files changed

+79
-35
lines changed

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ install:
1212
- node -v
1313
- npm -v
1414
- npm prune
15-
- npm install Microsoft/TypeScript
1615
- npm install
1716

1817
build: off

docs/Options.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,24 @@ Here documented only `electron-builder` specific options:
3535
| --- | ---
3636
| **name** | <a name="AppMetadata-name"></a>The application name.
3737
| 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>
38+
| **description** | <a name="AppMetadata-description"></a>The application description.
3839

3940
<a name="DevMetadata"></a>
4041
# Development `package.json`
4142
| Name | Description
4243
| --- | ---
43-
| 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>
44-
| license | <a name="DevMetadata-license"></a>*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name for this package.
4544
| **build** | <a name="DevMetadata-build"></a>See [.build](#BuildMetadata).
45+
| 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>
46+
| license | <a name="DevMetadata-license"></a>*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
4647
| directories | <a name="DevMetadata-directories"></a>See [.directories](#MetadataDirectories)
4748

4849
<a name="BuildMetadata"></a>
4950
## `.build`
5051
| Name | Description
5152
| --- | ---
52-
| **app-bundle-id** | <a name="BuildMetadata-app-bundle-id"></a>The bundle identifier to use in the application's plist.
53-
| **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>
54-
| **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>
53+
| app-bundle-id | <a name="BuildMetadata-app-bundle-id"></a>*OS X-only.* The bundle identifier to use in the application's plist.
54+
| 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>
55+
| 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>
5556
| productName | <a name="BuildMetadata-productName"></a>See [AppMetadata.productName](#AppMetadata-productName).
5657
| 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>
5758
| osx | <a name="BuildMetadata-osx"></a>See [.build.osx](#OsXBuildOptions).
@@ -83,6 +84,10 @@ See all [windows-installer options](https://github.com/electron/windows-installe
8384
### `.build.linux`
8485
| Name | Description
8586
| --- | ---
87+
| description | <a name="LinuxBuildOptions-description"></a>As [description](#AppMetadata-description) from application package.json, but allows you to specify different for Linux.
88+
| synopsis | <a name="LinuxBuildOptions-synopsis"></a>*deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description).
89+
| maintainer | <a name="LinuxBuildOptions-maintainer"></a>The maintainer. Defaults to [author](#AppMetadata-author).
90+
| vendor | <a name="LinuxBuildOptions-vendor"></a>The vendor. Defaults to [author](#AppMetadata-author).
8691
| compression | <a name="LinuxBuildOptions-compression"></a>*deb-only.* The compression type, one of `gz`, `bzip2`, `xz` (default: `xz`).
8792

8893
<a name="MetadataDirectories"></a>

src/linuxPackager.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class LinuxPackager extends PlatformPackager<LinuxBuildOptions> {
2323

2424
this.debOptions = Object.assign({
2525
name: this.metadata.name,
26-
comment: this.metadata.description,
26+
description: this.metadata.description,
2727
}, this.customBuildOptions)
2828

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

175+
const author = options.maintainer || `${this.metadata.author.name} <${this.metadata.author.email}>`
175176
const args = [
176177
"-s", "dir",
177178
"-t", target,
@@ -181,8 +182,9 @@ Icon=${this.metadata.name}
181182
"--force",
182183
"--after-install", scripts[0],
183184
"--after-remove", scripts[1],
184-
"--description", options.comment,
185-
"--maintainer", options.maintainer || `${this.metadata.author.name} <${this.metadata.author.email}>`,
185+
"--description", `${options.synopsis || ""}\n ${this.debOptions.description}`,
186+
"--maintainer", author,
187+
"--vendor", options.vendor || author,
186188
"--version", this.metadata.version,
187189
"--package", destination,
188190
"--deb-compression", options.compression || (this.devMetadata.build.compression === "store" ? "gz" : "xz"),
@@ -192,6 +194,8 @@ Icon=${this.metadata.name}
192194
use(this.devMetadata.license, it => args.push("--license", it))
193195
use(this.computeBuildNumber(), it => args.push("--iteration", it))
194196

197+
use(options.fpm, it => args.push(...it))
198+
195199
args.push(`${appOutDir}/=/opt/${this.appName}`)
196200
args.push(...(await this.packageFiles))
197201
await exec("fpm", args)

src/metadata.ts

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export interface AppMetadata extends Metadata {
1919
*/
2020
readonly productName?: string
2121

22+
/*
23+
The application description.
24+
*/
2225
readonly description: string
2326

2427
readonly author: AuthorMetadata
@@ -28,6 +31,11 @@ export interface AppMetadata extends Metadata {
2831
# Development `package.json`
2932
*/
3033
export interface DevMetadata extends Metadata {
34+
/*
35+
See [.build](#BuildMetadata).
36+
*/
37+
readonly build: BuildMetadata
38+
3139
/*
3240
The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package `projectUrl` (optional) or Linux Package URL (required)).
3341
@@ -36,15 +44,10 @@ export interface DevMetadata extends Metadata {
3644
readonly homepage?: string
3745

3846
/*
39-
*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name for this package.
47+
*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
4048
*/
4149
readonly license?: string
4250

43-
/*
44-
See [.build](#BuildMetadata).
45-
*/
46-
readonly build: BuildMetadata
47-
4851
/*
4952
See [.directories](#MetadataDirectories)
5053
*/
@@ -65,17 +68,17 @@ export interface AuthorMetadata {
6568
*/
6669
export interface BuildMetadata {
6770
/*
68-
The bundle identifier to use in the application's plist.
71+
*OS X-only.* The bundle identifier to use in the application's plist.
6972
*/
70-
readonly "app-bundle-id": string
73+
readonly "app-bundle-id"?: string
7174
/*
72-
The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory.
75+
*OS X-only.* The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory.
7376
7477
For example, `app-category-type=public.app-category.developer-tools` will set the application category to *Developer Tools*.
7578
7679
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).
7780
*/
78-
readonly "app-category-type": string
81+
readonly "app-category-type"?: string
7982

8083
/*
8184
*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.
@@ -85,7 +88,7 @@ export interface BuildMetadata {
8588
* If you don't plan to build windows installer, you can omit it.
8689
* If your project repository is public on GitHub, it will be `https://raw.githubusercontent.com/${user}/${project}/master/build/icon.ico` by default.
8790
*/
88-
readonly iconUrl: string
91+
readonly iconUrl?: string
8992

9093
/*
9194
See [AppMetadata.productName](#AppMetadata-productName).
@@ -122,6 +125,8 @@ export interface BuildMetadata {
122125
The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly.
123126
*/
124127
readonly compression?: "store" | "normal" | "maximum"
128+
129+
readonly "build-version": string
125130
}
126131

127132
/*
@@ -169,10 +174,28 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions {
169174
### `.build.linux`
170175
*/
171176
export interface LinuxBuildOptions {
172-
name: string
173-
comment: string
177+
/*
178+
As [description](#AppMetadata-description) from application package.json, but allows you to specify different for Linux.
179+
*/
180+
description?: string
181+
182+
/*
183+
*deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description).
184+
*/
185+
synopsis?: string
186+
187+
/*
188+
The maintainer. Defaults to [author](#AppMetadata-author).
189+
*/
190+
maintainer?: string
191+
192+
/*
193+
The vendor. Defaults to [author](#AppMetadata-author).
194+
*/
195+
vendor?: string
174196

175-
maintainer: string
197+
// should be not documented, only to experiment
198+
fpm?: string[]
176199

177200
//.desktop file template
178201
desktop?: string

src/platformPackager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
195195
return null
196196
}
197197

198-
//noinspection JSMethodCanBeStatic
199198
protected computeBuildNumber(): string {
200-
return process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM
199+
return this.devMetadata.build["build-version"] || process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM
201200
}
202201
}
203202

test/src/helpers/packTester.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,35 @@ async function checkLinuxResult(projectDir: string, packager: Packager, packager
137137
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-1.1.0-i386.deb`, productName)).deepEqual(expectedContents)
138138
}
139139

140-
const regexp = /^ *(\w+): *(.+)$/gm
141-
const info = (await exec("dpkg", ["--info", packageFile])).toString()
142-
let match: Array<string>
143-
const metadata: any = {}
144-
while ((match = regexp.exec(info)) !== null) {
145-
metadata[match[1]] = match[2]
146-
}
147-
assertThat(metadata).has.properties({
140+
assertThat(parseDebControl((await exec("dpkg", ["--info", packageFile])).toString())).has.properties({
148141
License: "MIT",
149142
Homepage: "http://foo.example.com",
150143
Maintainer: "Foo Bar <foo@example.com>",
144+
Vendor: "Foo Bar <foo@example.com>",
151145
Package: "testapp",
152-
Description: "Test Application",
146+
Description: " \n Test Application",
153147
})
154148
}
155149

150+
function parseDebControl(info: string): any {
151+
const regexp = /([\w]+): *(.+\n)([^:\n]+\n)?/g
152+
let match: Array<string>
153+
const metadata: any = {}
154+
info = info.substring(info.indexOf("Package:"))
155+
while ((match = regexp.exec(info)) !== null) {
156+
let value = match[2]
157+
if (match[3] != null) {
158+
value += match[3]
159+
}
160+
161+
if (value[value.length - 1] == "\n") {
162+
value = value.substring(0, value.length - 1)
163+
}
164+
metadata[match[1]] = value
165+
}
166+
return metadata
167+
}
168+
156169
async function checkOsXResult(packager: Packager, artifacts: Array<ArtifactCreated>) {
157170
const productName = getProductName(packager.metadata, packager.devMetadata)
158171
const packedAppDir = path.join(path.dirname(artifacts[0].file), (productName || packager.metadata.name) + ".app")

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
],
2727
"no-use-before-declare": true,
2828
"no-internal-module": true,
29+
"no-trailing-whitespace": true,
2930
"no-var-keyword": true,
3031
"one-line": [
3132
true,

0 commit comments

Comments
 (0)