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

Function checkDebianLibraryInstalled

buildtools/system_tools.go:126–145  ·  view source on GitHub ↗
(packageName string)

Source from the content-addressed store, hash-verified

124}
125
126func checkDebianLibraryInstalled(packageName string) (bool, error) {
127 // Use dpkg -l to check if the library is installed.
128 packageName = strings.TrimPrefix(packageName, "apt:")
129 executor := cmd.NewExecutor("", "dpkg", "-l", packageName)
130 out, err := executor.ExecuteOutput()
131 if err != nil {
132 // If not installed, dpkg -l will return exit status 1.
133 return false, nil
134 }
135
136 // Check if the library is installed.
137 lines := strings.SplitSeq(string(out), "\n")
138 for line := range lines {
139 if strings.HasPrefix(line, "ii") && strings.Contains(line, packageName) {
140 return true, nil
141 }
142 }
143
144 return false, nil
145}
146
147func checkRedHatLibraryInstalled(libraryName string) (bool, error) {
148 // Use rpm -q to check if the library is installed.

Callers 1

CheckSystemToolsFunction · 0.85

Calls 2

NewExecutorFunction · 0.92
ExecuteOutputMethod · 0.80

Tested by

no test coverage detected