Skip to content

Commit 2a381fa

Browse files
committed
main: add --rpmmd-cache options
This commit adds a new option `--rpmmd-cache` that is similar to the option in bootc-image-builder. It is also useful for osbuild/osbuild-composer#4904
1 parent cbb6852 commit 2a381fa

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

cmd/image-builder/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ func cmdManifestWrapper(pbar progress.ProgressBar, cmd *cobra.Command, args []st
145145
if err != nil {
146146
return nil, err
147147
}
148+
rpmmdCacheDir, err := cmd.Flags().GetString("rpmmd-cache")
149+
if err != nil {
150+
return nil, err
151+
}
148152
extraRepos, err := cmd.Flags().GetStringArray("extra-repo")
149153
if err != nil {
150154
return nil, err
@@ -299,6 +303,7 @@ func cmdManifestWrapper(pbar progress.ProgressBar, cmd *cobra.Command, args []st
299303
IgnoreWarnings: ignoreWarnings,
300304
CustomSeed: customSeed,
301305
Subscription: subscription,
306+
RpmmdCacheDir: rpmmdCacheDir,
302307

303308
ForceRepos: forceRepos,
304309
}
@@ -542,6 +547,7 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support.
542547
manifestCmd.Flags().Bool("with-sbom", false, `export SPDX SBOM document`)
543548
manifestCmd.Flags().Bool("ignore-warnings", false, `ignore warnings during manifest generation`)
544549
manifestCmd.Flags().String("registrations", "", `filename of a registrations file with e.g. subscription details`)
550+
manifestCmd.Flags().String("rpmmd-cache", "", `osbuild directory to cache rpm metadata`)
545551
rootCmd.AddCommand(manifestCmd)
546552

547553
uploadCmd := &cobra.Command{
@@ -574,7 +580,6 @@ operating systems like Fedora, CentOS and RHEL with easy customizations support.
574580
buildCmd.Flags().AddFlagSet(manifestCmd.Flags())
575581
buildCmd.Flags().Bool("with-manifest", false, `export osbuild manifest`)
576582
buildCmd.Flags().Bool("with-buildlog", false, `export osbuild buildlog`)
577-
// XXX: add --rpmmd cache too and put under /var/cache/image-builder/dnf
578583
buildCmd.Flags().String("cache", "/var/cache/image-builder/store", `osbuild directory to cache intermediate build artifacts"`)
579584
// XXX: add "--verbose" here, similar to how bib is doing this
580585
// (see https://github.com/osbuild/bootc-image-builder/pull/790/commits/5cec7ffd8a526e2ca1e8ada0ea18f927695dfe43)

cmd/image-builder/manifest.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type manifestOptions struct {
3131
WithSBOM bool
3232
IgnoreWarnings bool
3333
CustomSeed *int64
34+
RpmmdCacheDir string
3435

3536
ForceRepos []string
3637
UseBootstrapContainer bool
@@ -63,13 +64,13 @@ func generateManifest(dataDir string, extraRepos []string, img *imagefilter.Resu
6364
if err != nil {
6465
return err
6566
}
66-
// XXX: add --rpmmd/cachedir option like bib
6767
manifestGenOpts := &manifestgen.Options{
6868
DepsolveWarningsOutput: depsolveWarningsOutput,
6969
RpmDownloader: opts.RpmDownloader,
7070
UseBootstrapContainer: opts.UseBootstrapContainer,
7171
CustomSeed: opts.CustomSeed,
7272
Depsolver: manifestgenDepsolver,
73+
Cachedir: opts.RpmmdCacheDir,
7374
}
7475
if opts.WithSBOM {
7576
outputDir := basenameFor(img, opts.OutputDir)

test/test_manifest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,17 @@ def test_container_manifest_bootc_iso_smoke(build_container):
147147
assert re.match(
148148
f'bootc switch .* registry {bootc_payload_ref}',
149149
kickstart_stage["options"]["%post"][0]["commands"][0])
150+
151+
152+
def test_manifest_honors_rpmmd_cache(tmp_path, build_container):
153+
rpmmd_cache = tmp_path / "rpmmd"
154+
rpmmd_cache.mkdir()
155+
subprocess.check_call(podman_run + [
156+
"-v", f"{rpmmd_cache}:/rpmmd_cache",
157+
build_container,
158+
"manifest",
159+
"--distro", "centos-9",
160+
"minimal-raw",
161+
"--rpmmd-cache", "/rpmmd_cache",
162+
], text=True)
163+
assert len(list(rpmmd_cache.rglob("repomd.xml"))) > 0

0 commit comments

Comments
 (0)