diff --git a/changelog.txt b/changelog.txt index ad8a9e4..0ee568b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,5 +3,4 @@ and only contains the latest changes. Its purpose is to be shown in Olympus when updating. #changelog# -∙ Added the ground work for the future Flatpak package -∙ Fixed 1-click installing on Linux +∙ Also check for Maple updates when checking for Ahorn updates diff --git a/sharp/AhornHelper.cs b/sharp/AhornHelper.cs index 896e500..8c3d5dc 100644 --- a/sharp/AhornHelper.cs +++ b/sharp/AhornHelper.cs @@ -323,25 +323,25 @@ public static string GetJuliaVersion() { return GetJuliaOutput(@"println(VERSION)", out _); } - public static string GetAhornPkgVersion() { - return GetJuliaOutput(PrefixPkgActivate + @" + public static string GetPkgVersion(string package) { + return GetJuliaOutput(PrefixPkgActivate + $@" if !(""Ahorn"" ∈ keys(Pkg.installed())) return end try local ctx = Pkg.Types.Context() - println(string(ctx.env.manifest[ctx.env.project.deps[""Ahorn""]].tree_hash)) + println(string(ctx.env.manifest[ctx.env.project.deps[""{package}""]].tree_hash)) catch e println(""?"") end ", out _); } - public static string GetAhornVersion() { + public static string GetVersion(string package) { string path = AhornPath; if (string.IsNullOrEmpty(path) || !File.Exists(path)) - return GetAhornPkgVersion() + " (pkg)"; + return GetPkgVersion(package) + " (pkg)"; // julia-depot/packages/Ahorn/*/src/Ahorn.jl path = Path.GetDirectoryName(path); // julia-depot/packages/Ahorn/*/src @@ -350,11 +350,11 @@ public static string GetAhornVersion() { path = Path.GetDirectoryName(path); // julia-depot/packages path = Path.GetDirectoryName(path); // julia-depot if (string.IsNullOrEmpty(path) || !Directory.Exists(path)) - return GetAhornPkgVersion() + " (pkg)"; + return GetPkgVersion(package) + " (pkg)"; path = Path.Combine(path, "clones"); if (!Directory.Exists(path)) - return GetAhornPkgVersion() + " (pkg)"; + return GetPkgVersion(package) + " (pkg)"; foreach (string clone in Directory.EnumerateDirectories(path)) { string config = Path.Combine(clone, "config"); @@ -364,7 +364,7 @@ public static string GetAhornVersion() { using (StreamReader reader = new StreamReader(stream)) { if (!reader.ReadLineUntil("[remote \"origin\"]")) continue; - if (reader.ReadLine()?.Trim() != "url = https://github.com/CelestialCartographers/Ahorn.git") + if (reader.ReadLine()?.Trim() != $"url = https://github.com/CelestialCartographers/{package}.git") continue; } @@ -383,7 +383,7 @@ public static string GetAhornVersion() { } } - return GetAhornPkgVersion() + " (pkg)"; + return GetPkgVersion(package) + " (pkg)"; } } diff --git a/sharp/CmdAhornGetInfo.cs b/sharp/CmdAhornGetInfo.cs index 457ab18..79a4bf1 100644 --- a/sharp/CmdAhornGetInfo.cs +++ b/sharp/CmdAhornGetInfo.cs @@ -41,7 +41,9 @@ public class Info { public string AhornEnvPath = AhornHelper.AhornEnvPath; public string AhornPath = AhornHelper.AhornPath; public bool AhornIsLocal = AhornHelper.AhornIsLocal; - public string AhornVersion = AhornHelper.GetAhornVersion(); + public string AhornVersion = AhornHelper.GetVersion("Ahorn"); + + public string MapleVersion = AhornHelper.GetVersion("Maple"); } diff --git a/src/scenes/ahornsetup.lua b/src/scenes/ahornsetup.lua index 3f62b2b..6dbff95 100644 --- a/src/scenes/ahornsetup.lua +++ b/src/scenes/ahornsetup.lua @@ -404,16 +404,18 @@ If you really need to cancel the installation process: }) end -function scene.updateAhornAlert(installed, found) +function scene.updateAhornAlert(installedAhorn, installedMaple, foundAhorn, foundMaple) alert({ body = string.format([[ -Olympus has found a possibly newer version of Ahorn. +Olympus has found a possibly newer version of Ahorn and/or Maple. -Detected installed version: -%s +Detected installed versions: +Ahorn: %s +Maple: %s -Latest available version: -%s +Latest available versions: +Ahorn: %s +Maple: %s Just like installing Ahorn, IT WILL TAKE A LONG TIME. Olympus will detect hangs and abort too slow installation processes. @@ -425,7 +427,7 @@ If you really need to cancel the installation process: (love.system.getOS() == "OS X" and "Open the Activity Monitor and force-close the Julia process.") or (love.system.getOS() == "Linux" and "You probably know your way around htop and kill.") or ("... Good luck killing the Julia process.")), - installed, found), + installedAhorn, foundAhorn, installedMaple, foundMaple), buttons = { { "Install updates", @@ -784,8 +786,9 @@ Olympus can download Ahorn and start the installation process for you. uie.label(string.format([[ Found installation path: %s -Found version: %s]], - tostring(info.AhornPath), tostring(info.AhornVersion) +Found Ahorn version: %s +Found Maple version: %s]], + tostring(info.AhornPath), tostring(info.AhornVersion), tostring(info.MapleVersion) )), btnRow("check", { { "mainmenu/ahorn", "Launch Ahorn", scene.launchAhorn }, @@ -793,27 +796,34 @@ Found version: %s]], }):with(function(row) local btn = row.children[2] scene.latestGet:calls(function(thread, latest) - local installedHash, installedHashType = tostring(info.AhornVersion or ""):match("(.*) %((.*)%)") - - if installedHashType == "git" then - latest = latest and latest.sha - elseif installedHashType == "pkg" then - latest = latest and latest.commit - latest = latest and latest.tree - latest = latest and latest.sha - else - latest = nil + local function getLatest(latest, installedHashType) + if installedHashType == "git" then + latest = latest and latest.sha + elseif installedHashType == "pkg" then + latest = latest and latest.commit + latest = latest and latest.tree + latest = latest and latest.sha + else + latest = nil + end + return latest end - if not installedHash or not latest then + local installedAhornHash, installedAhornHashType = tostring(info.AhornVersion or ""):match("(.*) %((.*)%)") + local installedMapleHash, installedMapleHashType = tostring(info.MapleVersion or ""):match("(.*) %((.*)%)") + + local latestAhorn = getLatest(latest.ahorn, installedAhornHashType) + local latestMaple = getLatest(latest.maple, installedMapleHashType) + + if not installedAhornHash or not installedMapleHash or not latestAhorn or not latestMaple then return end - if installedHash ~= latest then + if installedAhornHash ~= latestAhorn or installedMapleHash ~= latestMaple then btn.children[1].children[1].image = uiu.image("download") btn.children[1].children[2].text = "Install updates" btn.cb = function() - scene.updateAhornAlert(installedHash, latest) + scene.updateAhornAlert(installedAhornHash, latestAhorn, installedMapleHash, latestMaple) end btn:with(utils.important(24)) end @@ -836,8 +846,10 @@ end function scene.load() scene.latestGet = threader.routine(function() - scene.latest = threader.wrap("utils").downloadJSON("https://api.github.com/repos/CelestialCartographers/Ahorn/commits/master"):result() - return scene.latest + return { + ahorn = threader.wrap("utils").downloadJSON("https://api.github.com/repos/CelestialCartographers/Ahorn/commits/master"):result(), + maple = threader.wrap("utils").downloadJSON("https://api.github.com/repos/CelestialCartographers/Maple/commits/master"):result() + } end) end