public bool Add(string addonName) { addonName = addonName.ToLower(); if (!AptL.IsInstalled(addonName)) { return(false); } Queue.Add(addonName); // don't delete dependencies if (!AptEnv.FetchRequiredDeps) { return(true); } // add unused dependencies to remove queue RepositoryAddonInfo info = AptRepo.GetAddonInfo(addonName); if (info.RequiredDeps != null) { // fetch list of needed dependencies List <string> usedDependecies = new List <string>(); foreach (LocalAddonInfo depInfo in AptL) { if (depInfo.Name.ToLower() != addonName) { List <string> deps = AptRepo.GetAddonInfo(depInfo.Name).RequiredDeps; if (deps != null) { foreach (string dependency in deps) { if (!usedDependecies.Contains(dependency.ToLower())) { usedDependecies.Add(dependency.ToLower()); } } } } } foreach (string dependency in info.RequiredDeps) { string name = dependency.ToLower(); if (!usedDependecies.Contains(name) && AptL.IsInstalled(name)) { Queue.Add(name); } } } return(true); }
public bool Install(string addonName, bool skipDependencies) { RepositoryAddonInfo info = AptRepo.GetAddonInfo(addonName); SendStatus("install", info.Name); bool success = false; // remove old if (AptL.IsInstalled(addonName)) { SendStatus("uninstall"); if (AptL.Uninstall(addonName)) { SendStatus("uninstall.success"); } else { SendStatus("uninstall.failed"); } } // download zip string zipFile = Path.Combine(AptEnv.AptZipPath, info.ZipFileName); if (!File.Exists(zipFile)) { SendStatus("zip.download"); if (AptR.DownloadZip(info)) { SendStatus("zip.download.success"); } else { SendStatus("zip.download.failed"); } } else { SendStatus("zip.cache"); } // install locally SendStatus("zip.extract"); if (AptL.Install(zipFile)) { SendStatus("install.success"); success = true; } else { SendStatus("install.failed"); } // use externals? if not, shall we download the deps? if (!skipDependencies && !AptEnv.UseExternals && AptEnv.FetchRequiredDeps) { bool successDeps = true; SendStatus("install.dependencies"); if (info.RequiredDeps != null) { for (int i = 0; i < info.RequiredDeps.Count; ++i) { SendDebugMessage("install.dependency", info.RequiredDeps[i]); // dep not in repository -> skip if (!AptRepo.IsAddonInRepository(info.RequiredDeps[i])) { continue; } // already installed? check version if (AptL.IsInstalled(info.RequiredDeps[i])) { if (AptL.GetAddonInfo(info.RequiredDeps[i]).Version >= AptRepo.GetAddonInfo(info.RequiredDeps[i]).Version) { continue; } } if (Install(info.RequiredDeps[i], true)) { SendStatus("install.dependency.success", info.RequiredDeps[i]); } else { SendStatus("install.dependency.failed", info.RequiredDeps[i]); successDeps = false; } } SendStatus("install.dependencies.finished", successDeps.ToString()); } else { SendStatus("install.dependencies.none"); } } // unpack? if (AptEnv.UnpackPackages) { SendStatus("unpack"); if (AptL.IsPackage(addonName)) { if (AptL.Unpack(addonName)) { SendStatus("unpack.success"); } else { SendStatus("unpack.failed"); } } else { SendStatus("unpack.nopackage"); } } // remove zip file? if (!AptEnv.KeepZips) { SendStatus("clear"); try { File.Delete(Path.Combine(AptEnv.AptZipPath, info.ZipFileName)); SendStatus("clear.success"); } catch (IOException e) { SendStatus("clear.failed"); } } if (success) { SendStatus("success"); } else { SendStatus("failed"); } return(success); }