Skip to content

Commit

Permalink
gen-manifest: include repo as pseudo package
Browse files Browse the repository at this point in the history
This is one possible fix for the issue raised in
https://github.com/osbuild/otk/pull/209/files#r1771119550

I.e. how we can ensure that we have the same repo configuration
between images and otk.

It works by adding a pseudo package for each repo, the resulting
diff in otk looks like this:
```yaml
--- a/test/data/images-ref/centos/9/x86_64/qcow2/centos_9-x86_64-qcow2-empty.yaml
+++ b/test/data/images-ref/centos/9/x86_64/qcow2/centos_9-x86_64-qcow2-empty.yaml
@@ -29,6 +29,9 @@ pipelines:
               - id: sha256:93cd8e20fc07f08337cb9d9fa9996274658f6395574e874379c4c4157e922700
               - id: sha256:bf35d0b80342ad44ca298ed07fcc9d3f8d43a2700964586a4a5e2c0a49766528
               - id: sha256:360688270679b1c512513cfab6d931c8c715318582a9974caa3c0f88a0ee053c
+              - id: sha256:912090e0bd496175c8eb6e2f082dbac1d94c3cb064be7dd4ce8fa79dab1e30e1
+              - id: sha256:3dff58cda3b953429f7b4aab66c3941dc99262bb8f1c04f8e2d0f78674f8572b
+              - id: sha256:3165be96f5833ae07a93e8baa073df6bae2dc719814af10288f844d637d8721a
         options:
           gpgkeys:
             - '-----BEGIN PGP PUBLIC KEY BLOCK-----
@@ -136,6 +139,9 @@ pipelines:
               - id: sha256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb
               - id: sha256:aba407b81ed016841ea552feadaf0663c7804a64554ba55d3109b3dc8198cdcb
               - id: sha256:3096fd17ccf8ee00173d4d753aa67e476526b800ae6eff06b055d71fc4ce6dff
+              - id: sha256:912090e0bd496175c8eb6e2f082dbac1d94c3cb064be7dd4ce8fa79dab1e30e1
+              - id: sha256:3dff58cda3b953429f7b4aab66c3941dc99262bb8f1c04f8e2d0f78674f8572b
+              - id: sha256:3165be96f5833ae07a93e8baa073df6bae2dc719814af10288f844d637d8721a
         options:
           gpgkeys:
             - '-----BEGIN PGP PUBLIC KEY BLOCK-----
@@ -406,12 +412,16 @@ sources:
         url: https://example.com/repo/packages/python3-jsonschema
       sha256:3096fd17ccf8ee00173d4d753aa67e476526b800ae6eff06b055d71fc4ce6dff:
         url: https://example.com/repo/packages/tcpdump
+      sha256:3165be96f5833ae07a93e8baa073df6bae2dc719814af10288f844d637d8721a:
+        url: https://rpmrepo.osbuild.org/v2/mirror/public/el9/cs9-x86_64-rt/repo:RT
       sha256:352db6b0cf337d13b4a9c05b2e4f13bafe02a311cb3dbf756ef2d44d52dca901:
         url: https://example.com/repo/packages/oddjob-mkhomedir
       sha256:360688270679b1c512513cfab6d931c8c715318582a9974caa3c0f88a0ee053c:
         url: https://example.com/repo/packages/qemu-img
       sha256:3993c379c029014a9c4b2adf5d23397b3c7421467a0cb3575ff925bb6f6329b0:
         url: https://example.com/repo/packages/coreutils
+      sha256:3dff58cda3b953429f7b4aab66c3941dc99262bb8f1c04f8e2d0f78674f8572b:
+        url: https://rpmrepo.osbuild.org/v2/mirror/public/el9/cs9-x86_64-baseos/repo:BaseOS
       sha256:3fc8516922a52d754083308fc413432652da40490b0a336294a5d765757be942:
         url: https://example.com/repo/packages/cloud-init
       sha256:43436865ed2d17b812735341ae5102c5ea86ce1eb70a0a43045a552a755da79d:
@@ -436,6 +446,8 @@ sources:
         url: https://example.com/repo/packages/rsync
       sha256:90aebae315675cbf04612de4f7d5874850f48e0b8dd82becbeaa47ca93f5ebfb:
         url: https://example.com/repo/packages/tar
+      sha256:912090e0bd496175c8eb6e2f082dbac1d94c3cb064be7dd4ce8fa79dab1e30e1:
+        url: https://rpmrepo.osbuild.org/v2/mirror/public/el9/cs9-x86_64-appstream/repo:AppStream
       sha256:9370ee4e95b7172989b9fd3f81860093529113ba42b69be340467d87a94bb253:
         url: https://example.com/repo/packages/shim-x64
       sha256:93cd8e20fc07f08337cb9d9fa9996274658f6395574e874379c4c4157e922700:
```
  • Loading branch information
mvo5 committed Sep 23, 2024
1 parent d61acd7 commit 5ccb90f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cmd/gen-manifests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ func depsolve(cacheDir string, packageSets map[string][]rpmmd.PackageSet, d dist
func mockDepsolve(packageSets map[string][]rpmmd.PackageSet, repos []rpmmd.RepoConfig) (map[string][]rpmmd.PackageSpec, map[string][]rpmmd.RepoConfig) {
depsolvedSets := make(map[string][]rpmmd.PackageSpec)
repoSets := make(map[string][]rpmmd.RepoConfig)

for name, pkgSetChain := range packageSets {
specSet := make([]rpmmd.PackageSpec, 0)
for _, pkgSet := range pkgSetChain {
Expand All @@ -393,6 +394,25 @@ func mockDepsolve(packageSets map[string][]rpmmd.PackageSet, repos []rpmmd.RepoC
specSet = append(specSet, spec)
}
}

// generate pseudo packages for the repos
for _, repo := range repos {
checksum := fmt.Sprintf("%x", sha256.Sum256([]byte(repo.Name)))
// the test repos have the form:
// https://rpmrepo..../el9/cs9-x86_64-rt-20240915
// drop the date as it's not needed for this level of
// mocks
baseURL := repo.BaseURLs[0]
if idx := strings.LastIndex(baseURL, "-"); idx > 0 {
baseURL = baseURL[:idx]
}
specSet = append(specSet, rpmmd.PackageSpec{
Name: "repo:" + repo.Name,
RemoteLocation: baseURL + "/repo:" + repo.Name,
Checksum: "sha256:" + checksum,
})
}

depsolvedSets[name] = specSet
repoSets[name] = repos
}
Expand Down

0 comments on commit 5ccb90f

Please sign in to comment.