Skip to content

Commit

Permalink
feat(nsis): use name instead of product name as inst dir
Browse files Browse the repository at this point in the history
Do not use version in the inst dir path.

Close #926, #941, #810, #928
  • Loading branch information
develar committed Nov 29, 2016
1 parent 3f97b86 commit 640fea0
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 70 deletions.
2 changes: 1 addition & 1 deletion docker/7/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM electronuserland/electron-builder:base

ENV NODE_VERSION 7.1.0
ENV NODE_VERSION 7.2.0

# https://github.com/npm/npm/issues/4531
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
Expand Down
10 changes: 5 additions & 5 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM buildpack-deps:yakkety-curl
FROM buildpack-deps:xenial-curl

# rpm is required for FPM to build rpm package
# yasm is required to build p7zip
Expand All @@ -15,9 +15,8 @@ ENV USE_SYSTEM_7ZA true
ENV DEBUG_COLORS true
ENV FORCE_COLOR true

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 && \
apt-get update -y && \
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 && \
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 && \
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 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
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 && \
Expand Down Expand Up @@ -48,4 +47,5 @@ WORKDIR /project
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV PATH "$HOME/.yarn/bin:$PATH"
2 changes: 1 addition & 1 deletion docker/wine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM electronuserland/electron-builder:latest

# libgnome-keyring-dev — to build keytar
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F9CB8DB0 && \
echo "deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu yakkety main " | tee /etc/apt/sources.list.d/wine.list && \
echo "deb http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial main " | tee /etc/apt/sources.list.d/wine.list && \
dpkg --add-architecture i386 && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
echo "deb http://download.mono-project.com/repo/debian wheezy main" | tee /etc/apt/sources.list.d/mono-xamarin.list && \
Expand Down
2 changes: 1 addition & 1 deletion nsis-auto-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"bluebird-lst-c": "^1.0.5",
"debug": "^2.3.3",
"fs-extra-p": "^3.0.2",
"fs-extra-p": "^3.0.3",
"ini": "^1.3.4",
"js-yaml": "^3.7.0",
"semver": "^5.3.0",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lint": "node ./test/lint.js",
"pretest": "yarn run compile && yarn run lint",
"check-deps": "node ./test/out/helpers/checkDeps.js",
"test": "node --trace-warnings ./test/out/helpers/runTests.js",
"test": "node ./test/out/helpers/runTests.js",
"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",
"pack-updater": "cd nsis-auto-updater && yarn --production && cd ..",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
Expand Down Expand Up @@ -70,7 +70,7 @@
"debug": "^2.3.3",
"electron-download-tf": "3.1.0",
"electron-macos-sign": "^1.3.4",
"fs-extra-p": "^3.0.2",
"fs-extra-p": "^3.0.3",
"hosted-git-info": "^2.1.5",
"ini": "^1.3.4",
"is-ci": "^1.0.10",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/create-self-signed-cert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function main() {

const tmpDir = new TmpDir()
const targetDir = process.cwd()
const tempPrefix = path.join(await tmpDir.getTempFile(null), sanitizeFileName(args.publisher))
const tempPrefix = path.join(await tmpDir.getTempFile(""), sanitizeFileName(args.publisher))
const cer = `${tempPrefix}.cer`
const pvk = `${tempPrefix}.pvk`

Expand Down
1 change: 1 addition & 0 deletions src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default class NsisTarget extends Target {
APP_GUID: guid,
PRODUCT_NAME: appInfo.productName,
PRODUCT_FILENAME: appInfo.productFilename,
APP_FILENAME: appInfo.name,
APP_DESCRIPTION: appInfo.description,
VERSION: version,

Expand Down
113 changes: 64 additions & 49 deletions src/util/tmp.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,90 @@
import { tmpdir } from "os"
import { remove, mkdirs, removeSync } from "fs-extra-p"
import { remove, mkdirs, removeSync, mkdtemp } from "fs-extra-p"
import * as path from "path"
import { getTempName } from "./util"
import BluebirdPromise from "bluebird-lst-c"
import { warn } from "./log"

const mkdtemp: any | null = require("fs-extra-p").mkdtemp
import { all } from "./promise"

process.setMaxListeners(30)

export class TmpDir {
private tmpFileCounter = 0
private tempDirectoryPromise: Promise<string>

private dir: string | null
let tempDirPromise: Promise<string> | null
let tempDir: string | null

getTempFile(suffix: string | null): Promise<string> {
if (this.tempDirectoryPromise == null) {
let promise: Promise<string>
if (mkdtemp == null) {
const dir = path.join(tmpdir(), getTempName("electron-builder"))
promise = mkdirs(dir, {mode: 448}).then(() => dir)
}
else {
promise = mkdtemp(`${path.join(process.env.TEST_DIR || tmpdir(), "electron-builder")}-`)
}
function getTempDir() {
if (tempDirPromise == null) {
let promise: Promise<string>
const systemTmpDir = process.env.TEST_DIR || tmpdir()
if (mkdtemp == null) {
const dir = path.join(systemTmpDir, getTempName("electron-builder"))
promise = mkdirs(dir, {mode: 448}).then(() => dir)
}
else {
promise = mkdtemp(`${path.join(systemTmpDir, "electron-builder")}-`)
}

this.tempDirectoryPromise = promise
.then(dir => {
this.dir = dir
const cleanup = () => {
if (this.dir == null) {
return
}
tempDirPromise = promise
.then(dir => {
tempDir = dir
const cleanup = () => {
if (tempDir == null) {
return
}

this.dir = null
try {
removeSync(dir)
}
catch (e) {
if (e.code !== "EPERM") {
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
}
tempDir = null
try {
removeSync(dir)
}
catch (e) {
if (e.code !== "EPERM") {
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
}
}
process.on("exit", cleanup)
process.on("uncaughtException", cleanup)
process.on("SIGINT", cleanup)
return dir
})
}
process.on("exit", cleanup)
process.on("uncaughtException", cleanup)
process.on("SIGINT", cleanup)
return dir
})
}

return tempDirPromise
}

let tmpFileCounter = 0

export class TmpDir {
private tempPrefixPromise: Promise<string> | null
private tempFiles: Array<string> = []

getTempFile(suffix: string): Promise<string> {
if (this.tempPrefixPromise == null) {
this.tempPrefixPromise = getTempDir().then(it => path.join(it, (tmpFileCounter++).toString(16)))
}

return this.tempDirectoryPromise
.then(it => suffix == null ? it : path.join(it, `t-${process.pid.toString(16)}-${(this.tmpFileCounter++).toString(16)}${suffix.startsWith(".") ? suffix : `-${suffix}`}`))
return this.tempPrefixPromise
.then(it => {
const result = `${it}-${(tmpFileCounter++).toString(16)}${suffix.length === 0 || suffix.startsWith(".") ? suffix : `-${suffix}`}`
this.tempFiles.push(result)
return result
})
}

cleanup(): Promise<any> {
const dir = this.dir
if (dir == null) {
const tempFiles = this.tempFiles
if (tempFiles.length === 0) {
return BluebirdPromise.resolve()
}

this.dir = null
return remove(dir)
this.tempFiles = []
this.tempPrefixPromise = null

return all(tempFiles.map(it => remove(it)
.catch(e => {
if (e.code === "EPERM") {
this.dir = dir
}
else {
warn(`Cannot delete temporary dir "${dir}": ${(e.stack || e).toString()}`)
if (e.code !== "EPERM") {
warn(`Cannot delete temporary dir "${it}": ${(e.stack || e).toString()}`)
}
})
))
}
}
2 changes: 1 addition & 1 deletion src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export function debug7zArgs(command: "a" | "x"): Array<string> {
return args
}

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

Expand Down
6 changes: 3 additions & 3 deletions templates/nsis/multiUser.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Var installMode
StrCpy $0 $1
System::Call 'Ole32::CoTaskMemFree(ir2)'
${endif}
StrCpy $INSTDIR "$0\${PRODUCT_FILENAME}\${VERSION}"
StrCpy $INSTDIR "$0\${APP_FILENAME}"
!endif

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

StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCT_FILENAME}\${VERSION}"
StrCpy $INSTDIR "$PROGRAMFILES\${APP_FILENAME}"

!ifdef APP_64
${if} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_FILENAME}\${VERSION}"
StrCpy $INSTDIR "$PROGRAMFILES64\${APP_FILENAME}"
${endif}
!endif

Expand Down
2 changes: 1 addition & 1 deletion templates/nsis/uninstaller.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Section "un.install"
${if} $installMode == "all"
SetShellVarContext current
${endif}
RMDir /r "$APPDATA\${PRODUCT_FILENAME}"
RMDir /r "$APPDATA\${APP_FILENAME}"
${if} $installMode == "all"
SetShellVarContext all
${endif}
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1363,9 +1363,9 @@ from@~0:
version "0.1.3"
resolved "https://registry.yarnpkg.com/from/-/from-0.1.3.tgz#ef63ac2062ac32acf7862e0d40b44b896f22f3bc"

fs-extra-p@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/fs-extra-p/-/fs-extra-p-3.0.2.tgz#074e44ca8ae535fe6999458458ff2eb7c956d0c8"
fs-extra-p@^3.0.2, fs-extra-p@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/fs-extra-p/-/fs-extra-p-3.0.3.tgz#2e48b1e6c196feb75ac6f0c6419760ce8b847f33"
dependencies:
bluebird-lst-c "^1.0.5"
fs-extra "^1.0.0"
Expand Down Expand Up @@ -3422,8 +3422,8 @@ [email protected]:
resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-0.0.2.tgz#cfedf88e60c00dd9697b61fdd2a8343a9b680eaf"

through2@^2.0.0, through2@^2.0.2, through2@~2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.2.tgz#316d3a4f444af641496aa7f45a713be72576baf4"
version "2.0.3"
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
dependencies:
readable-stream "^2.1.5"
xtend "~4.0.1"
Expand Down

0 comments on commit 640fea0

Please sign in to comment.