public static (bool, string) VerifyFileIsAvailableForPackage(CompDBXmlClass.Package pkg, string UUPPath) { string missingPackage = ""; // // Some download utilities that start with the letter U and finish with UPDump or start with the letter U and finish with UP.rg-adguard download files without respecting Microsoft filenames // We attempt to locate files based on what we think they use first. // string file = pkg.GetCommonlyUsedIncorrectFileName(); if (!File.Exists(Path.Combine(UUPPath, file))) { // // Wow, someone actually downloaded UUP files using a tool that respects Microsoft paths, that's exceptional // file = pkg.Payload.PayloadItem.Path; if (!File.Exists(Path.Combine(UUPPath, file))) { // // What a disapointment, they simply didn't download everything.. Oops. // TODO: generate missing files out of thin air // missingPackage = file; } } return(string.IsNullOrEmpty(missingPackage), missingPackage); }
public static bool GetTargetedPlan( string UUPPath, string LanguageCode, out List <EditionTarget> EditionTargets, ProgressCallback progressCallback = null) { progressCallback?.Invoke(Common.ProcessPhase.ReadingMetadata, true, 0, "Acquiring Composition Databases"); HashSet <CompDBXmlClass.CompDB> compDBs = FileLocator.GetCompDBsFromUUPFiles(UUPPath); string EditionPack = ""; // // Get base editions that are available with all their files // IEnumerable <CompDBXmlClass.CompDB> filteredCompDBs = compDBs.GetEditionCompDBsForLanguage(LanguageCode).Where(x => { (bool success, HashSet <string> missingfiles) = FileLocator.VerifyFilesAreAvailableForCompDB(x, UUPPath); return(success); }); if (filteredCompDBs.Count() > 0) { foreach (CompDBXmlClass.Package feature in filteredCompDBs.First().Features.Feature[0].Packages.Package) { CompDBXmlClass.Package pkg = filteredCompDBs.First().Packages.Package.First(x => x.ID == feature.ID); string file = pkg.GetCommonlyUsedIncorrectFileName(); // // We know already that all files exist, so it's just a matter of knowing which path format is used // file = !File.Exists(Path.Combine(UUPPath, file)) ? pkg.Payload.PayloadItem.Path : file; if (!file.EndsWith(".esd", StringComparison.InvariantCultureIgnoreCase) || !file.Contains("microsoft-windows-editionspecific", StringComparison.InvariantCultureIgnoreCase) || file.Contains("WOW64", StringComparison.InvariantCultureIgnoreCase) || file.Contains("arm64.arm", StringComparison.InvariantCultureIgnoreCase)) { // We do not care about this file continue; } EditionPack = file; } } return(ConversionPlanBuilder.GetTargetedPlan(UUPPath, compDBs, Path.Combine(UUPPath, EditionPack), LanguageCode, out EditionTargets, (string msg) => progressCallback?.Invoke(Common.ProcessPhase.ReadingMetadata, true, 0, msg))); }
internal static (bool Succeeded, string BaseESD) LocateFilesForSetupMediaCreation( string UUPPath, string LanguageCode, ProgressCallback?progressCallback = null) { progressCallback?.Invoke(Common.ProcessPhase.ReadingMetadata, true, 0, "Looking up Composition Database in order to find a Base ESD image appropriate for building windows setup files."); if (Planning.NET.FileLocator.GetCompDBsFromUUPFiles(UUPPath) is HashSet <CompDBXmlClass.CompDB> compDBs) { HashSet <CompDBXmlClass.CompDB> filteredCompDBs = compDBs.GetEditionCompDBsForLanguage(LanguageCode); if (filteredCompDBs.Count > 0) { foreach (var currentCompDB in filteredCompDBs) { foreach (CompDBXmlClass.Package feature in currentCompDB.Features.Feature[0].Packages.Package) { CompDBXmlClass.Package pkg = currentCompDB.Packages.Package.First(x => x.ID == feature.ID); string file = pkg.GetCommonlyUsedIncorrectFileName(); if (feature.PackageType == "MetadataESD") { if (!File.Exists(Path.Combine(UUPPath, file))) { file = pkg.Payload.PayloadItem.Path; if (!File.Exists(Path.Combine(UUPPath, file))) { break; } } return(true, Path.Combine(UUPPath, file)); } } } } progressCallback?.Invoke(Common.ProcessPhase.Error, true, 0, "While looking up the Composition Database, we couldn't find an edition composition for the specified language. This error is fatal."); return(false, null); } else { progressCallback?.Invoke(Common.ProcessPhase.Error, true, 0, "We couldn't find the Composition Database. Please make sure you have downloaded the <aggregatedmetadata> cabinet file, or the <CompDB> cabinet files (if the build is lower than RS3 RTM). This error is fatal."); return(false, null); } }
internal static (bool Succeeded, string BaseESD, HashSet <string> ReferencePackages, HashSet <string> ReferencePackagesToConvert) LocateFilesForBaseEditionCreation( string UUPPath, string LanguageCode, string EditionID, ProgressCallback progressCallback = null) { bool success = true; HashSet <string> ReferencePackages = new HashSet <string>(); HashSet <string> referencePackagesToConvert = new HashSet <string>(); string BaseESD = null; progressCallback?.Invoke(Common.ProcessPhase.ReadingMetadata, true, 0, "Enumerating files"); CompDBXmlClass.CompDB?compDB = GetEditionCompDBForLanguage(Planning.NET.FileLocator.GetCompDBsFromUUPFiles(UUPPath), EditionID, LanguageCode); if (compDB == null) { progressCallback?.Invoke(Common.ProcessPhase.ReadingMetadata, true, 0, "No compDB found"); goto error; } foreach (CompDBXmlClass.Package feature in compDB.Features.Feature[0].Packages.Package) { CompDBXmlClass.Package pkg = compDB.Packages.Package.First(x => x.ID == feature.ID); string file = pkg.GetCommonlyUsedIncorrectFileName(); if (!File.Exists(Path.Combine(UUPPath, file))) { file = pkg.Payload.PayloadItem.Path; if (!File.Exists(Path.Combine(UUPPath, file))) { progressCallback?.Invoke(Common.ProcessPhase.ReadingMetadata, true, 0, $"File {file} is missing"); goto error; } } if (feature.PackageType == "MetadataESD") { BaseESD = Path.Combine(UUPPath, file); continue; } if (file.EndsWith(".esd", StringComparison.InvariantCultureIgnoreCase)) { ReferencePackages.Add(Path.Combine(UUPPath, file)); } else if (file.EndsWith(".cab", StringComparison.InvariantCultureIgnoreCase)) { referencePackagesToConvert.Add(Path.Combine(UUPPath, file)); } } if (BaseESD == null) { progressCallback?.Invoke(Common.ProcessPhase.ReadingMetadata, true, 0, "Base ESD not found"); goto error; } goto exit; error: success = false; exit: return(success, BaseESD, ReferencePackages, referencePackagesToConvert); }