Add() public method

Adds a package
public Add ( Mono.Addins.Setup.Package p ) : void
p Mono.Addins.Setup.Package /// A package ///
return void
Esempio n. 1
0
        void Install(string[] args)
        {
            if (args.Length < 1)
            {
                PrintHelp("install");
                return;
            }

            PackageCollection packs = new PackageCollection();

            for (int n = 0; n < args.Length; n++)
            {
                if (File.Exists(args [n]))
                {
                    packs.Add(AddinPackage.FromFile(args [n]));
                }
                else
                {
                    string aname    = Addin.GetIdName(GetFullId(args[n]));
                    string aversion = Addin.GetIdVersion(args[n]);
                    if (aversion.Length == 0)
                    {
                        aversion = null;
                    }

                    AddinRepositoryEntry[] ads = service.Repositories.GetAvailableAddin(aname, aversion);
                    if (ads.Length == 0)
                    {
                        throw new InstallException("The addin '" + args[n] + "' is not available for install.");
                    }
                    packs.Add(AddinPackage.FromRepository(ads[ads.Length - 1]));
                }
            }
            Install(packs, true);
        }
Esempio n. 2
0
        internal override void Resolve(IProgressMonitor monitor, AddinStore service, PackageCollection toInstall, PackageCollection toUninstall, PackageCollection installedRequired, DependencyCollection unresolved)
        {
            Addin ia = service.Registry.GetAddin(Mono.Addins.Addin.GetIdName(info.Id));

            if (ia != null)
            {
                Package p = AddinPackage.FromInstalledAddin(ia);
                if (!toUninstall.Contains(p))
                {
                    toUninstall.Add(p);
                }

                if (!info.SupportsVersion(ia.Version))
                {
                    // This addin breaks the api of the currently installed one,
                    // it has to be removed, together with all dependencies

                    Addin[] ainfos = service.GetDependentAddins(info.Id, true);
                    foreach (Addin ainfo in ainfos)
                    {
                        p = AddinPackage.FromInstalledAddin(ainfo);
                        if (!toUninstall.Contains(p))
                        {
                            toUninstall.Add(p);
                        }
                    }
                }
            }

            foreach (Dependency dep in info.Dependencies)
            {
                service.ResolveDependency(monitor, dep, this, toInstall, toUninstall, installedRequired, unresolved);
            }
        }
        void Update(string [] args)
        {
            bool showAll = args.Length > 0 && args [0] == "-a";

            Console.WriteLine("Looking for updates...");
            service.Repositories.UpdateAllRepositories(null);

            PackageCollection packs = new PackageCollection();

            AddinRepositoryEntry[] addins = service.Repositories.GetAvailableAddins();
            foreach (PackageRepositoryEntry addin in addins)
            {
                Addin sinfo = registry.GetAddin(addin.Addin.Id);
                if (!showAll && IsHidden(sinfo))
                {
                    continue;
                }
                if (sinfo != null && Addin.CompareVersions(sinfo.Version, addin.Addin.Version) == 1)
                {
                    packs.Add(AddinPackage.FromRepository(addin));
                }
            }
            if (packs.Count > 0)
            {
                Install(packs);
            }
            else
            {
                Console.WriteLine("No updates found.");
            }
        }
Esempio n. 4
0
        void CheckInstall(string[] args)
        {
            if (args.Length < 1)
            {
                PrintHelp("check-install");
                return;
            }

            PackageCollection packs = new PackageCollection();

            for (int n = 0; n < args.Length; n++)
            {
                Addin addin = registry.GetAddin(GetFullId(args[n]));
                if (addin != null)
                {
                    continue;
                }
                string aname    = Addin.GetIdName(GetFullId(args[n]));
                string aversion = Addin.GetIdVersion(args[n]);
                if (aversion.Length == 0)
                {
                    aversion = null;
                }

                AddinRepositoryEntry[] ads = service.Repositories.GetAvailableAddin(aname, aversion);
                if (ads.Length == 0)
                {
                    throw new InstallException("The addin '" + args[n] + "' is not available for install.");
                }
                packs.Add(AddinPackage.FromRepository(ads[ads.Length - 1]));
            }
            Install(packs, false);
        }
Esempio n. 5
0
 public bool ResolveDependencies(IProgressStatus statusMonitor, AddinRepositoryEntry[] addins, out PackageCollection resolved, out PackageCollection toUninstall, out DependencyCollection unresolved)
 {
     resolved = new PackageCollection();
     for (int n = 0; n < addins.Length; n++)
     {
         resolved.Add(AddinPackage.FromRepository(addins [n]));
     }
     return(ResolveDependencies(statusMonitor, resolved, out toUninstall, out unresolved));
 }
        void Install(string[] args)
        {
            if (args.Length < 1)
            {
                PrintHelp("install");
                return;
            }

            PackageCollection packs = new PackageCollection();

            for (int n = 0; n < args.Length; n++)
            {
                if (File.Exists(args [n]))
                {
                    packs.Add(AddinPackage.FromFile(args [n]));
                }
                else
                {
                    string[] aname             = args[n].Split('/');
                    AddinRepositoryEntry[] ads = service.Repositories.GetAvailableAddin(aname[0], null);
                    if (ads.Length == 0)
                    {
                        throw new InstallException("The addin '" + args[n] + "' is not available for install.");
                    }
                    if (ads.Length > 1)
                    {
                        if (aname.Length < 2)
                        {
                            Console.WriteLine(args[n] + ": the addin version is required because there are several versions of the same addin available.");
                            return;
                        }
                        ads = service.Repositories.GetAvailableAddin(aname[0], aname[1]);
                        if (ads.Length == 0)
                        {
                            throw new InstallException("The addin " + aname[0] + " v" + aname[1] + " is not available.");
                        }
                    }

                    packs.Add(AddinPackage.FromRepository(ads[0]));
                }
            }
            Install(packs);
        }
Esempio n. 7
0
        internal void ResolveDependency(IProgressMonitor monitor, Dependency dep, AddinPackage parentPackage, PackageCollection toInstall, PackageCollection toUninstall, PackageCollection installedRequired, DependencyCollection unresolved)
        {
            AddinDependency adep = dep as AddinDependency;

            if (adep == null)
            {
                return;
            }

            string nsid = Addin.GetFullId(parentPackage.Addin.Namespace, adep.AddinId, null);

            foreach (Package p in toInstall)
            {
                AddinPackage ap = p as AddinPackage;
                if (ap != null)
                {
                    if (Addin.GetIdName(ap.Addin.Id) == nsid && ((AddinInfo)ap.Addin).SupportsVersion(adep.Version))
                    {
                        return;
                    }
                }
            }

            ArrayList addins = new ArrayList();

            addins.AddRange(service.Registry.GetAddins());
            addins.AddRange(service.Registry.GetAddinRoots());

            foreach (Addin addin in addins)
            {
                if (Addin.GetIdName(addin.Id) == nsid && addin.SupportsVersion(adep.Version))
                {
                    AddinPackage p = AddinPackage.FromInstalledAddin(addin);
                    if (!installedRequired.Contains(p))
                    {
                        installedRequired.Add(p);
                    }
                    return;
                }
            }

            AddinRepositoryEntry[] avaddins = service.Repositories.GetAvailableAddins();
            foreach (PackageRepositoryEntry avAddin in avaddins)
            {
                if (Addin.GetIdName(avAddin.Addin.Id) == nsid && ((AddinInfo)avAddin.Addin).SupportsVersion(adep.Version))
                {
                    toInstall.Add(AddinPackage.FromRepository(avAddin));
                    return;
                }
            }
            unresolved.Add(adep);
        }
Esempio n. 8
0
		/// <summary>
        /// Installs the plugin.
        /// </summary>
        /// <returns>
        /// The plugin.
        /// </returns>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        public bool InstallPlugin(int ndx, out Dictionary<string, object> result)
        {
            Dictionary<string, object> res = new Dictionary<string, object>();

            PackageCollection pack = new PackageCollection();
            PackageCollection toUninstall;
            DependencyCollection unresolved;

            IProgressStatus ps = new ConsoleProgressStatus(false);

            AddinRepositoryEntry[] available = GetSortedAvailbleAddins();

            if (ndx > (available.Length - 1))
            {
                MainConsole.Instance.Output("Selection out of range");
                result = res;
                return false;
            }

            AddinRepositoryEntry aentry = available[ndx];

            Package p = Package.FromRepository(aentry);
            pack.Add(p);

            ResolveDependencies(ps, pack, out toUninstall, out unresolved);

            // Attempt to install the plugin disabled
            if (Install(ps, pack) == true)
            {
                MainConsole.Instance.Output("Ignore the following error...");
                PluginRegistry.Update(ps);
                Addin addin = PluginRegistry.GetAddin(aentry.Addin.Id);
                PluginRegistry.DisableAddin(addin.Id);
                addin.Enabled = false;
                
                MainConsole.Instance.Output("Installation Success");
                ListInstalledAddins(out res);
                result = res;
                return true;
            } 
            else
            {                
                MainConsole.Instance.Output("Installation Failed");
                result = res;
                return false;
            }
        }
Esempio n. 9
0
        void Install(string[] args)
        {
            if (args.Length < 1) {
                PrintHelp ("install");
                return;
            }

            PackageCollection packs = new PackageCollection ();
            for (int n=0; n<args.Length; n++) {
                if (File.Exists (args [n])) {
                    packs.Add (AddinPackage.FromFile (args [n]));
                } else {
                    string aname = Addin.GetIdName (GetFullId (args[n]));
                    string aversion = Addin.GetIdVersion (args[n]);
                    if (aversion.Length == 0) aversion = null;

                    AddinRepositoryEntry[] ads = service.Repositories.GetAvailableAddin (aname, aversion);
                    if (ads.Length == 0)
                        throw new InstallException ("The addin '" + args[n] + "' is not available for install.");
                    packs.Add (AddinPackage.FromRepository (ads[ads.Length-1]));
                }
            }
            Install (packs, true);
        }
Esempio n. 10
0
        void CheckInstall(string[] args)
        {
            if (args.Length < 1) {
                PrintHelp ("check-install");
                return;
            }

            PackageCollection packs = new PackageCollection ();
            for (int n=0; n<args.Length; n++) {
                Addin addin = registry.GetAddin (GetFullId (args[n]));
                if (addin != null)
                    continue;
                string aname = Addin.GetIdName (GetFullId (args[n]));
                string aversion = Addin.GetIdVersion (args[n]);
                if (aversion.Length == 0) aversion = null;

                AddinRepositoryEntry[] ads = service.Repositories.GetAvailableAddin (aname, aversion);
                if (ads.Length == 0)
                    throw new InstallException ("The addin '" + args[n] + "' is not available for install.");
                packs.Add (AddinPackage.FromRepository (ads[ads.Length-1]));
            }
            Install (packs, false);
        }
Esempio n. 11
0
        void Update(string [] args)
        {
            bool showAll = args.Length > 0 && args [0] == "-a";

            Console.WriteLine ("Looking for updates...");
            service.Repositories.UpdateAllRepositories (null);

            PackageCollection packs = new PackageCollection ();
            AddinRepositoryEntry[] addins = service.Repositories.GetAvailableAddins ();
            foreach (PackageRepositoryEntry addin in addins) {
                Addin sinfo = registry.GetAddin (addin.Addin.Id);
                if (!showAll && IsHidden (sinfo))
                    continue;
                if (sinfo != null && Addin.CompareVersions (sinfo.Version, addin.Addin.Version) == 1)
                    packs.Add (AddinPackage.FromRepository (addin));
            }
            if (packs.Count > 0)
                Install (packs, true);
            else
                Console.WriteLine ("No updates found.");
        }
		void FillSummaryPage ()
		{
			btnPrev.Sensitive = true;
			
			AddinHeader[] infos = tree.GetSelectedAddins ();
			PackageCollection packs = new PackageCollection ();
			foreach (AddinHeader info in infos) {
				AddinRepositoryEntry arep = (AddinRepositoryEntry) tree.GetAddinData (info);
				packs.Add (Package.FromRepository (arep));
			}
			
			packagesToInstall = new PackageCollection (packs);
			
			PackageCollection toUninstall;
			DependencyCollection unresolved;
			bool res;
			
			InstallMonitor m = new InstallMonitor ();
			res = service.ResolveDependencies (m, packs, out toUninstall, out unresolved);
			
			StringBuilder sb = new StringBuilder ();
			if (!res) {
				sb.Append (Catalog.GetString ("<b><span foreground=\"red\">The selected add-ins can't be installed because there are dependency conflicts.</span></b>\n"));
				foreach (string s in m.Errors) {
					sb.Append (Catalog.GetString ("<b><span foreground=\"red\">" + s + "</span></b>\n"));
				}
				sb.Append ("\n");
			}
			
			if (m.Warnings.Count != 0) {
				foreach (string w in m.Warnings) {
					sb.Append (Catalog.GetString ("<b><span foreground=\"red\">" + w + "</span></b>\n"));
				}
				sb.Append ("\n");
			}
			
			sb.Append (Catalog.GetString ("<b>The following packages will be installed:</b>\n\n"));
			foreach (Package p in packs) {
				sb.Append (p.Name);
				if (!p.SharedInstall)
					sb.Append (Catalog.GetString (" (in user directory)"));
				sb.Append ("\n");
			}
			sb.Append ("\n");
			
			if (toUninstall.Count > 0) {
				sb.Append (Catalog.GetString ("<b>The following packages need to be uninstalled:</b>\n\n"));
				foreach (Package p in toUninstall) {
					sb.Append (p.Name + "\n");
				}
				sb.Append ("\n");
			}
			
			if (unresolved.Count > 0) {
				sb.Append (Catalog.GetString ("<b>The following dependencies could not be resolved:</b>\n\n"));
				foreach (Dependency p in unresolved) {
					sb.Append (p.Name + "\n");
				}
				sb.Append ("\n");
			}
			btnNext.Sensitive = res;
			labelSummary.Markup = sb.ToString ();
		}
Esempio n. 13
0
		void FillSummaryPage ()
		{
			PackageCollection packs = new PackageCollection ();
			
			if (filesToInstall != null) {
				foreach (string file in filesToInstall) {
					packs.Add (Package.FromFile (file));
				}
			}
			else {
				foreach (AddinRepositoryEntry arep in addinsToInstall) {
					packs.Add (Package.FromRepository (arep));
				}
			}
			
			packagesToInstall = new PackageCollection (packs);
			
			PackageCollection toUninstall;
			DependencyCollection unresolved;
			bool res;
			
			InstallMonitor m = new InstallMonitor ();
			res = service.ResolveDependencies (m, packs, out toUninstall, out unresolved);
			
			StringBuilder sb = new StringBuilder ();
			if (!res) {
				sb.Append ("<b><span foreground=\"red\">").Append (Catalog.GetString ("The selected add-ins can't be installed because there are dependency conflicts.")).Append ("</span></b>\n");
				foreach (string s in m.Errors) {
					sb.Append ("<b><span foreground=\"red\">" + s + "</span></b>\n");
				}
				sb.Append ("\n");
			}
			
			if (m.Warnings.Count != 0) {
				foreach (string w in m.Warnings) {
					sb.Append ("<b><span foreground=\"red\">" + w + "</span></b>\n");
				}
				sb.Append ("\n");
			}
			
			sb.Append ("<b>").Append (Catalog.GetString ("The following packages will be installed:")).Append ("</b>\n\n");
			foreach (Package p in packs) {
				sb.Append (p.Name);
				if (!p.SharedInstall)
					sb.Append (Catalog.GetString (" (in user directory)"));
				sb.Append ("\n");
			}
			sb.Append ("\n");
			
			if (toUninstall.Count > 0) {
				sb.Append ("<b>").Append (Catalog.GetString ("The following packages need to be uninstalled:")).Append ("</b>\n\n");
				foreach (Package p in toUninstall) {
					sb.Append (p.Name + "\n");
				}
				sb.Append ("\n");
			}
			
			if (unresolved.Count > 0) {
				sb.Append ("<b>").Append (Catalog.GetString ("The following dependencies could not be resolved:")).Append ("</b>\n\n");
				foreach (Dependency p in unresolved) {
					sb.Append (p.Name + "\n");
				}
				sb.Append ("\n");
			}
			buttonOk.Sensitive = res;
			ShowMessage (sb.ToString ());
		}
Esempio n. 14
0
        internal void ResolveDependency(IProgressMonitor monitor, Dependency dep, AddinPackage parentPackage, PackageCollection toInstall, PackageCollection toUninstall, PackageCollection installedRequired, DependencyCollection unresolved)
        {
            AddinDependency adep = dep as AddinDependency;
            if (adep == null)
                return;

            string nsid = Addin.GetFullId (parentPackage.Addin.Namespace, adep.AddinId, null);

            foreach (Package p in toInstall) {
                AddinPackage ap = p as AddinPackage;
                if (ap != null) {
                    if (Addin.GetIdName (ap.Addin.Id) == nsid && ((AddinInfo)ap.Addin).SupportsVersion (adep.Version))
                        return;
                }
            }

            ArrayList addins = new ArrayList ();
            addins.AddRange (service.Registry.GetAddins ());
            addins.AddRange (service.Registry.GetAddinRoots ());

            foreach (Addin addin in addins) {
                if (Addin.GetIdName (addin.Id) == nsid && addin.SupportsVersion (adep.Version)) {
                    AddinPackage p = AddinPackage.FromInstalledAddin (addin);
                    if (!installedRequired.Contains (p))
                        installedRequired.Add (p);
                    return;
                }
            }

            AddinRepositoryEntry[] avaddins = service.Repositories.GetAvailableAddins ();
            foreach (PackageRepositoryEntry avAddin in avaddins) {
                if (Addin.GetIdName (avAddin.Addin.Id) == nsid && ((AddinInfo)avAddin.Addin).SupportsVersion (adep.Version)) {
                    toInstall.Add (AddinPackage.FromRepository (avAddin));
                    return;
                }
            }
            unresolved.Add (adep);
        }
Esempio n. 15
0
 public bool ResolveDependencies(IProgressStatus statusMonitor, AddinRepositoryEntry[] addins, out PackageCollection resolved, out PackageCollection toUninstall, out DependencyCollection unresolved)
 {
     resolved = new PackageCollection ();
     for (int n=0; n<addins.Length; n++)
         resolved.Add (AddinPackage.FromRepository (addins [n]));
     return ResolveDependencies (statusMonitor, resolved, out toUninstall, out unresolved);
 }
Esempio n. 16
0
        void Install(string[] args)
        {
            bool prompt = !args.Any (a => a == "-y");
            var addins = args.Where (a => a != "-y");

            if (!addins.Any ()) {
                PrintHelp ("install");
                return;
            }

            PackageCollection packs = new PackageCollection ();
            foreach (string arg in addins) {
                if (File.Exists (arg)) {
                    packs.Add (AddinPackage.FromFile (arg));
                } else {
                    string aname = Addin.GetIdName (GetFullId (arg));
                    string aversion = Addin.GetIdVersion (arg);
                    if (aversion.Length == 0) aversion = null;

                    AddinRepositoryEntry[] ads = service.Repositories.GetAvailableAddin (aname, aversion);
                    if (ads.Length == 0)
                        throw new InstallException ("The addin '" + arg + "' is not available for install.");
                    packs.Add (AddinPackage.FromRepository (ads[ads.Length-1]));
                }
            }
            Install (packs, prompt);
        }
		internal override void Resolve (IProgressMonitor monitor, AddinStore service, PackageCollection toInstall, PackageCollection toUninstall, PackageCollection installedRequired, DependencyCollection unresolved)
		{
			Addin ia = service.Registry.GetAddin (info.Id);
			
			if (ia != null) {
				Package p = AddinPackage.FromInstalledAddin (ia);
				if (!toUninstall.Contains (p))
					toUninstall.Add (p);
					
				if (!info.SupportsVersion (ia.Version)) {
				
					// This addin breaks the api of the currently installed one,
					// it has to be removed, together with all dependencies
					
					Addin[] ainfos = service.GetDependentAddins (info.Id, true);
					foreach (Addin ainfo in ainfos) {
						p = AddinPackage.FromInstalledAddin (ainfo);
						if (!toUninstall.Contains (p))
							toUninstall.Add (p);
					}
				}
			}
			
			foreach (Dependency dep in info.Dependencies) {
				service.ResolveDependency (monitor, dep, this, toInstall, toUninstall, installedRequired, unresolved);
			}
		}
Esempio n. 18
0
		void Install (string[] args)
		{
			if (args.Length < 1) {
				PrintHelp ("install");
				return;
			}
			
			PackageCollection packs = new PackageCollection ();
			for (int n=0; n<args.Length; n++) {
				if (File.Exists (args [n])) { 
					packs.Add (AddinPackage.FromFile (args [n]));
				} else {
					string[] aname = args[n].Split ('/');
					AddinRepositoryEntry[] ads = service.Repositories.GetAvailableAddin (aname[0], null);
					if (ads.Length == 0)
						throw new InstallException ("The addin '" + args[n] + "' is not available for install.");
					if (ads.Length > 1) {
						if (aname.Length < 2) {
							Console.WriteLine (args[n] + ": the addin version is required because there are several versions of the same addin available.");
							return;
						}
						ads = service.Repositories.GetAvailableAddin (aname[0], aname[1]);
						if (ads.Length == 0)
							throw new InstallException ("The addin " + aname[0] + " v" + aname[1] + " is not available.");
					}
				
					packs.Add (AddinPackage.FromRepository (ads[0]));
				}
			}
			Install (packs);
		}