Skip to content

Commit 79c6b58

Browse files
authored
fix: Ensure skip_if_unavailable=False for dnf/tdnf (#730)
Azure Linux 4.0 defaults to skip_if_unavailable=True, a change in behavior from Azure Linux 3.0 and likely an inheritance from Fedora upstream. It is important to ensure metadata is refreshed successfully to ensure correctness of package install operations and to catch any typos in user-provided repository configuration. Otherwise, the wrong package versions might be silently installed.
1 parent aacff1f commit 79c6b58

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

toolkit/tools/pkg/imagecustomizerlib/customizepackages_rpm.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,15 @@ func refreshRpmPackageMetadata(ctx context.Context, imageChroot *safechroot.Chro
275275
_, span := startRefreshPackageMetadataSpan(ctx)
276276
defer span.End()
277277

278-
args := []string{pmHandler.getVerbosityOption(), "check-update", "--refresh", "--assumeyes"}
278+
// --setopt=skip_if_unavailable=False ensures failures to fetch repo metadata are fatal. TDNF already does this by
279+
// default, but DNF on some distros (e.g. Azure Linux 4.0) defaults to skip_if_unavailable=True, so we set it
280+
// explicitly for both. It is important to ensure metadata is refreshed successfully to ensure correctness of
281+
// package install operations and to catch any typos in user-provided repository configuration. Otherwise, the wrong
282+
// package versions might be silently installed.
283+
args := []string{
284+
pmHandler.getVerbosityOption(), "check-update", "--refresh", "--assumeyes",
285+
"--setopt=skip_if_unavailable=False",
286+
}
279287

280288
args = append(args, "--setopt=reposdir="+rpmsMountParentDirInChroot)
281289

0 commit comments

Comments
 (0)