Search in sources :

Example 6 with ExecutableOutput

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;
}
Also used : ExecutableOutput(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput)

Example 7 with ExecutableOutput

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;
}
Also used : ExecutableOutput(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput) File(java.io.File)

Example 8 with ExecutableOutput

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;
}
Also used : ExecutableOutput(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput) ArrayList(java.util.ArrayList) Executable(com.blackducksoftware.integration.hub.detect.util.executable.Executable) ExecutableRunnerException(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableRunnerException)

Example 9 with 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();
    }
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) ArrayList(java.util.ArrayList) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ExecutableOutput(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) Extraction(com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction) Executable(com.blackducksoftware.integration.hub.detect.util.executable.Executable) File(java.io.File)

Example 10 with ExecutableOutput

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();
    }
}
Also used : ExecutableOutput(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Extraction(com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction) File(java.io.File)

Aggregations

ExecutableOutput (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput)30 File (java.io.File)16 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)14 ArrayList (java.util.ArrayList)12 Executable (com.blackducksoftware.integration.hub.detect.util.executable.Executable)10 ExecutableRunnerException (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableRunnerException)9 ExecutableRunner (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableRunner)8 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)7 DetectFileFinder (com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder)7 Test (org.junit.Test)6 ExtractionId (com.blackducksoftware.integration.hub.detect.detector.ExtractionId)5 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)4 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)4 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)4 DetectConfiguration (com.blackducksoftware.integration.hub.detect.configuration.DetectConfiguration)3 DetectProperty (com.blackducksoftware.integration.hub.detect.configuration.DetectProperty)3 PropertyAuthority (com.blackducksoftware.integration.hub.detect.configuration.PropertyAuthority)3 DirectoryManager (com.blackducksoftware.integration.hub.detect.workflow.file.DirectoryManager)3 Arrays (java.util.Arrays)3 HashSet (java.util.HashSet)3