-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jason Hall <jason@chainguard.dev>
- Loading branch information
1 parent
9f518af
commit 7231a6d
Showing
4 changed files
with
47 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package vscode | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/loft-sh/devpod/pkg/command" | ||
"github.com/loft-sh/log" | ||
) | ||
|
||
// InstallAPKRequirements installs the requirements using apk. | ||
// | ||
// This is used by Alpine- and Wolfi-based images. | ||
func InstallAPKRequirements(logger log.Logger) { | ||
if !command.Exists("apk") { | ||
return | ||
} | ||
|
||
dependencies := []string{"build-base"} | ||
if all, err := os.ReadFile("/etc/os-release"); err != nil { | ||
logger.Errorf("Error reading /etc/os-release: %v", err) | ||
return | ||
} else if !bytes.Contains(all, []byte("ID=alpine")) { | ||
// Alpine needs gcompat for compatibility with musl. | ||
// Wolfi-based distros don't need this, and Wolfi doesn't have it. | ||
dependencies = append(dependencies, "gcompat") | ||
} | ||
logger.Debugf("Install apk requirements...") | ||
if !command.Exists("git") { | ||
dependencies = append(dependencies, "git") | ||
} | ||
if !command.Exists("bash") { | ||
dependencies = append(dependencies, "bash") | ||
} | ||
if !command.Exists("curl") { | ||
dependencies = append(dependencies, "curl") | ||
} | ||
|
||
out, err := exec.Command("sh", "-c", "apk update && apk add "+strings.Join(dependencies, " ")).CombinedOutput() | ||
if err != nil { | ||
logger.Errorf("Error updating apk dependencies: %v", command.WrapCommandError(out, err)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters