Skip to content

Commit 2625d7b

Browse files
authored
Add REPO_SNAPSHOT_TIME to the toolkit for package and image build. (#10369)
1 parent 6b3ca35 commit 2625d7b

22 files changed

Lines changed: 384 additions & 77 deletions

File tree

SPECS/tdnf/tdnf.spec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Summary: dnf equivalent using C libs
55
Name: tdnf
66
Version: 3.5.8
7-
Release: 2%{?dist}
7+
Release: 3%{?dist}
88
License: LGPLv2.1 AND GPLv2
99
Vendor: Microsoft Corporation
1010
Distribution: Azure Linux
@@ -237,7 +237,10 @@ fi
237237
/%{_lib}/systemd/system/tdnf*
238238

239239
%changelog
240-
* Thu Aug 29 2024 Sam Meluch <sammeluch@microsoft.com> - 3.5.8-2
240+
* Fri Sep 20 2024 Sam Meluch <sammeluch@microsoft.com> - 3.5.8-3
241+
- Fix an issue with snapshottime config option
242+
243+
* Wed Sep 18 2024 Sam Meluch <sammeluch@microsoft.com> - 3.5.8-2
241244
- Add virtual repo snapshot exclude repos
242245

243246
* Mon Sep 09 2024 Sam Meluch <sammeluch@microsoft.com> - 3.5.8-1

SPECS/tdnf/virtual-repo-snapshot.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From ef2e53818f93005d1dc2d96eaa36519069fa979d Mon Sep 17 00:00:00 2001
1+
From 7af976b8d0977f32f9903220d8b44378e72d4336 Mon Sep 17 00:00:00 2001
22
From: Sam Meluch <sammeluch@microsoft.com>
33
Date: Tue, 30 Apr 2024 13:56:44 -0700
44
Subject: [PATCH] Add virtual repo snapshot feature to tdnf
@@ -21,7 +21,7 @@ Subject: [PATCH] Add virtual repo snapshot feature to tdnf
2121
14 files changed, 958 insertions(+), 17 deletions(-)
2222

2323
diff --git a/client/config.c b/client/config.c
24-
index 8ddcc7a..805fff1 100644
24+
index 8ddcc7a..ef16467 100644
2525
--- a/client/config.c
2626
+++ b/client/config.c
2727
@@ -85,6 +85,7 @@ TDNFReadConfig(
@@ -38,7 +38,7 @@ index 8ddcc7a..805fff1 100644
3838
}
3939
+ else if (strcmp(cn->name, TDNF_CONF_KEY_SNAPSHOT_TIME) == 0)
4040
+ {
41-
+ pConf->pszSnapshotTime = cn->value; //assumes your system's time_t is typedef long
41+
+ pConf->pszSnapshotTime = strdup(cn->value); //assumes your system's time_t is typedef long
4242
+ }
4343
else if (strcmp(cn->name, TDNF_CONF_KEY_CLEAN_REQ_ON_REMOVE) == 0)
4444
{

toolkit/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ RUN_CHECK ?= n
4545
USE_PREVIEW_REPO ?= n
4646
DISABLE_UPSTREAM_REPOS ?= n
4747
DISABLE_DEFAULT_REPOS ?= n
48+
##help:var:REPO_SNAPSHOT_TIME:<posix_time>=Posix time to be used as a snapshot for remote repositories when fetching packages. Example: REPO_SNAPSHOT_TIME="1724119509".
49+
REPO_SNAPSHOT_TIME ?=
4850
TOOLCHAIN_CONTAINER_ARCHIVE ?=
4951
TOOLCHAIN_ARCHIVE ?=
5052
TOOLCHAIN_SOURCES_ARCHIVE ?=

toolkit/resources/imageconfigs/additionalfiles/iso_initrd/root/runliveinstaller

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,13 @@ cd /installer
143143
# Turn off echoing while the installer runs to stop sensitive data from rendering in the TTY session.
144144
stty -echo
145145

146+
# add call to static time file to populate liveinstaller option here
147+
if [[ -f "$CONFIG_ROOT/repo-snapshot-time.txt" ]]; then
148+
REPO_TIME=$(cat /"$CONFIG_ROOT/repo-snapshot-time.txt")
149+
fi
150+
146151
./liveinstaller --base-dir $CONFIG_ROOT --imager /installer/imager --input $UNATTENDED_CONFIG_FILE --template-config $CONFIG_ROOT/attended_config.json \
147-
--build-dir $PWD --log-file=/installer/log.txt
152+
--build-dir $PWD --log-file=/installer/log.txt --repo-snapshot-time="$REPO_TIME"
148153
installerExitCode=$?
149154

150155
# Consume any buffered stdin to prevent it from being passed to any future programs,

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ lua-5.4.6-1.azl3.aarch64.rpm
211211
lua-libs-5.4.6-1.azl3.aarch64.rpm
212212
azurelinux-rpm-macros-3.0-7.azl3.noarch.rpm
213213
azurelinux-check-macros-3.0-7.azl3.noarch.rpm
214-
tdnf-3.5.8-2.azl3.aarch64.rpm
215-
tdnf-cli-libs-3.5.8-2.azl3.aarch64.rpm
216-
tdnf-devel-3.5.8-2.azl3.aarch64.rpm
217-
tdnf-plugin-repogpgcheck-3.5.8-2.azl3.aarch64.rpm
214+
tdnf-3.5.8-3.azl3.aarch64.rpm
215+
tdnf-cli-libs-3.5.8-3.azl3.aarch64.rpm
216+
tdnf-devel-3.5.8-3.azl3.aarch64.rpm
217+
tdnf-plugin-repogpgcheck-3.5.8-3.azl3.aarch64.rpm
218218
libassuan-2.5.6-1.azl3.aarch64.rpm
219219
libassuan-devel-2.5.6-1.azl3.aarch64.rpm
220220
libgpg-error-1.47-1.azl3.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ lua-5.4.6-1.azl3.x86_64.rpm
211211
lua-libs-5.4.6-1.azl3.x86_64.rpm
212212
azurelinux-rpm-macros-3.0-7.azl3.noarch.rpm
213213
azurelinux-check-macros-3.0-7.azl3.noarch.rpm
214-
tdnf-3.5.8-2.azl3.x86_64.rpm
215-
tdnf-cli-libs-3.5.8-2.azl3.x86_64.rpm
216-
tdnf-devel-3.5.8-2.azl3.x86_64.rpm
217-
tdnf-plugin-repogpgcheck-3.5.8-2.azl3.x86_64.rpm
214+
tdnf-3.5.8-3.azl3.x86_64.rpm
215+
tdnf-cli-libs-3.5.8-3.azl3.x86_64.rpm
216+
tdnf-devel-3.5.8-3.azl3.x86_64.rpm
217+
tdnf-plugin-repogpgcheck-3.5.8-3.azl3.x86_64.rpm
218218
libassuan-2.5.6-1.azl3.x86_64.rpm
219219
libassuan-devel-2.5.6-1.azl3.x86_64.rpm
220220
libgpg-error-1.47-1.azl3.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,14 @@ systemd-bootstrap-libs-250.3-17.azl3.aarch64.rpm
584584
systemd-bootstrap-rpm-macros-250.3-17.azl3.noarch.rpm
585585
tar-1.35-1.azl3.aarch64.rpm
586586
tar-debuginfo-1.35-1.azl3.aarch64.rpm
587-
tdnf-3.5.8-2.azl3.aarch64.rpm
588-
tdnf-autoupdate-3.5.8-2.azl3.aarch64.rpm
589-
tdnf-cli-libs-3.5.8-2.azl3.aarch64.rpm
590-
tdnf-debuginfo-3.5.8-2.azl3.aarch64.rpm
591-
tdnf-devel-3.5.8-2.azl3.aarch64.rpm
592-
tdnf-plugin-metalink-3.5.8-2.azl3.aarch64.rpm
593-
tdnf-plugin-repogpgcheck-3.5.8-2.azl3.aarch64.rpm
594-
tdnf-python-3.5.8-2.azl3.aarch64.rpm
587+
tdnf-3.5.8-3.azl3.aarch64.rpm
588+
tdnf-autoupdate-3.5.8-3.azl3.aarch64.rpm
589+
tdnf-cli-libs-3.5.8-3.azl3.aarch64.rpm
590+
tdnf-debuginfo-3.5.8-3.azl3.aarch64.rpm
591+
tdnf-devel-3.5.8-3.azl3.aarch64.rpm
592+
tdnf-plugin-metalink-3.5.8-3.azl3.aarch64.rpm
593+
tdnf-plugin-repogpgcheck-3.5.8-3.azl3.aarch64.rpm
594+
tdnf-python-3.5.8-3.azl3.aarch64.rpm
595595
texinfo-7.0.3-1.azl3.aarch64.rpm
596596
texinfo-debuginfo-7.0.3-1.azl3.aarch64.rpm
597597
unzip-6.0-20.azl3.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -590,14 +590,14 @@ systemd-bootstrap-libs-250.3-17.azl3.x86_64.rpm
590590
systemd-bootstrap-rpm-macros-250.3-17.azl3.noarch.rpm
591591
tar-1.35-1.azl3.x86_64.rpm
592592
tar-debuginfo-1.35-1.azl3.x86_64.rpm
593-
tdnf-3.5.8-2.azl3.x86_64.rpm
594-
tdnf-autoupdate-3.5.8-2.azl3.x86_64.rpm
595-
tdnf-cli-libs-3.5.8-2.azl3.x86_64.rpm
596-
tdnf-debuginfo-3.5.8-2.azl3.x86_64.rpm
597-
tdnf-devel-3.5.8-2.azl3.x86_64.rpm
598-
tdnf-plugin-metalink-3.5.8-2.azl3.x86_64.rpm
599-
tdnf-plugin-repogpgcheck-3.5.8-2.azl3.x86_64.rpm
600-
tdnf-python-3.5.8-2.azl3.x86_64.rpm
593+
tdnf-3.5.8-3.azl3.x86_64.rpm
594+
tdnf-autoupdate-3.5.8-3.azl3.x86_64.rpm
595+
tdnf-cli-libs-3.5.8-3.azl3.x86_64.rpm
596+
tdnf-debuginfo-3.5.8-3.azl3.x86_64.rpm
597+
tdnf-devel-3.5.8-3.azl3.x86_64.rpm
598+
tdnf-plugin-metalink-3.5.8-3.azl3.x86_64.rpm
599+
tdnf-plugin-repogpgcheck-3.5.8-3.azl3.x86_64.rpm
600+
tdnf-python-3.5.8-3.azl3.x86_64.rpm
601601
texinfo-7.0.3-1.azl3.x86_64.rpm
602602
texinfo-debuginfo-7.0.3-1.azl3.x86_64.rpm
603603
unzip-6.0-20.azl3.x86_64.rpm

toolkit/scripts/imggen.mk

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ clean-imagegen:
7575
$(SCRIPTS_DIR)/safeunmount.sh "$(IMAGEGEN_DIR)" && \
7676
rm -rf $(IMAGEGEN_DIR)
7777

78+
# We need to clear the rpm package cache if we have a snapshot time. The filenames will all be
79+
# the same, but the actual .rpm files may be fundamentally different.
80+
$(STATUS_FLAGS_DIR)/imagegen_cleanup.flag: $(depend_REPO_SNAPSHOT_TIME)
81+
@echo "REPO_SNAPSHOT_TIME has changed, sanitizing rpm cache"
82+
rm -rf $(local_and_external_rpm_cache)
83+
touch $@
84+
7885
##help:target:fetch-image-packages=Locate and download all packages required for an image build.
7986
fetch-image-packages: $(image_package_cache_summary)
8087

@@ -113,7 +120,11 @@ ifeq ($(USE_PREVIEW_REPO),y)
113120
imagepkgfetcher_extra_flags += --use-preview-repo
114121
endif
115122

116-
$(image_package_cache_summary): $(go-imagepkgfetcher) $(chroot_worker) $(toolchain_rpms) $(imggen_local_repo) $(depend_REPO_LIST) $(REPO_LIST) $(depend_CONFIG_FILE) $(CONFIG_FILE) $(validate-config) $(RPMS_DIR) $(imggen_rpms)
123+
ifneq ($(REPO_SNAPSHOT_TIME),)
124+
imagepkgfetcher_extra_flags += --repo-snapshot-time=$(REPO_SNAPSHOT_TIME)
125+
endif
126+
127+
$(image_package_cache_summary): $(go-imagepkgfetcher) $(chroot_worker) $(toolchain_rpms) $(imggen_local_repo) $(depend_REPO_LIST) $(REPO_LIST) $(depend_CONFIG_FILE) $(CONFIG_FILE) $(validate-config) $(RPMS_DIR) $(imggen_rpms) $(depend_REPO_SNAPSHOT_TIME) $(STATUS_FLAGS_DIR)/imagegen_cleanup.flag
117128
$(if $(CONFIG_FILE),,$(error Must set CONFIG_FILE=))
118129
$(go-imagepkgfetcher) \
119130
--input=$(CONFIG_FILE) \
@@ -146,7 +157,7 @@ $(imager_disk_output_dir): $(STATUS_FLAGS_DIR)/imager_disk_output.flag
146157
@touch $@
147158
@echo Finished updating $@
148159

149-
$(STATUS_FLAGS_DIR)/imager_disk_output.flag: $(go-imager) $(image_package_cache_summary) $(license_results_file_img) $(imggen_local_repo) $(depend_CONFIG_FILE) $(CONFIG_FILE) $(validate-config) $(assets_files)
160+
$(STATUS_FLAGS_DIR)/imager_disk_output.flag: $(go-imager) $(image_package_cache_summary) $(license_results_file_img) $(imggen_local_repo) $(depend_CONFIG_FILE) $(CONFIG_FILE) $(validate-config) $(assets_files) $(depend_REPO_SNAPSHOT_TIME)
150161
$(if $(CONFIG_FILE),,$(error Must set CONFIG_FILE=))
151162
mkdir -p $(imager_disk_output_dir) && \
152163
rm -rf $(imager_disk_output_dir)/* && \
@@ -159,6 +170,7 @@ $(STATUS_FLAGS_DIR)/imager_disk_output.flag: $(go-imager) $(image_package_cache_
159170
--log-color=$(LOG_COLOR) \
160171
--local-repo $(local_and_external_rpm_cache) \
161172
--tdnf-worker $(chroot_worker) \
173+
--repo-snapshot-time=$(REPO_SNAPSHOT_TIME) \
162174
--repo-file=$(imggen_local_repo) \
163175
--output-image-contents=$(image_package_manifest) \
164176
--assets $(assets_dir) \
@@ -198,7 +210,7 @@ image: $(imager_disk_output_dir) $(imager_disk_output_files) $(go-roast) $(depen
198210
$(if $(filter y,$(ENABLE_TRACE)),--enable-trace) \
199211
--timestamp-file=$(TIMESTAMP_DIR)/roast.jsonl
200212

201-
$(image_external_package_cache_summary): $(cached_file) $(go-imagepkgfetcher) $(chroot_worker) $(graph_file) $(depend_REPO_LIST) $(REPO_LIST) $(depend_CONFIG_FILE) $(CONFIG_FILE) $(validate-config)
213+
$(image_external_package_cache_summary): $(cached_file) $(go-imagepkgfetcher) $(chroot_worker) $(graph_file) $(depend_REPO_LIST) $(REPO_LIST) $(depend_CONFIG_FILE) $(CONFIG_FILE) $(validate-config) $(depend_REPO_SNAPSHOT_TIME) $(STATUS_FLAGS_DIR)/imagegen_cleanup.flag
202214
$(if $(CONFIG_FILE),,$(error Must set CONFIG_FILE=))
203215
$(go-imagepkgfetcher) \
204216
--input=$(CONFIG_FILE) \
@@ -229,7 +241,7 @@ $(image_external_package_cache_summary): $(cached_file) $(go-imagepkgfetcher) $(
229241

230242
# We need to ensure that initrd_img recursive build will never run concurrently with another build component, so add all ISO prereqs as
231243
# order-only-prerequisites to initrd_img
232-
iso_deps = $(go-isomaker) $(go-imager) $(depend_CONFIG_FILE) $(CONFIG_FILE) $(validate-config) $(image_package_cache_summary) $(license_results_file_img)
244+
iso_deps = $(go-isomaker) $(go-imager) $(depend_CONFIG_FILE) $(CONFIG_FILE) $(validate-config) $(image_package_cache_summary) $(license_results_file_img) $(depend_REPO_SNAPSHOT_TIME)
233245
# The initrd bundles these files into the image, we should rebuild it if they change
234246
initrd_bundled_files = $(go-liveinstaller) $(go-imager) $(assets_files) $(initrd_assets_files) $(imggen_local_repo)
235247

@@ -250,6 +262,7 @@ iso: $(initrd_img) $(iso_deps)
250262
--input $(CONFIG_FILE) \
251263
--release-version $(RELEASE_VERSION) \
252264
--resources $(RESOURCES_DIR) \
265+
--repo-snapshot-time=$(REPO_SNAPSHOT_TIME) \
253266
--iso-repo $(local_and_external_rpm_cache) \
254267
--log-level=$(LOG_LEVEL) \
255268
--log-file=$(LOGS_DIR)/imggen/isomaker.log \

toolkit/scripts/pkggen.mk

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ endif
123123

124124
# Convert the dependency information in the json file into a graph structure
125125
# We require all the toolchain RPMs to be available here to help resolve unfixable cyclic dependencies
126-
$(graph_file): $(specs_file) $(go-grapher) $(toolchain_rpms) $(TOOLCHAIN_MANIFEST) $(pkggen_local_repo) $(graphpkgfetcher_cloned_repo) $(chroot_worker) $(depend_REPO_LIST) $(REPO_LIST)
126+
$(graph_file): $(specs_file) $(go-grapher) $(toolchain_rpms) $(TOOLCHAIN_MANIFEST) $(pkggen_local_repo) $(graphpkgfetcher_cloned_repo) $(chroot_worker) $(depend_REPO_LIST) $(REPO_LIST) $(depend_REPO_SNAPSHOT_TIME)
127127
$(go-grapher) \
128128
--input $(specs_file) \
129129
$(logging_command) \
@@ -146,6 +146,7 @@ $(graph_file): $(specs_file) $(go-grapher) $(toolchain_rpms) $(TOOLCHAIN_MANIFES
146146
--tls-key=$(TLS_KEY) \
147147
--tmp-dir=$(grapher_working_dir) \
148148
--tdnf-worker=$(chroot_worker) \
149+
--repo-snapshot-time=$(REPO_SNAPSHOT_TIME) \
149150
$(foreach repo, $(pkggen_local_repo) $(graphpkgfetcher_cloned_repo) $(REPO_LIST), --repo-file=$(repo))
150151

151152
# We want to detect changes in the RPM cache, but we are not responsible for directly rebuilding any missing files.
@@ -192,12 +193,16 @@ graphpkgfetcher_extra_flags += $(if $(CONFIG_FILE),--base-dir="$(CONFIG_BASE_DIR
192193
$(cached_file): $(depend_CONFIG_FILE) $(depend_PACKAGE_BUILD_LIST) $(depend_PACKAGE_REBUILD_LIST) $(depend_PACKAGE_IGNORE_LIST) $(depend_TEST_RUN_LIST) $(depend_TEST_RERUN_LIST) $(depend_TEST_IGNORE_LIST)
193194
endif
194195

196+
ifneq ($(REPO_SNAPSHOT_TIME),)
197+
graphpkgfetcher_extra_flags += --repo-snapshot-time=$(REPO_SNAPSHOT_TIME)
198+
endif
199+
195200
ifeq ($(PRECACHE),y)
196201
# Use highly parallel downlader to fully hydrate the cache before trying to use the package manager to download packages
197202
$(cached_file): $(STATUS_FLAGS_DIR)/precache.flag
198203
endif
199204

200-
$(cached_file): $(graph_file) $(go-graphpkgfetcher) $(chroot_worker) $(pkggen_local_repo) $(depend_REPO_LIST) $(REPO_LIST) $(cached_remote_rpms) $(TOOLCHAIN_MANIFEST) $(toolchain_rpms) $(depend_EXTRA_BUILD_LAYERS)
205+
$(cached_file): $(graph_file) $(go-graphpkgfetcher) $(chroot_worker) $(pkggen_local_repo) $(depend_REPO_LIST) $(REPO_LIST) $(cached_remote_rpms) $(TOOLCHAIN_MANIFEST) $(toolchain_rpms) $(depend_EXTRA_BUILD_LAYERS) $(depend_REPO_SNAPSHOT_TIME) $(STATUS_FLAGS_DIR)/build_packages_cache_cleanup.flag
201206
mkdir -p $(remote_rpms_cache_dir) && \
202207
$(go-graphpkgfetcher) \
203208
--input=$(graph_file) \
@@ -260,6 +265,13 @@ clean-compress-rpms:
260265
clean-compress-srpms:
261266
rm -rf $(srpms_archive)
262267

268+
# We need to clear the rpm package cache if we have a snapshot time. The filenames will all be
269+
# the same, but the actual .rpm files may be fundamentally different.
270+
$(STATUS_FLAGS_DIR)/build_packages_cache_cleanup.flag: $(depend_REPO_SNAPSHOT_TIME)
271+
@echo "REPO_SNAPSHOT_TIME has changed, sanitizing rpm cache"
272+
rm -rf $(remote_rpms_cache_dir)
273+
touch $@
274+
263275
ifeq ($(REBUILD_PACKAGES),y)
264276
$(RPMS_DIR): $(STATUS_FLAGS_DIR)/build-rpms.flag
265277
@touch $@

0 commit comments

Comments
 (0)