Skip to content

Commit 6c9fc41

Browse files
authored
feat(kiwi): allow enabling imageinclude to inject .repo files (#490)
Refactors kiwi wrapper package to allow specifying all of the various RPM repo options. Adds command-line option to azldev image build: --remote-repo-include-in-image
1 parent 493ce48 commit 6c9fc41

File tree

3 files changed

+543
-256
lines changed

3 files changed

+543
-256
lines changed

internal/app/azldev/cmds/image/build.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ type ImageBuildOptions struct {
3232
// specified via RemoteRepoPaths.
3333
NoRemoteRepoGpgCheck bool
3434

35+
// RemoteRepoIncludeInImage marks all remote repositories specified via RemoteRepoPaths
36+
// as part of the system image repository setup (imageinclude=true).
37+
RemoteRepoIncludeInImage bool
38+
3539
// TargetArch specifies the target architecture to build for (e.g., "x86_64" or "aarch64").
3640
// If left empty, the host architecture will be used.
3741
TargetArch ImageArch
@@ -122,6 +126,8 @@ This command invokes kiwi-ng via sudo to build the image.`,
122126
"URIs to remote repositories (http:// or https://) to include during build (can be specified multiple times)")
123127
cmd.Flags().BoolVar(&options.NoRemoteRepoGpgCheck, "remote-repo-no-gpgcheck", false,
124128
"Disable GPG checking for all remote repositories specified via --remote-repo (not for production use)")
129+
cmd.Flags().BoolVar(&options.RemoteRepoIncludeInImage, "remote-repo-include-in-image", false,
130+
"Include all remote repositories specified via --remote-repo in the built image's repository setup")
125131

126132
return cmd
127133
}
@@ -231,8 +237,7 @@ func createKiwiRunner(
231237
options *ImageBuildOptions,
232238
) (*kiwi.Runner, error) {
233239
runner := kiwi.NewRunner(env, filepath.Dir(imageConfig.Definition.Path)).
234-
WithTargetDir(targetDir).
235-
WithRemoteRepoGPGCheck(!options.NoRemoteRepoGpgCheck)
240+
WithTargetDir(targetDir)
236241

237242
if imageConfig.Definition.Profile != "" {
238243
runner.WithProfile(imageConfig.Definition.Profile)
@@ -242,14 +247,20 @@ func createKiwiRunner(
242247
runner.WithTargetArch(string(options.TargetArch))
243248
}
244249

250+
// Build per-repo options for remote repositories.
251+
remoteRepoOptions := &kiwi.RepoOptions{
252+
DisableRepoGPGCheck: options.NoRemoteRepoGpgCheck,
253+
ImageInclude: options.RemoteRepoIncludeInImage,
254+
}
255+
245256
for _, repoURI := range options.RemoteRepoPaths {
246-
if err := runner.AddRemoteRepo(repoURI); err != nil {
257+
if err := runner.AddRemoteRepo(repoURI, remoteRepoOptions); err != nil {
247258
return nil, fmt.Errorf("invalid remote repository:\n%w", err)
248259
}
249260
}
250261

251262
for _, repoPath := range options.LocalRepoPaths {
252-
runner.AddLocalRepo(repoPath)
263+
runner.AddLocalRepo(repoPath, nil)
253264
}
254265

255266
return runner, nil

0 commit comments

Comments
 (0)