diff --git a/Earthfile b/Earthfile index 3b30dce..f99182d 100644 --- a/Earthfile +++ b/Earthfile @@ -62,7 +62,7 @@ build-immucore: COPY main.go /work COPY --dir internal /work COPY --dir pkg /work - RUN CGO_ENABLED=0 go build -o immucore -ldflags "-X main.Version=$VERSION" + RUN CGO_ENABLED=0 go build -o immucore -ldflags "-X internal/version.Version=$VERSION" SAVE ARTIFACT /work/immucore AS LOCAL build/immucore-$VERSION build-dracut: diff --git a/dracut/28immucore/generator.sh b/dracut/28immucore/generator.sh index 2ea753d..12c2cb7 100755 --- a/dracut/28immucore/generator.sh +++ b/dracut/28immucore/generator.sh @@ -29,8 +29,8 @@ oem_label=$(getarg rd.cos.oemlabel=) echo "After=sysroot.mount" echo "[Service]" echo "Type=oneshot" - echo "RemainAfterExit=no" - echo "ExecStart=/usr/bin/immucore start" + echo "RemainAfterExit=yes" + echo "ExecStart=/usr/bin/immucore start --dry-run" } > "$GENERATOR_DIR"/immucore.service diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..7c64f3a --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,34 @@ +package version + +import "runtime" + +var ( + version = "v0.0.1" + // gitCommit is the git sha1 + gitCommit = "" +) + +func GetVersion() string { + return version +} + +// BuildInfo describes the compiled time information. +type BuildInfo struct { + // Version is the current semver. + Version string `json:"version,omitempty"` + // GitCommit is the git sha1. + GitCommit string `json:"git_commit,omitempty"` + // GoVersion is the version of the Go compiler used. + GoVersion string `json:"go_version,omitempty"` +} + +// Get returns build info +func Get() BuildInfo { + v := BuildInfo{ + Version: GetVersion(), + GitCommit: gitCommit, + GoVersion: runtime.Version(), + } + + return v +} diff --git a/main.go b/main.go index 72ad5b9..3ca0d47 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/kairos-io/immucore/internal/version" "os" "github.com/kairos-io/immucore/internal/cmd" @@ -23,6 +24,8 @@ func main() { Commands: cmd.Commands, } + + fmt.Println(version.Get()) err := app.Run(os.Args) if err != nil { diff --git a/pkg/mount/mount.go b/pkg/mount/mount.go index 7b0f312..336d91a 100644 --- a/pkg/mount/mount.go +++ b/pkg/mount/mount.go @@ -203,8 +203,11 @@ func (s *State) Register(g *herd.Graph) error { func(ctx context.Context) error { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Caller().Logger() cmd := fmt.Sprintf("losetup --show -f %s", s.path("/run/initramfs/cos-state", s.TargetImage)) - log.Logger.Debug().Str("targetImage", s.TargetImage).Str("fullcmd", cmd).Msg("Mounting image") + log.Logger.Debug().Str("targetImage", s.TargetImage).Str("path", s.Rootdir).Str("fullcmd", cmd).Msg("Mounting image") _, err := utils.SH(cmd) + if err != nil { + log.Logger.Debug().Err(err).Msg("") + } return err }, )) @@ -238,14 +241,14 @@ func (s *State) Register(g *herd.Graph) error { s.MountOP( fmt.Sprintf("/dev/disk/by-label/%s", s.TargetLabel), s.Rootdir, - "ext2", // are images always ext2? + "ext4", // are images always ext2? []string{ "ro", // or rw "suid", "dev", "exec", "auto", - "nouser", + //"nouser", "async", }, 60*time.Second), ),