From 2aee7ab5a006e7b308decbeda826b62cc9db41c9 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 14 Feb 2023 09:48:44 +0100 Subject: [PATCH] Symlink /sysroot/oem to /oem so we can run rootfs stage Looks like we need to have the oem partition loaded for some cases, and during rootfs we should pick it up. Currently we only mount it under /sysroot/oem. IIRC in cos-immutable-rootfs it was mounted under /oem directly, the rootfs stage service run and then when cos-layout was launched it made sure to unmount /oem so it could mount it under /sysroot/oem In our case its a bit more complicated, we may need to mount it under /oem before the rootfs run, then unmount it and mount it in the proper place. Im hoping we can get away with just creating the symlink Signed-off-by: Itxaka --- internal/cmd/commands.go | 6 +++++- pkg/mount/mount.go | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/cmd/commands.go b/internal/cmd/commands.go index 31b9895..ba7fa7c 100644 --- a/internal/cmd/commands.go +++ b/internal/cmd/commands.go @@ -59,7 +59,11 @@ Sends a generic event payload with the configuration found in the scanned direct img := utils.ReadCMDLineArg("cos-img/filename=") if len(img) == 0 { - log.Logger.Fatal().Msg("Could not get the image name from cmdline (i.e. cos-img/filename=/cOS/active.img)") + if c.Bool("dry-run") { + img = []string{"fake"} + } else { + log.Logger.Fatal().Msg("Could not get the image name from cmdline (i.e. cos-img/filename=/cOS/active.img)") + } } log.Debug().Strs("TargetImage", img).Msg("Target image") g := herd.DAG() diff --git a/pkg/mount/mount.go b/pkg/mount/mount.go index a10989e..da91345 100644 --- a/pkg/mount/mount.go +++ b/pkg/mount/mount.go @@ -92,6 +92,13 @@ func (s *State) RunStageOp(stage string) func(context.Context) error { return err } } + if _, err := os.Stat("/oem"); os.IsNotExist(err) { + err = os.Symlink("/sysroot/oem", "/oem") + if err != nil { + s.Logger.Err(err).Msg("creating symlink") + return err + } + } } cmd := fmt.Sprintf("elemental run-stage %s", stage)