Create "Platform"-Property for Repos
This commit is contained in:
parent
5cae428440
commit
21dc22965d
|
@ -22,7 +22,7 @@ You can also add something like this to your Readme: [![UpTool2](https://img.shi
|
|||
- %APPDATA%\UpTool2
|
||||
- Apps
|
||||
- __APPGUID
|
||||
- `info.xml` Local copy of some app information, like [this](https://github.com/JFronny/UpTool2#app-layout) but missing ID, File, Hash and Icon
|
||||
- `info.xml` Local copy of some app information, like [this](https://github.com/JFronny/UpTool2#app-layout) but missing ID, File, Hash, Platform and Icon
|
||||
- [`package.zip`](https://github.com/JFronny/UpTool2#package-layout) The package that was downloaded on install
|
||||
- `app` The app install path
|
||||
- `__APPFILES` Copy of the app files from above, may contain user-configs
|
||||
|
@ -53,6 +53,7 @@ You can also add something like this to your Readme: [![UpTool2](https://img.shi
|
|||
- `Hash` The files SHA256 Hash
|
||||
- `Icon` The apps icon, (optional)
|
||||
- `MainFile` Main binary, used for starting, (optional)
|
||||
- `Platform` The platform this works on (optional, defaults to current)
|
||||
## Package layout
|
||||
- `Install.bat` The script for installing the app
|
||||
- `Remove.bat` The script for removing the app
|
||||
|
|
|
@ -8,5 +8,10 @@ namespace UpToolLib
|
|||
{
|
||||
public static readonly Dictionary<Guid, App> Apps = new Dictionary<Guid, App>();
|
||||
public static Version MinimumVer => Version.Parse("0.0.0.0");
|
||||
public const string Windows = "WINDOWS";
|
||||
public const string Posix = "POSIX";
|
||||
|
||||
public static string CurrentPlatform =>
|
||||
PlatformCheck.IsWindows ? Windows : PlatformCheck.IsPosix ? Posix : throw new Exception("Unexpeccted PlatformCheck");
|
||||
}
|
||||
}
|
17
UpToolLib/PlatformCheck.cs
Normal file
17
UpToolLib/PlatformCheck.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace UpToolLib
|
||||
{
|
||||
public static class PlatformCheck
|
||||
{
|
||||
public static bool IsWindows => new[]
|
||||
{
|
||||
PlatformID.Xbox, PlatformID.Win32S, PlatformID.Win32Windows, PlatformID.Win32NT,
|
||||
PlatformID.WinCE
|
||||
}
|
||||
.Contains(Environment.OSVersion.Platform);
|
||||
|
||||
public static bool IsPosix => !IsWindows;
|
||||
}
|
||||
}
|
|
@ -41,12 +41,7 @@ namespace UpToolLib.Tool
|
|||
CreateNoWindow = true,
|
||||
WindowStyle = ProcessWindowStyle.Hidden
|
||||
}).WaitForExit();*/
|
||||
int key = new[]
|
||||
{
|
||||
PlatformID.Xbox, PlatformID.Win32S, PlatformID.Win32Windows, PlatformID.Win32NT,
|
||||
PlatformID.WinCE
|
||||
}
|
||||
.Contains(Environment.OSVersion.Platform) ? 0 :
|
||||
int key = PlatformCheck.IsWindows ? 0 :
|
||||
File.Exists(Path.Combine(tmp, "Remove.sh")) ? 1 : 2;
|
||||
ProcessStartInfo prc = new ProcessStartInfo
|
||||
{
|
||||
|
|
|
@ -150,12 +150,7 @@ Online: {appI.Hash.ToUpper()}");
|
|||
CreateNoWindow = true,
|
||||
WindowStyle = ProcessWindowStyle.Hidden
|
||||
}).WaitForExit();*/
|
||||
int key = new[]
|
||||
{
|
||||
PlatformID.Xbox, PlatformID.Win32S, PlatformID.Win32Windows, PlatformID.Win32NT,
|
||||
PlatformID.WinCE
|
||||
}
|
||||
.Contains(Environment.OSVersion.Platform) ? 0 :
|
||||
int key = PlatformCheck.IsWindows ? 0 :
|
||||
File.Exists(Path.Combine(tmp, "Install.sh")) ? 1 : 2;
|
||||
ProcessStartInfo prc = new ProcessStartInfo
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace UpToolLib.Tool
|
|||
{
|
||||
#endif
|
||||
ExternalFunctionalityManager.Instance.Log($"[{i + 1}] Loading {repArr[i]}");
|
||||
XDocument repo = XDocument.Load(new Uri(repArr[i]).Unshorten().AbsoluteUri);
|
||||
XDocument repo = XDocument.Load(new Uri(repArr[i]).TryUnshorten().AbsoluteUri);
|
||||
repArr.AddRange(repo.Element("repo").Elements("repolink").Select(s => s.Value)
|
||||
.Where(s => !repArr.Contains(s)));
|
||||
XElement[] tmpApparray = repo.Element("repo").Elements("app").Where(app =>
|
||||
|
@ -38,7 +38,7 @@ namespace UpToolLib.Tool
|
|||
.Select(s =>
|
||||
{
|
||||
ExternalFunctionalityManager.Instance.Log($"- Loading {s.Value}");
|
||||
return XDocument.Load(new Uri(s.Value).Unshorten().AbsoluteUri).Element("app");
|
||||
return XDocument.Load(new Uri(s.Value).TryUnshorten().AbsoluteUri).Element("app");
|
||||
}))
|
||||
.ToArray();
|
||||
foreach (XElement app in tmpApparray)
|
||||
|
@ -63,13 +63,13 @@ namespace UpToolLib.Tool
|
|||
tmpAppsList.Last()
|
||||
.Add(new XElement("Icon",
|
||||
ExternalFunctionalityManager.Instance.FetchImageB64(
|
||||
new Uri(app.Element("Icon").Value).Unshorten())));
|
||||
new Uri(app.Element("Icon").Value).TryUnshorten())));
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
tmpAppsList.Last().Add(new XElement("Platform", app.Element("Platform") == null || !new[]{GlobalVariables.Posix, GlobalVariables.Windows}.Contains(app.Element("Platform").Value) ? GlobalVariables.CurrentPlatform : app.Element("Platform").Value));
|
||||
XElement app1 = app;
|
||||
if (tmpAppsList.Count(a => a.Element("ID").Value == app1.Element("ID").Value) > 1)
|
||||
tmpAppsList.Where(a => a.Element("ID").Value == app.Element("ID").Value).Reverse()
|
||||
|
@ -109,6 +109,7 @@ namespace UpToolLib.Tool
|
|||
string xml = PathTool.InfoXml;
|
||||
XDocument.Load(xml).Element("meta").Element("LocalRepo").Elements().ToList().ForEach(app =>
|
||||
{
|
||||
if (app.Element("Platform").Value != GlobalVariables.CurrentPlatform) return;
|
||||
Guid id = Guid.Parse(app.Element("ID").Value);
|
||||
string locInPath = PathTool.GetInfoPath(id);
|
||||
XElement locIn = File.Exists(locInPath) ? XDocument.Load(locInPath).Element("app") : app;
|
||||
|
|
20
UpToolLib/Tool/TryUnshorten.cs
Normal file
20
UpToolLib/Tool/TryUnshorten.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using CC_Functions.Misc;
|
||||
|
||||
namespace UpToolLib.Tool
|
||||
{
|
||||
public static class TryUnshortenExt
|
||||
{
|
||||
public static Uri TryUnshorten(this Uri self)
|
||||
{
|
||||
try
|
||||
{
|
||||
return self.Unshorten();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return self;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user