🎨 大部分的 make 指令

This commit is contained in:
zhaoyupeng
2025-11-24 18:37:44 +08:00
commit 27fa38aef0
38 changed files with 4356 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package maker
import (
"context"
"fmt"
"os/exec"
)
func (m *maker) DependencyCheck(ctx context.Context) error {
// 1. test wget command
if err := checkCommand(ctx, "wget", "--version"); err != nil {
return fmt.Errorf("wget 命令未找到: %w", err)
}
// 2. test tar command
if err := checkCommand(ctx, "tar", "--version"); err != nil {
return fmt.Errorf("tar 命令未找到: %w", err)
}
// 3. test docker command
if err := checkCommand(ctx, "docker", "info"); err != nil {
return fmt.Errorf("docker 命令未找到: %w", err)
}
return nil
}
// checkCommand checks if a command is available by running it with the specified args
func checkCommand(ctx context.Context, name string, args ...string) error {
cmd := exec.CommandContext(ctx, name, args...)
if err := cmd.Run(); err != nil {
return err
}
return nil
}