Skip to content

Commit 7ea1a57

Browse files
committed
JBDS-4015 Only one MSI installer can be running at the same time
1 parent 1b4941b commit 7ea1a57

16 files changed

Lines changed: 203 additions & 112 deletions

browser/main.js

Lines changed: 46 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -77,69 +77,57 @@ let mainModule =
7777
.run( ['$rootScope', '$location', '$timeout', 'installerDataSvc', ($rootScope, $location, $timeout, installerDataSvc) => {
7878
let reqs = Util.resolveFile('.', 'requirements.json');
7979

80-
installerDataSvc.addItemToInstall(
81-
VirtualBoxInstall.key(),
82-
new VirtualBoxInstall(
83-
reqs['virtualbox.exe'].version,
84-
reqs['virtualbox.exe'].revision,
85-
installerDataSvc,
86-
reqs['virtualbox.exe'].url,
87-
null,
88-
'virtualbox',
89-
reqs['virtualbox.exe'].sha256sum)
90-
);
80+
let virtualbox = new VirtualBoxInstall(
81+
reqs['virtualbox.exe'].version,
82+
reqs['virtualbox.exe'].revision,
83+
installerDataSvc,
84+
reqs['virtualbox.exe'].url,
85+
null,
86+
'virtualbox',
87+
reqs['virtualbox.exe'].sha256sum),
9188

92-
installerDataSvc.addItemToInstall(
93-
CygwinInstall.key(),
94-
new CygwinInstall(
95-
installerDataSvc,
96-
reqs['cygwin.exe'].url,
97-
null,
98-
'cygwin',
99-
reqs['cygwin.exe'].sha256sum)
100-
);
89+
cygwin = new CygwinInstall(
90+
installerDataSvc,
91+
reqs['cygwin.exe'].url,
92+
null,
93+
'cygwin',
94+
reqs['cygwin.exe'].sha256sum),
10195

102-
installerDataSvc.addItemToInstall(
103-
VagrantInstall.key(),
104-
new VagrantInstall(
105-
installerDataSvc,
106-
reqs['vagrant.msi'].url,
107-
null,
108-
'vagrant',
109-
reqs['vagrant.msi'].sha256sum)
110-
);
96+
vagrant = new VagrantInstall(
97+
installerDataSvc,
98+
reqs['vagrant.msi'].url,
99+
null,
100+
'vagrant',
101+
reqs['vagrant.msi'].sha256sum),
111102

112-
installerDataSvc.addItemToInstall(
113-
CDKInstall.key(),
114-
new CDKInstall(
115-
installerDataSvc,
116-
$timeout,
117-
reqs['cdk.zip'].dmUrl,
118-
reqs['rhel-vagrant-virtualbox.box'].dmUrl,
119-
reqs['oc.zip'].url,
120-
null,
121-
'cdk',
122-
reqs['oc.zip'].sha256sum)
123-
);
103+
cdk = new CDKInstall(
104+
installerDataSvc,
105+
$timeout,
106+
reqs['cdk.zip'].dmUrl,
107+
reqs['rhel-vagrant-virtualbox.box'].dmUrl,
108+
reqs['oc.zip'].url,
109+
null,
110+
'cdk',
111+
reqs['oc.zip'].sha256sum),
124112

125-
installerDataSvc.addItemToInstall(
126-
JdkInstall.key(),
127-
new JdkInstall(
128-
installerDataSvc,
129-
reqs['jdk.msi'].dmUrl,
130-
null,
131-
reqs['jdk.msi'].prefix,
132-
'jdk8')
133-
);
113+
jdk = new JdkInstall(
114+
installerDataSvc,
115+
reqs['jdk.msi'].dmUrl,
116+
null,
117+
reqs['jdk.msi'].prefix,
118+
'jdk8'),
119+
120+
jbds = new JbdsInstall(
121+
installerDataSvc,
122+
reqs['jbds.jar'].dmUrl,
123+
null,
124+
'developer-studio');
125+
126+
installerDataSvc.addItemsToInstall(virtualbox,cygwin,vagrant,cdk,jdk,jbds);
127+
128+
jdk.thenInstall(jbds);
129+
jdk.thenInstall(virtualbox).thenInstall(cygwin).thenInstall(vagrant).thenInstall(cdk);
134130

135-
installerDataSvc.addItemToInstall(
136-
JbdsInstall.key(),
137-
new JbdsInstall(
138-
installerDataSvc,
139-
reqs['jbds.jar'].dmUrl,
140-
null,
141-
'developer-studio')
142-
);
143131
}]);
144132

145133
export default mainModule;

browser/model/cdk.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ class CDKInstall extends InstallableItem {
8888
}
8989

9090
install(progress, success, failure) {
91-
let vagrantInstall = this.installerDataSvc.getInstallable(VagrantInstall.key());
92-
if( vagrantInstall !== undefined && vagrantInstall.isInstalled() ) {
91+
if(!this.getInstallAfter() || this.getInstallAfter().isInstalled()) {
9392
this.postVagrantInstall(progress, success, failure);
9493
} else {
95-
progress.setStatus('Waiting for Vagrant to finish installation');
94+
let name = this.getInstallAfter().productName;
95+
progress.setStatus(`Waiting for ${name} to finish installation`);
9696
ipcRenderer.on('installComplete', (event, arg) => {
97-
if (arg == 'vagrant') {
97+
if (!this.isInstalled() && this.getInstallAfter().isInstalled()) {
9898
this.postVagrantInstall(progress, success, failure);
9999
}
100100
});

browser/model/cygwin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ class CygwinInstall extends InstallableItem {
7474
}
7575

7676
install(progress, success, failure) {
77-
let vboxInstall = this.installerDataSvc.getInstallable(VirtualBoxInstall.key());
78-
if( vboxInstall !== undefined && vboxInstall.isInstalled() ) {
77+
if( !this.getInstallAfter() || this.getInstallAfter().isInstalled() ) {
7978
this.postVirtualboxInstall(progress, success, failure);
8079
} else {
81-
progress.setStatus('Waiting for VirtualBox to finish installation');
80+
let name = this.getInstallAfter().productName;
81+
progress.setStatus(`Waiting for ${name} to finish installation`);
8282
ipcRenderer.on('installComplete', (event, arg) => {
83-
if (arg == 'virtualbox') {
83+
if (!this.isInstalled() && this.getInstallAfter().isInstalled() ) {
8484
this.postVirtualboxInstall(progress, success, failure);
8585
}
8686
});

browser/model/installable-item.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class InstallableItem {
5555

5656
this.downloader = null;
5757
this.downloadFolder = path.normalize(path.join(__dirname,"../../../.."));
58+
59+
this.installAfter = undefined;
5860
}
5961

6062
getProductName() {
@@ -180,6 +182,19 @@ class InstallableItem {
180182
this.downloader.restartDownload();
181183
}
182184

185+
getInstallAfter() {
186+
let installable = this.installAfter;
187+
while ( installable !== undefined && installable.isSkipped()) {
188+
installable = installable.installAfter;
189+
}
190+
return installable;
191+
}
192+
193+
thenInstall(installer) {
194+
installer.installAfter = this;
195+
return installer;
196+
}
197+
183198
}
184199

185200
export default InstallableItem;

browser/model/jbds.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ class JbdsInstall extends InstallableItem {
131131
}
132132

133133
install(progress, success, failure) {
134-
let jdkInstall = this.installerDataSvc.getInstallable(JdkInstall.key());
135-
if (jdkInstall !== undefined && jdkInstall.isInstalled()) {
134+
if ( !this.getInstallAfter() || this.getInstallAfter().isInstalled() ) {
136135
this.postInstall(progress, success, failure);
137136
} else {
138-
progress.setStatus('Waiting for JDK to finish installation');
137+
let name = this.getInstallAfter().productName;
138+
progress.setStatus(`Waiting for ${name} to finish installation`);
139139
ipcRenderer.on('installComplete', (event, arg) => {
140-
if (arg == 'jdk') {
140+
if(!this.isInstalled() && this.getInstallAfter().isInstalled()) {
141141
this.postInstall(progress, success, failure);
142142
}
143143
});
@@ -155,15 +155,15 @@ class JbdsInstall extends InstallableItem {
155155
Logger.info(JbdsInstall.key() + ' - Generate devstudio auto install file content SUCCESS');
156156

157157
installer.writeFile(this.installConfigFile, data)
158-
.then((result) => {
159-
return this.postJDKInstall(installer, result);
160-
})
161-
.then((result) => {
162-
return installer.succeed(result);
163-
})
164-
.catch((error) => {
165-
return installer.fail(error);
166-
});
158+
.then((result) => {
159+
return this.postJDKInstall(installer, result);
160+
})
161+
.then((result) => {
162+
return installer.succeed(result);
163+
})
164+
.catch((error) => {
165+
return installer.fail(error);
166+
});
167167
} else {
168168
success();
169169
}
@@ -245,7 +245,7 @@ class JbdsInstall extends InstallableItem {
245245
return new Promise((resolve, reject) => {
246246
let jdkInstall = this.installerDataSvc.getInstallable(JdkInstall.key());
247247

248-
if (jdkInstall !== undefined && jdkInstall.isInstalled()) {
248+
if (jdkInstall.isInstalled()) {
249249
return this.headlessInstall(installer, result)
250250
.then((res) => { return resolve(res); })
251251
.catch((err) => { return reject(err); });

browser/model/jdk-install.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class JdkInstall extends InstallableItem {
131131
}
132132

133133
install(progress, success, failure) {
134-
let cdkInstall = this.installerDataSvc.getInstallable(JdkInstall.key());
135134
if(this.selectedOption === "install") {
136135
progress.setStatus('Installing');
137136
let installer = new Installer(JdkInstall.key(), progress, success, failure);

browser/model/vagrant.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ class VagrantInstall extends InstallableItem {
124124
}
125125

126126
install(progress, success, failure) {
127-
let cygwinInstall = this.installerDataSvc.getInstallable(CygwinInstall.key());
128-
if( cygwinInstall !== undefined && cygwinInstall.isInstalled() ) {
127+
if( !this.getInstallAfter() || this.getInstallAfter().isInstalled() ) {
129128
this.postCygwinInstall(progress, success, failure);
130129
} else {
131-
progress.setStatus('Waiting for Cygwin to finish installation');
130+
let name = this.getInstallAfter().productName;
131+
progress.setStatus(`Waiting for ${name} to finish installation`);
132132
ipcRenderer.on('installComplete', (event, arg) => {
133-
if (arg == 'cygwin') {
133+
if (!this.isInstalled() && this.getInstallAfter().isInstalled()) {
134134
this.postCygwinInstall(progress, success, failure);
135135
}
136136
});

browser/model/virtualbox.js

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -148,26 +148,40 @@ class VirtualBoxInstall extends InstallableItem {
148148
}
149149

150150
install(progress, success, failure) {
151+
if( !this.getInstallAfter() || this.getInstallAfter().isInstalled() ) {
152+
this.postOpenJdk(progress, success, failure);
153+
} else {
154+
let name = this.getInstallAfter().productName;
155+
progress.setStatus(`Waiting for ${name} to finish installation`);
156+
ipcRenderer.on('installComplete', (event, arg) => {
157+
if (!this.isInstalled() && this.getInstallAfter().isInstalled()) {
158+
this.postOpenJdk(progress, success, failure);
159+
}
160+
});
161+
}
162+
}
163+
164+
postOpenJdk(progress, success, failure) {
151165
let installer = new Installer(VirtualBoxInstall.key(), progress, success, failure);
152166
if(this.selectedOption === "install") {
153167
installer.execFile(this.downloadedFile,
154-
['--extract',
155-
'-path',
156-
this.installerDataSvc.tempDir(),
157-
'--silent'])
158-
.then((result) => {
159-
return this.configure(installer, result)
160-
})
161-
.then((result) => {
162-
return installer.succeed(result);
163-
})
164-
.catch((error) => {
165-
return installer.fail(error);
166-
});
168+
['--extract',
169+
'-path',
170+
this.installerDataSvc.tempDir(),
171+
'--silent'])
172+
.then((result) => {
173+
return this.configure(installer, result)
174+
})
175+
.then((result) => {
176+
return installer.succeed(result);
177+
})
178+
.catch((error) => {
179+
return installer.fail(error);
180+
});
167181
} else {
168182
success();
169183
}
170-
}
184+
};
171185

172186
setup(progress, success, failure) {
173187
//no need to setup anything for vbox

browser/services/data.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ class InstallerDataService {
6969
this.toInstall.add(key);
7070
}
7171

72+
addItemsToInstall(...items) {
73+
for (const item of items) {
74+
this.addItemToInstall(item.keyName,item);
75+
}
76+
}
77+
7278
getIpcRenderer() {
7379
return this.ipcRenderer;
7480
}
@@ -204,7 +210,6 @@ class InstallerDataService {
204210
Logger.error(key + ' failed to install: ' + error);
205211
}
206212
);
207-
208213
}
209214

210215
setupDone(progress,key) {

test/unit/model/cdk-test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import VirtualboxInstall from "model/virtualbox";
1212
import Logger from 'services/logger';
1313
import Downloader from 'model/helpers/downloader';
1414
import Installer from 'model/helpers/installer';
15+
import InstallableItem from 'model/installable-item';
1516
import chaiAsPromised from 'chai-as-promised';
1617

1718
chai.use(chaiAsPromised);
@@ -190,7 +191,8 @@ describe('CDK installer', function() {
190191
it('should wait if vagrant has not finished installing', function() {
191192
let stub = sandbox.stub(installer, 'postVagrantInstall');
192193
let progressStub = sandbox.stub(fakeProgress, 'setStatus').throws('done');
193-
194+
let item2 = new InstallableItem('vagrant', 1000, 'url', 'installFile', 'targetFolderName', installerDataSvc);
195+
item2.thenInstall(installer);
194196
try {
195197
installer.install(fakeProgress, () => {}, (err) => {});
196198
} catch (err) {
@@ -204,7 +206,9 @@ describe('CDK installer', function() {
204206
it('should install once vagrant has finished', function() {
205207
let stub = sandbox.stub(installer, 'postVagrantInstall').returns();
206208
sandbox.stub(vagrantInstallStub, 'isInstalled').returns(true);
207-
209+
let item2 = new InstallableItem('cygwin', 1000, 'url', 'installFile', 'targetFolderName', installerDataSvc);
210+
item2.setInstallComplete();
211+
item2.thenInstall(installer);
208212
installer.install(fakeProgress, () => {}, (err) => {});
209213

210214
expect(stub).calledOnce;

0 commit comments

Comments
 (0)