use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails in project synopsys-detect by blackducksoftware.
the class RpmPackageManagerTest method testValidWithEpoch.
@Test
public void testValidWithEpoch() throws ExecutableRunnerException, NotOwnedByAnyPkgException {
StringBuilder sb = new StringBuilder();
sb.append("{ epoch: \"9\", name: \"boost-devel\", version: \"1.53.0-27.el7\", arch: \"x86_64\" }\n");
String pkgMgrOwnedByOutput = sb.toString();
RpmPackageManagerResolver pkgMgr = new RpmPackageManagerResolver(new Gson());
List<PackageDetails> pkgs = pkgMgr.resolvePackages(new ClangPackageManagerInfoFactory().rpm(), null, null, pkgMgrOwnedByOutput);
assertEquals(1, pkgs.size());
assertEquals("boost-devel", pkgs.get(0).getPackageName());
assertEquals("9:1.53.0-27.el7", pkgs.get(0).getPackageVersion());
assertEquals("x86_64", pkgs.get(0).getPackageArch());
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails in project synopsys-detect by blackducksoftware.
the class RpmPackageManagerTest method testParseSingleVariant.
@Test
public void testParseSingleVariant() throws NotOwnedByAnyPkgException {
RpmPackageManagerResolver resolver = new RpmPackageManagerResolver(new Gson());
final String queryPackageOutputLine = "{ epoch: \"(none)\", name: \"glibc-headers\", version: \"2.28-101.el8\", arch: \"x86_64\" }";
Optional<PackageDetails> pkg = resolver.generatePackageFromQueryOutputLine(queryPackageOutputLine);
assertTrue(pkg.isPresent());
assertEquals("glibc-headers", pkg.get().getPackageName());
assertEquals("2.28-101.el8", pkg.get().getPackageVersion());
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails in project synopsys-detect by blackducksoftware.
the class RpmPackageManagerTest method testValidNoEpoch.
@Test
public void testValidNoEpoch() throws ExecutableRunnerException, NotOwnedByAnyPkgException {
StringBuilder sb = new StringBuilder();
sb.append("{ epoch: \"(none)\", name: \"boost-devel\", version: \"1.53.0-27.el7\", arch: \"x86_64\" }\n");
String pkgMgrOwnedByOutput = sb.toString();
RpmPackageManagerResolver pkgMgr = new RpmPackageManagerResolver(new Gson());
List<PackageDetails> pkgs = pkgMgr.resolvePackages(new ClangPackageManagerInfoFactory().rpm(), null, null, pkgMgrOwnedByOutput);
assertEquals(1, pkgs.size());
assertEquals("boost-devel", pkgs.get(0).getPackageName());
assertEquals("1.53.0-27.el7", pkgs.get(0).getPackageVersion());
assertEquals("x86_64", pkgs.get(0).getPackageArch());
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails in project synopsys-detect by blackducksoftware.
the class RpmPackageManagerResolver method generatePackageFromQueryOutputLine.
public Optional<PackageDetails> generatePackageFromQueryOutputLine(String queryOutputLine) throws NotOwnedByAnyPkgException {
logger.trace(String.format("packageLine: %s", queryOutputLine));
Optional<String> packageJson = extractPackageJson(queryOutputLine);
if (!packageJson.isPresent()) {
logger.debug(String.format("Skipping line: %s (not a package)", queryOutputLine));
return Optional.empty();
}
RpmPackage rpmPackage;
try {
rpmPackage = gson.fromJson(packageJson.get(), RpmPackage.class);
} catch (JsonSyntaxException e) {
logger.warn(String.format("Skipping rpm 'who owns this file' query output line: %s (invalid JSON syntax)", queryOutputLine));
return Optional.empty();
}
PackageDetails dependencyDetails = buildPackageDetails(rpmPackage);
return Optional.of(dependencyDetails);
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails in project synopsys-detect by blackducksoftware.
the class DpkgPkgDetailsResolver method parsePackageDetailsFromInfoOutput.
private Optional<PackageDetails> parsePackageDetailsFromInfoOutput(String packageName, String packageInfoOutput) {
String packageArchitecture = null;
String packageVersion = null;
String[] packageInfoOutputLines = packageInfoOutput.split("\\n");
for (String packageInfoOutputLine : packageInfoOutputLines) {
if (foundUninstalledStatus(packageName, packageInfoOutputLine)) {
return Optional.empty();
}
packageArchitecture = parseNeededValueFromLineIfPresent(packageName, packageInfoOutputLine, "Architecture", packageArchitecture);
packageVersion = parseNeededValueFromLineIfPresent(packageName, packageInfoOutputLine, "Version", packageVersion);
}
if ((packageVersion == null) || (packageArchitecture == null)) {
logger.warn("Unable to determine all details for package {} (version: {}; architecture: {}); this package will be omitted from the output", packageName, packageVersion, packageArchitecture);
return Optional.empty();
}
return Optional.of(new PackageDetails(packageName, packageVersion, packageArchitecture));
}
Aggregations