From 0b27ef8e51246d6d1ff4998b313e43a33648062d Mon Sep 17 00:00:00 2001 From: AtomicFS Date: Wed, 15 Jan 2025 17:24:09 +0100 Subject: [PATCH] fix(cmd): passing coreboot version into container Signed-off-by: AtomicFS --- cmd/firmware-action/filesystem/git.go | 8 +++----- cmd/firmware-action/recipes/coreboot.go | 11 +++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/cmd/firmware-action/filesystem/git.go b/cmd/firmware-action/filesystem/git.go index d8a99e4f..81dd1361 100644 --- a/cmd/firmware-action/filesystem/git.go +++ b/cmd/firmware-action/filesystem/git.go @@ -8,7 +8,6 @@ import ( "log/slog" "os" "os/exec" - "path/filepath" "regexp" "strings" ) @@ -24,12 +23,11 @@ func gitRun(subdir string, command []string) (string, error) { } // Change current working directory into the repository / submodule - subdirPath := filepath.Join(pwd, subdir) defer os.Chdir(pwd) // nolint:errcheck - err = os.Chdir(subdirPath) + err = os.Chdir(subdir) if err != nil { slog.Error( - fmt.Sprintf("Failed to change current working directory to '%s'", subdirPath), + fmt.Sprintf("Failed to change current working directory to '%s'", subdir), slog.Any("error", err), ) return "", err @@ -40,7 +38,7 @@ func gitRun(subdir string, command []string) (string, error) { describe, err := cmd.CombinedOutput() if err != nil { slog.Error( - fmt.Sprintf("Failed to run git command in '%s'", subdirPath), + fmt.Sprintf("Failed to run git command in '%s'", subdir), slog.Any("error", err), ) return "", err diff --git a/cmd/firmware-action/recipes/coreboot.go b/cmd/firmware-action/recipes/coreboot.go index 1c22355c..89474b88 100644 --- a/cmd/firmware-action/recipes/coreboot.go +++ b/cmd/firmware-action/recipes/coreboot.go @@ -437,13 +437,8 @@ func corebootPassEnvVars(repoPath string) (map[string]string, error) { } // If .coreboot-version file exists in coreboot directory, do nothing - pwd, err := os.Getwd() - if err != nil { - return nil, err - } - - corebootVersionPath := filepath.Join(pwd, repoPath, ".coreboot-version") - err = filesystem.CheckFileExists(corebootVersionPath) + corebootVersionPath := filepath.Join(repoPath, ".coreboot-version") + err := filesystem.CheckFileExists(corebootVersionPath) if errors.Is(err, os.ErrExist) { return envVariables, nil } @@ -452,7 +447,7 @@ func corebootPassEnvVars(repoPath string) (map[string]string, error) { // coreboot build system would at this point attempt to run git describe, which would fail // Define a new environment variable KERNELVERSION with value from git describe // and then pass it into the container - err = filesystem.CheckFileExists(filepath.Join(pwd, repoPath)) + err = filesystem.CheckFileExists(repoPath) if errors.Is(err, filesystem.ErrPathIsDirectory) { describe, err := filesystem.GitDescribeCoreboot(repoPath) if err != nil {