use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class BitbakeExtractor method executeBitbakeForTargetArchitecture.
private String executeBitbakeForTargetArchitecture(final File outputDirectory, final File buildEnvScript, final String packageName, File bash) {
final String bitbakeCommand = "bitbake -c listtasks " + packageName;
final ExecutableOutput executableOutput = runBitbake(outputDirectory, buildEnvScript, bitbakeCommand, bash);
final int returnCode = executableOutput.getReturnCode();
String targetArchitecture = null;
if (returnCode == 0) {
targetArchitecture = bitbakeListTasksParser.parseTargetArchitecture(executableOutput.getStandardOutput()).orElse(null);
} else {
logger.error(String.format("Executing command '%s' returned a non-zero exit code %s", bitbakeCommand, returnCode));
}
return targetArchitecture;
}
use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class BitbakeExtractor method executeBitbakeForRecipeDependsFile.
private File executeBitbakeForRecipeDependsFile(final File outputDirectory, final File bitbakeBuildDirectory, final File buildEnvScript, final String packageName, File bash) {
final String bitbakeCommand = "bitbake -g " + packageName;
final ExecutableOutput executableOutput = runBitbake(outputDirectory, buildEnvScript, bitbakeCommand, bash);
final int returnCode = executableOutput.getReturnCode();
File recipeDependsFile = null;
if (returnCode == 0) {
recipeDependsFile = detectFileFinder.findFile(bitbakeBuildDirectory, RECIPE_DEPENDS_FILE_NAME);
} else {
logger.error(String.format("Executing command '%s' returned a non-zero exit code %s", bitbakeCommand, returnCode));
}
return recipeDependsFile;
}
use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class BitbakeExtractor method runBitbake.
private ExecutableOutput runBitbake(final File outputDirectory, final File buildEnvScript, final String bitbakeCommand, File bash) {
final List<String> arguments = new ArrayList<>();
arguments.add("-c");
arguments.add(". " + buildEnvScript + "; " + bitbakeCommand);
final Executable sourceExecutable = new Executable(outputDirectory, bash, arguments);
ExecutableOutput executableOutput = null;
try {
executableOutput = executableRunner.execute(sourceExecutable);
} catch (final ExecutableRunnerException e) {
logger.error(String.format("Failed executing command '%s'", sourceExecutable.getExecutableDescription()));
logger.debug(e.getMessage(), e);
}
return executableOutput;
}
use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class CondaCliExtractor method extract.
public Extraction extract(final File directory, final File condaExe, ExtractionId extractionId) {
try {
File workingDirectory = directoryManager.getExtractionOutputDirectory(extractionId);
final List<String> condaListOptions = new ArrayList<>();
condaListOptions.add("list");
final String condaEnvironmentName = detectConfiguration.getProperty(DetectProperty.DETECT_CONDA_ENVIRONMENT_NAME, PropertyAuthority.None);
if (StringUtils.isNotBlank(condaEnvironmentName)) {
condaListOptions.add("-n");
condaListOptions.add(condaEnvironmentName);
}
condaListOptions.add("--json");
final Executable condaListExecutable = new Executable(directory, condaExe, condaListOptions);
final ExecutableOutput condaListOutput = executableRunner.execute(condaListExecutable);
final String listJsonText = condaListOutput.getStandardOutput();
final ExecutableOutput condaInfoOutput = executableRunner.execute(workingDirectory, condaExe, "info", "--json");
final String infoJsonText = condaInfoOutput.getStandardOutput();
final DependencyGraph dependencyGraph = condaListParser.parse(listJsonText, infoJsonText);
final ExternalId externalId = externalIdFactory.createPathExternalId(Forge.ANACONDA, directory.toString());
final DetectCodeLocation detectCodeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.CONDA, directory.toString(), externalId, dependencyGraph).build();
return new Extraction.Builder().success(detectCodeLocation).build();
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput in project hub-detect by blackducksoftware.
the class CpanCliExtractor method extract.
public Extraction extract(final File directory, final File cpanExe, final File cpanmExe, ExtractionId extractionId) {
try {
File workingDirectory = directoryManager.getExtractionOutputDirectory(extractionId);
final ExecutableOutput cpanListOutput = executableRunner.execute(workingDirectory, cpanExe, "-l");
final List<String> listText = cpanListOutput.getStandardOutputAsList();
final ExecutableOutput showdepsOutput = executableRunner.execute(workingDirectory, cpanmExe, "--showdeps", ".");
final List<String> showdeps = showdepsOutput.getStandardOutputAsList();
final DependencyGraph dependencyGraph = cpanListParser.parse(listText, showdeps);
final ExternalId externalId = externalIdFactory.createPathExternalId(Forge.CPAN, directory.toString());
final DetectCodeLocation detectCodeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.CPAN, directory.toString(), externalId, dependencyGraph).build();
return new Extraction.Builder().success(detectCodeLocation).build();
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
Aggregations