diff --git a/.gitignore b/.gitignore
index a52d982..b8c3f65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -236,3 +236,4 @@ _Pvt_Extensions
# FAKE - F# Make
.fake/
+vpm.*.7z
diff --git a/src/vpm/ChooseDir.xaml b/src/vpm/ChooseDir.xaml
index f36a127..7609ab8 100644
--- a/src/vpm/ChooseDir.xaml
+++ b/src/vpm/ChooseDir.xaml
@@ -3,10 +3,9 @@
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:vpm"
- mc:Ignorable="d" Height="96" Width="399"
+ mc:Ignorable="d" Height="173" Width="399"
BorderThickness="0"
GlowBrush="Black"
ResizeMode="CanResizeWithGrip"
@@ -33,9 +32,18 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/vpm/Program.cs b/src/vpm/Program.cs
index 4fdc976..b085152 100644
--- a/src/vpm/Program.cs
+++ b/src/vpm/Program.cs
@@ -116,26 +116,19 @@ static void Main(string[] args)
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Initialization complete.");
Console.ResetColor();
-
- VpmConfig.Instance.WinApp.BeginInvoke(() =>
- {
- var winapp = VpmConfig.Instance.WinApp;
- var window = VpmConfig.Instance.AgreeWindow = new UserAgree();
- winapp.MainWindow = window;
- window.Show();
- });
- while (!VpmConfig.Instance.AgreementsAgreed)
- {
- Thread.Sleep(10);
- }
- if (VpmConfig.Instance.InstallationCancelled)
+ if (!VpmConfig.Instance.Arguments.Quiet)
{
- VpmUtils.CleanUp();
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Installation is canceled");
- Thread.Sleep(5000);
- Environment.Exit(0);
+
+ if (!VpmUtils.PromptYayOrNay(
+ "Vpm does not ask individual licenses anymore. " +
+ "It is the user's responsibility to know and fully comply with the licenses " +
+ "of the currently installed pack and all of its dependencies.\n" +
+ "Do you agree?"))
+ {
+ VpmUtils.CleanUp();
+ Environment.Exit(0);
+ }
}
vpack.Install();
diff --git a/src/vpm/UserAgree.xaml b/src/vpm/UserAgree.xaml
deleted file mode 100644
index bcd991a..0000000
--- a/src/vpm/UserAgree.xaml
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/vpm/UserAgree.xaml.cs b/src/vpm/UserAgree.xaml.cs
deleted file mode 100644
index 7dd5483..0000000
--- a/src/vpm/UserAgree.xaml.cs
+++ /dev/null
@@ -1,173 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Timers;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using System.Windows.Threading;
-using MahApps.Metro.Controls;
-using CefSharp;
-using CefSharp.Wpf;
-
-namespace vpm
-{
- ///
- /// Interaction logic for UserAgree.xaml
- ///
- public partial class UserAgree : MetroWindow
- {
- public JsVPackInterop InteropObj;
- public ListBoxItem SelectedPack;
- public bool PackChanged = false;
- public UserAgree()
- {
- InitializeComponent();
- }
-
- public void DisableAgree()
- {
- Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
- {
- AgreeAndInstall.IsEnabled = false;
- }));
- }
- public void EnableAgree()
- {
- Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
- {
- AgreeAndInstall.IsEnabled = true;
- }));
- }
-
- public void ContinueFromJS()
- {
- Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
- {
- AgreeAndInstall.IsEnabled = true;
- AgreeAndInstall.IsChecked = true;
- if (VPackList.SelectedIndex < VPackList.Items.Count - 1)
- VPackList.SelectedIndex = (VPackList.SelectedIndex + 1) % VPackList.Items.Count;
- }));
- }
- private void ContinueInstall_Click(object sender, RoutedEventArgs e)
- {
- VpmConfig.Instance.InstallationCancelled = false;
- VpmConfig.Instance.WaitSignal = false;
- VpmConfig.Instance.AgreementsAgreed = true;
- VpmConfig.Instance.AgreeWindow.Close();
- }
-
- private void UserAgree_OnInitialized(object sender, EventArgs e)
- {
-
- InteropObj = new JsVPackInterop
- {
- UserAgreeWindow = this
- };
- Browser.RegisterJsObject("vpm", InteropObj);
- foreach (var vpack in VpmConfig.Instance.PackList)
- {
- var item = new ListBoxItem
- {
- Content = vpack,
- Background = new SolidColorBrush
- {
- Color = Color.FromRgb(255, 0, 0)
- },
- };
- VPackList.Items.Add(item);
- }
- var delay = new Timer { Interval = 1000 };
- delay.Elapsed += (o, ee) =>
- {
- Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
- {
- VPackList.SelectedIndex = 0;
- delay.Stop();
- }));
- };
- delay.Start();
- }
-
- private void VPackList_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if(e.AddedItems.Count <= 0) return;
- PackChanged = true;
- SelectedPack = (ListBoxItem)e.AddedItems[0];
- var pack = (VPack)SelectedPack.Content;
- AgreeAndInstall.IsChecked = pack.Agreed;
- Browser.Load(pack.LicenseUrl);
- }
-
- private void AgreeAndInstall_OnChecked(object sender, RoutedEventArgs e)
- {
- SelectedPack.Background = new SolidColorBrush
- {
- Color = Color.FromRgb(0, 255, 0)
- };
- var pack = (VPack)SelectedPack.Content;
- pack.Agreed = true;
-
- ContinueInstall.IsEnabled = (from ListBoxItem item in VPackList.Items select (VPack) item.Content).Aggregate(true, (current, ipack) => current && ipack.Agreed);
- if (ContinueInstall.IsEnabled) ContinueInstall.Opacity = 1;
-
- }
-
- private void Browser_OnLoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
- {
- Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action( () =>
- {
- if (PackChanged)
- {
- if (e.IsLoading)
- {
- LoadingCover.Visibility = Visibility.Visible;
- LoadingRing.IsActive = true;
- AgreeAndInstall.IsEnabled = false;
- InteropObj.CurrentPack = (VPack)SelectedPack.Content;
- }
- else
- {
- LoadingCover.Visibility = Visibility.Hidden;
- LoadingRing.IsActive = false;
- AgreeAndInstall.IsEnabled = true;
- NextPack.IsEnabled = true;
- PackChanged = false;
- }
- }
- else
- {
- SmallLoadingRing.IsActive = e.IsLoading;
- }
- }));
- }
-
- private void NextPack_OnClick(object sender, RoutedEventArgs e)
- {
- VPackList.SelectedIndex = (VPackList.SelectedIndex + 1) % VPackList.Items.Count;
- }
-
- private void AgreeAndInstall_OnIsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- if ((bool)e.NewValue) AgreeAndInstall.Opacity = 1;
- else AgreeAndInstall.Opacity = 0.5;
- }
-
- private void OnCancelled(object sender, EventArgs e)
- {
- VpmConfig.Instance.InstallationCancelled = true;
- VpmConfig.Instance.WaitSignal = false;
- VpmConfig.Instance.AgreementsAgreed = true;
- VpmConfig.Instance.DirWindow.Close();
- }
- }
-}
diff --git a/src/vpm/packages.config b/src/vpm/packages.config
index 2870414..9b25ba2 100644
--- a/src/vpm/packages.config
+++ b/src/vpm/packages.config
@@ -1,9 +1,5 @@
-
-
-
-
diff --git a/src/vpm/utils.cs b/src/vpm/utils.cs
index 06b408d..de13025 100644
--- a/src/vpm/utils.cs
+++ b/src/vpm/utils.cs
@@ -1,431 +1,431 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Management.Automation;
-using System.Net;
-using System.Reflection;
-using System.Text.RegularExpressions;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Xml;
-using LibGit2Sharp;
-using LibGit2Sharp.Handlers;
-using Microsoft.Win32;
-using PowerArgs;
-
-namespace vpm
-{
- public class UpdateTimer
- {
- private static UpdateTimer _instance;
- public static UpdateTimer Instance => _instance ?? (_instance = new UpdateTimer());
-
- private Stopwatch Stopwatch = new Stopwatch();
-
- public long msLimit = 50;
-
- public UpdateTimer()
- {
- Stopwatch.Start();
- }
-
- public void Reset()
- {
- Stopwatch.Restart();
- }
-
- public bool Update()
- {
- if (ms > msLimit)
- {
- Reset();
- return true;
- }
- return false;
- }
-
- public long ms => Stopwatch.ElapsedMilliseconds;
- }
-
- public enum MachineType
- {
- Native = 0,
- x86 = 0x014c,
- Itanium = 0x0200,
- x64 = 0x8664
- }
-
- public class VersionRelation
- {
- // value is current - existing
- public int MajorDiff { get; private set; }
- public int MinorDiff { get; private set; }
- public int BuildDiff { get; private set; }
- public int RevisionDiff { get; private set; }
-
- public VersionRelation(System.Version curr, System.Version existing)
- {
- MajorDiff = curr.Major - existing.Major;
- MinorDiff = curr.Minor - existing.Minor;
- BuildDiff = curr.Build - existing.Build;
- RevisionDiff = curr.Revision - existing.Revision;
- }
- }
-
- public static class VpmUtils
- {
- public static Task StartSTATask(Func func)
- {
- var tcs = new TaskCompletionSource();
- Thread thread = new Thread(() =>
- {
- try
- {
- tcs.SetResult(func());
- }
- catch (Exception e)
- {
- tcs.SetException(e);
- }
- });
- thread.SetApartmentState(ApartmentState.STA);
- thread.Start();
- VpmConfig.Instance.ApplicationThread = thread;
- return tcs.Task;
- }
-
- public static void Wait()
- {
- while (VpmConfig.Instance.WaitSignal)
- {
- Thread.Sleep(10);
- }
- }
- public static void ConsoleClearLine()
- {
- Console.SetCursorPosition(0, Math.Max(Console.CursorTop - 1, 0));
- Console.Write(new String(' ', Console.BufferWidth));
- Console.SetCursorPosition(0, Math.Max(Console.CursorTop - 1, 0));
- }
-
- public static MachineType GetMachineType(string fileName)
- {
- const int PE_POINTER_OFFSET = 60;
- const int MACHINE_OFFSET = 4;
- byte[] data = new byte[4096];
- using (Stream s = new FileStream(fileName, FileMode.Open, FileAccess.Read))
- {
- s.Read(data, 0, 4096);
- }
- // dos header is 64 bytes, last element, long (4 bytes) is the address of the PE header
- int PE_HEADER_ADDR = BitConverter.ToInt32(data, PE_POINTER_OFFSET);
- int machineUint = BitConverter.ToUInt16(data, PE_HEADER_ADDR + MACHINE_OFFSET);
- return (MachineType) machineUint;
- }
-
- public static void CleanUp()
- {
- var tempdir = VpmConfig.Instance.VpmTempDir;
- Console.WriteLine("Removing vpm temp folder.");
- File.SetAttributes(tempdir, FileAttributes.Normal);
- PatientDeleteDirectory(tempdir, true, 0, 3);
- Console.WriteLine("Killing GUI");
- VpmConfig.Instance.ApplicationThread.Abort();
- }
-
- public static void PatientDeleteDirectory(string path, bool recursive, int currtry, int maxtry)
- {
- try
- {
- DeleteDirectory(path, recursive);
- }
- catch (Exception e)
- {
- if (e is IOException || e is UnauthorizedAccessException)
- {
- if (currtry < maxtry)
- {
- Console.WriteLine("It seems to be a file is not released yet. Waiting 5 seconds");
- Thread.Sleep(5000);
- PatientDeleteDirectory(path, recursive, currtry + 1, maxtry);
- }
- else
- {
- Console.WriteLine("Files didn't unlock in {0}.\nYou might have to delete it yourself.",
- VpmConfig.Instance.VpmTempDir);
- }
- }
- else throw e;
- }
- }
-
- public static void DeleteDirectory(string path, bool recursive)
- {
- // Delete all files and sub-folders?
- if (recursive)
- {
- // Yep... Let's do this
- var subfolders = Directory.GetDirectories(path);
- foreach (var s in subfolders)
- {
- DeleteDirectory(s, recursive);
- }
- }
-
- // Get all files of the folder
- var files = Directory.GetFiles(path);
- foreach (var f in files)
- {
- // Get the attributes of the file
- var attr = File.GetAttributes(f);
-
- // Is this file marked as 'read-only'?
- if ((attr & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
- {
- // Yes... Remove the 'read-only' attribute, then
- File.SetAttributes(f, attr ^ FileAttributes.ReadOnly);
- }
-
- // Delete the file
- File.Delete(f);
- }
-
- // When we get here, all the files of the folder were
- // already deleted, so we just delete the empty folder
- Directory.Delete(path);
- }
-
- public static bool PromptYayOrNay(string question, string note = "", string ch1 = "Y", string ch2 = "N")
- {
- bool first = true;
- while (true)
- {
- if (first)
- {
- Console.ForegroundColor = ConsoleColor.Yellow;
- Console.WriteLine(question + " (" + ch1 + " or " + ch2 + ")");
- if (!string.IsNullOrEmpty(note)) Console.WriteLine(note);
- Console.ResetColor();
- }
- var decision = Console.ReadLine();
- if (decision == null) continue;
- decision = decision.ToLower();
- if (decision.Contains(ch1.ToLower()))
- {
- return true;
- }
- if (decision.Contains(ch2.ToLower()))
- {
- return false;
- }
- first = false;
- }
- }
-
- public static void ConfirmContinue()
- {
- if (Args.GetAmbientArgs().Quiet) return;
- if (PromptYayOrNay("Do you still want to continue?")) return;
- CleanUp();
- Environment.Exit(0);
- }
-
- public static bool IsAliasExisting(string name)
- {
- var packsdir = Path.Combine(Args.GetAmbientArgs().VVVVDir, "packs");
- if (!Directory.Exists(packsdir))
- {
- Directory.CreateDirectory(packsdir);
- return false;
- }
- foreach (var d in Directory.GetDirectories(packsdir))
- {
- var cname = Path.GetFullPath(d)
- .TrimEnd(Path.DirectorySeparatorChar)
- .Split(Path.DirectorySeparatorChar)
- .Last();
- if (string.Equals(cname, name, StringComparison.InvariantCultureIgnoreCase))
- {
- return true;
- }
- }
- return false;
- }
-
- public static bool IsPackAlreadyInTemp(string name)
- {
- var packsdir = VpmConfig.Instance.VpmTempDir;
- foreach (var d in Directory.GetDirectories(packsdir))
- {
- var cname = Path.GetFullPath(d)
- .TrimEnd(Path.DirectorySeparatorChar)
- .Split(Path.DirectorySeparatorChar)
- .Last();
- if (string.Equals(cname, name, StringComparison.InvariantCultureIgnoreCase))
- {
- return true;
- }
- }
- return false;
- }
-
- public static bool IsPackExisting(string name, IEnumerable aliases, out string matched)
- {
- if (IsAliasExisting(name))
- {
- matched = name;
- return true;
- }
- if (aliases != null)
- {
- foreach (var a in aliases.Where(IsAliasExisting))
- {
- matched = a;
- return true;
- }
- }
- matched = "";
- return false;
- }
-
- public static XmlDocument ParseAndValidateXmlFile(string xmlfile)
- {
- /*
- var xmlsettings = new XmlReaderSettings
- {
- Async = false,
- DtdProcessing = DtdProcessing.Parse,
- ValidationType = ValidationType.DTD
- };
- xmlsettings.ValidationEventHandler += (sender, args) =>
- {
- throw new Exception(".vpack validation error: " + args.Message);
- };
- var reader = XmlReader.Create(Args.GetAmbientArgs().VPackFile, xmlsettings);
- while (reader.Read());
- */
-
- var doc = new XmlDocument();
- string xmltext = "";
- string url = "";
- if (xmlfile.StartsWith("http://", true, CultureInfo.InvariantCulture))
- url = xmlfile;
- if (xmlfile.StartsWith("https://", true, CultureInfo.InvariantCulture))
- url = xmlfile;
-
- if (xmlfile.StartsWith("vpm://", true, CultureInfo.InvariantCulture))
- url = xmlfile.Replace("vpm://", "http://");
- if (xmlfile.StartsWith("vpms://", true, CultureInfo.InvariantCulture))
- url = xmlfile.Replace("vpms://", "https://");
-
- if (url != "")
- {
- var client = new WebClient();
- try
- {
- var stream = client.OpenRead(url);
- var reader = new StreamReader(stream);
- xmltext = reader.ReadToEnd();
- }
- catch (Exception)
- {
- Console.WriteLine("Problem with URL " + xmlfile);
- throw;
- }
- }
- else
- {
- xmltext = File.ReadAllText(xmlfile);
- }
-
- var installregex = new Regex(@"(.*?)<\/install>", RegexOptions.Multiline | RegexOptions.Singleline);
- var imatch = installregex.Match(xmltext);
- var installtext = imatch.Groups[1].Value;
- installtext = installtext.Replace("<", "<");
- installtext = installtext.Replace(">", ">");
-
- xmltext = Regex.Replace(
- xmltext, @".*?<\/install>", "" + installtext + "",
- RegexOptions.Multiline | RegexOptions.Singleline);
-
- doc.LoadXml(xmltext);
- return doc;
- }
-
- public static void CopyDirectory(
- string src,
- string dst,
- string[] ignore = null,
- string[] match = null,
- Action