forked from PhoenicisOrg/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
103 lines (81 loc) · 3.92 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
include("engines.wine.quick_script.quick_script");
const Wine = include("engines.wine.engine.object");
include("utils.functions.filesystem.extract");
const {ls, mkdir, fileExists, cat, cp, getFileSize, fileName, lns, remove, touch, writeToFile, createTempFile, createTempDir, chmod, Checksum} = include("utils.functions.filesystem.files");
include("engines.wine.verbs.luna");
const operatingSystemFetcher = Bean("operatingSystemFetcher");
class InstallerScript extends QuickScript {
constructor() {
super();
}
go() {
this._name = this._name || "Custom Installer";
const setupWizard = SetupWizard(InstallationType.APPS, this._name, this.miniature());
// if no name given, ask user
if (this._name == "Custom Installer") {
this._name = setupWizard.textbox(tr("Please enter the name of your application."));
}
setupWizard.presentation(this._name, this._editor, this._applicationHomepage, this._author);
// get installation file from concrete InstallerScript implementation
const installationCommand = this._installationCommand(setupWizard);
const wine = new Wine().wizard(setupWizard);
// let user select wine settings if desired
if (this._wineUserSettings) {
const architectures = ["x86", "amd64"];
const selectedArchitecture = setupWizard.menu(
tr("Please select the wine architecture."),
["x86 (recommended)", "amd64"],
"x86 (recommended)"
);
this._wineArchitecture = architectures[selectedArchitecture.index];
const distributions = wine.availableDistributions(this._wineArchitecture);
const shownDistributions = distributions.map(distribution => {
if (distribution == "upstream") {
return "upstream (recommended)";
} else {
return distribution;
}
});
const selectedDistribution = setupWizard.menu(
tr("Please select the wine distribution."),
shownDistributions,
"upstream (recommended)"
);
this._wineDistribution = distributions[selectedDistribution.index];
const operatingSystem = operatingSystemFetcher.fetchCurrentOperationSystem().getWinePackage();
const versions = wine.availableVersions(
`${this._wineDistribution}-${operatingSystem}-${this._wineArchitecture}`
);
const shownVersions = versions.map(version => {
if (version == LATEST_STABLE_VERSION) {
return `${version} (recommended)`;
} else {
return version;
}
});
const selectedVersion = setupWizard.menu(
tr("Please select the wine version."),
shownVersions,
LATEST_STABLE_VERSION + " (recommended)"
);
this._wineVersion = versions[selectedVersion.index];
}
// setup the prefix
wine.prefix(this._name, this._wineDistribution, this._wineArchitecture, this._wineVersion).luna();
this._preInstall(wine, setupWizard);
// back to generic wait (might have been changed in preInstall)
setupWizard.wait(tr("Please wait..."));
wine.run(installationCommand.command, installationCommand.args, null, false, true);
// if no executable given, ask user
if (!this._executable) {
this._executable = fileName(
setupWizard.browse(tr("Please select the executable."), wine.prefixDirectory(), ["exe"])
);
}
this._createShortcut(wine.prefix());
this._postInstall(wine, setupWizard);
// back to generic wait (might have been changed in postInstall)
setupWizard.wait(tr("Please wait..."));
setupWizard.close();
}
}