MCPcopy Index your code
hub / github.com/celer-pkg/celer / CheckSystemTools

Function CheckSystemTools

buildtools/system_tools.go:12–105  ·  view source on GitHub ↗

CheckSystemTools checks if the system tools are installed.

(packageNames []string)

Source from the content-addressed store, hash-verified

10
11// CheckSystemTools checks if the system tools are installed.
12func CheckSystemTools(packageNames []string) error {
13 osType, err := getOSType()
14 if err != nil {
15 return err
16 }
17
18 // Check if python3-pip is installed when python3 packages are needed.
19 if slices.ContainsFunc(packageNames, func(item string) bool {
20 return strings.HasPrefix(item, "python3:")
21 }) {
22 packageNames = append(packageNames, "apt:python3-pip")
23 }
24
25 var missedTools []string
26 for _, packageName := range packageNames {
27 packageName = strings.TrimSpace(packageName)
28 if packageName == "" ||
29 strings.HasPrefix(packageName, "python3") ||
30 strings.HasPrefix(packageName, "msys2") ||
31 strings.Contains(packageName, "@") {
32 continue
33 }
34
35 // Skip packages that don't match the current distro's prefix.
36 switch osType {
37 case "debian", "ubuntu":
38 if strings.HasPrefix(packageName, "yum:") {
39 continue
40 }
41 case "centos", "fedora", "rhel":
42 if strings.HasPrefix(packageName, "apt:") {
43 continue
44 }
45 }
46
47 var (
48 installed bool
49 err error
50 )
51
52 // Check installed based on OS type.
53 switch osType {
54 case "debian", "ubuntu":
55 installed, err = checkDebianLibraryInstalled(packageName)
56 case "centos", "fedora", "rhel":
57 installed, err = checkRedHatLibraryInstalled(packageName)
58 default:
59 return fmt.Errorf("unsupported package manager prefix in package name: %s", packageName)
60 }
61 if err != nil {
62 return err
63 }
64
65 if !installed {
66 switch osType {
67 case "debian", "ubuntu":
68 packageName = strings.TrimPrefix(packageName, "apt:")
69 case "centos", "fedora", "rhel":

Callers 3

checkServerToolsFunction · 0.92
checkClientToolsFunction · 0.92
CheckToolsFunction · 0.85

Calls 4

getOSTypeFunction · 0.85
SprintfMethod · 0.80

Tested by

no test coverage detected