Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions data/projects.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ description_long: Fast ASN.1 parser and serializer with definitions
PKCS#7, PKCS#8, PKCS#12, PKCS#5, X.509 and TSP

[bencode]
dpkg_build_dependencies: python3-pbr
dpkg_dependencies: python3-pbr
rpm_build_dependencies: python3-pbr
version: >=4.1.0
build_system: setuptools
rpm_template_spec: bencode.spec
setup_name: bencode.py
setup_name: bencode_py
wheel_name: bencode_py
homepage_url: https://github.com/fuzeman/bencode.py
download_url: https://pypi.org/project/bencode.py
Expand Down
43 changes: 17 additions & 26 deletions data/rpm_templates/bencode.spec
Original file line number Diff line number Diff line change
@@ -1,50 +1,41 @@
%define name bencode
%define version {version}
%define unmangled_name bencode.py
%define unmangled_version {version}
%define release 1

Summary: Simple bencode parser
Name: %{{name}}
Version: %{{version}}
Release: %{{release}}
Source0: %{{unmangled_name}}-%{{unmangled_version}}.tar.gz
License: BitTorrent Open Source License
Name: bencode
Version: {version}
Release: 1
Group: Development/Libraries
BuildRoot: %{{_tmppath}}/%{{unmangled_name}}-release-%{{version}}-%{{release}}-buildroot
Prefix: %{{_prefix}}
BuildArch: noarch
Vendor: Dean Gardiner <me@dgardiner.net>
License: BitTorrent Open Source License
Summary: Simple bencode parser
Url: https://github.com/fuzeman/bencode.py
BuildRequires: python3-setuptools >= 17.0 , python3-devel, python3-pbr
Vendor: Dean Gardiner <me@dgardiner.net>
Source0: bencode_py-%{{version}}.tar.gz
BuildArch: noarch
BuildRequires: python3-devel, pyproject-rpm-macros, python3-pip, python3-setuptools, python3-wheel

%{{?python_disable_dependency_generator}}

%description
Simple bencode parser, forked from the bencode package
by Thomas Rampelberg.

%package -n python3-%{{name}}
Summary: Simple bencode parser for Python 3
Summary: Python 3 module of Simple bencode parser

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

%prep
%autosetup -n %{{unmangled_name}}-%{{unmangled_version}}
%autosetup -p1 -n bencode_py-%{{version}}

%build
%pyproject_wheel

%install
%pyproject_install
rm -rf %{{buildroot}}/usr/share/doc/%{{name}}/

%clean
rm -rf %{{buildroot}}

%files -n python3-%{{name}}
%{{python3_sitelib}}/bencode/
%{{python3_sitelib}}/bencodepy/
%license LICENSE

%{{python3_sitelib}}/bencode
%{{python3_sitelib}}/bencodepy
%{{python3_sitelib}}/bencode_py*.dist-info

%changelog
Expand Down
39 changes: 9 additions & 30 deletions l2tdevtools/spec_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class RPMSpecFileGenerator:
"%description -n %{{name}}-data",
"{description:s}",
"",
"",
]

_SPEC_TEMPLATE_PYTHON3_BODY = [
Expand All @@ -47,7 +46,6 @@ class RPMSpecFileGenerator:
"%install",
"%pyproject_install",
"",
"",
]

_SPEC_TEMPLATE_TOOLS_PACKAGE_DEFINITION = [
Expand All @@ -58,7 +56,6 @@ class RPMSpecFileGenerator:
"%description -n %{{name}}-tools",
"{description:s}",
"",
"",
]

LOG_FILENAME = "build.log"
Expand Down Expand Up @@ -107,7 +104,6 @@ def _GenerateSpecFile(
"vendor": None,
"version": None,
}

has_data_package = False

python_module_name = project_name
Expand All @@ -124,7 +120,6 @@ def _GenerateSpecFile(
os.path.isdir(tools_directory)
and glob.glob(os.path.join(tools_directory, "*.py"))
)

if project_definition.srpm_name:
package_name = project_definition.srpm_name
elif project_definition.rpm_name:
Expand Down Expand Up @@ -167,7 +162,11 @@ def _GenerateSpecFile(
)

if not configuration["license"]:
configuration["license"] = pyproject_toml_project.get("license", None)
license_value = pyproject_toml_project.get("license")
if isinstance(license_value, dict):
license_value = license_value.get("text")

configuration["license"] = license_value

if not configuration["summary"]:
configuration["summary"] = pyproject_toml_project.get(
Expand Down Expand Up @@ -262,7 +261,6 @@ def _GenerateSpecFile(
build_requires,
configuration,
)

if project_name != package_name:
python_package_name = f"python3-{package_name:s}"
else:
Expand All @@ -278,7 +276,6 @@ def _GenerateSpecFile(
configuration,
output_file_object,
)

if has_tools_package:
self._WriteToolsPackageDefinition(output_file_object, configuration)

Expand All @@ -299,7 +296,6 @@ def _GenerateSpecFile(
license_line,
doc_line,
)

if has_tools_package:
self._WriteToolsPackageFiles(output_file_object)

Expand Down Expand Up @@ -351,14 +347,14 @@ def _GetInstallDefinition(self, project_name):
),
"rm -rf %{buildroot}/usr/share/doc/%{name}/",
]

if project_name == "astroid":
lines.extend(["rm -rf %{buildroot}%{python3_sitelib}/astroid/tests"])

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

lines.append("")

return "\n".join(lines)

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

output_file_object.write(
(
"%changelog\n"
f"* {date_time_string:s} {self._EMAIL_ADDRESS:s} {version:s}-1\n"
"- Auto-generated\n"
)
"%changelog\n"
f"* {date_time_string:s} {self._EMAIL_ADDRESS:s} {version:s}-1\n"
"- Auto-generated\n"
)

def _WriteDataPackageDefinition(self, output_file_object, configuration):
Expand All @@ -459,7 +453,6 @@ def _WriteDataPackageDefinition(self, output_file_object, configuration):
"description": configuration["description"],
"summary": configuration["summary"],
}

output_string = "\n".join(self._SPEC_TEMPLATE_DATA_PACKAGE_DEFINITION)
output_string = output_string.format(**template_mappings)
output_file_object.write(output_string)
Expand All @@ -477,9 +470,7 @@ def _WriteDataPackageFiles(self, output_file_object):
"%doc ACKNOWLEDGEMENTS AUTHORS README.md",
"%{_datadir}/%{name}/*",
"",
"",
]

output_string = "\n".join(template)
output_file_object.write(output_string)

Expand Down Expand Up @@ -536,7 +527,6 @@ def _WritePython3PackageDefinition(
"requires": ", ".join(requires),
"summary": configuration["summary"],
}

template = ["%package -n {name:s}"]

if requires:
Expand All @@ -549,10 +539,8 @@ def _WritePython3PackageDefinition(
"%description -n {name:s}",
"{description:s}",
"",
"",
]
)

output_string = "\n".join(template)
output_string = output_string.format(**template_mappings)
output_file_object.write(output_string)
Expand Down Expand Up @@ -592,7 +580,6 @@ def _WritePython3PackageFiles(
"name": name,
"setup_name": setup_name,
}

template = ["%files -n {name:s}", "{license:s}", "{doc:s}"]

if project_definition.architecture_dependent:
Expand All @@ -602,7 +589,6 @@ def _WritePython3PackageFiles(
"%{{_libdir}}/python3*/site-packages/{setup_name:s}*.dist-info",
]
)

else:
template.extend(
[
Expand Down Expand Up @@ -648,7 +634,6 @@ def _WriteSpecFileFromTempate(
"rpm_requires": ", ".join(rpm_requires),
"version": project_version,
}

template_file_path = os.path.join(
self._data_path, "rpm_templates", project_definition.rpm_template_spec
)
Expand Down Expand Up @@ -700,7 +685,6 @@ def _WriteSourcePackageDefinition(
"vendor": configuration["vendor"],
"version": configuration["version"],
}

template = [
"Name: {name:s}",
"Version: {version:s}",
Expand All @@ -711,7 +695,6 @@ def _WriteSourcePackageDefinition(
"Url: {url:s}",
"Vendor: {vendor:s}",
]

template.append("Source0: {source:s}")

if not project_definition.architecture_dependent:
Expand All @@ -728,10 +711,8 @@ def _WriteSourcePackageDefinition(
"%description",
"{description:s}",
"",
"",
]
)

output_string = "\n".join(template)
output_string = output_string.format(**template_mappings)
output_file_object.write(output_string)
Expand All @@ -748,7 +729,6 @@ def _WriteToolsPackageDefinition(self, output_file_object, configuration):
"project_name": configuration["name"],
"summary": configuration["summary"],
}

output_string = "\n".join(self._SPEC_TEMPLATE_TOOLS_PACKAGE_DEFINITION)
output_string = output_string.format(**template_mappings)
output_file_object.write(output_string)
Expand Down Expand Up @@ -790,7 +770,6 @@ def Generate(
"python3-setuptools",
"python3-wheel",
]

if project_definition.architecture_dependent:
rpm_build_dependencies.append("gcc")

Expand Down
2 changes: 1 addition & 1 deletion tests/download_helpers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class LibyalGitHubReleasesDownloadHelperTest(test_lib.BaseTestCase):
_PROJECT_ORGANIZATION = "libyal"
_PROJECT_NAME = "libevt"
_PROJECT_STATUS = "alpha"
_PROJECT_VERSION = "20260523"
_PROJECT_VERSION = "20260705"

@classmethod
def setUpClass(cls):
Expand Down
4 changes: 2 additions & 2 deletions tests/download_helpers/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class PyPIDownloadHelperTest(test_lib.BaseTestCase):
_GIT_URL = "https://github.com/log2timeline/dfvfs.git"

_PROJECT_NAME = "dfvfs"
_PROJECT_VERSION = "20260411"
_PYPI_VERSION = "20260411"
_PROJECT_VERSION = "20260712"
_PYPI_VERSION = "20260712"

@classmethod
def setUpClass(cls):
Expand Down
Loading