private void CommitMeta(InstallPlanEntry entry) { _logger.Log("Saving config data... "); var kcPath = Path.Combine(entry.TmpDir.GetDirectories().First().FullName, "koinonia.config.json"); var kcDestPath = Path.Combine(PathUtils.DefaultAbsolutePackagesPath, entry.RelativeDestPath); var cFilePath = Path.Combine(kcDestPath, "koinonia.config.json"); if (!File.Exists(cFilePath)) { entry.FullMappings.Default = Path.Combine(PathUtils.DefaultRelativePackagesPath, entry.RelativeDestPath); File.Copy(kcPath, cFilePath); } kcPath = Path.Combine(entry.TmpDir.GetDirectories().First().FullName, "installer.kcs"); if (File.Exists(kcPath)) { _logger.Log("Saving installer... "); kcDestPath = Path.Combine(PathUtils.DefaultAbsolutePackagesPath, entry.RelativeDestPath); cFilePath = Path.Combine(kcDestPath, "installer.kcs"); if (!File.Exists(cFilePath)) { File.Copy(kcPath, cFilePath); } } }
private void Commit(InstallPlanEntry entry) { //DANCE, BABY, DANCE! var mappings = entry.ConfigData.Mappings; if (mappings != null) { _logger.Log("Processing mappings..."); CommitDefaultMapping(entry); CommitRootMapping(entry); CommitDocs(entry); CommitTests(entry); } else //Default case, where no mappings are needed { var rootPath = entry.TmpDir.GetDirectories().First().FullName; var rootDir = new DirectoryInfo(rootPath); var destPath = Path.Combine(PathUtils.DefaultAbsolutePackagesPath, entry.RelativeDestPath); var destDir = new DirectoryInfo(destPath); _logger.Log("Mappings not found. Using standard paths. "); _logger.Log("Copying from " + rootDir.FullName + " to " + destDir.FullName); FileUtils.CopyFilesRecursively(rootDir, destDir); entry.FullMappings.Default = Path.Combine(PathUtils.DefaultRelativePackagesPath, entry.RelativeDestPath); } CommitMeta(entry); }
private void RegisterInstall(InstallPlanEntry _) { _installsRegistry.AddInstall(new Install() { AuthorName = _.AuthorName, RepositoryName = _.RepositoryName, Name = _.Name, CommitSha = _.CommitSha, Type = _.Type, ConfigData = _.ConfigData, Mappings = _.FullMappings, AssociatedDate = _.AssociatedDate }); }
private void ExtractPackage(InstallPlanEntry entry) { entry.RelativeInstallationPath = entry.RepositoryName; entry.TmpPath = Path.Combine(_installationTempPath, entry.RelativeInstallationPath); entry.TmpDir = new DirectoryInfo(entry.TmpPath); //Download _logger.Log("Downloading " + entry); _logger.Log(" URL: " + _githubApi.GetZipballUrl(entry.AuthorName, entry.RepositoryName, entry.Name)); var bytes = _githubApi.GetZipball(entry.AuthorName, entry.RepositoryName, entry.Name); _logger.Log("Decompressing " + entry); //Decompress ZipUtils.Decompress(entry.TmpPath, bytes); }
private void CommitDefaultMapping(InstallPlanEntry entry) { var mapping = entry.ConfigData.Mappings.Default; if (!string.IsNullOrEmpty(mapping)) { _logger.Log("Using default mapping: " + mapping); var rootPath = entry.TmpDir.GetDirectories().First().FullName; rootPath = Path.Combine(rootPath, mapping); var rootDir = new DirectoryInfo(rootPath); var destPath = Path.Combine(PathUtils.DefaultAbsolutePackagesPath, entry.RelativeDestPath); var destDir = new DirectoryInfo(destPath); _logger.Log("Copying from " + rootDir.FullName + " to " + destDir.FullName); FileUtils.CopyFilesRecursively(rootDir, destDir); entry.FullMappings.Default = Path.Combine(PathUtils.DefaultRelativePackagesPath, entry.RelativeDestPath); } }
private void CommitRootMapping(InstallPlanEntry entry) { DirectoryInfo rootDir; DirectoryInfo relDestDir; string destPath; DirectoryInfo destDir; string mapping; mapping = entry.ConfigData.Mappings.Root; if (!string.IsNullOrEmpty(mapping)) { _logger.Log("Using root mapping: " + mapping); string rootPath; rootPath = Path.Combine(entry.TmpDir.GetDirectories().First().FullName, mapping); rootDir = new DirectoryInfo(rootPath); relDestDir = new DirectoryInfo(mapping); //only needed to fetch directory name destPath = Path.Combine(PathUtils.RootPath, relDestDir.Name); destDir = new DirectoryInfo(destPath); _logger.Log("Copying from " + rootDir.FullName + " to " + destDir.FullName); FileUtils.CopyFilesRecursively(rootDir, destDir); entry.FullMappings.Root = relDestDir.Name; } }
private InstallPlanEntry Add(Downloadable downloadable) { _logger.Log("Adding " + downloadable + " to the queue"); if (downloadable.ConfigData == null) { _logger.Log("Fetching config file for " + downloadable); downloadable.FetchConfigData(); } if (downloadable.ConfigData == null) { throw new ConfigDataNotFoundException(downloadable); } var installationEntry = new InstallPlanEntry() { AuthorName = downloadable.AuthorName, RepositoryName = downloadable.RepositoryName, CommitSha = downloadable.CommitSha, Name = downloadable.Name, Type = downloadable.Type, ConfigData = downloadable.ConfigData, AssociatedDate = downloadable.AssociatedDate }; PlanInstall.Add(installationEntry); return(installationEntry); }
private void AnalyzePackage(InstallPlanEntry entry) { _logger.Log("Checking dependencies in " + entry); if (entry.ConfigData.Dependencies.Any()) { foreach (var dependency in entry.ConfigData.Dependencies) { _logger.Log(" Processing " + dependency.Key + " @ " + dependency.Value); var depData = GithubSchemeDecoder.DecodeShort(dependency.Key); // See if this package is already planned to be installed var depEntry = PlanInstall.FirstOrDefault(_ => depData.Owner == _.AuthorName && depData.Name == _.RepositoryName); if (depEntry != null) { continue; //Already been processed } // See if we got this package registered var host = _hostsRegistry.DownloadablesHosts.FirstOrDefault(_ => depData.Owner == _.AuthorName && depData.Name == _.RepositoryName); // If not, create it locally if (host == null) { host = new DownloadablesHost() { AuthorName = depData.Owner, RepositoryName = depData.Name, }; } if (_installsRegistry.Installs.Where(i => i.IsInstallOf(host)).Any()) { _logger.Log(dependency.Key + " is already installed."); continue; } host.FetchDownloadables(); var downloadable = host.Downloadables.FirstOrDefault(); //TODO: need version here if (!string.IsNullOrEmpty(dependency.Value)) { downloadable = host.Downloadables.FirstOrDefault(_ => _.Name == dependency.Value); } if (downloadable == null) { throw new Exception("No Downloadables found for " + host); } var newEntry = Add(downloadable); AnalyzePackage(newEntry); } } else { _logger.Log(" Seeing no dependencies for " + entry); } }