Skip to content

Commit

Permalink
feat: clear error if rpmbuild is not installed, update deps for deb a…
Browse files Browse the repository at this point in the history
…nd rpm
  • Loading branch information
develar committed Jun 26, 2019
1 parent ec937b2 commit c605b6a
Show file tree
Hide file tree
Showing 21 changed files with 102 additions and 178 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -34,7 +34,7 @@
"@types/debug": "^4.1.4",
"@types/is-ci": "^2.0.0",
"@types/semver": "^6.0.1",
"app-builder-bin": "3.0.1",
"app-builder-bin": "3.0.2",
"archiver": "^3.0.0",
"async-exit-hook": "^2.0.1",
"bluebird-lst": "^1.0.9",
Expand Down
1 change: 0 additions & 1 deletion packages/app-builder-lib/package.json
Expand Up @@ -42,7 +42,6 @@
"homepage": "https://github.com/electron-userland/electron-builder",
"dependencies": {
"7zip-bin": "~4.1.0",
"app-builder-bin": "3.0.1",
"async-exit-hook": "^2.0.1",
"bluebird-lst": "^1.0.9",
"chromium-pickle-js": "^0.2.0",
Expand Down
13 changes: 0 additions & 13 deletions packages/app-builder-lib/scheme.json
Expand Up @@ -1236,19 +1236,6 @@
"string"
]
},
"depends": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
]
},
"description": {
"description": "As [description](/configuration/configuration#Metadata-description) from application package.json, but allows you to specify different for Linux.",
"type": [
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/codeSign/windowsCodeSign.ts
Expand Up @@ -28,7 +28,7 @@ export interface WindowsSignOptions {
}

export interface WindowsSignTaskConfiguration extends WindowsSignOptions {
// set if output path differs from input (e.g. osslsigncode cannot sign file inplace)
// set if output path differs from input (e.g. osslsigncode cannot sign file in-place)
resultOutputPath?: string

hash: string
Expand Down
6 changes: 0 additions & 6 deletions packages/app-builder-lib/src/options/linuxOptions.ts
Expand Up @@ -21,12 +21,6 @@ export interface LinuxConfiguration extends CommonLinuxOptions, PlatformSpecific
*/
readonly vendor?: string | null

/**
* @deprecated
* @private
*/
readonly depends?: Array<string> | null

/**
* The executable name. Defaults to `productName`.
* Cannot be specified per target, allowed only in the `linux`.
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/packager.ts
Expand Up @@ -238,7 +238,7 @@ export class Packager {
}

try {
log.info({version: PACKAGE_VERSION}, "electron-builder")
log.info({version: PACKAGE_VERSION, os: require("os").release()}, "electron-builder")
}
catch (e) {
// error in dev mode without babel
Expand Down
83 changes: 34 additions & 49 deletions packages/app-builder-lib/src/targets/fpm.ts
@@ -1,20 +1,19 @@
import { path7za } from "7zip-bin"
import { appBuilderPath } from "app-builder-bin"
import { Arch, debug, exec, log, TmpDir, toLinuxArchString, use } from "builder-util"
import { smarten } from "../appInfo"
import { objectToArgs } from "../util/appBuilder"
import { computeEnv } from "../util/bundledTool"
import { Arch, debug, executeAppBuilder, log, TmpDir, toLinuxArchString, use } from "builder-util"
import { unlinkIfExists } from "builder-util/out/fs"
import { ensureDir, outputFile, readFile } from "fs-extra-p"
import * as path from "path"
import { DebOptions, LinuxTargetSpecificOptions } from ".."
import { smarten } from "../appInfo"
import { Target } from "../core"
import * as errorMessages from "../errorMessages"
import { LinuxPackager } from "../linuxPackager"
import { objectToArgs } from "../util/appBuilder"
import { computeEnv } from "../util/bundledTool"
import { isMacOsSierra } from "../util/macosVersion"
import { getTemplatePath } from "../util/pathManager"
import { installPrefix, LinuxTargetHelper } from "./LinuxTargetHelper"
import { fpmPath, getLinuxToolsPath } from "./tools"
import { getLinuxToolsPath } from "./tools"

interface FpmOptions {
maintainer: string | undefined
Expand Down Expand Up @@ -91,8 +90,6 @@ export default class FpmTarget extends Target {
}

async build(appOutDir: string, arch: Arch): Promise<any> {
const fpmMetaInfoOptions = await this.computeFpmMetaInfoOptions()

const target = this.name

// tslint:disable:no-invalid-template-strings
Expand Down Expand Up @@ -126,77 +123,60 @@ export default class FpmTarget extends Target {
const options = this.options
const synopsis = options.synopsis
const args = [
"-s", "dir",
"-t", target,
"--architecture", (target === "pacman" && arch === Arch.ia32) ? "i686" : toLinuxArchString(arch),
"--name", appInfo.linuxPackageName,
"--force",
"--after-install", scripts[0],
"--after-remove", scripts[1],
"--description", smarten(target === "rpm" ? this.helper.getDescription(options)! : `${synopsis || ""}\n ${this.helper.getDescription(options)}`),
"--version", appInfo.version,
"--package", artifactPath,
]

objectToArgs(args, fpmMetaInfoOptions as any)
objectToArgs(args, await this.computeFpmMetaInfoOptions() as any)

if (debug.enabled) {
args.push(
"--log", "debug",
"--debug")
args.push("--log", "debug")
}

const packageCategory = options.packageCategory
if (packageCategory != null) {
args.push("--category", packageCategory)
}

const compression = options.compression
if (target === "deb") {
args.push("--deb-compression", compression || "xz")
use((options as DebOptions).priority, it => args.push("--deb-priority", it!))
}
else if (target === "rpm") {
args.push("--rpm-compression", (compression === "xz" ? "xzmt" : compression) || "xzmt")
args.push("--rpm-os", "linux")

if (synopsis != null) {
args.push("--rpm-summary", smarten(synopsis))
}
}

// noinspection JSDeprecatedSymbols
let depends = options.depends || packager.platformSpecificBuildOptions.depends
if (depends == null) {
if (target === "deb") {
depends = ["gconf2", "gconf-service", "libnotify4", "libappindicator1", "libxtst6", "libnss3", "libxss1"]
}
else if (target === "pacman") {
// noinspection SpellCheckingInspection
depends = ["c-ares", "ffmpeg", "gtk3", "http-parser", "libevent", "libvpx", "libxslt", "libxss", "minizip", "nss", "re2", "snappy", "libnotify", "libappindicator-gtk2", "libappindicator-gtk3", "libappindicator-sharp"]
}
else if (target === "rpm") {
// noinspection SpellCheckingInspection
depends = ["libnotify", "libappindicator", "libXScrnSaver"]
}
else {
depends = []
}
const fpmConfiguration: FpmConfiguration = {
args, target,
}
else if (!Array.isArray(depends)) {
// noinspection SuspiciousTypeOfGuard
if (typeof depends === "string") {
depends = [depends as string]

if (options.compression != null) {
fpmConfiguration.compression = options.compression
}

// noinspection JSDeprecatedSymbols
const depends = options.depends
if (depends != null) {
if (Array.isArray(depends)) {
fpmConfiguration.customDepends = depends
}
else {
throw new Error(`depends must be Array or String, but specified as: ${depends}`)
// noinspection SuspiciousTypeOfGuard
if (typeof depends === "string") {
fpmConfiguration.customDepends = [depends as string]
}
else {
throw new Error(`depends must be Array or String, but specified as: ${depends}`)
}
}
}

for (const dep of depends) {
args.push("--depends", dep)
}

use(packager.info.metadata.license, it => args.push("--license", it!))
use(appInfo.buildNumber, it => args.push("--iteration", it!))

Expand All @@ -218,10 +198,8 @@ export default class FpmTarget extends Target {

const env = {
...process.env,
FPM_COMPRESS_PROGRAM: appBuilderPath,
SZA_PATH: path7za,
SZA_COMPRESSION_LEVEL: packager.compression === "store" ? "0" : "9",
SZA_ARCHIVE_TYPE: "xz",
}

// rpmbuild wants directory rpm with some default config files. Even if we can use dylibbundler, path to such config files are not changed (we need to replace in the binary)
Expand All @@ -233,12 +211,19 @@ export default class FpmTarget extends Target {
DYLD_LIBRARY_PATH: computeEnv(process.env.DYLD_LIBRARY_PATH, [path.join(linuxToolsPath, "lib")]),
})
}
await exec(await fpmPath.value, args, {env})
await executeAppBuilder(["fpm", "--configuration", JSON.stringify(fpmConfiguration)], undefined, {env})

await packager.dispatchArtifactCreated(artifactPath, this, arch)
}
}

interface FpmConfiguration {
target: string
args: Array<string>
customDepends?: Array<string>
compression?: string | null
}

async function writeConfigFile(tmpDir: TmpDir, templatePath: string, options: any): Promise<string> {
//noinspection JSUnusedLocalSymbols
function replacer(match: string, p1: string) {
Expand Down
19 changes: 1 addition & 18 deletions packages/app-builder-lib/src/targets/tools.ts
@@ -1,23 +1,6 @@
import { getBin, getBinFromUrl } from "../binDownload"
import { Lazy } from "lazy-val"
import * as path from "path"
import { getBinFromUrl } from "../binDownload"

export function getLinuxToolsPath() {
//noinspection SpellCheckingInspection
return getBinFromUrl("linux-tools", "mac-10.12.3", "SQ8fqIRVXuQVWnVgaMTDWyf2TLAJjJYw3tRSqQJECmgF6qdM7Kogfa6KD49RbGzzMYIFca9Uw3MdsxzOPRWcYw==")
}

export const fpmPath = new Lazy(() => {
if (process.platform === "win32" || process.env.USE_SYSTEM_FPM === "true") {
return Promise.resolve("fpm")
}

return getBin("fpm")
.then(it => path.join(it, "fpm"))
})

// noinspection JSUnusedGlobalSymbols
export function prefetchBuildTools(): Promise<any> {
// yes, we starting to use native Promise
return fpmPath.value
}
2 changes: 1 addition & 1 deletion packages/builder-util/package.json
Expand Up @@ -11,7 +11,7 @@
"out"
],
"dependencies": {
"app-builder-bin": "3.0.1",
"app-builder-bin": "3.0.2",
"temp-file": "^3.3.3",
"fs-extra-p": "^8.0.2",
"is-ci": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/builder-util/src/log.ts
Expand Up @@ -82,8 +82,8 @@ export class Logger {
return message
}

const fieldPadding = " ".repeat(Math.max(1, 16 - message.length))
let text = message + fieldPadding
const fieldPadding = " ".repeat(Math.max(2, 16 - message.length))
let text = (level === "error" ? color(message) : message) + fieldPadding
const fieldNames = Object.keys(fields)
let counter = 0
for (const name of fieldNames) {
Expand Down
27 changes: 7 additions & 20 deletions test/out/linux/__snapshots__/debTest.js.snap
Expand Up @@ -73,7 +73,7 @@ Array [
exports[`arm 3`] = `
Object {
"Architecture": "armv7l",
"Depends": "gconf2, gconf-service, libnotify4, libappindicator1, libxtst6, libnss3, libxss1",
"Depends": "libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libappindicator1, libgnome-keyring0, gir1.2-gnomekeyring-1.0",
"Homepage": "http://foo.example.com",
"License": "MIT",
"Maintainer": "Foo Bar <foo@example.com>",
Expand Down Expand Up @@ -144,7 +144,7 @@ Array [
exports[`arm 6`] = `
Object {
"Architecture": "armv7l",
"Depends": "gconf2, gconf-service, libnotify4, libappindicator1, libxtst6, libnss3, libxss1",
"Depends": "libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libappindicator1, libgnome-keyring0, gir1.2-gnomekeyring-1.0",
"Homepage": "http://foo.example.com",
"License": "MIT",
"Maintainer": "Foo Bar <foo@example.com>",
Expand All @@ -158,19 +158,6 @@ Object {
exports[`arm 7`] = `"Test Application (test quite “ #378)"`;

exports[`custom depends 1`] = `
"[Desktop Entry]
Name=Test App ßW
Exec=\\"/opt/Test App ßW/Boo\\" %U
Terminal=false
Type=Application
Icon=Boo
StartupWMClass=Test App ßW
Comment=Test Application (test quite “ #378)
Categories=Development;
"
`;

exports[`custom depends 2`] = `
Object {
"linux": Array [
Object {
Expand All @@ -181,7 +168,7 @@ Object {
}
`;

exports[`custom depends 3`] = `
exports[`custom depends 2`] = `
Array [
"/",
"/opt/",
Expand Down Expand Up @@ -239,7 +226,7 @@ Array [
]
`;

exports[`custom depends 4`] = `
exports[`custom depends 3`] = `
Object {
"Architecture": "amd64",
"Depends": "foo",
Expand All @@ -253,7 +240,7 @@ Object {
}
`;

exports[`custom depends 5`] = `"Test Application (test quite “ #378)"`;
exports[`custom depends 4`] = `"Test Application (test quite “ #378)"`;

exports[`deb 1`] = `
Object {
Expand Down Expand Up @@ -327,7 +314,7 @@ Array [
exports[`deb 3`] = `
Object {
"Architecture": "amd64",
"Depends": "gconf2, gconf-service, libnotify4, libappindicator1, libxtst6, libnss3, libxss1",
"Depends": "libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libappindicator1, libgnome-keyring0, gir1.2-gnomekeyring-1.0",
"Homepage": "http://foo.example.com",
"License": "MIT",
"Maintainer": "Foo Bar <foo@example.com>",
Expand Down Expand Up @@ -425,7 +412,7 @@ Array [
exports[`no quotes for safe exec name 4`] = `
Object {
"Architecture": "amd64",
"Depends": "gconf2, gconf-service, libnotify4, libappindicator1, libxtst6, libnss3, libxss1",
"Depends": "libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libappindicator1, libgnome-keyring0, gir1.2-gnomekeyring-1.0",
"Homepage": "http://foo.example.com",
"License": "MIT",
"Maintainer": "Foo Bar <foo@example.com>",
Expand Down
6 changes: 3 additions & 3 deletions test/out/updater/__snapshots__/differentialUpdateTest.js.snap
Expand Up @@ -39,7 +39,7 @@ Object {
"linux": Array [
Object {
"arch": "x64",
"file": "Test App ßW 1.0.1.AppImage",
"file": "Test App ßW-1.0.1.AppImage",
"safeArtifactName": "TestApp-1.0.1-x86_64.AppImage",
"updateInfo": Object {
"blockMapSize": "@blockMapSize",
Expand All @@ -55,10 +55,10 @@ Object {
"blockMapSize": "@blockMapSize",
"sha512": "@sha512",
"size": "@size",
"url": "Test App ßW 1.0.1.AppImage",
"url": "Test App ßW-1.0.1.AppImage",
},
],
"path": "Test App ßW 1.0.1.AppImage",
"path": "Test App ßW-1.0.1.AppImage",
"releaseDate": "@releaseDate",
"sha512": "@sha512",
"version": "1.0.1",
Expand Down

0 comments on commit c605b6a

Please sign in to comment.