From 63ccbc7124afabe932e1cb399dcb0b176701c535 Mon Sep 17 00:00:00 2001 From: Tau Date: Fri, 12 Jul 2024 14:10:15 +0200 Subject: [PATCH] saves configuration to new root after upgrade --- core/system.go | 8 +++++++- settings/config.go | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/system.go b/core/system.go index 73d2cdf0..2168651a 100644 --- a/core/system.go +++ b/core/system.go @@ -408,7 +408,7 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation) error { return pkgM.ClearUnstagedPackages() }, nil, 10, &goodies.NoErrorHandler{}, false) - // Stage 5: Write abimage.abr.new to future/ + // Stage 5: Write abimage.abr.new and config to future/ // ------------------------------------------------ PrintVerboseSimple("[Stage 5] -------- ABSystemRunOperation") @@ -430,6 +430,12 @@ func (s *ABSystem) RunOperation(operation ABSystemOperation) error { return err } + err = settings.WriteConfigToFile(filepath.Join(systemNew, "/usr/share/abroot/abroot.json")) + if err != nil { + PrintVerboseErr("ABSystem.RunOperation", 5.25, err) + return err + } + // from this point on, it is not possible to stop the upgrade // so we remove the stage file. Note that interrupting the upgrade // from this point on will not leave the system in an inconsistent diff --git a/settings/config.go b/settings/config.go index 909aa917..10ea8f67 100644 --- a/settings/config.go +++ b/settings/config.go @@ -130,3 +130,8 @@ func init() { Cnf.FullImageName = fmt.Sprintf("%s/%s:%s", Cnf.Registry, Cnf.Name, Cnf.Tag) } + +// WriteConfigToFile writes the current configuration to a file +func WriteConfigToFile(file string) error { + return viper.WriteConfigAs(file) +}