forked from electron-userland/electron-builder
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Linux deb — specify license, package url electron-userland#242
- Loading branch information
Showing
12 changed files
with
155 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ install: | |
- node -v | ||
- npm -v | ||
- npm prune | ||
- npm install Microsoft/TypeScript | ||
- npm install | ||
|
||
build: off | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { Packager } from "./packager" | ||
export { PackagerOptions, ArtifactCreated } from "./platformPackager" | ||
export { BuildOptions, build, createPublisher } from "./builder" | ||
export { AppMetadata, DevMetadata, Platform, getProductName } from "./metadata" | ||
export { AppMetadata, DevMetadata, Platform, getProductName, BuildMetadata, DebOptions } from "./metadata" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"start": "electron ." | ||
}, | ||
"author": "Foo Bar <[email protected]>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"electron-prebuilt": "^0.37.3" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,33 +106,53 @@ async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions | |
await checkOsXResult(packager, artifacts.get(Platform.OSX)) | ||
} | ||
else if (platform === "linux") { | ||
const productName = getProductName(packager.metadata, packager.devMetadata) | ||
const expectedContents = expectedLinuxContents.map(it => { | ||
if (it === "/opt/TestApp/TestApp") { | ||
return "/opt/" + productName + "/" + productName | ||
} | ||
else if (it === "/usr/share/applications/TestApp.desktop") { | ||
return `/usr/share/applications/${productName}.desktop` | ||
} | ||
else { | ||
return it.replace(new RegExp("/opt/TestApp/", "g"), `/opt/${productName}/`) | ||
} | ||
}) | ||
|
||
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName), null, 2)) | ||
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName), null, 2)) | ||
|
||
assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName)).deepEqual(expectedContents) | ||
if (packagerOptions.arch === "all" || packagerOptions.arch === "ia32") { | ||
assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName)).deepEqual(expectedContents) | ||
} | ||
await checkLinuxResult(projectDir, packager, packagerOptions) | ||
} | ||
else if (platform === "win32") { | ||
await checkWindowsResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.WINDOWS)) | ||
} | ||
} | ||
} | ||
|
||
async function checkLinuxResult(projectDir: string, packager: Packager, packagerOptions: PackagerOptions) { | ||
const productName = getProductName(packager.metadata, packager.devMetadata) | ||
const expectedContents = expectedLinuxContents.map(it => { | ||
if (it === "/opt/TestApp/TestApp") { | ||
return "/opt/" + productName + "/" + productName | ||
} | ||
else if (it === "/usr/share/applications/TestApp.desktop") { | ||
return `/usr/share/applications/${productName}.desktop` | ||
} | ||
else { | ||
return it.replace(new RegExp("/opt/TestApp/", "g"), `/opt/${productName}/`) | ||
} | ||
}) | ||
|
||
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb", productName), null, 2)) | ||
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName), null, 2)) | ||
|
||
const packageFile = projectDir + "/dist/TestApp-1.0.0-amd64.deb" | ||
assertThat(await getContents(packageFile, productName)).deepEqual(expectedContents) | ||
if (packagerOptions.arch === "all" || packagerOptions.arch === "ia32") { | ||
assertThat(await getContents(projectDir + "/dist/TestApp-1.0.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({ | ||
License: "MIT", | ||
Homepage: "http://foo.example.com", | ||
Maintainer: "Foo Bar <[email protected]>", | ||
Package: "testapp", | ||
Description: "Test Application", | ||
}) | ||
} | ||
|
||
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") | ||
|