macaron.build_spec_generator.reproducible_central package

Submodules

macaron.build_spec_generator.reproducible_central.reproducible_central module

This module contains the logic to generate a build spec in the Reproducible Central format.

class macaron.build_spec_generator.reproducible_central.reproducible_central.ReproducibleCentralBuildTool(value)

Bases: str, Enum

Represent the name of the build tool used in the Reproducible Central’s Buildspec.

https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/doc/BUILDSPEC.md

MAVEN = 'mvn'
GRADLE = 'gradle'
SBT = 'sbt'
macaron.build_spec_generator.reproducible_central.reproducible_central.format_build_command_info(build_command_info)

Return the prettified str format for a list of GenericBuildCommandInfo instances.

Parameters:

build_command_info (GenericBuildCommandInfo) – A list of GenericBuildCommandInfo instances.

Returns:

The prettified output.

Return type:

str

macaron.build_spec_generator.reproducible_central.reproducible_central.remove_shell_quote(cmd)

Remove shell quotes from a shell command.

Parameters:

cmd (list[str]) – The shell command as list of string.

Returns:

The shell command with all quote removed.

Return type:

list[str]

Examples

>>> cmd = "mvn -f fit/core-reference/pom.xml verify '-Dit.test=RESTITCase' '-Dmodernizer.skip=true' '-Drat.skip=true'"
>>> remove_shell_quote(cmd.split())
['mvn', '-f', 'fit/core-reference/pom.xml', 'verify', '-Dit.test=RESTITCase', '-Dmodernizer.skip=true', '-Drat.skip=true']
macaron.build_spec_generator.reproducible_central.reproducible_central.get_rc_build_command(cmds_sequence)

Return a single command as a string to be used in RC buildspec from a sequence of commands.

The build commands in the sequence will be && together, because RC’s build spec is a shell script.

Parameters:

cmds_sequence (list[list[str]]) – The sequence of build commands.

Returns:

A bash command to be used in RC’s command field.

Return type:

str

macaron.build_spec_generator.reproducible_central.reproducible_central.get_rc_default_build_command(rc_build_tool_name)

Return a default build command for a type of Reproducible Central build tool type.

Parameters:

rc_build_tool_name (ReproducibleCentralBuildTool) – The type of build tool to get the default build command.

Returns:

The build command as a list of strings or None if we cannot get one for this tool.

Return type:

list[str] | None

macaron.build_spec_generator.reproducible_central.reproducible_central.get_rc_build_tool_name(component_id, session)

Return the ReproducibleCentralBuildTool instance corresponding to the build tool of the component.

Parameters:
  • component_id (int) – The id of the component we are finding build command for.

  • session (sqlalchemy.orm.Session) – The SQLAlchemy Session opened for the database to extract build information.

Returns:

The ReproducibleCentralBuildTool instance for this component.

Return type:

ReproducibleCentralBuildTool | None

macaron.build_spec_generator.reproducible_central.reproducible_central.get_lookup_build_command_info(component_id, session)

Return the highest confidence build command information from the database for a component.

The build command is found by looking up CheckFacts for build-related checks.

Parameters:
  • component_id (int) – The id of the component we are finding the build command for.

  • session (sqlalchemy.orm.Session) – The SQLAlchemy Session opened for the database to extract build information.

Returns:

The GenericBuildCommandInfo object for the highest confidence build command; or None if there was an error, or no build command is found from the database.

Return type:

GenericBuildCommandInfo | None

macaron.build_spec_generator.reproducible_central.reproducible_central.get_lookup_build_command_jdk(build_command_info)

Return the JDK version from a GenericBuildCommandInfo object.

Return type:

str | None

macaron.build_spec_generator.reproducible_central.reproducible_central.gen_reproducible_central_build_spec(purl, session, patches)

Return the content of a Reproducible Central Buildspec File.

The Reproducible Central Buildspec File Format can be found here: https://github.com/jvm-repo-rebuild/reproducible-central/blob/e1708dd8dde3cdbe66b0cec9948812b601e90ba6/doc/BUILDSPEC.md#format

Parameters:
  • purl (PackageURL) – The PackageURL to generate build spec for.

  • session (sqlalchemy.orm.Session) – The SQLAlchemy Session opened for the database to extract build information.

  • patches (Mapping[PatchCommandBuildTool, Mapping[str, PatchValueType | None]]) – The patches to apply to the build commands in build_info before being populated in the output Buildspec.

Returns:

The content of the Buildspec as string or None if there is an error. The errors that can happen are: 1. The input PURL is invalid, 2. There is no supported build tool for this PURL, 3. Failed to patch the build commands using the provided patches, 4. The database from session doesn’t contain enough information.

Return type:

str | None