Skip to content

Commit f8a958c

Browse files
Add support for kernel flavor versioning (#15578)
1 parent cfa3271 commit f8a958c

25 files changed

Lines changed: 980 additions & 91 deletions

File tree

toolkit/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ TEST_RUN_LIST ?=
3333
TEST_RERUN_LIST ?=
3434
##help:var:TEST_IGNORE_LIST:<spec_list>=List of space-separated spec folders to ignore for package tests. Must not overlap with "TEST_RERUN_LIST", may overlap with "TEST_RUN_LIST". Example: TEST_IGNORE_LIST="acl".
3535
TEST_IGNORE_LIST ?=
36+
##help:var:EXTRA_MACROS_FILES:<file1> <file2>=Space separated list of additional files whose contents will be appended to the versions macro file used during package builds. Example: EXTRA_MACROS_FILES="file1 file2".
37+
EXTRA_MACROS_FILES ?=
3638

3739
######## SET INCREMENTAL BUILD FLAGS ########
3840

@@ -168,7 +170,7 @@ endif
168170
VALIDATE_IMAGE_GPG ?= n
169171

170172
# Default GPG keys for package GPG validation, used with VALIDATE_TOOLCHAIN_GPG and VALIDATE_IMAGE_GPG
171-
default_gpg_keys := $(wildcard $(PROJECT_ROOT)/SPECS/azurelinux-repos/MICROSOFT-*-GPG-KEY) $(wildcard $(toolkit_root)/repos/MICROSOFT-*-GPG-KEY)
173+
default_gpg_keys := $(strip $(wildcard $(PROJECT_ROOT)/SPECS/azurelinux-repos/MICROSOFT-*-GPG-KEY) $(wildcard $(toolkit_root)/repos/MICROSOFT-*-GPG-KEY))
172174
TOOLCHAIN_GPG_VALIDATION_KEYS ?= $(default_gpg_keys)
173175
IMAGE_GPG_VALIDATION_KEYS ?= $(default_gpg_keys)
174176

toolkit/docs/building/building.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ To reproduce an ISO build, run the same make invocation as before, but set:
814814
| TEST_RUN_LIST | | Explicit list of packages to test. The package test will be skipped if the build system thinks it is already up-to-date. The argument accepts both spec and package names. Example: for `python-werkzeug.spec`, which builds the `python3-werkzeug` package both `python-werkzeug` and `python3-werkzeug` are correct.
815815
| TEST_RERUN_LIST | | Always test these package, even if it its corresponding package is up-to-date. The argument accepts both spec and package names. Example: for `python-werkzeug.spec`, which builds the `python3-werkzeug` package both `python-werkzeug` and `python3-werkzeug` are correct.
816816
| TEST_IGNORE_LIST | | Ignore testing these packages. Ignoring and forcing the same test re-run is invalid and will fail the build. The argument accepts both spec and package names. Example: for `python-werkzeug.spec`, which builds the `python3-werkzeug` package both `python-werkzeug` and `python3-werkzeug` are correct.
817+
| EXTRA_MACROS_FILES | | Space separated list of additional `<macros.name>` containing additional RPM macros, which will be available to the build. Used to resolve versions of kernel Out of Tree Module packages.
817818

818819
---
819820

toolkit/docs/how_it_works/3_package_building.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ The files can be ingested into the `graphviz` tools to visualize them, although
117117
dot -Tpng -o visualized.png < graph.dot
118118
```
119119

120+
### Dynamic versioning
121+
We have a versionsprocessor tool that iterates over all Specs and writes their release and versions into a macro file in a format of
122+
`azl_<package_name>_release`, `azl_<package_name>_version`, note that the `<package_name>` needs any `-` replaced with `_` due to macros not allowing `-`.
123+
120124
### Stage 1: Grapher
121125

122126
The `grapher` tool reads the `specs.json` file and converts it into an acyclic directed graph. Inter-package dependencies are represented by directed edges in the graph.

toolkit/scripts/pkggen.mk

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ validate-pkggen-config = $(STATUS_FLAGS_DIR)/validate-image-config-pkggen.flag
3333

3434
# Outputs
3535
specs_file = $(PKGBUILD_DIR)/specs.json
36+
rel_versions_macro_file = $(PKGBUILD_DIR)/macros.releaseversions
3637
graph_file = $(PKGBUILD_DIR)/graph.dot
3738
cached_file = $(PKGBUILD_DIR)/cached_graph.dot
3839
preprocessed_file = $(PKGBUILD_DIR)/preprocessed_graph.dot
@@ -50,6 +51,8 @@ $(call create_folder,$(rpmbuilding_logs_dir))
5051
parse-specs: $(specs_file)
5152
##help:target:graph-cache=Resolve package dependencies and cache the results.
5253
graph-cache: $(cached_file)
54+
##help:target:generate-versions-macros-file=Generate a macros file containing version and release macros for all specs.
55+
generate-versions-macros-file: $(rel_versions_macro_file)
5356
##help:target:graph=Create the initial package build graph.
5457
workplan graph: $(graph_file)
5558
graph-preprocessed: $(preprocessed_file)
@@ -89,10 +92,29 @@ analyze-built-graph: $(go-graphanalytics)
8992
exit 1; \
9093
fi
9194

95+
# Parse all SPECS in $(SPECS_DIR) and generate a release versions macros file containing macros of spec file versions and release.
96+
$(rel_versions_macro_file): $(chroot_worker) $(SPECS_DIR) $(build_specs) $(build_spec_dirs) $(go-versionsprocessor)
97+
$(go-versionsprocessor) \
98+
--dir $(SPECS_DIR) \
99+
--dist-tag $(DIST_TAG) \
100+
$(logging_command) \
101+
--build-dir $(parse_working_dir) \
102+
--worker-tar $(chroot_worker) \
103+
--cpu-prof-file=$(PROFILE_DIR)/versionsprocessor.cpu.pprof \
104+
--mem-prof-file=$(PROFILE_DIR)/versionsprocessor.mem.pprof \
105+
--trace-file=$(PROFILE_DIR)/versionsprocessor.trace \
106+
$(if $(EXTRA_MACROS_FILES),$(foreach file,$(EXTRA_MACROS_FILES),--extra-macros-file=$(file))) \
107+
$(if $(filter y,$(ENABLE_CPU_PROFILE)),--enable-cpu-prof) \
108+
$(if $(filter y,$(ENABLE_MEM_PROFILE)),--enable-mem-prof) \
109+
$(if $(filter y,$(ENABLE_TRACE)),--enable-trace) \
110+
--timestamp-file=$(TIMESTAMP_DIR)/versionsprocessor.jsonl \
111+
$(if $(TARGET_ARCH),--target-arch="$(TARGET_ARCH)") \
112+
--output $@
113+
92114
# Parse specs in $(SPECS_DIR) and generate a specs.json file encoding all dependency information
93115
# We look at the same pack list as the srpmpacker tool via the target $(SRPM_PACK_LIST) if it is set.
94116
# We only parse the spec files we will actually pack.
95-
$(specs_file): $(chroot_worker) $(SPECS_DIR) $(build_specs) $(build_spec_dirs) $(go-specreader) $(depend_SPECS_DIR) $(depend_SRPM_PACK_LIST) $(depend_RUN_CHECK)
117+
$(specs_file): $(rel_versions_macro_file) $(chroot_worker) $(SPECS_DIR) $(build_specs) $(build_spec_dirs) $(go-specreader) $(depend_SPECS_DIR) $(depend_SRPM_PACK_LIST) $(depend_RUN_CHECK)
96118
$(go-specreader) \
97119
--dir $(SPECS_DIR) \
98120
$(if $(SRPM_PACK_LIST),--spec-list="$(SRPM_PACK_LIST)") \
@@ -103,6 +125,7 @@ $(specs_file): $(chroot_worker) $(SPECS_DIR) $(build_specs) $(build_spec_dirs) $
103125
--toolchain-rpms-dir="$(TOOLCHAIN_RPMS_DIR)" \
104126
--dist-tag $(DIST_TAG) \
105127
--worker-tar $(chroot_worker) \
128+
--versions-macro-file $(rel_versions_macro_file) \
106129
$(if $(filter y,$(RUN_CHECK)),--run-check) \
107130
$(logging_command) \
108131
--cpu-prof-file=$(PROFILE_DIR)/specreader.cpu.pprof \
@@ -297,7 +320,7 @@ $(RPMS_DIR):
297320
@touch $@
298321
endif
299322

300-
$(STATUS_FLAGS_DIR)/build-rpms.flag: $(no_repo_acl) $(preprocessed_file) $(chroot_worker) $(go-scheduler) $(go-pkgworker) $(depend_STOP_ON_PKG_FAIL) $(CONFIG_FILE) $(depend_CONFIG_FILE) $(depend_PACKAGE_BUILD_LIST) $(depend_PACKAGE_REBUILD_LIST) $(depend_PACKAGE_IGNORE_LIST) $(depend_MAX_CASCADING_REBUILDS) $(depend_TEST_RUN_LIST) $(depend_TEST_RERUN_LIST) $(depend_TEST_IGNORE_LIST) $(pkggen_rpms) $(srpms) $(BUILD_SRPMS_DIR) $(depend_EXTRA_BUILD_LAYERS) $(depend_LICENSE_CHECK_MODE)
323+
$(STATUS_FLAGS_DIR)/build-rpms.flag: $(rel_versions_macro_file) $(no_repo_acl) $(preprocessed_file) $(chroot_worker) $(go-scheduler) $(go-pkgworker) $(depend_STOP_ON_PKG_FAIL) $(CONFIG_FILE) $(depend_CONFIG_FILE) $(depend_PACKAGE_BUILD_LIST) $(depend_PACKAGE_REBUILD_LIST) $(depend_PACKAGE_IGNORE_LIST) $(depend_MAX_CASCADING_REBUILDS) $(depend_TEST_RUN_LIST) $(depend_TEST_RERUN_LIST) $(depend_TEST_IGNORE_LIST) $(pkggen_rpms) $(srpms) $(BUILD_SRPMS_DIR) $(depend_EXTRA_BUILD_LAYERS) $(depend_LICENSE_CHECK_MODE)
301324
$(go-scheduler) \
302325
--input="$(preprocessed_file)" \
303326
--output="$(built_file)" \
@@ -315,6 +338,7 @@ $(STATUS_FLAGS_DIR)/build-rpms.flag: $(no_repo_acl) $(preprocessed_file) $(chroo
315338
--distro-release-version="$(RELEASE_VERSION)" \
316339
--distro-build-number="$(BUILD_NUMBER)" \
317340
--rpmmacros-file="$(TOOLCHAIN_MANIFESTS_DIR)/macros.override" \
341+
--versions-macro-file="$(rel_versions_macro_file)" \
318342
--build-attempts="$$(($(PACKAGE_BUILD_RETRIES)+1))" \
319343
--check-attempts="$$(($(CHECK_BUILD_RETRIES)+1))" \
320344
$(if $(MAX_CASCADING_REBUILDS),--max-cascading-rebuilds="$(MAX_CASCADING_REBUILDS)") \

toolkit/scripts/srpm_pack.mk

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# update - Check signatures and updating any mismatches in the signatures file
1414
SRPM_FILE_SIGNATURE_HANDLING ?= enforce
1515

16-
SRPM_BUILD_CHROOT_DIR = $(BUILD_DIR)/SRPM_packaging
17-
SRPM_BUILD_LOGS_DIR = $(LOGS_DIR)/pkggen/srpms
18-
16+
SRPM_BUILD_CHROOT_DIR = $(BUILD_DIR)/SRPM_packaging
17+
SRPM_BUILD_LOGS_DIR = $(LOGS_DIR)/pkggen/srpms
18+
rel_versions_macro_file = $(PKGBUILD_DIR)/macros.releaseversions
1919
# Configure the list of packages we want to process into SRPMs
2020
# Strip any whitespace from user input and reasign using override so we can compare it with the empty string
2121
override SRPM_PACK_LIST := $(strip $(SRPM_PACK_LIST))
@@ -77,7 +77,7 @@ $(STATUS_FLAGS_DIR)/build_srpms.flag: $(local_specs) $(local_spec_dirs) $(local_
7777
$(STATUS_FLAGS_DIR)/build_toolchain_srpms.flag: $(STATUS_FLAGS_DIR)/build_srpms.flag
7878
@touch $@
7979
else
80-
$(STATUS_FLAGS_DIR)/build_srpms.flag: $(chroot_worker) $(local_specs) $(local_spec_dirs) $(SPECS_DIR) $(go-srpmpacker) $(depend_SRPM_PACK_LIST) $(local_spec_sources)
80+
$(STATUS_FLAGS_DIR)/build_srpms.flag: $(rel_versions_macro_file) $(chroot_worker) $(local_specs) $(local_spec_dirs) $(SPECS_DIR) $(go-srpmpacker) $(depend_SRPM_PACK_LIST) $(local_spec_sources)
8181
GODEBUG=netdns=go $(go-srpmpacker) \
8282
--dir=$(SPECS_DIR) \
8383
--output-dir=$(BUILD_SRPMS_DIR) \
@@ -88,6 +88,7 @@ $(STATUS_FLAGS_DIR)/build_srpms.flag: $(chroot_worker) $(local_specs) $(local_sp
8888
--tls-cert=$(TLS_CERT) \
8989
--tls-key=$(TLS_KEY) \
9090
--build-dir=$(SRPM_BUILD_CHROOT_DIR) \
91+
--versions-macro-file=$(rel_versions_macro_file) \
9192
--signature-handling=$(SRPM_FILE_SIGNATURE_HANDLING) \
9293
--worker-tar=$(chroot_worker) \
9394
$(if $(filter y,$(RUN_CHECK)),--run-check) \

toolkit/scripts/toolkit.mk

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ rpms_snapshot_dir_name = rpms_snapshots
2525
rpms_snapshot_build_dir = $(BUILD_DIR)/$(rpms_snapshot_dir_name)
2626
rpms_snapshot_logs_path = $(LOGS_DIR)/$(rpms_snapshot_dir_name)/rpms_snapshot.log
2727
rpms_snapshot_per_specs = $(rpms_snapshot_build_dir)/$(specs_dir_name)_$(rpms_snapshot_name)
28+
rel_versions_macro_file = $(PKGBUILD_DIR)/macros.releaseversions
2829

2930
valid_arch_spec_names_build_dir = $(BUILD_DIR)/valid_arch_spec_names
3031
valid_arch_spec_names = $(valid_arch_spec_names_build_dir)/valid_arch_spec_names.txt
@@ -75,14 +76,15 @@ $(toolkit_archive_versioned_compressed): $(toolkit_archive) $(rpms_snapshot) $(d
7576
tar --update -f $(toolkit_archive_versioned) -C $(toolkit_build_dir) $(toolkit_release_file_relative_path) $(toolkit_rpms_snapshot_file_relative_path) && \
7677
$(ARCHIVE_TOOL) --best -c $(toolkit_archive_versioned) > $(toolkit_archive_versioned_compressed)
7778

78-
$(toolkit_archive): $(go_tool_targets) $(mariner_repos_files) $(toolkit_component_extra_files) $(toolkit_root_files)
79+
$(toolkit_archive): $(go_tool_targets) $(mariner_repos_files) $(toolkit_component_extra_files) $(toolkit_root_files) $(rel_versions_macro_file)
7980
rm -rf $(toolkit_prep_dir) && \
8081
mkdir -p $(toolkit_prep_dir) && \
8182
mkdir -p $(toolkit_repos_dir) && \
8283
mkdir -p $(toolkit_tools_dir) && \
8384
cp -r $(toolkit_root_files) $(toolkit_prep_dir) && \
8485
cp $(mariner_repos_files) $(toolkit_repos_dir) && \
8586
cp $(toolkit_component_extra_files) $(toolkit_prep_dir) && \
87+
cp $(rel_versions_macro_file) $(toolkit_prep_dir) && \
8688
cp $(go_tool_targets) $(toolkit_tools_dir) && \
8789
rm -rf $(toolkit_prep_dir)/out && \
8890
tar -cvp -f $(toolkit_archive) -C $(dir $(toolkit_prep_dir)) $(notdir $(toolkit_prep_dir))
@@ -93,12 +95,13 @@ rpms-snapshot: $(rpms_snapshot)
9395
$(rpms_snapshot): $(rpms_snapshot_per_specs) $(depend_SPECS_DIR)
9496
cp $(rpms_snapshot_per_specs) $(rpms_snapshot)
9597

96-
$(rpms_snapshot_per_specs): $(go-rpmssnapshot) $(chroot_worker) $(local_specs) $(local_spec_dirs) $(SPECS_DIR)
98+
$(rpms_snapshot_per_specs): $(go-rpmssnapshot) $(chroot_worker) $(local_specs) $(local_spec_dirs) $(SPECS_DIR) $(rel_versions_macro_file)
9799
@mkdir -p "$(rpms_snapshot_build_dir)"
98100
$(go-rpmssnapshot) \
99101
--input="$(SPECS_DIR)" \
100102
--output="$(rpms_snapshot_per_specs)" \
101103
--build-dir="$(rpms_snapshot_build_dir)" \
104+
--versions-macro-file $(rel_versions_macro_file) \
102105
--dist-tag=$(DIST_TAG) \
103106
--worker-tar="$(chroot_worker)" \
104107
--log-level=$(LOG_LEVEL) \
@@ -114,13 +117,14 @@ run-specarchchecker: $(valid_arch_spec_names)
114117
@cat $(valid_arch_spec_names) && echo "" # File doesn't have a newline at the end, so add one via echo.
115118
@echo "Valid arch spec names generated under '$(valid_arch_spec_names)'."
116119

117-
$(valid_arch_spec_names): $(go-specarchchecker) $(chroot_worker) $(local_specs) $(local_spec_dirs) $(SPECS_DIR) $(depend_PACKAGE_BUILD_LIST) $(depend_PACKAGE_REBUILD_LIST)
120+
$(valid_arch_spec_names): $(go-specarchchecker) $(chroot_worker) $(local_specs) $(local_spec_dirs) $(SPECS_DIR) $(depend_PACKAGE_BUILD_LIST) $(depend_PACKAGE_REBUILD_LIST) $(rel_versions_macro_file)
118121
$(go-specarchchecker) \
119122
--input="$(SPECS_DIR)" \
120123
--output="$@" \
121124
--packages="$(PACKAGE_BUILD_LIST)" \
122125
--rebuild-packages="$(PACKAGE_REBUILD_LIST)" \
123126
--build-dir="$(valid_arch_spec_names_build_dir)" \
127+
--versions-macro-file $(rel_versions_macro_file) \
124128
$(if $(filter y,$(RUN_CHECK)),--test-only) \
125129
--dist-tag=$(DIST_TAG) \
126130
--worker-tar="$(chroot_worker)" \

toolkit/scripts/tools.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ go_tool_list = \
6262
scheduler \
6363
specarchchecker \
6464
specreader \
65+
versionsprocessor \
6566
srpmpacker \
6667
validatechroot \
6768

toolkit/tools/internal/safechroot/chrootinterface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ type ChrootInterface interface {
88
Run(toRun func() error) error
99
UnsafeRun(toRun func() error) error
1010
AddFiles(filesToCopy ...FileToCopy) error
11+
AddRPMMacrosFile(macrosFilePath string) error
1112
}

toolkit/tools/internal/safechroot/dummychroot.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ func (d *DummyChroot) UnsafeRun(toRun func() error) (err error) {
2323
func (d *DummyChroot) AddFiles(filesToCopy ...FileToCopy) (err error) {
2424
return AddFilesToDestination(d.RootDir(), filesToCopy...)
2525
}
26+
27+
func (d *DummyChroot) AddRPMMacrosFile(macrosFilePath string) error {
28+
return AddRPMMacrosFile(d, macrosFilePath)
29+
}

toolkit/tools/internal/safechroot/safechroot.go

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import (
1414
"time"
1515

1616
"github.com/microsoft/azurelinux/toolkit/tools/internal/buildpipeline"
17+
"github.com/microsoft/azurelinux/toolkit/tools/internal/directory"
1718
"github.com/microsoft/azurelinux/toolkit/tools/internal/file"
1819
"github.com/microsoft/azurelinux/toolkit/tools/internal/logger"
1920
"github.com/microsoft/azurelinux/toolkit/tools/internal/retry"
21+
"github.com/microsoft/azurelinux/toolkit/tools/internal/rpm"
2022
"github.com/microsoft/azurelinux/toolkit/tools/internal/shell"
2123
"github.com/microsoft/azurelinux/toolkit/tools/internal/systemdependency"
2224

@@ -160,6 +162,60 @@ func NewOverlayMountPoint(chrootDir, source, target, lowerDir, upperDir, workDir
160162
return
161163
}
162164

165+
func (c *Chroot) AddRPMMacrosFile(macrosFilePath string) error {
166+
return AddRPMMacrosFile(c, macrosFilePath)
167+
}
168+
169+
func AddRPMMacrosFile(c ChrootInterface, macrosFilePath string) (err error) {
170+
var macroDir string
171+
172+
doGetMacroDir := func() error {
173+
var macroErr error
174+
175+
macroDir, macroErr = rpm.GetMacroDir()
176+
if macroErr != nil {
177+
logger.Log.Errorf("Failed to get RPM macro directory: %s", macroErr)
178+
return macroErr
179+
}
180+
181+
return macroErr
182+
}
183+
184+
c.Run(doGetMacroDir)
185+
186+
// Destination path inside the chroot (same path as on the host).
187+
macrosDestDir := filepath.Join(c.RootDir(), macroDir)
188+
macrosDestFile := filepath.Join(macrosDestDir, filepath.Base(macrosFilePath))
189+
190+
exists, existsErr := file.PathExists(macrosDestFile)
191+
if existsErr != nil {
192+
logger.Log.Errorf("Failed to check if macros file exists (%s): %s", macrosDestFile, existsErr)
193+
return existsErr
194+
}
195+
196+
if exists {
197+
logger.Log.Warningf("Macros file (%s) already exists, skipping copy", macrosDestFile)
198+
return nil
199+
}
200+
201+
// Ensure destination directory exists and copy the file.
202+
mkdirErr := directory.EnsureDirExists(macrosDestDir)
203+
if mkdirErr != nil {
204+
logger.Log.Errorf("Failed to create macros directory inside chroot (%s): %s", macrosDestDir, mkdirErr)
205+
return mkdirErr
206+
}
207+
208+
copyErr := file.Copy(macrosFilePath, macrosDestFile)
209+
if copyErr != nil {
210+
logger.Log.Errorf("Failed to copy release version macros file into chroot (%s -> %s): %s", macrosFilePath, macrosDestFile, copyErr)
211+
return copyErr
212+
}
213+
214+
logger.Log.Infof("Copied release version macros file into chroot (%s -> %s)", macrosFilePath, macrosDestFile)
215+
216+
return
217+
}
218+
163219
// GetSource gets the source device of the mount.
164220
func (m *MountPoint) GetSource() string {
165221
return m.source
@@ -209,7 +265,7 @@ func NewChroot(rootDir string, isExistingDir bool) *Chroot {
209265
// This call will block until the chroot initializes successfully.
210266
// Only one Chroot will initialize at a given time.
211267
func (c *Chroot) Initialize(tarPath string, extraDirectories []string, extraMountPoints []*MountPoint,
212-
includeDefaultMounts bool,
268+
includeDefaultMounts bool, releaseVersionMacrosFile ...string,
213269
) (err error) {
214270
// On failed initialization, cleanup all chroot files
215271
const leaveChrootOnDisk = false
@@ -319,6 +375,16 @@ func (c *Chroot) Initialize(tarPath string, extraDirectories []string, extraMoun
319375
activeChroots = append(activeChroots, c)
320376
}
321377

378+
// If a release version macros file is provided, copy it into the default RPM macros directory
379+
// inside the chroot so rpmspec/rpmbuild pick it up automatically.
380+
if len(releaseVersionMacrosFile) > 0 && releaseVersionMacrosFile[0] != "" {
381+
err = c.AddRPMMacrosFile(releaseVersionMacrosFile[0])
382+
if err != nil {
383+
err = fmt.Errorf("failed to add release version macros file to chroot:\n%w", err)
384+
return
385+
}
386+
}
387+
322388
return
323389
}
324390

0 commit comments

Comments
 (0)