Exemplo n.º 1
0
        public void Run()
        {
            // fetch dependencies
            foreach (string dependency in DependencyQueue)
            {
                SendDebugMessage("upgrade.run.depdendency", dependency);

                // already in the addon queue
                if (UpdateQueue.Contains(dependency))
                {
                    SendDebugMessage("upgrade.run.depdendency.inaddonqueue", dependency);
                    continue;
                }

                // no new version -> next one
                if (AptL.IsInstalled(dependency))
                {
                    if (AptL.GetAddonInfo(dependency).Version >= AptRepo.GetAddonInfo(dependency).Version)
                    {
                        SendDebugMessage("upgrade.run.depdendency.uptodate", dependency);
                        continue;
                    }
                }

                // install
                Install(dependency, true);
            }

            // fetch addons
            foreach (string addon in UpdateQueue)
            {
                SendDebugMessage("upgrade.run.install", addon);

                // install
                Install(addon, true);
            }
        }
Exemplo n.º 2
0
        public int Prepare()
        {
            UpdateQueue = new List <string>();

            bool usePatterns = NamePatterns.Count > 0;

            foreach (LocalAddonInfo local in AptL)
            {
                string name  = local.Name.ToLower();
                bool   match = false;

                SendDebugMessage("upgrade.prepare", name);

                // excluded?
                if (ExcludedAddons.Contains(name))
                {
                    SendDebugMessage("upgrade.prepare.excluded", name);
                    continue;
                }

                // use name patterns?
                if (usePatterns)
                {
                    for (int i = 0; i < NamePatterns.Count; ++i)
                    {
                        // *
                        if (NamePatterns[i].Contains("*"))
                        {
                            if (name.Contains(NamePatterns[i].Replace("*", "")))
                            {
                                match = true;
                                SendDebugMessage("upgrade.prepare.pattern.match", name, NamePatterns[i]);
                                break;
                            }
                        }
                        else
                        {
                            if (name == NamePatterns[i])
                            {
                                match = true;
                                SendDebugMessage("upgrade.prepare.pattern.match", name, NamePatterns[i]);
                                break;
                            }
                        }
                    }
                }

                // addon doesn't match -> next one
                if (usePatterns && !match)
                {
                    SendDebugMessage("upgrade.prepare.pattern.nomatch", name);
                    continue;
                }

                // check if it's a module of some addon
                RepositoryAddonInfo update = AptRepo.GetAddonInfo(name);
                string parent = AptL.IsModule(local.Name);

                // if it's a module, add parent to queue
                if (parent != null)
                {
                    SendDebugMessage("upgrade.prepare.ismodule", name, parent);

                    // addon in repository?
                    if (!AptRepo.IsAddonInRepository(parent))
                    {
                        SendDebugMessage("upgrade.prepare.parent.notinrepo", parent);
                        SendStatus("notinrepo");
                        continue;
                    }

                    // no new version -> next one
                    if (AptL.GetAddonInfo(parent).Version >= AptRepo.GetAddonInfo(parent).Version)
                    {
                        SendDebugMessage("upgrade.prepare.parent.noewnewversion", parent);
                        SendStatus("nonewversion");
                        continue;
                    }

                    AddToQueue(parent);
                }
                else
                {
                    // addon in repository?
                    if (!AptRepo.IsAddonInRepository(name))
                    {
                        SendDebugMessage("upgrade.prepare.notinrepo", name);
                        SendStatus("notinrepo");
                        continue;
                    }

                    // no new version -> next one
                    if (local.Version >= update.Version)
                    {
                        SendDebugMessage("upgrade.prepare.nonewversion", name);
                        SendStatus("nonewversion");
                        continue;
                    }

                    AddToQueue(name);
                }

                // fetch dependencies?
                if (!AptEnv.UseExternals && AptEnv.FetchRequiredDeps)
                {
                    SendDebugMessage("upgrade.prepare.dependencies.resolve" + name);
                    SendStatus("resolvedeps");

                    if (update.RequiredDeps != null)
                    {
                        bool depError = false;

                        for (int i = 0; i < update.RequiredDeps.Count; ++i)
                        {
                            if (AptRepo.IsAddonInRepository(update.RequiredDeps[i]))
                            {
                                SendDebugMessage("upgrade.prepare.dependencies.add", update.RequiredDeps[i]);
                                AddDependency(update.RequiredDeps[i]);
                            }
                            else
                            {
                                SendDebugMessage("upgrade.prepare.dependencies.unresolved", update.RequiredDeps[i]);
                                UnresolvedDeps.Add(update.RequiredDeps[i]);
                                depError = true;
                            }
                        }

                        if (depError)
                        {
                            SendStatus("unresolveddeps");
                        }
                    }
                    else
                    {
                        SendDebugMessage("upgrade.prepare.dependencies.nodeps");
                        SendStatus("nodeps");
                    }
                }
            }

            return(UpdateQueue.Count + DependencyQueue.Count);
        }