Skip to content

Commit

Permalink
fix(cmd): passing coreboot version into container
Browse files Browse the repository at this point in the history
Signed-off-by: AtomicFS <[email protected]>
  • Loading branch information
AtomicFS committed Jan 22, 2025
1 parent 1ccd2d4 commit 38c7b20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
8 changes: 3 additions & 5 deletions cmd/firmware-action/filesystem/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"log/slog"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
)
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 3 additions & 8 deletions cmd/firmware-action/recipes/coreboot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down

0 comments on commit 38c7b20

Please sign in to comment.