(packageName string)
| 124 | } |
| 125 | |
| 126 | func 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 | |
| 147 | func checkRedHatLibraryInstalled(libraryName string) (bool, error) { |
| 148 | // Use rpm -q to check if the library is installed. |
no test coverage detected