Skip to content

Commit 9d2724e

Browse files
authored
feat: add --pipeline-dirs flag to build command (#2323)
* feat: add --pipeline-dirs flag to build command Adds --pipeline-dirs flag to accept multiple pipeline directories, matching the test command functionality. The existing --pipeline-dir (singular) is kept for backward compatibility. Directories are searched in order with first match winning. For example, if both custom1/fetch.yaml and custom2/fetch.yaml exist, custom1 wins: melange build --pipeline-dirs custom1 --pipeline-dirs custom2 --pipeline-dir original config.yaml # Searches: original/ -> custom1/ -> custom2/ -> /usr/share/melange/pipelines/ This enables layered pipeline overrides for teams with shared repositories. Search order: 1. --pipeline-dir value (if specified)| (for backward compatibility) 2. --pipeline-dirs values (left to right) 3. Built-in pipeline directory Signed-off-by: Debasish Biswas <debasishbsws.dev@gmail.com> * update the docs Signed-off-by: Debasish Biswas <debasishbsws.dev@gmail.com> --------- Signed-off-by: Debasish Biswas <debasishbsws.dev@gmail.com>
1 parent 0f2f34d commit 9d2724e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

docs/md/melange_build.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ melange build [flags]
6262
--package-append strings extra packages to install for each of the build environments
6363
--persist-lint-results persist lint results to JSON files in packages/{arch}/ directory
6464
--pipeline-dir string directory used to extend defined built-in pipelines
65+
--pipeline-dirs strings directories used to extend defined built-in pipelines
6566
-r, --repository-append strings path to extra repositories to include in the build environment
6667
--rm clean up intermediate artifacts (e.g. container images, temp dirs) (default true)
6768
--runner string which runner to use to enable running commands, default is based on your platform. Options are ["bubblewrap" "docker" "qemu"]

pkg/cli/build.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func addBuildFlags(fs *pflag.FlagSet, flags *BuildFlags) {
4747
fs.StringVar(&flags.BuildDate, "build-date", "", "date used for the timestamps of the files inside the image")
4848
fs.StringVar(&flags.WorkspaceDir, "workspace-dir", "", "directory used for the workspace at /home/build")
4949
fs.StringVar(&flags.PipelineDir, "pipeline-dir", "", "directory used to extend defined built-in pipelines")
50+
fs.StringSliceVar(&flags.PipelineDirs, "pipeline-dirs", []string{}, "directories used to extend defined built-in pipelines")
5051
fs.StringVar(&flags.SourceDir, "source-dir", "", "directory used for included sources")
5152
fs.StringVar(&flags.CacheDir, "cache-dir", "./melange-cache/", "directory used for cached inputs")
5253
fs.StringVar(&flags.CacheSource, "cache-source", "", "directory or bucket used for preloading the cache")
@@ -97,6 +98,7 @@ type BuildFlags struct {
9798
BuildDate string
9899
WorkspaceDir string
99100
PipelineDir string
101+
PipelineDirs []string
100102
SourceDir string
101103
CacheDir string
102104
CacheSource string
@@ -191,9 +193,9 @@ func (flags *BuildFlags) BuildOptions(ctx context.Context, args ...string) ([]bu
191193
build.WithBuildDate(flags.BuildDate),
192194
build.WithWorkspaceDir(flags.WorkspaceDir),
193195
// Order matters, so add any specified pipelineDir before
194-
// builtin pipelines.
196+
// builtin pipelines. Support both --pipeline-dir (singular, deprecated)
197+
// and --pipeline-dirs (plural, new). --pipeline-dir is processed first.
195198
build.WithPipelineDir(flags.PipelineDir),
196-
build.WithPipelineDir(BuiltinPipelineDir),
197199
build.WithCacheDir(flags.CacheDir),
198200
build.WithCacheSource(flags.CacheSource),
199201
build.WithPackageCacheDir(flags.ApkCacheDir),
@@ -244,6 +246,13 @@ func (flags *BuildFlags) BuildOptions(ctx context.Context, args ...string) ([]bu
244246
opts = append(opts, build.WithSourceDir(flags.SourceDir))
245247
}
246248

249+
// Add multiple pipeline directories from --pipeline-dirs
250+
for i := range flags.PipelineDirs {
251+
opts = append(opts, build.WithPipelineDir(flags.PipelineDirs[i]))
252+
}
253+
// Always append built-in pipeline directory as fallback
254+
opts = append(opts, build.WithPipelineDir(BuiltinPipelineDir))
255+
247256
if auth, ok := os.LookupEnv("HTTP_AUTH"); !ok {
248257
// Fine, no auth.
249258
} else if parts := strings.SplitN(auth, ":", 4); len(parts) != 4 {

0 commit comments

Comments
 (0)