public void InstallDependencies(IDependencySolver dependencySolver) { //FIXME: We should check for all repositories, not the first one //FileRepository rt = (FileRepository) Upfile.Repositories[0]; upfile = Upfile.Instance(); PackageList pList = PackageList.Instance(); DependencyDefinition[] dependencies = dependencySolver.SolveDependencies(upfile.Dependencies); foreach (DependencyDefinition packageDefinition in dependencies) { PackageRepo result = pList.FindPackageAndRepository(packageDefinition); if (result.Repository != null) { using (TemporaryDirectory td = result.Repository.DownloadPackage(result.Package)) { InstallPackage(result.Package, td, packageDefinition); } } } }
public void LoadDependencies(DependencyDefinition dependency, PackageList packageList, DependencyHelper.ConflictChecker checkConflict, out DependencyNode node) { node = new DependencyNode(dependency); if (Contains(dependency.Name)) { DependencyNode existing = FindByName(dependency.Name); checkConflict(ref existing, node); } else { nodeList.Add(node); Upset package = packageList.FindPackageAndRepository(dependency).Package; if (package == null) { throw new MissingDependencyException(string.Format(" depends on {0} ({1}) but it is not present in any of your specified repository", dependency.Name, dependency.Requirement)); } if (package.Dependencies != null) { DependencyNode child; foreach (DependencyDefinition packageDependency in package.Dependencies) { child = null; try { LoadDependencies(packageDependency, packageList, checkConflict, out child); AddDependency(node, child); } catch (MissingDependencyException e) { throw new MissingDependencyException(dependency.Name + e.Message); } } } } }
private LockfileSnapshot LoadLockfile() { string pattern = @"([\w\.\-]+)\s\(([\w\.\+!\*]+)\)"; LockfileSnapshot result = new LockfileSnapshot(); using (StreamReader file = new StreamReader(lockfilePath)) { string line = file.ReadLine(); if (line == null || line != "# UPFILE DEPENDENCIES") { throw new FileLoadException("Cannot load Upfile.lock, it is missing the \'UPFILE DEPENDENCIES\' header"); } List <DependencyDefinition> upfileDependencyList = new List <DependencyDefinition>(); Match match; while (!string.IsNullOrEmpty(line = file.ReadLine())) { match = Regex.Match(line, pattern); if (!match.Success || match.Groups.Count < 3) { throw new FileLoadException("Cannot load Upfile.lock, the line " + line + " does not match \'package_name (version_requirement)\'"); } DependencyDefinition temp = new DependencyDefinition { Name = match.Groups[1].Value, Version = match.Groups[2].Value }; upfileDependencyList.Add(temp); } result.upfileDependencies = upfileDependencyList.ToArray(); if (line == null) { throw new FileLoadException("Cannot load Upfile.lock, it is incomplete"); } line = file.ReadLine(); if (line == null || line != "# SOLVED DEPENDENCIES") { throw new FileLoadException("Cannot load Upfile.lock, it is missing the \'SOLVED DEPENDENCIES\' header"); } List <PackageRepo> installableList = new List <PackageRepo>(); line = file.ReadLine(); PackageList packageList = PackageList.Instance(); while (!string.IsNullOrEmpty(line)) { match = Regex.Match(line, pattern); if (!match.Success || match.Groups.Count < 3) { throw new FileLoadException("Cannot load Upfile.lock, the line " + line + " does not match \'package_name (installed_version)\'"); } PackageRepo temp = packageList.FindPackageAndRepository(new DependencyDefinition { Name = match.Groups[1].Value, Version = match.Groups[2].Value + "!" // Check for exact version }); if (temp.Package != null && temp.Repository != null) { installableList.Add(temp); } else { installableList.Add(new PackageRepo { Package = new Upset { PackageName = match.Groups[1].Value, PackageVersion = match.Groups[2].Value } }); } // Read the dependencies while ((line = file.ReadLine()) != null && line.StartsWith("\t")) { match = Regex.Match(line, pattern); if (!match.Success || match.Groups.Count < 3) { throw new FileLoadException("Cannot load Upfile.lock, the line " + line + " does not match \'package_name (version_requirement)\'"); } } } result.installableDependencies = installableList.ToArray(); } return(result); }