From 82c614f2d90c960d9ad2a200003a0a9dd4fc3689 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Fri, 6 Dec 2024 15:59:39 -0500 Subject: [PATCH] engine: resources: Workaround broken debian package when building images --- engine/resources/virt_builder.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/engine/resources/virt_builder.go b/engine/resources/virt_builder.go index 9c64ca08..8adcc576 100644 --- a/engine/resources/virt_builder.go +++ b/engine/resources/virt_builder.go @@ -151,6 +151,10 @@ type VirtBuilderRes struct { // in these logs in cleartext! LogOutput bool `lang:"log_output" yaml:"log_output"` + // Tweaks adds some random tweaks to work around common bugs. This + // defaults to true. + Tweaks bool `lang:"tweaks" yaml:"tweaks"` + varDir string } @@ -251,6 +255,7 @@ func (obj *VirtBuilderRes) Default() engine.Res { RootSSHInject: true, Bootstrap: true, LogOutput: true, + Tweaks: true, } } @@ -445,10 +450,20 @@ func (obj *VirtBuilderRes) CheckApply(ctx context.Context, apply bool) (bool, er cmdArgs = append(cmdArgs, args...) } + // XXX: Tweak for debian grub-pc bug: + // https://www.mail-archive.com/guestfs@lists.libguestfs.org/msg00062.html + if obj.Tweaks && obj.Update && obj.getDistro() == "debian" { + args := []string{"--run-command", "apt-mark hold grub-pc"} + cmdArgs = append(cmdArgs, args...) + } if obj.Update { arg := "--update" cmdArgs = append(cmdArgs, arg) } + if obj.Tweaks && obj.Update && obj.getDistro() == "debian" { + args := []string{"--firstboot-command", "apt-mark unhold grub-pc"} + cmdArgs = append(cmdArgs, args...) + } if obj.SelinuxRelabel { arg := "--selinux-relabel" @@ -622,6 +637,9 @@ func (obj *VirtBuilderRes) Cmp(r engine.Res) error { if obj.LogOutput != res.LogOutput { return fmt.Errorf("the LogOutput value differs") } + if obj.Tweaks != res.Tweaks { + return fmt.Errorf("the Tweaks value differs") + } return nil }