Skip to content

Commit 640fea0

Browse files
committed
feat(nsis): use name instead of product name as inst dir
Do not use version in the inst dir path. Close #926, #941, #810, #928
1 parent 3f97b86 commit 640fea0

File tree

12 files changed

+86
-70
lines changed

12 files changed

+86
-70
lines changed

docker/7/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM electronuserland/electron-builder:base
22

3-
ENV NODE_VERSION 7.1.0
3+
ENV NODE_VERSION 7.2.0
44

55
# https://github.com/npm/npm/issues/4531
66
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \

docker/base/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM buildpack-deps:yakkety-curl
1+
FROM buildpack-deps:xenial-curl
22

33
# rpm is required for FPM to build rpm package
44
# yasm is required to build p7zip
@@ -15,9 +15,8 @@ ENV USE_SYSTEM_7ZA true
1515
ENV DEBUG_COLORS true
1616
ENV FORCE_COLOR true
1717

18-
RUN apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg && echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
19-
apt-get update -y && \
20-
apt-get install --no-install-recommends -y git snapcraft yarn xorriso bsdtar build-essential autoconf libssl-dev icnsutils graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev lzip rpm yasm && \
18+
RUN curl -L https://yarnpkg.com/latest.tar.gz | tar xvz && mv dist yarn && ln -s /yarn/bin/yarn /usr/local/bin/yarn && apt-get update -y && \
19+
apt-get install --no-install-recommends -y git snapcraft xorriso bsdtar build-essential autoconf libssl-dev icnsutils graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev lzip rpm yasm && \
2120
apt-get clean && \
2221
rm -rf /var/lib/apt/lists/* && \
2322
curl -L http://tukaani.org/xz/xz-$XZ_VERSION.tar.xz | tar -xJ && cd xz-$XZ_VERSION && ./configure && make && make install && cd .. && rm -rf xz-$XZ_VERSION && ldconfig && \
@@ -48,4 +47,5 @@ WORKDIR /project
4847
RUN locale-gen en_US.UTF-8
4948
ENV LANG en_US.UTF-8
5049
ENV LANGUAGE en_US:en
51-
ENV LC_ALL en_US.UTF-8
50+
ENV LC_ALL en_US.UTF-8
51+
ENV PATH "$HOME/.yarn/bin:$PATH"

docker/wine/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM electronuserland/electron-builder:latest
22

33
# libgnome-keyring-dev — to build keytar
44
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F9CB8DB0 && \
5-
echo "deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu yakkety main " | tee /etc/apt/sources.list.d/wine.list && \
5+
echo "deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial main " | tee /etc/apt/sources.list.d/wine.list && \
66
dpkg --add-architecture i386 && \
77
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
88
echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list && \

nsis-auto-updater/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"bluebird-lst-c": "^1.0.5",
1616
"debug": "^2.3.3",
17-
"fs-extra-p": "^3.0.2",
17+
"fs-extra-p": "^3.0.3",
1818
"ini": "^1.3.4",
1919
"js-yaml": "^3.7.0",
2020
"semver": "^5.3.0",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"lint": "node ./test/lint.js",
1919
"pretest": "yarn run compile && yarn run lint",
2020
"check-deps": "node ./test/out/helpers/checkDeps.js",
21-
"test": "node --trace-warnings ./test/out/helpers/runTests.js",
21+
"test": "node ./test/out/helpers/runTests.js",
2222
"test-linux": "docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /test.sh",
2323
"pack-updater": "cd nsis-auto-updater && yarn --production && cd ..",
2424
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
@@ -70,7 +70,7 @@
7070
"debug": "^2.3.3",
7171
"electron-download-tf": "3.1.0",
7272
"electron-macos-sign": "^1.3.4",
73-
"fs-extra-p": "^3.0.2",
73+
"fs-extra-p": "^3.0.3",
7474
"hosted-git-info": "^2.1.5",
7575
"ini": "^1.3.4",
7676
"is-ci": "^1.0.10",

src/cli/create-self-signed-cert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async function main() {
1616

1717
const tmpDir = new TmpDir()
1818
const targetDir = process.cwd()
19-
const tempPrefix = path.join(await tmpDir.getTempFile(null), sanitizeFileName(args.publisher))
19+
const tempPrefix = path.join(await tmpDir.getTempFile(""), sanitizeFileName(args.publisher))
2020
const cer = `${tempPrefix}.cer`
2121
const pvk = `${tempPrefix}.pvk`
2222

src/targets/nsis.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export default class NsisTarget extends Target {
9494
APP_GUID: guid,
9595
PRODUCT_NAME: appInfo.productName,
9696
PRODUCT_FILENAME: appInfo.productFilename,
97+
APP_FILENAME: appInfo.name,
9798
APP_DESCRIPTION: appInfo.description,
9899
VERSION: version,
99100

src/util/tmp.ts

Lines changed: 64 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,90 @@
11
import { tmpdir } from "os"
2-
import { remove, mkdirs, removeSync } from "fs-extra-p"
2+
import { remove, mkdirs, removeSync, mkdtemp } from "fs-extra-p"
33
import * as path from "path"
44
import { getTempName } from "./util"
55
import BluebirdPromise from "bluebird-lst-c"
66
import { warn } from "./log"
7-
8-
const mkdtemp: any | null = require("fs-extra-p").mkdtemp
7+
import { all } from "./promise"
98

109
process.setMaxListeners(30)
1110

12-
export class TmpDir {
13-
private tmpFileCounter = 0
14-
private tempDirectoryPromise: Promise<string>
15-
16-
private dir: string | null
11+
let tempDirPromise: Promise<string> | null
12+
let tempDir: string | null
1713

18-
getTempFile(suffix: string | null): Promise<string> {
19-
if (this.tempDirectoryPromise == null) {
20-
let promise: Promise<string>
21-
if (mkdtemp == null) {
22-
const dir = path.join(tmpdir(), getTempName("electron-builder"))
23-
promise = mkdirs(dir, {mode: 448}).then(() => dir)
24-
}
25-
else {
26-
promise = mkdtemp(`${path.join(process.env.TEST_DIR || tmpdir(), "electron-builder")}-`)
27-
}
14+
function getTempDir() {
15+
if (tempDirPromise == null) {
16+
let promise: Promise<string>
17+
const systemTmpDir = process.env.TEST_DIR || tmpdir()
18+
if (mkdtemp == null) {
19+
const dir = path.join(systemTmpDir, getTempName("electron-builder"))
20+
promise = mkdirs(dir, {mode: 448}).then(() => dir)
21+
}
22+
else {
23+
promise = mkdtemp(`${path.join(systemTmpDir, "electron-builder")}-`)
24+
}
2825

29-
this.tempDirectoryPromise = promise
30-
.then(dir => {
31-
this.dir = dir
32-
const cleanup = () => {
33-
if (this.dir == null) {
34-
return
35-
}
26+
tempDirPromise = promise
27+
.then(dir => {
28+
tempDir = dir
29+
const cleanup = () => {
30+
if (tempDir == null) {
31+
return
32+
}
3633

37-
this.dir = null
38-
try {
39-
removeSync(dir)
40-
}
41-
catch (e) {
42-
if (e.code !== "EPERM") {
43-
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
44-
}
34+
tempDir = null
35+
try {
36+
removeSync(dir)
37+
}
38+
catch (e) {
39+
if (e.code !== "EPERM") {
40+
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
4541
}
4642
}
47-
process.on("exit", cleanup)
48-
process.on("uncaughtException", cleanup)
49-
process.on("SIGINT", cleanup)
50-
return dir
51-
})
43+
}
44+
process.on("exit", cleanup)
45+
process.on("uncaughtException", cleanup)
46+
process.on("SIGINT", cleanup)
47+
return dir
48+
})
49+
}
50+
51+
return tempDirPromise
52+
}
53+
54+
let tmpFileCounter = 0
55+
56+
export class TmpDir {
57+
private tempPrefixPromise: Promise<string> | null
58+
private tempFiles: Array<string> = []
59+
60+
getTempFile(suffix: string): Promise<string> {
61+
if (this.tempPrefixPromise == null) {
62+
this.tempPrefixPromise = getTempDir().then(it => path.join(it, (tmpFileCounter++).toString(16)))
5263
}
5364

54-
return this.tempDirectoryPromise
55-
.then(it => suffix == null ? it : path.join(it, `t-${process.pid.toString(16)}-${(this.tmpFileCounter++).toString(16)}${suffix.startsWith(".") ? suffix : `-${suffix}`}`))
65+
return this.tempPrefixPromise
66+
.then(it => {
67+
const result = `${it}-${(tmpFileCounter++).toString(16)}${suffix.length === 0 || suffix.startsWith(".") ? suffix : `-${suffix}`}`
68+
this.tempFiles.push(result)
69+
return result
70+
})
5671
}
5772

5873
cleanup(): Promise<any> {
59-
const dir = this.dir
60-
if (dir == null) {
74+
const tempFiles = this.tempFiles
75+
if (tempFiles.length === 0) {
6176
return BluebirdPromise.resolve()
6277
}
6378

64-
this.dir = null
65-
return remove(dir)
79+
this.tempFiles = []
80+
this.tempPrefixPromise = null
81+
82+
return all(tempFiles.map(it => remove(it)
6683
.catch(e => {
67-
if (e.code === "EPERM") {
68-
this.dir = dir
69-
}
70-
else {
71-
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
84+
if (e.code !== "EPERM") {
85+
warn(`Cannot delete temporary dir "${it}": ${(e.stack || e).toString()}`)
7286
}
7387
})
88+
))
7489
}
7590
}

src/util/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export function debug7zArgs(command: "a" | "x"): Array<string> {
224224
return args
225225
}
226226

227-
let tmpDirCounter = 0
227+
export let tmpDirCounter = 0
228228
// add date to avoid use stale temp dir
229229
const tempDirPrefix = `${process.pid.toString(16)}-${Date.now().toString(16)}`
230230

templates/nsis/multiUser.nsh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Var installMode
2929
StrCpy $0 $1
3030
System::Call 'Ole32::CoTaskMemFree(ir2)'
3131
${endif}
32-
StrCpy $INSTDIR "$0\${PRODUCT_FILENAME}\${VERSION}"
32+
StrCpy $INSTDIR "$0\${APP_FILENAME}"
3333
!endif
3434

3535
# сhecks registry for previous installation path — for uninstall only, currently, installation path is not customizable
@@ -49,11 +49,11 @@ Var installMode
4949
StrCpy $installMode all
5050
SetShellVarContext all
5151

52-
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT_FILENAME}\${VERSION}"
52+
StrCpy $INSTDIR "$PROGRAMFILES\${APP_FILENAME}"
5353

5454
!ifdef APP_64
5555
${if} ${RunningX64}
56-
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_FILENAME}\${VERSION}"
56+
StrCpy $INSTDIR "$PROGRAMFILES64\${APP_FILENAME}"
5757
${endif}
5858
!endif
5959

0 commit comments

Comments
 (0)