Skip to content

Commit 791f476

Browse files
committed
fix: Ensure skip_if_unavailable=True during RPM package metadata refresh (dnf/tdnf)
1 parent 45e488f commit 791f476

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's important to ensure repo metadata is refreshed successfully to ensure correct package
281+
// versions are installed as intended by the user's repo configuration. It also has the benefit of failing slightly
282+
// faster when repos are misconfigured.
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)