diff --git a/config/docker/l2tbuilds_ubuntu.Dockerfile b/config/docker/l2tbuilds_ubuntu.Dockerfile index fb82ddc5..92970b08 100644 --- a/config/docker/l2tbuilds_ubuntu.Dockerfile +++ b/config/docker/l2tbuilds_ubuntu.Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:resolute +FROM ubuntu:noble # Create container with: # docker build -f l2tbuilds_ubuntu.Dockerfile --force-rm --no-cache -t log2timeline/l2tbuilds_ubuntu . diff --git a/data/rpm_templates/artifacts.spec b/data/rpm_templates/artifacts.spec index 50160ff8..0d5ad926 100644 --- a/data/rpm_templates/artifacts.spec +++ b/data/rpm_templates/artifacts.spec @@ -15,7 +15,7 @@ BuildArch: noarch Vendor: Forensic artifacts Packager: Forensic artifacts Url: https://github.com/ForensicArtifacts/artifacts -BuildRequires: python3-devel, python3-setuptools +BuildRequires: python3-devel, python3-pip, python3-setuptools %{{?python_disable_dependency_generator}} diff --git a/data/rpm_templates/plaso.spec b/data/rpm_templates/plaso.spec index 4fde4a3d..daa6d50c 100644 --- a/data/rpm_templates/plaso.spec +++ b/data/rpm_templates/plaso.spec @@ -15,7 +15,7 @@ BuildArch: noarch Vendor: Log2Timeline maintainers Packager: Log2Timeline maintainers Url: https://github.com/log2timeline/plaso -BuildRequires: python3-devel, python3-setuptools +BuildRequires: python3-devel, python3-pip, python3-setuptools %{{?python_disable_dependency_generator}} diff --git a/l2tdevtools/build_helpers/dpkg.py b/l2tdevtools/build_helpers/dpkg.py index 49de8850..5e7e5546 100644 --- a/l2tdevtools/build_helpers/dpkg.py +++ b/l2tdevtools/build_helpers/dpkg.py @@ -2,6 +2,7 @@ """Helper for building projects from source.""" import datetime +import fileinput import glob import logging import os @@ -264,6 +265,23 @@ def _CreatePackagingFiles(self, source_directory, project_version): source_directory)) return False + if self.distribution == 'noble': + control_file_path = os.path.join(debian_directory, 'control') + for line in fileinput.input(control_file_path, inplace=True): + if line.startswith('Build-Depends:'): + line = line.rstrip() + ', pybuild-plugin-pyproject\n' + print(line, end='') + + patches_path = os.path.join(debian_directory, 'patches') + if not os.path.exists(patches_path): + os.mkdir(patches_path) + + # pyproject_patch = os.path.join(patches_path, 'pyproject.patch') + # TODO: add option to control patches for noble pyproject.toml builds + + # TODO: create series file + # patches_series = os.path.join(patches_path, 'series') + return True # pylint: disable=redundant-returns-doc,unused-argument @@ -831,7 +849,14 @@ def _DetermineBuildConfiguration(self, source_directory): for directory_entry in os.listdir(dist_packages): directory_entry_path = os.path.join(dist_packages, directory_entry) - if directory_entry.endswith('.egg-info'): + if directory_entry.endswith('.dist-info'): + # pylint: disable=simplifiable-if-statement + if os.path.isdir(directory_entry_path): + build_configuration.has_dist_info_directory = True + else: + build_configuration.has_dist_info_file = True + + elif directory_entry.endswith('.egg-info'): # pylint: disable=simplifiable-if-statement if os.path.isdir(directory_entry_path): build_configuration.has_egg_info_directory = True diff --git a/l2tdevtools/dependency_writers/dpkg.py b/l2tdevtools/dependency_writers/dpkg.py index fc6933e1..aeb7d2ba 100644 --- a/l2tdevtools/dependency_writers/dpkg.py +++ b/l2tdevtools/dependency_writers/dpkg.py @@ -33,7 +33,7 @@ class DPKGControlWriter(interface.DependencyFileWriter): 'Standards-Version: 4.1.4', 'X-Python3-Version: >= 3.6', 'Homepage: {homepage_url:s}', - ''] # yapf: disable + ''] _DATA_PACKAGE = [ 'Package: {project_name:s}-data', @@ -41,7 +41,7 @@ class DPKGControlWriter(interface.DependencyFileWriter): 'Depends: ${{misc:Depends}}', 'Description: Data files for {name_description:s}', '{description_long:s}', - ''] # yapf: disable + ''] _PYTHON3_PACKAGE = [ 'Package: python3-{python_module_name:s}', @@ -49,7 +49,7 @@ class DPKGControlWriter(interface.DependencyFileWriter): 'Depends: {python3_dependencies:s}${{misc:Depends}}', 'Description: Python 3 module of {python_module_description:s}', '{description_long:s}', - ''] # yapf: disable + ''] _TOOLS_PACKAGE = [ 'Package: {project_name:s}-tools', @@ -58,7 +58,7 @@ class DPKGControlWriter(interface.DependencyFileWriter): '${{misc:Depends}}'), 'Description: {tools_description:s}', '{tool_description_long:s}', - ''] # yapf: disable + ''] def Write(self): """Writes a dpkg control file.""" @@ -91,11 +91,10 @@ def Write(self): [' {0:s}'.format(line) for line in tool_description_long.split('\n')]) file_content = [] - file_content.extend(self._PYTHON3_FILE_HEADER) data_dependency = '' - if os.path.isdir('data'): + if self._project_definition.name in ('artifacts', 'plaso'): data_dependency = '{0:s}-data (>= ${{binary:Version}})'.format( self._project_definition.name) @@ -153,7 +152,7 @@ class DPKGRulesWriter(interface.DependencyFileWriter): PATH = os.path.join('config', 'dpkg', 'rules') - _FILE_CONTENT = [ + _HEADER = [ '#!/usr/bin/make -f', '', '%:', @@ -164,12 +163,30 @@ class DPKGRulesWriter(interface.DependencyFileWriter): '', ''] + _DATA_PACKAGE = [ + '.PHONY: override_dh_auto_install', + 'override_dh_auto_install:', + '\tdh_auto_install', + '\tmkdir -p debian/tmp/usr/share/{project_name:s}', + ('\tmv debian/tmp/usr/lib/python*/dist-packages/{project_name:s}/data/* ' + 'debian/tmp/usr/share/{project_name:s}'), + '\trmdir debian/tmp/usr/lib/python*/dist-packages/{project_name:s}/data', + '\tfind debian/tmp/usr/bin/ -type f -exec mv {{}} {{}}.py \\;', + '', + ''] + def Write(self): """Writes a dpkg control file.""" template_mappings = { 'project_name': self._project_definition.name} - file_content = '\n'.join(self._FILE_CONTENT) + file_content = [] + file_content.extend(self._HEADER) + + if self._project_definition.name in ('artifacts', 'plaso'): + file_content.extend(self._DATA_PACKAGE) + + file_content = '\n'.join(file_content) file_content = file_content.format(**template_mappings) with open(self.PATH, 'w', encoding='utf-8') as file_object: diff --git a/l2tdevtools/dpkg_files.py b/l2tdevtools/dpkg_files.py index 4b1fc1b6..78bb6b38 100644 --- a/l2tdevtools/dpkg_files.py +++ b/l2tdevtools/dpkg_files.py @@ -14,6 +14,8 @@ class DPKGBuildConfiguration(object): Attributes: has_bin_directory (bool): True if the Python module creates a /usr/bin directory. + has_dist_info_directory (bool): True if the Python module has + a .dist_info directory in the dist-packages directory. has_egg_info_directory (bool): True if the Python module has an .egg_info directory in the dist-packages directory. has_egg_info_file (bool): True if the Python module has @@ -30,6 +32,7 @@ def __init__(self): """Initializes a dpkg build configuration.""" super(DPKGBuildConfiguration, self).__init__() self.has_bin_directory = False + self.has_dist_info_directory = False self.has_egg_info_directory = False self.has_egg_info_file = False self.has_module_source_files = False @@ -509,7 +512,11 @@ def _GeneratePython3ModuleInstallFile(self, dpkg_path, template_values): module_directory) for module_directory in module_directories]) - if self._build_configuration.has_egg_info_directory: + if self._build_configuration.has_dist_info_directory: + template_data.append( + 'usr/lib/python3*/dist-packages/*.dist-info/*') + + elif self._build_configuration.has_egg_info_directory: template_data.append( 'usr/lib/python3*/dist-packages/*.egg-info/*') diff --git a/tests/update.py b/tests/update.py index a0ca466a..e04e7627 100644 --- a/tests/update.py +++ b/tests/update.py @@ -20,7 +20,7 @@ class GithubRepoDownloadHelperTest(test_lib.BaseTestCase): _DOWNLOAD_URL = 'https://github.com/ForensicArtifacts/artifacts/releases' _PROJECT_NAME = 'artifacts' - _PROJECT_VERSION = '20250913' + _PROJECT_VERSION = '20260127' def testGetPackageDownloadURLs(self): """Tests the GetPackageDownloadURLs function."""