mirror of
https://github.com/kairos-io/immucore.git
synced 2025-09-02 15:14:27 +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) {
|
Action: func(c *cli.Context) (err error) {
|
||||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Logger()
|
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()
|
g := herd.DAG()
|
||||||
s := &mount.State{
|
s := &mount.State{
|
||||||
Logger: log.Logger,
|
Logger: log.Logger,
|
||||||
Rootdir: utils.GetRootDir(),
|
Rootdir: utils.GetRootDir(),
|
||||||
MountRoot: true,
|
MountRoot: true,
|
||||||
TargetLabel: utils.BootStateToLabel(),
|
TargetLabel: utils.BootStateToLabel(),
|
||||||
TargetImage: utils.BootStateToImage(),
|
TargetImage: img[0],
|
||||||
|
IsRecovery: utils.IsRecovery(),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.Register(g)
|
err = s.Register(g)
|
||||||
|
@@ -32,20 +32,16 @@ func BootStateToLabel() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BootStateToImage() string {
|
func IsRecovery() bool {
|
||||||
runtime, err := state.NewRuntime()
|
runtime, err := state.NewRuntime()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return false
|
||||||
}
|
}
|
||||||
switch runtime.BootState {
|
switch runtime.BootState {
|
||||||
case "active_boot":
|
|
||||||
return "/cOS/active.img"
|
|
||||||
case "passive_boot":
|
|
||||||
return "/cOS/passive.img"
|
|
||||||
case "recovery_boot":
|
case "recovery_boot":
|
||||||
return "/cOS/recovery.img"
|
return true
|
||||||
default:
|
default:
|
||||||
return ""
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@ type State struct {
|
|||||||
MountRoot bool // e.g. if true, it tries to find the image to loopback mount
|
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 (
|
const (
|
||||||
@@ -235,7 +236,7 @@ func (s *State) Register(g *herd.Graph) error {
|
|||||||
stateName := runtime.State.Name
|
stateName := runtime.State.Name
|
||||||
stateFs := runtime.State.Type
|
stateFs := runtime.State.Type
|
||||||
// Recovery is a different partition
|
// Recovery is a different partition
|
||||||
if s.TargetLabel == "COS_RECOVERY" {
|
if s.IsRecovery {
|
||||||
stateName = runtime.Recovery.Name
|
stateName = runtime.Recovery.Name
|
||||||
stateFs = runtime.Recovery.Type
|
stateFs = runtime.Recovery.Type
|
||||||
}
|
}
|
||||||
@@ -282,7 +283,7 @@ func (s *State) Register(g *herd.Graph) error {
|
|||||||
|
|
||||||
// depending on /run/cos-layout.env
|
// depending on /run/cos-layout.env
|
||||||
// This is building the mountRoot dependendency if it was enabled
|
// 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")
|
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
|
// 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")
|
s.Logger.Debug().Bool("overlaycondition", rootFSType(s.Rootdir) != "overlay").Msg("condition")
|
||||||
// TODO: Add fsck
|
// TODO: Add fsck
|
||||||
// mount overlay
|
// mount overlay
|
||||||
|
Reference in New Issue
Block a user