private static string GetBuildVersion(string productName, string dockerfileVersion, string variables, Options options) { if (options.ProductVersions.TryGetValue(productName, out string version)) { return(version); } return(VersionUpdater.GetBuildVersion(productName, dockerfileVersion, variables)); }
public static IEnumerable <IDependencyUpdater> CreateUpdaters( string productName, string dockerfileVersion, string repoRoot, Options options) { string versionsPath = System.IO.Path.Combine(repoRoot, Program.VersionsFilename); string versions = File.ReadAllText(versionsPath); // The format of the sha variable name is '<productName>|<dockerfileVersion>|<os>|<arch>|sha'. // The 'os' and 'arch' segments are optional. string shaVariablePattern = $"\"(?<{ShaVariableGroupName}>{Regex.Escape(productName)}\\|{Regex.Escape(dockerfileVersion)}.*\\|sha)\":"; Regex shaVariableRegex = new Regex(shaVariablePattern); return(shaVariableRegex.Matches(versions) .Select(match => match.Groups[ShaVariableGroupName].Value) .Select(variable => { Trace.TraceInformation($"Updating {variable}"); string[] parts = variable.Split('|'); DockerfileShaUpdater updater = new DockerfileShaUpdater() { _productName = productName, _buildVersion = VersionUpdater.GetBuildVersion(productName, dockerfileVersion, versions), _dockerfileVersion = dockerfileVersion, _os = parts.Length >= 4 ? parts[2] : string.Empty, _arch = parts.Length >= 5 ? parts[3] : string.Empty, _options = options, _versions = versions, Path = versionsPath, VersionGroupName = ShaValueGroupName }; string archPattern = updater._arch == string.Empty ? string.Empty : "|" + updater._arch; string osPattern = updater._os == string.Empty ? string.Empty : "|" + updater._os; updater.Regex = new Regex( $"{shaVariablePattern.Replace(".*", Regex.Escape(osPattern + archPattern))} \"(?<{ShaValueGroupName}>.*)\""); return updater; }) .ToArray()); }
private async Task <string> GetDotNetReleaseChecksumsShaAsync( string productDownloadUrl) { string buildVersion = _buildVersion; // The release checksum file contains content for all products in the release (runtime, sdk, etc.) // and is referenced by the runtime version. if (_productName.Contains("sdk", StringComparison.OrdinalIgnoreCase) || _productName.Contains("aspnet", StringComparison.OrdinalIgnoreCase)) { buildVersion = VersionUpdater.GetBuildVersion("runtime", _dockerfileVersion, _versions); } IDictionary <string, string> checksumEntries = await GetDotnetReleaseChecksums(buildVersion); string installerFileName = productDownloadUrl.Substring(productDownloadUrl.LastIndexOf('/') + 1); if (!checksumEntries.TryGetValue(installerFileName, out string sha)) { Trace.TraceInformation($"Failed to find `{installerFileName}` sha"); } return(sha); }