Skip to content

Commit dd77cb5

Browse files
authored
Changes for building rpms (#1254)
1 parent 4265797 commit dd77cb5

7 files changed

Lines changed: 63 additions & 14 deletions

File tree

config/docker/l2tbuilds_ubuntu.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:resolute
1+
FROM ubuntu:noble
22

33
# Create container with:
44
# docker build -f l2tbuilds_ubuntu.Dockerfile --force-rm --no-cache -t log2timeline/l2tbuilds_ubuntu .

data/rpm_templates/artifacts.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ BuildArch: noarch
1515
Vendor: Forensic artifacts <forensicartifacts@googlegroups.com>
1616
Packager: Forensic artifacts <forensicartifacts@googlegroups.com>
1717
Url: https://github.com/ForensicArtifacts/artifacts
18-
BuildRequires: python3-devel, python3-setuptools
18+
BuildRequires: python3-devel, python3-pip, python3-setuptools
1919

2020
%{{?python_disable_dependency_generator}}
2121

data/rpm_templates/plaso.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ BuildArch: noarch
1515
Vendor: Log2Timeline maintainers <log2timeline-maintainers@googlegroups.com>
1616
Packager: Log2Timeline maintainers <log2timeline-maintainers@googlegroups.com>
1717
Url: https://github.com/log2timeline/plaso
18-
BuildRequires: python3-devel, python3-setuptools
18+
BuildRequires: python3-devel, python3-pip, python3-setuptools
1919

2020
%{{?python_disable_dependency_generator}}
2121

l2tdevtools/build_helpers/dpkg.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Helper for building projects from source."""
33

44
import datetime
5+
import fileinput
56
import glob
67
import logging
78
import os
@@ -264,6 +265,23 @@ def _CreatePackagingFiles(self, source_directory, project_version):
264265
source_directory))
265266
return False
266267

268+
if self.distribution == 'noble':
269+
control_file_path = os.path.join(debian_directory, 'control')
270+
for line in fileinput.input(control_file_path, inplace=True):
271+
if line.startswith('Build-Depends:'):
272+
line = line.rstrip() + ', pybuild-plugin-pyproject\n'
273+
print(line, end='')
274+
275+
patches_path = os.path.join(debian_directory, 'patches')
276+
if not os.path.exists(patches_path):
277+
os.mkdir(patches_path)
278+
279+
# pyproject_patch = os.path.join(patches_path, 'pyproject.patch')
280+
# TODO: add option to control patches for noble pyproject.toml builds
281+
282+
# TODO: create series file
283+
# patches_series = os.path.join(patches_path, 'series')
284+
267285
return True
268286

269287
# pylint: disable=redundant-returns-doc,unused-argument
@@ -831,7 +849,14 @@ def _DetermineBuildConfiguration(self, source_directory):
831849
for directory_entry in os.listdir(dist_packages):
832850
directory_entry_path = os.path.join(dist_packages, directory_entry)
833851

834-
if directory_entry.endswith('.egg-info'):
852+
if directory_entry.endswith('.dist-info'):
853+
# pylint: disable=simplifiable-if-statement
854+
if os.path.isdir(directory_entry_path):
855+
build_configuration.has_dist_info_directory = True
856+
else:
857+
build_configuration.has_dist_info_file = True
858+
859+
elif directory_entry.endswith('.egg-info'):
835860
# pylint: disable=simplifiable-if-statement
836861
if os.path.isdir(directory_entry_path):
837862
build_configuration.has_egg_info_directory = True

l2tdevtools/dependency_writers/dpkg.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ class DPKGControlWriter(interface.DependencyFileWriter):
3333
'Standards-Version: 4.1.4',
3434
'X-Python3-Version: >= 3.6',
3535
'Homepage: {homepage_url:s}',
36-
''] # yapf: disable
36+
'']
3737

3838
_DATA_PACKAGE = [
3939
'Package: {project_name:s}-data',
4040
'Architecture: all',
4141
'Depends: ${{misc:Depends}}',
4242
'Description: Data files for {name_description:s}',
4343
'{description_long:s}',
44-
''] # yapf: disable
44+
'']
4545

4646
_PYTHON3_PACKAGE = [
4747
'Package: python3-{python_module_name:s}',
4848
'Architecture: all',
4949
'Depends: {python3_dependencies:s}${{misc:Depends}}',
5050
'Description: Python 3 module of {python_module_description:s}',
5151
'{description_long:s}',
52-
''] # yapf: disable
52+
'']
5353

5454
_TOOLS_PACKAGE = [
5555
'Package: {project_name:s}-tools',
@@ -58,7 +58,7 @@ class DPKGControlWriter(interface.DependencyFileWriter):
5858
'${{misc:Depends}}'),
5959
'Description: {tools_description:s}',
6060
'{tool_description_long:s}',
61-
''] # yapf: disable
61+
'']
6262

6363
def Write(self):
6464
"""Writes a dpkg control file."""
@@ -91,11 +91,10 @@ def Write(self):
9191
[' {0:s}'.format(line) for line in tool_description_long.split('\n')])
9292

9393
file_content = []
94-
9594
file_content.extend(self._PYTHON3_FILE_HEADER)
9695

9796
data_dependency = ''
98-
if os.path.isdir('data'):
97+
if self._project_definition.name in ('artifacts', 'plaso'):
9998
data_dependency = '{0:s}-data (>= ${{binary:Version}})'.format(
10099
self._project_definition.name)
101100

@@ -153,7 +152,7 @@ class DPKGRulesWriter(interface.DependencyFileWriter):
153152

154153
PATH = os.path.join('config', 'dpkg', 'rules')
155154

156-
_FILE_CONTENT = [
155+
_HEADER = [
157156
'#!/usr/bin/make -f',
158157
'',
159158
'%:',
@@ -164,12 +163,30 @@ class DPKGRulesWriter(interface.DependencyFileWriter):
164163
'',
165164
'']
166165

166+
_DATA_PACKAGE = [
167+
'.PHONY: override_dh_auto_install',
168+
'override_dh_auto_install:',
169+
'\tdh_auto_install',
170+
'\tmkdir -p debian/tmp/usr/share/{project_name:s}',
171+
('\tmv debian/tmp/usr/lib/python*/dist-packages/{project_name:s}/data/* '
172+
'debian/tmp/usr/share/{project_name:s}'),
173+
'\trmdir debian/tmp/usr/lib/python*/dist-packages/{project_name:s}/data',
174+
'\tfind debian/tmp/usr/bin/ -type f -exec mv {{}} {{}}.py \\;',
175+
'',
176+
'']
177+
167178
def Write(self):
168179
"""Writes a dpkg control file."""
169180
template_mappings = {
170181
'project_name': self._project_definition.name}
171182

172-
file_content = '\n'.join(self._FILE_CONTENT)
183+
file_content = []
184+
file_content.extend(self._HEADER)
185+
186+
if self._project_definition.name in ('artifacts', 'plaso'):
187+
file_content.extend(self._DATA_PACKAGE)
188+
189+
file_content = '\n'.join(file_content)
173190
file_content = file_content.format(**template_mappings)
174191

175192
with open(self.PATH, 'w', encoding='utf-8') as file_object:

l2tdevtools/dpkg_files.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class DPKGBuildConfiguration(object):
1414
Attributes:
1515
has_bin_directory (bool): True if the Python module creates
1616
a /usr/bin directory.
17+
has_dist_info_directory (bool): True if the Python module has
18+
a .dist_info directory in the dist-packages directory.
1719
has_egg_info_directory (bool): True if the Python module has
1820
an .egg_info directory in the dist-packages directory.
1921
has_egg_info_file (bool): True if the Python module has
@@ -30,6 +32,7 @@ def __init__(self):
3032
"""Initializes a dpkg build configuration."""
3133
super(DPKGBuildConfiguration, self).__init__()
3234
self.has_bin_directory = False
35+
self.has_dist_info_directory = False
3336
self.has_egg_info_directory = False
3437
self.has_egg_info_file = False
3538
self.has_module_source_files = False
@@ -509,7 +512,11 @@ def _GeneratePython3ModuleInstallFile(self, dpkg_path, template_values):
509512
module_directory)
510513
for module_directory in module_directories])
511514

512-
if self._build_configuration.has_egg_info_directory:
515+
if self._build_configuration.has_dist_info_directory:
516+
template_data.append(
517+
'usr/lib/python3*/dist-packages/*.dist-info/*')
518+
519+
elif self._build_configuration.has_egg_info_directory:
513520
template_data.append(
514521
'usr/lib/python3*/dist-packages/*.egg-info/*')
515522

tests/update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GithubRepoDownloadHelperTest(test_lib.BaseTestCase):
2020
_DOWNLOAD_URL = 'https://github.com/ForensicArtifacts/artifacts/releases'
2121

2222
_PROJECT_NAME = 'artifacts'
23-
_PROJECT_VERSION = '20250913'
23+
_PROJECT_VERSION = '20260127'
2424

2525
def testGetPackageDownloadURLs(self):
2626
"""Tests the GetPackageDownloadURLs function."""

0 commit comments

Comments
 (0)