Skip to content

Commit 83c40cb

Browse files
authored
Changes for building bencode rpm (#1280)
1 parent f3d077c commit 83c40cb

5 files changed

Lines changed: 32 additions & 63 deletions

File tree

data/projects.ini

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ description_long: Fast ASN.1 parser and serializer with definitions
2929
PKCS#7, PKCS#8, PKCS#12, PKCS#5, X.509 and TSP
3030

3131
[bencode]
32-
dpkg_build_dependencies: python3-pbr
33-
dpkg_dependencies: python3-pbr
34-
rpm_build_dependencies: python3-pbr
32+
version: >=4.1.0
33+
build_system: setuptools
3534
rpm_template_spec: bencode.spec
36-
setup_name: bencode.py
35+
setup_name: bencode_py
3736
wheel_name: bencode_py
3837
homepage_url: https://github.com/fuzeman/bencode.py
3938
download_url: https://pypi.org/project/bencode.py

data/rpm_templates/bencode.spec

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,41 @@
1-
%define name bencode
2-
%define version {version}
3-
%define unmangled_name bencode.py
4-
%define unmangled_version {version}
5-
%define release 1
6-
7-
Summary: Simple bencode parser
8-
Name: %{{name}}
9-
Version: %{{version}}
10-
Release: %{{release}}
11-
Source0: %{{unmangled_name}}-%{{unmangled_version}}.tar.gz
12-
License: BitTorrent Open Source License
1+
Name: bencode
2+
Version: {version}
3+
Release: 1
134
Group: Development/Libraries
14-
BuildRoot: %{{_tmppath}}/%{{unmangled_name}}-release-%{{version}}-%{{release}}-buildroot
15-
Prefix: %{{_prefix}}
16-
BuildArch: noarch
17-
Vendor: Dean Gardiner <me@dgardiner.net>
5+
License: BitTorrent Open Source License
6+
Summary: Simple bencode parser
187
Url: https://github.com/fuzeman/bencode.py
19-
BuildRequires: python3-setuptools >= 17.0 , python3-devel, python3-pbr
8+
Vendor: Dean Gardiner <me@dgardiner.net>
9+
Source0: bencode_py-%{{version}}.tar.gz
10+
BuildArch: noarch
11+
BuildRequires: python3-devel, pyproject-rpm-macros, python3-pip, python3-setuptools, python3-wheel
12+
13+
%{{?python_disable_dependency_generator}}
2014

2115
%description
2216
Simple bencode parser, forked from the bencode package
2317
by Thomas Rampelberg.
2418

2519
%package -n python3-%{{name}}
26-
Summary: Simple bencode parser for Python 3
20+
Summary: Python 3 module of Simple bencode parser
2721

2822
%description -n python3-%{{name}}
2923
Simple bencode parser, forked from the bencode package
3024
by Thomas Rampelberg.
3125

3226
%prep
33-
%autosetup -n %{{unmangled_name}}-%{{unmangled_version}}
27+
%autosetup -p1 -n bencode_py-%{{version}}
3428

3529
%build
3630
%pyproject_wheel
3731

3832
%install
3933
%pyproject_install
40-
rm -rf %{{buildroot}}/usr/share/doc/%{{name}}/
41-
42-
%clean
43-
rm -rf %{{buildroot}}
44-
4534
%files -n python3-%{{name}}
46-
%{{python3_sitelib}}/bencode/
47-
%{{python3_sitelib}}/bencodepy/
35+
%license LICENSE
36+
37+
%{{python3_sitelib}}/bencode
38+
%{{python3_sitelib}}/bencodepy
4839
%{{python3_sitelib}}/bencode_py*.dist-info
4940

5041
%changelog

l2tdevtools/spec_file.py

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class RPMSpecFileGenerator:
3434
"%description -n %{{name}}-data",
3535
"{description:s}",
3636
"",
37-
"",
3837
]
3938

4039
_SPEC_TEMPLATE_PYTHON3_BODY = [
@@ -47,7 +46,6 @@ class RPMSpecFileGenerator:
4746
"%install",
4847
"%pyproject_install",
4948
"",
50-
"",
5149
]
5250

5351
_SPEC_TEMPLATE_TOOLS_PACKAGE_DEFINITION = [
@@ -58,7 +56,6 @@ class RPMSpecFileGenerator:
5856
"%description -n %{{name}}-tools",
5957
"{description:s}",
6058
"",
61-
"",
6259
]
6360

6461
LOG_FILENAME = "build.log"
@@ -107,7 +104,6 @@ def _GenerateSpecFile(
107104
"vendor": None,
108105
"version": None,
109106
}
110-
111107
has_data_package = False
112108

113109
python_module_name = project_name
@@ -124,7 +120,6 @@ def _GenerateSpecFile(
124120
os.path.isdir(tools_directory)
125121
and glob.glob(os.path.join(tools_directory, "*.py"))
126122
)
127-
128123
if project_definition.srpm_name:
129124
package_name = project_definition.srpm_name
130125
elif project_definition.rpm_name:
@@ -167,7 +162,11 @@ def _GenerateSpecFile(
167162
)
168163

169164
if not configuration["license"]:
170-
configuration["license"] = pyproject_toml_project.get("license", None)
165+
license_value = pyproject_toml_project.get("license")
166+
if isinstance(license_value, dict):
167+
license_value = license_value.get("text")
168+
169+
configuration["license"] = license_value
171170

172171
if not configuration["summary"]:
173172
configuration["summary"] = pyproject_toml_project.get(
@@ -262,7 +261,6 @@ def _GenerateSpecFile(
262261
build_requires,
263262
configuration,
264263
)
265-
266264
if project_name != package_name:
267265
python_package_name = f"python3-{package_name:s}"
268266
else:
@@ -278,7 +276,6 @@ def _GenerateSpecFile(
278276
configuration,
279277
output_file_object,
280278
)
281-
282279
if has_tools_package:
283280
self._WriteToolsPackageDefinition(output_file_object, configuration)
284281

@@ -299,7 +296,6 @@ def _GenerateSpecFile(
299296
license_line,
300297
doc_line,
301298
)
302-
303299
if has_tools_package:
304300
self._WriteToolsPackageFiles(output_file_object)
305301

@@ -351,14 +347,14 @@ def _GetInstallDefinition(self, project_name):
351347
),
352348
"rm -rf %{buildroot}/usr/share/doc/%{name}/",
353349
]
354-
355350
if project_name == "astroid":
356351
lines.extend(["rm -rf %{buildroot}%{python3_sitelib}/astroid/tests"])
357352

358353
elif project_name == "pylint":
359354
lines.extend(["rm -rf %{buildroot}%{python3_sitelib}/pylint/test"])
360355

361356
lines.append("")
357+
362358
return "\n".join(lines)
363359

364360
def _GetLicenseFileDefinition(self, source_directory):
@@ -441,11 +437,9 @@ def _WriteChangeLog(self, output_file_object, version):
441437
date_time_string = date_time.strftime("%a %b %e %Y")
442438

443439
output_file_object.write(
444-
(
445-
"%changelog\n"
446-
f"* {date_time_string:s} {self._EMAIL_ADDRESS:s} {version:s}-1\n"
447-
"- Auto-generated\n"
448-
)
440+
"%changelog\n"
441+
f"* {date_time_string:s} {self._EMAIL_ADDRESS:s} {version:s}-1\n"
442+
"- Auto-generated\n"
449443
)
450444

451445
def _WriteDataPackageDefinition(self, output_file_object, configuration):
@@ -459,7 +453,6 @@ def _WriteDataPackageDefinition(self, output_file_object, configuration):
459453
"description": configuration["description"],
460454
"summary": configuration["summary"],
461455
}
462-
463456
output_string = "\n".join(self._SPEC_TEMPLATE_DATA_PACKAGE_DEFINITION)
464457
output_string = output_string.format(**template_mappings)
465458
output_file_object.write(output_string)
@@ -477,9 +470,7 @@ def _WriteDataPackageFiles(self, output_file_object):
477470
"%doc ACKNOWLEDGEMENTS AUTHORS README.md",
478471
"%{_datadir}/%{name}/*",
479472
"",
480-
"",
481473
]
482-
483474
output_string = "\n".join(template)
484475
output_file_object.write(output_string)
485476

@@ -536,7 +527,6 @@ def _WritePython3PackageDefinition(
536527
"requires": ", ".join(requires),
537528
"summary": configuration["summary"],
538529
}
539-
540530
template = ["%package -n {name:s}"]
541531

542532
if requires:
@@ -549,10 +539,8 @@ def _WritePython3PackageDefinition(
549539
"%description -n {name:s}",
550540
"{description:s}",
551541
"",
552-
"",
553542
]
554543
)
555-
556544
output_string = "\n".join(template)
557545
output_string = output_string.format(**template_mappings)
558546
output_file_object.write(output_string)
@@ -592,7 +580,6 @@ def _WritePython3PackageFiles(
592580
"name": name,
593581
"setup_name": setup_name,
594582
}
595-
596583
template = ["%files -n {name:s}", "{license:s}", "{doc:s}"]
597584

598585
if project_definition.architecture_dependent:
@@ -602,7 +589,6 @@ def _WritePython3PackageFiles(
602589
"%{{_libdir}}/python3*/site-packages/{setup_name:s}*.dist-info",
603590
]
604591
)
605-
606592
else:
607593
template.extend(
608594
[
@@ -648,7 +634,6 @@ def _WriteSpecFileFromTempate(
648634
"rpm_requires": ", ".join(rpm_requires),
649635
"version": project_version,
650636
}
651-
652637
template_file_path = os.path.join(
653638
self._data_path, "rpm_templates", project_definition.rpm_template_spec
654639
)
@@ -700,7 +685,6 @@ def _WriteSourcePackageDefinition(
700685
"vendor": configuration["vendor"],
701686
"version": configuration["version"],
702687
}
703-
704688
template = [
705689
"Name: {name:s}",
706690
"Version: {version:s}",
@@ -711,7 +695,6 @@ def _WriteSourcePackageDefinition(
711695
"Url: {url:s}",
712696
"Vendor: {vendor:s}",
713697
]
714-
715698
template.append("Source0: {source:s}")
716699

717700
if not project_definition.architecture_dependent:
@@ -728,10 +711,8 @@ def _WriteSourcePackageDefinition(
728711
"%description",
729712
"{description:s}",
730713
"",
731-
"",
732714
]
733715
)
734-
735716
output_string = "\n".join(template)
736717
output_string = output_string.format(**template_mappings)
737718
output_file_object.write(output_string)
@@ -748,7 +729,6 @@ def _WriteToolsPackageDefinition(self, output_file_object, configuration):
748729
"project_name": configuration["name"],
749730
"summary": configuration["summary"],
750731
}
751-
752732
output_string = "\n".join(self._SPEC_TEMPLATE_TOOLS_PACKAGE_DEFINITION)
753733
output_string = output_string.format(**template_mappings)
754734
output_file_object.write(output_string)
@@ -790,7 +770,6 @@ def Generate(
790770
"python3-setuptools",
791771
"python3-wheel",
792772
]
793-
794773
if project_definition.architecture_dependent:
795774
rpm_build_dependencies.append("gcc")
796775

tests/download_helpers/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class LibyalGitHubReleasesDownloadHelperTest(test_lib.BaseTestCase):
104104
_PROJECT_ORGANIZATION = "libyal"
105105
_PROJECT_NAME = "libevt"
106106
_PROJECT_STATUS = "alpha"
107-
_PROJECT_VERSION = "20260523"
107+
_PROJECT_VERSION = "20260705"
108108

109109
@classmethod
110110
def setUpClass(cls):

tests/download_helpers/pypi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class PyPIDownloadHelperTest(test_lib.BaseTestCase):
1818
_GIT_URL = "https://github.com/log2timeline/dfvfs.git"
1919

2020
_PROJECT_NAME = "dfvfs"
21-
_PROJECT_VERSION = "20260411"
22-
_PYPI_VERSION = "20260411"
21+
_PROJECT_VERSION = "20260712"
22+
_PYPI_VERSION = "20260712"
2323

2424
@classmethod
2525
def setUpClass(cls):

0 commit comments

Comments
 (0)