コード例 #1
0
        public void Update(Install install)
        {
            var update = new Updater(this, this, GithubApi, Logger);

            update.Update(install);


            var reimports = Installs.Where(i => i.ConfigData.RequiresFullReimport && !i.InstallFinalized).ToArray();

            if (reimports.Any())
            {
                var msg = "Following packages require full reimport to function properly:\n";
                foreach (var reimport in reimports)
                {
                    msg += reimport.ToShortString() + "\n";
                }

                ThreadingUtils.DispatchOnMainThread(() =>
                {
                    if (EditorUtility.DisplayDialog("Koinonia", msg, "Ok", "No, I'll do it myself"))
                    {
                        EditorApplication.ExecuteMenuItem("Assets/Reimport All");
                    }
                    else
                    {
                        AssetDatabase.Refresh();
                    }
                });
            }
            else
            {
                ThreadingUtils.DispatchOnMainThread(AssetDatabase.Refresh);
            }
        }
コード例 #2
0
        public void UninstallNode(Install selectedPackage)
        {
            var installation = new Uninstallation(this, this, GithubApi, Logger);
            var result       = installation.Uninstall(selectedPackage);

            if (selectedPackage.ConfigData.RequiresFullReimport)
            {
                var msg = "Deinstalled package requires full reimport " + selectedPackage.ToShortString();

                ThreadingUtils.DispatchOnMainThread(() =>
                {
                    if (EditorUtility.DisplayDialog("Koinonia", msg, "Ok", "No, I'll do it myself"))
                    {
                        EditorApplication.ExecuteMenuItem("Assets/Reimport All");
                    }
                    else
                    {
                        AssetDatabase.Refresh();
                    }
                });
            }
            else
            {
                ThreadingUtils.DispatchOnMainThread(AssetDatabase.Refresh);
            }
        }
コード例 #3
0
        public bool TryFinalizeInstall(Install install)
        {
            Logger.Log("Finalizing " + install.ToShortString());

            if (!File.Exists(install.GetInstallerPath()))
            {
                Logger.Log("No installer found for " + install.ToShortString() + " - This is normal.");
                Logger.Log("Considering " + install.ToShortString() + " installed.");
                return(true); //Nothing to install
            }

            Logger.Log("Found installer at " + install.GetInstallerPath());
            Logger.Log("Compiling now...");

            var installerCode = File.ReadAllText(install.GetInstallerPath());

            CSharpCodeProvider provider   = new CSharpCodeProvider();
            CompilerParameters parameters = new CompilerParameters();

            // True - memory generation, false - external file generation
            parameters.GenerateInMemory = true;
            // True - exe file generation, false - dll file generation
            parameters.GenerateExecutable = false;

            var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToArray();

            foreach (var assembly in assemblies)
            {
                parameters.ReferencedAssemblies.Add(assembly.Location);
            }

            CompilerResults results = provider.CompileAssemblyFromSource(parameters, installerCode);

            if (results.Errors.HasErrors)
            {
                StringBuilder sb = new StringBuilder();

                foreach (CompilerError error in results.Errors)
                {
                    sb.AppendLine(String.Format("Error ({0}): {1}", error.ErrorNumber, error.ErrorText));
                }



                throw new InvalidOperationException(sb.ToString());
            }

            Logger.Log("Compiled! Executing...");

            Assembly resultAssembly = results.CompiledAssembly;
            Type     program        = resultAssembly.GetTypes().FirstOrDefault(t => typeof(Installer).IsAssignableFrom(t));

            var installer = (Installer)Activator.CreateInstance(program, new object[] { CliFrontend });

            MethodInfo main = program.GetMethod("PostInstall");

            return((bool)main.Invoke(installer, new object[] { install }));
        }
コード例 #4
0
ファイル: Uninstallation.cs プロジェクト: Siniana/Universum
        private void Commit(Install install)
        {
            //DANCE, BABY, DANCE!

            if (Directory.Exists(install.FullMappings.Default))
            {
                Directory.Delete(install.FullMappings.Default, true);
            }

            if (Directory.Exists(install.FullMappings.Root))
            {
                Directory.Delete(install.FullMappings.Root, true);
            }
        }
コード例 #5
0
ファイル: Uninstallation.cs プロジェクト: Siniana/Universum
 public InstallationResult Uninstall(Install install)
 {
     try
     {
         Install_Internal(install);
     }
     catch (ConfigDataNotFoundException ex)
     {
         _logger.LogProblem(ex.Message);
         return(new InstallationResult()
         {
             Success = false
         });
     }
     return(new InstallationResult()
     {
         Success = true
     });
 }
コード例 #6
0
ファイル: Uninstallation.cs プロジェクト: Siniana/Universum
        private void Install_Internal(Install install)
        {
            Add(install);

            foreach (var entry in UninstallPlan.ToArray())
            {
                Commit(entry);
            }

            foreach (var entry in UninstallPlan.ToArray())
            {
                _installsRegistry.RemoveInstall(entry);
            }

            _installsRegistry.Commit();

            foreach (var entry in UninstallPlan)
            {
                _logger.Log("Unnstalled " + entry.RepositoryName + " @ " + entry.Name);
            }
        }
コード例 #7
0
ファイル: Install.cs プロジェクト: Siniana/Universum
 public static string GetInstallerPath(this Install install)
 {
     return(Path.Combine(install.FullMappings.Default, "installer.kcs"));
 }
コード例 #8
0
ファイル: Uninstallation.cs プロジェクト: Siniana/Universum
        private void Add(Install toUninstall)
        {
            _logger.Log("Adding " + toUninstall.ToShortString() + " to the deinstall queue");

            UninstallPlan.Add(toUninstall);
        }
コード例 #9
0
 public void RemoveInstall(Install inst)
 {
     InstallsRegistry.Remove(inst);
 }
コード例 #10
0
 public void AddInstall(Install inst)
 {
     InstallsRegistry.Add(inst);
 }
コード例 #11
0
ファイル: Installation.cs プロジェクト: Siniana/Universum
        public bool Update(Install install)
        {
            var host = new DownloadablesHost()
            {
                AuthorName     = install.AuthorName,
                RepositoryName = install.RepositoryName
            };

            host.FetchDownloadables();

            Downloadable update = null;

            switch (install.Type)
            {
            case DownloadableType.Branch:
                var newsetCommit = host.Downloadables.FirstOrDefault(s => s.Type == DownloadableType.Branch && s.Name == install.Name);
                if (newsetCommit == null)
                {
                    _logger.LogProblem("No commits found for branch " + install.Name);
                    return(false);
                }
                if (newsetCommit.CommitSha != install.CommitSha)
                {
                    update = newsetCommit;
                }
                else
                {
                    _logger.Log("Nothing to update");
                }
                break;

            case DownloadableType.Tag:
                _logger.LogProblem("Updating Tags is not supported. Install release instead.");
                return(false);

            case DownloadableType.Release:
                var release = host.Downloadables.FirstOrDefault(s => s.Type == DownloadableType.Release && s.AssociatedDate > install.AssociatedDate);
                if (release == null)
                {
                    _logger.Log("Nothing to update");
                    return(false);
                }
                else
                {
                    update = release;
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (update == null)
            {
                return(false);
            }
            _logger.Log("Will replace " + install.AssociatedDate + " with " + update.AssociatedDate);

            var uninstall = new Uninstallation(_hostsRegistry, _installsRegistry, _githubApi, _logger);

            uninstall.Uninstall(install);

            var installation = new Installation(_hostsRegistry, _installsRegistry, _githubApi, _logger);

            installation.Install(update);

            return(true);
        }