Skip to content
Next Next commit
- fix #1148
  • Loading branch information
madoar committed Dec 25, 2019
commit e64ad1613529ee8ba82715b949b1565af27fd936
42 changes: 21 additions & 21 deletions Engines/Wine/Verbs/D9VK/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { ls, cp, remove } = include("utils.functions.filesystem.files");
const operatingSystemFetcher = Bean("operatingSystemFetcher");
const Optional = Java.type("java.util.Optional");
const OverrideDLL = include("engines.wine.plugins.override_dll");
const { getGithubReleases } = include("utils.functions.net.githubreleases");
const { fetchGithubReleases, downloadGithubRelease, extractGithubReleaseStrings } = include("utils.functions.net.githubreleases");

/**
* Verb to install D9VK
Expand All @@ -28,6 +28,16 @@ class D9VK {
return this;
}

selectGithubVersion(wizard) {
Comment thread
madoar marked this conversation as resolved.
Outdated
const versions = fetchGithubReleases("Joshua-Ashton", "d9vk", wizard);

if (!this.d9vkVersion || typeof this.d9vkVersion !== 'string') {
return versions[0];
} else {
return versions.find(version => version.name === this.d9vkVersion);
}
}
Comment thread
madoar marked this conversation as resolved.
Outdated

go() {
const wizard = this.wine.wizard();
const prefixDirectory = this.wine.prefixDirectory();
Expand All @@ -36,8 +46,7 @@ class D9VK {

print("NOTE: Wine version should be greater or equal to 3.10");

if (operatingSystemFetcher.fetchCurrentOperationSystem().getFullName() !== "Linux")
{
if (operatingSystemFetcher.fetchCurrentOperationSystem().getFullName() !== "Linux") {
const question = tr("D9VK is currently unsupported on non-Linux operating systems due to MoltenVK implementation being incomplete. Select how do you want to approach this situation.")
const choices = [
tr("YES, continue with DXVK installation regardless"),
Expand All @@ -55,35 +64,24 @@ class D9VK {
// choice: "Exit D9VK Installer, but continue with the script"
return this;
default:
// do nothing
// do nothing
}
}
else
{
else {
wizard.message(tr("Please ensure you have the latest drivers (418.30 minimum for NVIDIA and mesa 19 for AMD) or else D9VK might not work correctly."));
}

if (typeof this.d9vkVersion !== 'string')
{
const versions = getGithubReleases("Joshua-Ashton", "d9vk", wizard);
this.d9vkVersion = versions[0];
}
const selectedVersion = this.selectGithubVersion(wizard);

var setupFile = new Resource()
.wizard(wizard)
.url(
`https://github.com/Joshua-Ashton/d9vk/releases/download/${this.d9vkVersion}/d9vk-${this.d9vkVersion}.tar.gz`
)
.name(`d9vk-${this.d9vkVersion}.tar.gz`)
.get();
var setupFile = this.downloadGithubRelease(selectedVersion, wizard);

new Extractor()
.wizard(wizard)
.archive(setupFile)
.to(`${prefixDirectory}/TMP/`)
.extract();

const d9vkTmpDir = `${prefixDirectory}/TMP/d9vk-${this.d9vkVersion}`;
const d9vkTmpDir = `${prefixDirectory}/TMP/d9vk-${selectedVersion.name}`;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this pattern in multiple places and I don't like it. The version name should not be needed in the folder names in my opinion, especially because we have no "safe" method to fetch it. Who guarantees that name or tag_name contains the correct version name?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, also it does not seem to be required at all.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These folder names seem to be dependent on the content of the downloaded archives. I don't think we can replace them with a real temporary directory.


// copy 32 bits dll to system* and apply override
ls(`${d9vkTmpDir}/x32`).forEach(file => {
Expand Down Expand Up @@ -115,8 +113,10 @@ class D9VK {
wine.wizard(wizard);
wine.prefix(container);

const versions = getGithubReleases("Joshua-Ashton", "d9vk", wizard);
const selectedVersion = wizard.menu(tr("Please select the version."), versions, versions[0]);
const versions = fetchGithubReleases("Joshua-Ashton", "d9vk", wizard);
const versionStrings = extractGithubReleaseStrings(versions);

const selectedVersion = wizard.menu(tr("Please select the version."), versionStrings, versionStrings[0]);

// install selected version
new D9VK(wine).withVersion(selectedVersion.text).go();
Comment thread
madoar marked this conversation as resolved.
Expand Down
32 changes: 17 additions & 15 deletions Engines/Wine/Verbs/FAudio/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Wine = include("engines.wine.engine.object");
const Resource = include("utils.functions.net.resource");
const { Extractor } = include("utils.functions.filesystem.extract");
const { ls, cp } = include("utils.functions.filesystem.files");
const { getGithubReleases } = include("utils.functions.net.githubreleases");
const { fetchGithubReleases, downloadGithubRelease, extractGithubReleaseStrings } = include("utils.functions.net.githubreleases");

const Optional = Java.type("java.util.Optional");

Expand All @@ -29,6 +29,16 @@ class FAudio {
return this;
}

selectGithubVersion(wizard) {
const versions = fetchGithubReleases("Kron4ek", "FAudio-Builds", wizard);

if (!this.faudioVersion || typeof this.faudioVersion !== 'string') {
return versions[0];
} else {
return versions.find(version => version.name === this.faudioVersion);
}
}

go() {
const wizard = this.wine.wizard();
const prefixDirectory = this.wine.prefixDirectory();
Expand All @@ -38,26 +48,17 @@ class FAudio {
throw "FAudio does not support 32bit architecture.";
}

if (typeof this.faudioVersion !== "string") {
const versions = getGithubReleases("Kron4ek", "FAudio-Builds", wizard);
this.faudioVersion = versions[0];
}
const selectedVersion = this.selectGithubVersion(wizard);

const setupFile = new Resource()
.wizard(wizard)
.url(
`https://github.com/Kron4ek/FAudio-Builds/releases/download/${this.faudioVersion}/faudio-${this.faudioVersion}.tar.xz`
)
.name(`faudio-${this.faudioVersion}.tar.xz`)
.get();
const setupFile = downloadGithubRelease(selectedVersion, wizard);

new Extractor()
.wizard(wizard)
.archive(setupFile)
.to(`${prefixDirectory}/FAudio/`)
.extract();

const faudioDir = `${prefixDirectory}/FAudio/faudio-${this.faudioVersion}`;
const faudioDir = `${prefixDirectory}/FAudio/faudio-${selectedVersion.name}`;

ls(`${faudioDir}/x64`).forEach(file => {
if (file.endsWith(".dll")) {
Expand All @@ -75,9 +76,10 @@ class FAudio {
wine.prefix(container);
wine.wizard(wizard);

const versions = getGithubReleases("Kron4ek", "FAudio-Builds", wizard);
const versions = fetchGithubReleases("Kron4ek", "FAudio-Builds", wizard);
const versionStrings = extractGithubReleaseStrings(versions);

const selectedVersion = wizard.menu(tr("Please select the version."), versions, versions[0]);
const selectedVersion = wizard.menu(tr("Please select the version."), versionStrings, versionStrings[0]);

// install selected version
new FAudio(wine).withVersion(selectedVersion.text).go();
Expand Down
44 changes: 23 additions & 21 deletions Engines/Wine/Verbs/VK9/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { Extractor } = include("utils.functions.filesystem.extract");
const operatingSystemFetcher = Bean("operatingSystemFetcher");
const Optional = Java.type("java.util.Optional");
const OverrideDLL = include("engines.wine.plugins.override_dll");
const { getGithubReleases } = include("utils.functions.net.githubreleases");
const { fetchGithubReleases, downloadGithubRelease, extractGithubReleaseStrings } = include("utils.functions.net.githubreleases");

/**
* Verb to install VK9
Expand All @@ -27,14 +27,23 @@ class VK9 {
return this;
}

selectGithubVersion(wizard) {
const versions = fetchGithubReleases("disks86", "VK9", wizard);

if (!this.vk9Version || typeof this.vk9Version !== 'string') {
return versions[0];
} else {
return versions.find(version => version.name === this.vk9Version);
}
}

go() {
const wizard = this.wine.wizard();
const prefixDirectory = this.wine.prefixDirectory();
const system32directory = this.wine.system32directory();
const system64directory = this.wine.system64directory();

if (operatingSystemFetcher.fetchCurrentOperationSystem().getFullName() !== "Linux")
{
if (operatingSystemFetcher.fetchCurrentOperationSystem().getFullName() !== "Linux") {
const question = tr("VK9 is currently unsupported on non-Linux operating systems due to MoltenVK implementation being incomplete. Select how do you want to approach this situation.")
const choices = [
tr("YES, continue with VK9 installation regardless"),
Expand All @@ -52,43 +61,34 @@ class VK9 {
// choice: "Exit VK9 Installer, but continue with the script"
return this;
default:
// do nothing
// do nothing
}
}

print("NOTE: wine version should be greater or equal to 3.5");
print("NOTE: works from 0.28.0");

if (typeof this.vk9Version !== "string") {
const versions = getGithubReleases("disks86", "VK9", wizard);
this.vk9Version = versions[0];
}
const selectedVersion = this.selectGithubVersion(wizard);

const setupFile32 = new Resource()
.wizard(wizard)
.url(
`https://github.com/disks86/VK9/releases/download/${this.vk9Version}/${this.vk9Version}-bin-x86-Release.zip`
)
.name(`${this.vk9Version}-bin-x86-Realease.zip`)
.get();
const setupFile32 = downloadGithubRelease(selectedVersion, wizard);

new Extractor()
.wizard(wizard)
.archive(setupFile32)
.to(`${prefixDirectory}/TMP32/`)
.extract();

cp(`${prefixDirectory}/TMP32/${this.vk9Version}-bin-x86-Release/d3d9.dll`, system32directory);
cp(`${prefixDirectory}/TMP32/${selectedVersion.name}-bin-x86-Release/d3d9.dll`, system32directory);

remove(`${prefixDirectory}/TMP32/`);

if (this.wine.architecture() === "amd64") {
const setupFile64 = new Resource()
.wizard(wizard)
.url(
`https://github.com/disks86/VK9/releases/download/${this.vk9Version}/${this.vk9Version}-bin-x86_64-Release.zip`
`https://github.com/disks86/VK9/releases/download/${selectedVersion.name}/${selectedVersion.name}-bin-x86_64-Release.zip`
)
.name(`${this.vk9Version}-bin-x86_64-Realease.zip`)
.name(`${selectedVersion.name}-bin-x86_64-Realease.zip`)
.get();

new Extractor()
Expand All @@ -97,7 +97,7 @@ class VK9 {
.to(`${prefixDirectory}/TMP64/`)
.extract();

cp(`${prefixDirectory}/TMP64/${this.vk9Version}-bin-x86_64-Release/d3d9.dll`, system64directory);
cp(`${prefixDirectory}/TMP64/${selectedVersion.name}-bin-x86_64-Release/d3d9.dll`, system64directory);

remove(`${prefixDirectory}/TMP64/`);
}
Expand All @@ -112,8 +112,10 @@ class VK9 {
wine.wizard(wizard);
wine.prefix(container);

const versions = getGithubReleases("disks86", "VK9", wizard);
const selectedVersion = wizard.menu(tr("Please select the version."), versions, versions[0]);
const versions = fetchGithubReleases("disks86", "VK9", wizard);
const versionStrings = extractGithubReleaseStrings(versions);

const selectedVersion = wizard.menu(tr("Please select the version."), versionStrings, versionStrings[0]);

// install selected version
new VK9(wine).withVersion(selectedVersion.text).go();
Expand Down
30 changes: 16 additions & 14 deletions Engines/Wine/Verbs/gallium9/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Wine = include("engines.wine.engine.object");
const Resource = include("utils.functions.net.resource");
const { Extractor } = include("utils.functions.filesystem.extract");
const { remove, lns } = include("utils.functions.filesystem.files");
const { getGithubReleases } = include("utils.functions.net.githubreleases");
const { fetchGithubReleases, downloadGithubRelease, extractGithubReleaseStrings } = include("utils.functions.net.githubreleases");

const Optional = Java.type("java.util.Optional");

Expand All @@ -29,29 +29,30 @@ class Gallium9 {
return this;
}

selectGithubVersion(wizard) {
const versions = fetchGithubReleases("iXit", "wine-nine-standalone", wizard);

if (!this.gallium9Version || typeof this.gallium9Version !== 'string') {
return versions[0];
} else {
return versions.find(version => version.name === this.gallium9Version);
}
}

go() {
const wizard = this.wine.wizard();
const prefixDirectory = this.wine.prefixDirectory();
const system32directory = this.wine.system32directory();

if (typeof this.gallium9Version !== "string") {
const versions = getGithubReleases("iXit", "wine-nine-standalone", wizard);
this.gallium9Version = versions[0];
}
const selectedVersion = this.selectGithubVersion(wizard);

wizard.message(
tr(
"Using Gallium 9 requires to have a driver supporting the Gallium 9 state tracker, as well as d3dapater9.so installed (ex: libd3d9adapter-mesa package). Please be sure it is installed (both 32 and 64 bits)."
)
);

const setupFile = new Resource()
.wizard(wizard)
.url(
`https://github.com/iXit/wine-nine-standalone/releases/download/${this.gallium9Version}/gallium-nine-standalone-${this.gallium9Version}.tar.gz`
)
.name(`gallium-nine-standalone-${this.gallium9Version}.tar.gz`)
.get();
const setupFile = downloadGithubRelease(selectedVersion, wizard);

new Extractor()
.wizard(wizard)
Expand Down Expand Up @@ -95,9 +96,10 @@ class Gallium9 {
const wine = new Wine();
const wizard = SetupWizard(InstallationType.VERBS, "gallium9", Optional.empty());

const versions = getGithubReleases("iXit", "wine-nine-standalone", wizard);
const versions = fetchGithubReleases("iXit", "wine-nine-standalone", wizard);
const versionStrings = extractGithubReleaseStrings(versions);

const selectedVersion = wizard.menu(tr("Please select the version."), versions, versions[0]);
const selectedVersion = wizard.menu(tr("Please select the version."), versionStrings, versionStrings[0]);

wine.prefix(container);
wine.wizard(wizard);
Expand Down
28 changes: 20 additions & 8 deletions Utils/Functions/Net/GithubReleases/script.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
const Downloader = include("utils.functions.net.download");
const {createTempDir, remove, cat} = include("utils.functions.filesystem.files");
const Resource = include("utils.functions.net.resource");
const { createTempDir, remove, cat } = include("utils.functions.filesystem.files");

/**
* Get an array of tag corresponding to the releases in a git repository
* Fetches an array of tag corresponding to the releases in a git repository
*
* @param {string} repositoryOwner owner of the repository
* @param {string} repositoryName name of the repository
* @param {wizard} wizard the wizard
* @returns {string[]} list of version tag in the repository
* @returns {object[]} list of version objects in the repository
*/
module.getGithubReleases = function getGithubReleases(repositoryOwner, repositoryName, wizard) {
module.fetchGithubReleases = function fetchGithubReleases(repositoryOwner, repositoryName, wizard) {
Comment thread
madoar marked this conversation as resolved.
Outdated
const tmpDir = createTempDir();

const releasesFile = new Downloader()
.wizard(wizard)
.url(
`https://api.github.com/repos/${repositoryOwner}/${repositoryName}/releases`
)
.url(`https://api.github.com/repos/${repositoryOwner}/${repositoryName}/releases`)
.message(tr("Fetching versions list..."))
.to(tmpDir + "/releases.json")
.get();

const versions = JSON.parse(cat(releasesFile)).map(version => version.tag_name);
const versions = JSON.parse(cat(releasesFile));

remove(tmpDir);

return versions;
};

module.extractGithubReleaseStrings = function extractGithubReleaseStrings(versions) {
return versions.map(version => version.name);
}
Comment thread
madoar marked this conversation as resolved.
Outdated

module.downloadGithubRelease = function downloadGithubRelease(version, wizard) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be

module.downloadGithubRelease = function (version, wizard) {

?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

return new Resource()
.wizard(wizard)
.url(version.tarball_url)
// TODO: generate a more "random" name to prevent file conflicts
.name(`${version.name}.tar.xz`)
Comment thread
madoar marked this conversation as resolved.
Outdated
.get();
}