|
11 | 11 | namespace RaspberryPiDotnetRepository;
|
12 | 12 |
|
13 | 13 | public class Orchestrator(
|
14 |
| - SdkDownloader sdkDownloader, |
15 |
| - PackageRequester packageRequester, |
16 |
| - PackageGenerator packageGenerator, |
17 |
| - Indexer indexer, |
18 |
| - CdnClient cdnClient, |
19 |
| - ExtraFileGenerator extraFileGenerator, |
20 |
| - ManifestManager manifestManager, |
21 |
| - BlobStorageClient blobStorage, |
22 |
| - StatisticsService statistics, |
| 14 | + SdkDownloader sdkDownloader, |
| 15 | + PackageRequester packageRequester, |
| 16 | + PackageGenerator packageGenerator, |
| 17 | + Indexer indexer, |
| 18 | + CdnClient cdnClient, |
| 19 | + ExtraFileGenerator extraFileGenerator, |
| 20 | + ManifestManager manifestManager, |
| 21 | + BlobStorageClient blobStorage, |
| 22 | + StatisticsService statistics, |
23 | 23 | IHostApplicationLifetime appLifetime,
|
24 |
| - IOptions<Options> options, |
25 |
| - ILogger<Orchestrator> logger |
| 24 | + IOptions<Options> options, |
| 25 | + ILogger<Orchestrator> logger |
26 | 26 | ): BackgroundService {
|
27 | 27 |
|
28 | 28 | private static readonly Version MIN_DOTNET_MINOR_VERSION = new(6, 0);
|
@@ -55,42 +55,42 @@ protected override async Task ExecuteAsync(CancellationToken ct) {
|
55 | 55 | ReleaseIndexFile[] releaseIndexFiles = await Task.WhenAll(packageIndicesByDebianRelease.Select(releaseFiles => indexer.generateReleaseIndex(releaseFiles.Key, releaseFiles)));
|
56 | 56 |
|
57 | 57 | // Write readme, badges, and GPG public key
|
58 |
| - string readmeFilename = await extraFileGenerator.generateReadme(); |
59 |
| - IEnumerable<UploadableFile> badgeFiles = await extraFileGenerator.generateReadmeBadges(upstreamReleases.First(release => release.isLatestMinorVersion)); |
60 |
| - string gpgPublicKeyFile = extraFileGenerator.copyGpgPublicKey(); |
| 58 | + string readmeFilename = await extraFileGenerator.generateReadme(); |
| 59 | + IEnumerable<UploadableFile> badgeFiles = await extraFileGenerator.generateReadmeBadges(upstreamReleases.First(release => release.isLatestMinorVersion)); |
| 60 | + string gpgPublicKeyFile = extraFileGenerator.copyGpgPublicKey(); |
| 61 | + string addRepoScriptFile = await extraFileGenerator.generateAddRepoScript(); |
61 | 62 |
|
62 | 63 | // Upload .deb packages to Azure Blob Storage
|
63 | 64 | string repoBaseDir = options.Value.repositoryBaseDir;
|
64 | 65 | await Task.WhenAll(generatedPackages.Where(p => !p.isUpToDateInBlobStorage).Select(p =>
|
65 | 66 | blobStorage.uploadFile(Path.Combine(repoBaseDir, p.filePathRelativeToRepo), p.filePathRelativeToRepo, "application/vnd.debian.binary-package", ct)));
|
66 | 67 |
|
67 | 68 | // Upload Packages.gz indices to Azure Blob Storage
|
68 |
| - Task<BlobContentInfo?[]> packageIndexUploads = Task.WhenAll(packageIndicesByDebianRelease.SelectMany(debianRelease => debianRelease).Where(file => !file.isUpToDateInBlobStorage).Select( |
69 |
| - packageIndexFile => |
70 |
| - blobStorage.uploadFile(Path.Combine(repoBaseDir, packageIndexFile.filePathRelativeToRepo), packageIndexFile.filePathRelativeToRepo, |
71 |
| - packageIndexFile.isCompressed ? "application/gzip" : "text/plain", ct))); |
| 69 | + Task<BlobContentInfo?[]> packageIndexUploads = Task.WhenAll(packageIndicesByDebianRelease.SelectMany(debianRelease => debianRelease).Select(packageIndexFile => |
| 70 | + blobStorage.uploadFile(Path.Combine(repoBaseDir, packageIndexFile.filePathRelativeToRepo), packageIndexFile.filePathRelativeToRepo, |
| 71 | + packageIndexFile.isCompressed ? "application/gzip" : "text/plain", ct))); |
72 | 72 |
|
73 |
| - // Upload InRelease index files to Azure Blob Storage |
74 |
| - Task<BlobContentInfo?[]> releaseIndexUploads = Task.WhenAll(releaseIndexFiles.Where(file => !file.isUpToDateInBlobStorage).SelectMany(file => |
| 73 | + // Upload InRelease indices to Azure Blob Storage |
| 74 | + Task<BlobContentInfo?[]> releaseIndexUploads = Task.WhenAll(releaseIndexFiles.SelectMany(file => |
75 | 75 | new[] { file.inreleaseFilePathRelativeToRepo, file.releaseFilePathRelativeToRepo, file.releaseGpgFilePathRelativeToRepo }.Select(relativeFilePath =>
|
76 |
| - blobStorage.uploadFile(Path.Combine(repoBaseDir, relativeFilePath), relativeFilePath, Path.GetExtension(relativeFilePath) == ".gpg" ? "application/pgp-signature" : "text/plain", |
77 |
| - ct)))); |
| 76 | + blobStorage.uploadFile(Path.Combine(repoBaseDir, relativeFilePath), relativeFilePath, |
| 77 | + ".gpg".Equals(Path.GetExtension(relativeFilePath), StringComparison.OrdinalIgnoreCase) ? "application/pgp-signature" : "text/plain", ct)))); |
78 | 78 |
|
79 | 79 | await packageIndexUploads;
|
80 | 80 | await releaseIndexUploads;
|
81 | 81 |
|
82 |
| - // Upload badge JSON files to Azure Blob Storage |
83 |
| - await Task.WhenAll(badgeFiles.Where(file => !file.isUpToDateInBlobStorage) |
84 |
| - .Select(file => blobStorage.uploadFile(Path.Combine(repoBaseDir, file.filePathRelativeToRepo), file.filePathRelativeToRepo, "application/json", ct))); |
| 82 | + // Upload badge JSON and other extra files to Azure Blob Storage |
| 83 | + await Task.WhenAll(badgeFiles.Select(file => blobStorage.uploadFile(Path.Combine(repoBaseDir, file.filePathRelativeToRepo), file.filePathRelativeToRepo, "application/json", ct))); |
85 | 84 | await blobStorage.uploadFile(Path.Combine(repoBaseDir, readmeFilename), readmeFilename, "text/plain", ct);
|
86 | 85 | await blobStorage.uploadFile(Path.Combine(repoBaseDir, gpgPublicKeyFile), gpgPublicKeyFile, "application/pgp-keys", ct);
|
87 |
| - |
88 |
| - // Clear CDN cache |
89 |
| - await cdnClient.purge(["/dists/*", "/badges/*", "/manifest.json"]); |
| 86 | + await blobStorage.uploadFile(Path.Combine(repoBaseDir, addRepoScriptFile), addRepoScriptFile, "application/x-sh", ct); |
90 | 87 |
|
91 | 88 | // Upload manifest.json file to Azure Blob Storage
|
92 | 89 | await blobStorage.uploadFile(manifestManager.manifestFilePath, manifestManager.manifestFilename, "application/json", ct);
|
93 | 90 |
|
| 91 | + // Clear CDN cache |
| 92 | + await cdnClient.purge(["/dists/*", "/badges/*", "/manifest.json"]); |
| 93 | + |
94 | 94 | // Delete outdated .deb package files from Azure Blob Storage
|
95 | 95 | await Task.WhenAll(oldManifest?.packages.Except(newManifest.packages).Select(packageToDelete => blobStorage.deleteFile(packageToDelete.filePathRelativeToRepo, ct)) ?? []);
|
96 | 96 |
|
|
0 commit comments