Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit 5882a33

Browse files
committed
Added silent installers for 32/64 bit; updated install script to check arch
Added check for existing installs; install will be skipped if already installed Fixes brave/brave-browser#1540
1 parent 879e881 commit 5882a33

File tree

4 files changed

+39
-17
lines changed

4 files changed

+39
-17
lines changed

app/windowsInit.js

+37-16
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,38 @@ function CopyManifestFile () {
5757
}
5858

5959
const getBraveCoreInstallerPath = () => {
60+
const os = require('os')
6061
const appDir = getBraveBinPath()
61-
return path.join(appDir, 'resources', 'BraveBrowserSetup.exe')
62+
return path.join(appDir, 'resources',
63+
os.arch() === 'x32' ? 'BraveBrowserSetup32.exe' : 'BraveBrowserSetup64.exe')
6264
}
6365

6466
function InstallBraveCore () {
65-
// TODO(bsclifton): get a proper version of the omaha installer
66-
// (built using https://github.com/brave/devops/pull/335)
67-
//const cmd = getBraveCoreInstallerPath() + " /silent /install"
68-
const cmd = getBraveCoreInstallerPath() + " /install"
67+
const fs = require('fs')
68+
69+
// expected install paths
70+
const braveCoreInstallLocations = [
71+
'%USERPROFILE%\\AppData\\Local\\BraveSoftware\\Brave-Browser\\Application',
72+
'%ProgramFiles(x86)%\\BraveSoftware\\Brave-Browser\\Application',
73+
'%ProgramFiles%\\BraveSoftware\\Brave-Browser\\Application'
74+
]
75+
76+
// check for existing installations
77+
for (let i=0; i < braveCoreInstallLocations.length; i++) {
78+
const path = braveCoreInstallLocations[i]
79+
const resolvedPath = path.replace(/%([^%]+)%/g, function(_, variableToResolve) {
80+
return process.env[variableToResolve]
81+
})
82+
if (fs.existsSync(resolvedPath)) {
83+
return false
84+
}
85+
}
86+
87+
// brave-core is not installed; go ahead with silent install
88+
const cmd = getBraveCoreInstallerPath() + " /silent /install"
6989
execSync(cmd)
90+
91+
return true
7092
}
7193

7294
// windows installation events etc...
@@ -94,22 +116,21 @@ if (process.platform === 'win32') {
94116
CopyManifestFile()
95117
// Launch defaults helper to add defaults on install
96118
spawn(getBraveDefaultsBinPath(), [], { detached: true })
97-
// Silent install brave-core
98-
// TODO(bsclifton):
99-
// - don't install if already installed
100-
// - verify this doesn't run twice AND that it doesn't run on uninstall
101-
InstallBraveCore()
102-
// relaunch and append argument expected in:
103-
// https://github.com/brave/brave-browser/issues/1545
104-
app.relaunch({args: ['--relaunch', '--upgrade-from-muon']})
105-
app.exit()
106-
return
107-
108119
} else if (isSquirrelUninstall) {
109120
// Launch defaults helper to remove defaults on uninstall
110121
// Sync to avoid file path in use on uninstall
111122
spawnSync(getBraveDefaultsBinPath(), ['-uninstall'])
112123
}
124+
// silent install brave-core
125+
if (isSquirrelFirstRun || isSquirrelInstall || isSquirrelUpdate) {
126+
if (InstallBraveCore()) {
127+
// relaunch and append argument expected in:
128+
// https://github.com/brave/brave-browser/issues/1545
129+
app.relaunch({args: ['--relaunch', '--upgrade-from-muon']})
130+
app.exit()
131+
return
132+
}
133+
}
113134

114135
if (shouldQuit(channel)) {
115136
process.exit(0)
Binary file not shown.

res/BraveBrowserSetup64.exe

1.09 MB
Binary file not shown.

tools/buildPackage.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ if (isLinux) {
152152
cmds.push('move .\\temp.VisualElementsManifest.xml "' + path.join(buildDir, 'resources', 'Update.VisualElementsManifest.xml') + '"')
153153
cmds.push('copy .\\res\\start-tile-70.png "' + path.join(buildDir, 'resources', 'start-tile-70.png') + '"')
154154
cmds.push('copy .\\res\\start-tile-150.png "' + path.join(buildDir, 'resources', 'start-tile-150.png') + '"')
155-
cmds.push('copy .\\res\\BraveBrowserSetup.exe "' + path.join(buildDir, 'resources', 'BraveBrowserSetup.exe') + '"')
155+
cmds.push('copy .\\res\\BraveBrowserSetup32.exe "' + path.join(buildDir, 'resources', 'BraveBrowserSetup32.exe') + '"')
156+
cmds.push('copy .\\res\\BraveBrowserSetup64.exe "' + path.join(buildDir, 'resources', 'BraveBrowserSetup64.exe') + '"')
156157
cmds.push('makensis.exe -DARCH=' + arch + ` res/${channel}/braveDefaults.nsi`)
157158
cmds.push('ncp ./app/extensions ' + path.join(buildDir, 'resources', 'extensions'))
158159
// Make sure the Brave.exe binary is squirrel aware so we get squirrel events and so that Squirrel doesn't auto create shortcuts.

0 commit comments

Comments
 (0)