mirror of
https://github.com/kairos-io/immucore.git
synced 2025-08-31 06:10:35 +00:00
Fixes recovery
- Add isRecovery to state - Get the TargetImage from cmdline - Add isrecovery to conditions Signed-off-by: Itxaka <itxaka@spectrocloud.com>
This commit is contained in:
@@ -31,13 +31,16 @@ Sends a generic event payload with the configuration found in the scanned direct
|
||||
},
|
||||
Action: func(c *cli.Context) (err error) {
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Logger()
|
||||
img := utils.ReadCMDLineArg("cos-img/filename=")
|
||||
log.Debug().Strs("TargetImage", img).Msg("Target image")
|
||||
g := herd.DAG()
|
||||
s := &mount.State{
|
||||
Logger: log.Logger,
|
||||
Rootdir: utils.GetRootDir(),
|
||||
MountRoot: true,
|
||||
TargetLabel: utils.BootStateToLabel(),
|
||||
TargetImage: utils.BootStateToImage(),
|
||||
TargetImage: img[0],
|
||||
IsRecovery: utils.IsRecovery(),
|
||||
}
|
||||
|
||||
err = s.Register(g)
|
||||
|
@@ -32,20 +32,16 @@ func BootStateToLabel() string {
|
||||
}
|
||||
}
|
||||
|
||||
func BootStateToImage() string {
|
||||
func IsRecovery() bool {
|
||||
runtime, err := state.NewRuntime()
|
||||
if err != nil {
|
||||
return ""
|
||||
return false
|
||||
}
|
||||
switch runtime.BootState {
|
||||
case "active_boot":
|
||||
return "/cOS/active.img"
|
||||
case "passive_boot":
|
||||
return "/cOS/passive.img"
|
||||
case "recovery_boot":
|
||||
return "/cOS/recovery.img"
|
||||
return true
|
||||
default:
|
||||
return ""
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -35,7 +35,8 @@ type State struct {
|
||||
StateDir string // e.g. "/usr/local/.state"
|
||||
MountRoot bool // e.g. if true, it tries to find the image to loopback mount
|
||||
|
||||
fstabs []*fstab.Mount
|
||||
fstabs []*fstab.Mount
|
||||
IsRecovery bool // if its recovery it needs different stuff
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -235,7 +236,7 @@ func (s *State) Register(g *herd.Graph) error {
|
||||
stateName := runtime.State.Name
|
||||
stateFs := runtime.State.Type
|
||||
// Recovery is a different partition
|
||||
if s.TargetLabel == "COS_RECOVERY" {
|
||||
if s.IsRecovery {
|
||||
stateName = runtime.Recovery.Name
|
||||
stateFs = runtime.Recovery.Type
|
||||
}
|
||||
@@ -282,7 +283,7 @@ func (s *State) Register(g *herd.Graph) error {
|
||||
|
||||
// depending on /run/cos-layout.env
|
||||
// This is building the mountRoot dependendency if it was enabled
|
||||
mountRootCondition := herd.ConditionalOption(func() bool { return s.MountRoot }, herd.WithDeps(opMountRoot))
|
||||
mountRootCondition := herd.ConditionalOption(func() bool { return s.MountRoot && !s.IsRecovery }, herd.WithDeps(opMountRoot))
|
||||
s.Logger.Debug().Bool("mountRootCondition", s.MountRoot).Msg("condition")
|
||||
|
||||
// TODO: this needs to be run after sysroot so we can link to /sysroot/system/oem and after /oem mounted
|
||||
@@ -369,7 +370,7 @@ func (s *State) Register(g *herd.Graph) error {
|
||||
}
|
||||
}
|
||||
|
||||
overlayCondition := herd.ConditionalOption(func() bool { return rootFSType(s.Rootdir) != "overlay" }, herd.WithDeps(opMountBaseOverlay))
|
||||
overlayCondition := herd.ConditionalOption(func() bool { return rootFSType(s.Rootdir) != "overlay" && !s.IsRecovery }, herd.WithDeps(opMountBaseOverlay))
|
||||
s.Logger.Debug().Bool("overlaycondition", rootFSType(s.Rootdir) != "overlay").Msg("condition")
|
||||
// TODO: Add fsck
|
||||
// mount overlay
|
||||
|
Reference in New Issue
Block a user