mirror of
https://github.com/kairos-io/immucore.git
synced 2025-08-16 05:03:21 +00:00
Try to mount oem under livemedia (#110)
This commit is contained in:
parent
3c9586f1e7
commit
6bf656cd21
@ -260,5 +260,5 @@ func GetOemLabel() string {
|
|||||||
Log.Debug().Err(err).Msg("runtime")
|
Log.Debug().Err(err).Msg("runtime")
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return runtime.OEM.Label
|
return runtime.OEM.FilesystemLabel
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,13 @@ func (s *State) RegisterLiveMedia(g *herd.Graph) error {
|
|||||||
// Waits for sysroot to be there, just in case
|
// Waits for sysroot to be there, just in case
|
||||||
s.LogIfError(s.WaitForSysrootDagStep(g), "Waiting for sysroot")
|
s.LogIfError(s.WaitForSysrootDagStep(g), "Waiting for sysroot")
|
||||||
// Run rootfs
|
// Run rootfs
|
||||||
s.LogIfError(s.RootfsStageDagStep(g, cnst.OpSentinel, cnst.OpWaitForSysroot), "rootfs stage")
|
|
||||||
|
// Try to mount oem ONLY if we are on recovery squash
|
||||||
|
// The check to see if its enabled its on the DAG step itself
|
||||||
|
s.LogIfError(s.MountOemDagStep(g, cnst.OpWaitForSysroot), "oem mount")
|
||||||
|
|
||||||
|
s.LogIfError(s.RootfsStageDagStep(g, herd.WithDeps(cnst.OpSentinel, cnst.OpWaitForSysroot), herd.WithWeakDeps(cnst.OpMountOEM)), "rootfs stage")
|
||||||
// Run initramfs inside the /sysroot chroot!
|
// Run initramfs inside the /sysroot chroot!
|
||||||
s.LogIfError(s.InitramfsStageDagStep(g, herd.WithDeps(cnst.OpSentinel, cnst.OpWaitForSysroot, cnst.OpRootfsHook), herd.WithWeakDeps()), "initramfs stage")
|
s.LogIfError(s.InitramfsStageDagStep(g, herd.WithDeps(cnst.OpSentinel, cnst.OpWaitForSysroot, cnst.OpRootfsHook), herd.WithWeakDeps(cnst.OpMountOEM)), "initramfs stage")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ func (s *State) RegisterNormalBoot(g *herd.Graph) error {
|
|||||||
s.LogIfError(s.MountOemDagStep(g, cnst.OpMountRoot), "oem mount")
|
s.LogIfError(s.MountOemDagStep(g, cnst.OpMountRoot), "oem mount")
|
||||||
|
|
||||||
// Run yip stage rootfs. Requires root+oem+sentinel to be mounted
|
// Run yip stage rootfs. Requires root+oem+sentinel to be mounted
|
||||||
s.LogIfError(s.RootfsStageDagStep(g, cnst.OpMountRoot, cnst.OpMountOEM, cnst.OpSentinel), "running rootfs stage")
|
s.LogIfError(s.RootfsStageDagStep(g, herd.WithDeps(cnst.OpMountRoot, cnst.OpMountOEM, cnst.OpSentinel)), "running rootfs stage")
|
||||||
|
|
||||||
// Populate state bind mounts, overlay mounts, custom-mounts from /run/cos/cos-layout.env
|
// Populate state bind mounts, overlay mounts, custom-mounts from /run/cos/cos-layout.env
|
||||||
// Requires stage rootfs to have run, which usually creates the cos-layout.env file
|
// Requires stage rootfs to have run, which usually creates the cos-layout.env file
|
||||||
|
@ -102,13 +102,13 @@ func (s *State) MountRootDagStep(g *herd.Graph) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RootfsStageDagStep will add the rootfs stage.
|
// RootfsStageDagStep will add the rootfs stage.
|
||||||
func (s *State) RootfsStageDagStep(g *herd.Graph, deps ...string) error {
|
func (s *State) RootfsStageDagStep(g *herd.Graph, opts ...herd.OpOption) error {
|
||||||
return g.Add(cnst.OpRootfsHook, herd.WithDeps(deps...), herd.WithCallback(s.RunStageOp("rootfs")))
|
return g.Add(cnst.OpRootfsHook, append(opts, herd.WithCallback(s.RunStageOp("rootfs")))...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitramfsStageDagStep will add the rootfs stage.
|
// InitramfsStageDagStep will add the rootfs stage.
|
||||||
func (s *State) InitramfsStageDagStep(g *herd.Graph, deps herd.OpOption, weakDeps herd.OpOption) error {
|
func (s *State) InitramfsStageDagStep(g *herd.Graph, opts ...herd.OpOption) error {
|
||||||
return g.Add(cnst.OpInitramfsHook, deps, weakDeps, herd.WithCallback(s.RunStageOp("initramfs")))
|
return g.Add(cnst.OpInitramfsHook, append(opts, herd.WithCallback(s.RunStageOp("initramfs")))...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadEnvLayoutDagStep will add the stage to load from cos-layout.env and fill the proper CustomMounts, OverlayDirs and BindMounts.
|
// LoadEnvLayoutDagStep will add the stage to load from cos-layout.env and fill the proper CustomMounts, OverlayDirs and BindMounts.
|
||||||
@ -177,8 +177,14 @@ func (s *State) MountOemDagStep(g *herd.Graph, deps ...string) error {
|
|||||||
return g.Add(cnst.OpMountOEM,
|
return g.Add(cnst.OpMountOEM,
|
||||||
herd.WithDeps(deps...),
|
herd.WithDeps(deps...),
|
||||||
herd.EnableIf(func() bool {
|
herd.EnableIf(func() bool {
|
||||||
// Check if we can get the label. If we cant then we don't run this step
|
runtime, _ := state.NewRuntime()
|
||||||
return internalUtils.GetOemLabel() != ""
|
switch runtime.BootState {
|
||||||
|
// Don't run this on LiveCD/Netboot
|
||||||
|
case state.LiveCD:
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return internalUtils.GetOemLabel() != ""
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
herd.WithCallback(
|
herd.WithCallback(
|
||||||
s.MountOP(
|
s.MountOP(
|
||||||
|
@ -20,7 +20,7 @@ func (s *State) RegisterUKI(g *herd.Graph) error {
|
|||||||
s.LogIfError(s.UKIUdevDaemon(g), "udev")
|
s.LogIfError(s.UKIUdevDaemon(g), "udev")
|
||||||
|
|
||||||
// Run rootfs stage
|
// Run rootfs stage
|
||||||
s.LogIfError(s.RootfsStageDagStep(g, cnst.OpSentinel, cnst.OpUkiUdev), "uki rootfs")
|
s.LogIfError(s.RootfsStageDagStep(g, herd.WithDeps(cnst.OpSentinel, cnst.OpUkiUdev)), "uki rootfs")
|
||||||
|
|
||||||
// Remount root RO
|
// Remount root RO
|
||||||
s.LogIfError(s.UKIRemountRootRODagStep(g), "remount root")
|
s.LogIfError(s.UKIRemountRootRODagStep(g), "remount root")
|
||||||
@ -43,7 +43,7 @@ func (s *State) RegisterUKI(g *herd.Graph) error {
|
|||||||
s.LogIfError(s.MountCustomBindsDagStep(g), "custom binds mount")
|
s.LogIfError(s.MountCustomBindsDagStep(g), "custom binds mount")
|
||||||
|
|
||||||
// run initramfs stage
|
// run initramfs stage
|
||||||
s.LogIfError(s.InitramfsStageDagStep(g, herd.WithDeps(cnst.OpMountBind), herd.WithWeakDeps()), "uki initramfs")
|
s.LogIfError(s.InitramfsStageDagStep(g, herd.WithDeps(cnst.OpMountBind)), "uki initramfs")
|
||||||
|
|
||||||
s.LogIfError(g.Add(cnst.OpWriteFstab,
|
s.LogIfError(g.Add(cnst.OpWriteFstab,
|
||||||
herd.WithDeps(cnst.OpLoadConfig, cnst.OpCustomMounts, cnst.OpMountBind, cnst.OpOverlayMount),
|
herd.WithDeps(cnst.OpLoadConfig, cnst.OpCustomMounts, cnst.OpMountBind, cnst.OpOverlayMount),
|
||||||
|
@ -68,17 +68,19 @@ var _ = Describe("mounting immutable setup", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
func checkLiveCDDag(dag [][]herd.GraphEntry, actualDag string) {
|
func checkLiveCDDag(dag [][]herd.GraphEntry, actualDag string) {
|
||||||
Expect(len(dag)).To(Equal(4), actualDag)
|
Expect(len(dag)).To(Equal(5), actualDag)
|
||||||
Expect(len(dag[0])).To(Equal(1), actualDag)
|
Expect(len(dag[0])).To(Equal(1), actualDag)
|
||||||
Expect(len(dag[1])).To(Equal(2), actualDag)
|
Expect(len(dag[1])).To(Equal(2), actualDag)
|
||||||
Expect(len(dag[2])).To(Equal(1), actualDag)
|
Expect(len(dag[2])).To(Equal(1), actualDag)
|
||||||
Expect(len(dag[3])).To(Equal(1), actualDag)
|
Expect(len(dag[3])).To(Equal(1), actualDag)
|
||||||
|
Expect(len(dag[4])).To(Equal(1), actualDag)
|
||||||
|
|
||||||
Expect(dag[0][0].Name).To(Equal("init"))
|
Expect(dag[0][0].Name).To(Equal("init"))
|
||||||
Expect(dag[1][0].Name).To(Or(Equal(cnst.OpSentinel), Equal(cnst.OpWaitForSysroot)), actualDag)
|
Expect(dag[1][0].Name).To(Or(Equal(cnst.OpSentinel), Equal(cnst.OpWaitForSysroot)), actualDag)
|
||||||
Expect(dag[1][1].Name).To(Or(Equal(cnst.OpSentinel), Equal(cnst.OpWaitForSysroot)), actualDag)
|
Expect(dag[1][1].Name).To(Or(Equal(cnst.OpSentinel), Equal(cnst.OpWaitForSysroot)), actualDag)
|
||||||
Expect(dag[2][0].Name).To(Equal(cnst.OpRootfsHook), actualDag)
|
Expect(dag[2][0].Name).To(Equal(cnst.OpMountOEM), actualDag)
|
||||||
Expect(dag[3][0].Name).To(Equal(cnst.OpInitramfsHook), actualDag)
|
Expect(dag[3][0].Name).To(Equal(cnst.OpRootfsHook), actualDag)
|
||||||
|
Expect(dag[4][0].Name).To(Equal(cnst.OpInitramfsHook), actualDag)
|
||||||
|
|
||||||
}
|
}
|
||||||
func checkDag(dag [][]herd.GraphEntry, actualDag string) {
|
func checkDag(dag [][]herd.GraphEntry, actualDag string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user