diff --git a/Engines/Wine/Engine/Implementation/script.js b/Engines/Wine/Engine/Implementation/script.js index 536cbd9b9c..acf7a7dd97 100644 --- a/Engines/Wine/Engine/Implementation/script.js +++ b/Engines/Wine/Engine/Implementation/script.js @@ -32,6 +32,7 @@ var engineImplementation = { return fileExists(this.getLocalDirectory(subCategory, version)); }, install: function (subCategory, version) { + this._installRuntime(this.getWizard()); var parts = subCategory.split("-"); var distribution = parts[0]; var architecture = parts[2]; @@ -98,6 +99,110 @@ var engineImplementation = { ); } }, + _installRuntime: function (setupWizard) { + var runtimeJsonPath = this._wineEnginesDirectory + "/runtime.json"; + var runtimeJson; + var runtimeJsonFile; + var downloadamd64 = false; + var downloadx86 = false; + if (!fileExists(runtimeJsonPath)) { + mkdir(this._wineEnginesDirectory + "/runtime"); + runtimeJsonFile = new Downloader() + .wizard(this._wizard) + .message(tr("Downloading runtime json")) + .url("https://phoenicis.playonlinux.com/index.php/runtime?os=linux") + .to(runtimeJsonPath) + .get(); + + runtimeJson = JSON.parse(cat(runtimeJsonFile)); + downloadamd64 = true; + downloadx86 = true; + } + else { + var oldRuntimeJsonFile = cat(this._wineEnginesDirectory + "/runtime.json"); + var oldRuntimeJson = JSON.parse(oldRuntimeJsonFile); + + runtimeJsonFile = new Downloader() + .wizard(this._wizard) + .message(tr("Downloading runtime json")) + .url("https://phoenicis.playonlinux.com/index.php/runtime?os=linux") + .to(runtimeJsonPath) + .get(); + + runtimeJson = JSON.parse(cat(runtimeJsonFile)); + var oldCheckSumamd64; + var oldCheckSumx86; + oldRuntimeJson.forEach(function (arch){ + if (arch.arch == "amd64") { + oldCheckSumamd64 = arch.sha1sum; + } + else { + oldCheckSumx86 = arch.sha1sum; + } + }); + runtimeJson.forEach(function (arch){ + if (arch.arch == "amd64" && arch.sha1sum != oldCheckSumamd64){ + downloadamd64 = true; + } + else if (arch.arch == "x86" && arch.sha1sum != oldCheckSumx86){ + downloadx86 = true; + } + }); + } + + if (downloadx86 == true) { + remove(this._wineEnginesDirectory + "/runtime/lib"); + mkdir(this._wineEnginesDirectory + "/TMP"); + that = this; + runtimeJson.forEach(function (arch){ + var runtime; + + if (arch.arch == "x86") { + runtime = new Downloader() + .wizard(setupWizard) + .url(arch.url) + .message(tr("Downloading x86 runtime")) + .checksum(arch.sha1sum) + .to(that._wineEnginesDirectory + "/TMP/" + arch.url.substring(arch.url.lastIndexOf('/')+1)) + .get(); + + new Extractor() + .wizard(setupWizard) + .archive(runtime) + .to(that._wineEnginesDirectory + "/runtime") + .extract(); + + } + }); + remove(this._wineEnginesDirectory + "/TMP"); + } + if (downloadamd64 == true) { + remove(this._wineEnginesDirectory + "/runtime/lib64"); + mkdir(this._wineEnginesDirectory + "/TMP"); + var that = this; + runtimeJson.forEach(function (arch){ + var runtime; + + if (arch.arch == "amd64") { + runtime = new Downloader() + .wizard(setupWizard) + .url(arch.url) + .message(tr("Downloading amd64 runtime")) + .checksum(arch.sha1sum) + .to(that._wineEnginesDirectory + "/TMP/" + arch.url.substring(arch.url.lastIndexOf('/')+1)) + .get(); + + new Extractor() + .wizard(setupWizard) + .archive(runtime) + .to(that._wineEnginesDirectory + "/runtime") + .extract(); + + } + }); + remove(this._wineEnginesDirectory + "/TMP"); + } + }, _installGecko: function (setupWizard, winePackage, localDirectory) { if (winePackage.geckoUrl) { var gecko = new Resource() @@ -253,9 +358,11 @@ var engineImplementation = { ldPath = userData.ldPath + ldPath; } if (architecture == "amd64") { - ldPath = this.getLocalDirectory(subCategory, version) + "/lib64/:" + ldPath + ldPath = this._wineEnginesDirectory + "runtime/lib64/:" + this._wineEnginesDirectory + "runtime/lib/:" + + this.getLocalDirectory(subCategory, version) + "/lib64/:" + + this.getLocalDirectory(subCategory, version) + "/lib/:"+ ldPath; } else { - ldPath = this.getLocalDirectory(subCategory, version) + "/lib/:" + ldPath + ldPath = this._wineEnginesDirectory + "runtime/lib/:" + this.getLocalDirectory(subCategory, version) + "/lib/:" + ldPath; } environment.put("LD_LIBRARY_PATH", ldPath);