Skip to content

Commit

Permalink
Changes to rpm build helper (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Mar 17, 2024
1 parent 677b4ea commit c73448c
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 411 deletions.
2 changes: 2 additions & 0 deletions data/rpm_templates/artifacts.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Packager: Forensic artifacts <[email protected]>
Url: https://github.com/ForensicArtifacts/artifacts
BuildRequires: python3-devel, python3-setuptools

%{{?python_disable_dependency_generator}}

%description
A free, community-sourced, machine-readable knowledge base of forensic artifacts that the world can use both as an information source and within other tools.

Expand Down
2 changes: 2 additions & 0 deletions data/rpm_templates/plaso.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Packager: Log2Timeline maintainers <[email protected]>
Url: https://github.com/log2timeline/plaso
BuildRequires: python3-devel, python3-setuptools

%{{?python_disable_dependency_generator}}

%description
Plaso (log2timeline) is a framework to create super timelines. Its purpose is to extract timestamps from various files found on typical computer systems and aggregate them.

Expand Down
33 changes: 4 additions & 29 deletions l2tdevtools/build_helpers/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,25 +199,6 @@ def _GetFilenameSafeProjectInformation(self, source_helper_object):

return project_name, project_version

def _GetSetupPySpecFilePath(self, source_helper_object, source_directory):
"""Retrieves the path of the setup.py generated .spec file.
Args:
source_helper_object (SourceHelper): source helper.
source_directory (str): name of the source directory.
Returns:
str: path of the setup.py generated .spec file.
"""
if self._project_definition.setup_name:
setup_name = self._project_definition.setup_name
else:
setup_name = source_helper_object.project_name

spec_filename = '{0:s}.spec'.format(setup_name)

return os.path.join(source_directory, 'dist', spec_filename)

def _MoveFilesToCurrentDirectory(self, filenames_glob):
"""Moves files into the current directory.
Expand Down Expand Up @@ -461,17 +442,14 @@ def _GenerateSpecFile(
if project_name.startswith('python-'):
project_name = project_name[7:]

input_file_path = self._GetSetupPySpecFilePath(
source_helper_object, source_directory)

spec_filename = '{0:s}.spec'.format(project_name)
output_file_path = os.path.join(self._rpmbuild_specs_path, spec_filename)

try:
result = spec_file_generator.Generate(
self._project_definition, source_directory, source_package_filename,
project_name, project_version, input_file_path, output_file_path)
except FileNotFoundError:
project_name, project_version, output_file_path)
except (FileNotFoundError, TypeError):
result = False

if not result:
Expand Down Expand Up @@ -739,17 +717,14 @@ def _GenerateSpecFile(
if project_name.startswith('python-'):
project_name = project_name[7:]

input_file_path = self._GetSetupPySpecFilePath(
source_helper_object, source_directory)

spec_filename = '{0:s}.spec'.format(project_name)
output_file_path = os.path.join(self._rpmbuild_specs_path, spec_filename)

try:
result = spec_file_generator.Generate(
self._project_definition, source_directory, source_package_filename,
project_name, project_version, input_file_path, output_file_path)
except FileNotFoundError:
project_name, project_version, output_file_path)
except (FileNotFoundError, TypeError):
result = False

if not result:
Expand Down
6 changes: 3 additions & 3 deletions l2tdevtools/dpkg_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,8 @@ def _GenerateRulesFile(self, dpkg_path):
if self._project_definition.build_system == 'configure_make':
self._GenerateConfigureMakeRulesFile(dpkg_path)

elif self._project_definition.build_system in ('pyproject', 'setup_py'):
self._GenerateSetupPyRulesFile(dpkg_path)
else:
self._GeneratePyProjectRulesFile(dpkg_path)

filename = os.path.join(dpkg_path, 'rules')
stat_info = os.stat(filename)
Expand Down Expand Up @@ -563,7 +563,7 @@ def _GenerateConfigureMakeRulesFile(self, dpkg_path):
self._project_definition.dpkg_template_rules,
self._RULES_TEMPLATE_CONFIGURE_MAKE, template_values, output_filename)

def _GenerateSetupPyRulesFile(self, dpkg_path):
def _GeneratePyProjectRulesFile(self, dpkg_path):
"""Generates the dpkg build rules file.
Args:
Expand Down
1 change: 1 addition & 0 deletions l2tdevtools/helpers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ProjectHelper(cli.CLIHelper):
'vstools',
'winevt-kb',
'winreg-kb',
'winshl-kb',
'winsps-kb'])

def __init__(self, project_path):
Expand Down
Loading

0 comments on commit c73448c

Please sign in to comment.