Skip to content

Commit

Permalink
feat(snap): do not all apt-get install and update if build packages a…
Browse files Browse the repository at this point in the history
…lready installed

So, reduce risk that build will be failed because of sudo. Yes - snapcraft can also install build packages. But at least electron-builder doesn't fail.
  • Loading branch information
develar committed Jan 30, 2018
1 parent d8c0df0 commit ba9e9da
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/electron-builder-lib/src/targets/snap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Target } from "../core"
import { LinuxPackager } from "../linuxPackager"
import { LinuxTargetHelper } from "./LinuxTargetHelper"
import { createStageDir, StageDir } from "./targetUtil"
import BluebirdPromise from "bluebird-lst"

// usr/share/fonts is required, cannot run otherwise
const unnecessaryFiles = [
Expand Down Expand Up @@ -110,8 +111,14 @@ export default class SnapTarget extends Target {
}
else {
if (options.buildPackages != null && options.buildPackages.length > 0) {
await spawn("apt-get", ["-qq", "update"])
await spawn("apt-get", ["-qq", "install", "--no-install-recommends"].concat(options.buildPackages))
const notInstalledPackages = await BluebirdPromise.filter(options.buildPackages, (it): Promise<boolean> => {
return exec("dpkg", ["-s", it])
.then(result => result.includes("is not installed"))
})
if (notInstalledPackages.length > 0) {
await spawn("apt-get", ["-qq", "update"])
await spawn("apt-get", ["-qq", "install", "--no-install-recommends"].concat(notInstalledPackages))
}
}
const spawnOptions = {
cwd: stageDir.dir,
Expand Down Expand Up @@ -156,4 +163,4 @@ export default class SnapTarget extends Target {
stdio: ["ignore", "inherit", "inherit"],
})
}
}
}

0 comments on commit ba9e9da

Please sign in to comment.