From 2534062ec792dc1279a3a51a19d91b5b482728f0 Mon Sep 17 00:00:00 2001 From: Jan Pazdziora Date: Sat, 17 Feb 2024 15:14:11 +0100 Subject: [PATCH] Stop using bdist_rpm. Addressing $ make spec python3 setup.py bdist_rpm --spec-only --install-script=bdist_rpm/install_script running bdist_rpm /usr/lib/python3.12/site-packages/setuptools/_distutils/dist.py:988: SetuptoolsDeprecationWarning: Deprecated command !! ******************************************************************************** bdist_rpm is deprecated and will be removed in a future version. Use bdist_wheel (wheel packages) instead. This deprecation is overdue, please update your project and remove deprecated calls to avoid build errors in the future. See https://github.com/pypa/setuptools/issues/1988 for details. ******************************************************************************** !! --- Makefile | 39 +++++++++++++++++------ pyproject.toml | 23 ++++++++++++++ rpm2swidtag.spec.in | 76 +++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 22 ------------- 4 files changed, 128 insertions(+), 32 deletions(-) create mode 100644 pyproject.toml create mode 100644 rpm2swidtag.spec.in diff --git a/Makefile b/Makefile index 928d7f6..dc06df6 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,41 @@ -srpm: - python3 setup.py bdist_rpm --source-only --install-script=bdist_rpm/install_script - ls -l dist/*.src.rpm - -rpm: - python3 setup.py bdist_rpm --binary-only --install-script=bdist_rpm/install_script - ls -l dist/*.noarch.rpm +NAME = $(shell eval echo $$( awk '/^name/ { print $$NF }' pyproject.toml)) +VERSION = $(shell eval echo $$( awk '/^version/ { print $$NF }' pyproject.toml)) +DIST = dist +SPECFILE = dist/$(NAME).spec spec: - python3 setup.py bdist_rpm --spec-only --install-script=bdist_rpm/install_script - ls -l dist/*.spec + mkdir -p $(DIST) + rpm -D "version $(VERSION)" --eval "$$( cat rpm2swidtag.spec.in )" > $(SPECFILE) + ls -l $(DIST)/*.spec + +tar-gz: + rm -rf $(DIST)/$(NAME)-$(VERSION) + # python3 -m build -o $(DIST) --no-isolation --skip-dependency-check --sdist . + mkdir -p $(DIST)/$(NAME)-$(VERSION) + cp -lrp -t dist/$(NAME)-$(VERSION) $(shell ls | grep -v dist) + for i in $(shell cat .gitignore) ; do rm -rf $(DIST)/$$i ; done + tar -C $(DIST) -cvzf $(DIST)/$(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION) + rm -rf $(DIST)/$(NAME)-$(VERSION) + ls -l $(DIST)/*.tar.gz + +srpm: spec tar-gz + rpmbuild -D '_srcrpmdir $(DIST)' -D '_sourcedir $(DIST)' -bs $(SPECFILE) + ls -l $(DIST)/*.src.rpm + +rpm: spec tar-gz + rpmbuild -D '_rpmdir $(DIST)' -D '_sourcedir $(PWD)/$(DIST)' -bb $(SPECFILE) + mv $(DIST)/noarch/*.noarch.rpm $(DIST) + ls -l $(DIST)/*.noarch.rpm test: ./test.sh test-pylint: - pylint-3 --disable=R --disable=C --indent-string="\t" --extension-pkg-whitelist=rpm,lxml lib/*/*.py setup.py + pylint-3 --disable=R --disable=C --indent-string="\t" --extension-pkg-whitelist=rpm,lxml lib/*/*.py clean: rm -rf $(shell cat .gitignore) +.PHONY: spec tar-gz srpm rpm test test-pylint clean + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b2bbfc4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ + +[project] +name = "rpm2swidtag" +version = "0.8.20" +authors = [{name = "Jan Pazdziora", email = "jpazdziora@redhat.com"}] +license = {text = "ASL 2.0"} +description = "Tools for producing SWID tags from rpm package headers and inspecting the SWID tags" +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Environment :: Plugins", + "Intended Audience :: System Administrators", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "License :: OSI Approved :: Apache Software License", + "Operating System :: POSIX", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3", + "Topic :: Security", + "Topic :: Software Development :: Build Tools", + "Topic :: System :: Systems Administration", +] + diff --git a/rpm2swidtag.spec.in b/rpm2swidtag.spec.in new file mode 100644 index 0000000..73d9329 --- /dev/null +++ b/rpm2swidtag.spec.in @@ -0,0 +1,76 @@ +Name: rpm2swidtag +Version: %{version} +Release: 1%%{?dist} + +Summary: Tools for producing SWID tags from rpm package headers and inspecting the SWID tags +License: ASL 2.0 +URL: https://github.com/swidtags/rpm2swidtag +Source: %%{name}-%%{version}.tar.gz + +Requires: python3-rpm +Requires: python3-lxml +Requires: python3-zstandard +Requires: dnf-plugins-core +Requires: xmlsec1-openssl +Obsoletes: dnf-plugin-swidtags +Obsoletes: swid-tools + +BuildArch: noarch +BuildRequires: make +BuildRequires: python3-devel +BuildRequires: python3-build +BuildRequires: python3-setuptools +BuildRequires: python3-wheel +BuildRequires: python3-rpm +BuildRequires: python3-lxml +BuildRequires: python3-zstandard +BuildRequires: openssl +BuildRequires: xmlsec1-openssl +BuildRequires: createrepo_c +BuildRequires: fakechroot +BuildRequires: fakeroot +BuildRequires: dnf +BuildRequires: dnf-plugins-core +BuildRequires: gzip +BuildRequires: gnupg2 +BuildRequires: python3-pylint + + +%%description +Tools for producing SWID tags from rpm package headers and inspecting the SWID tags. + +%%prep +%%autosetup -p1 + +%%generate_buildrequires +%%pyproject_buildrequires + +%%build +%%pyproject_wheel + +%%install +%%pyproject_install +%%pyproject_save_files '*' +auto + +%%check +%%pyproject_check_import +make test-pylint test + +%%files -f %%{pyproject_files} + +%%post + +if rpm -q rpm2swidtag dnf-plugin-swidtags 2> /dev/null | grep -E -q '(rpm2swidtag|dnf-plugin-swidtags)-0\.[1-7]\.[0-9]-' ; then + echo + echo "Please run dnf-plugin-swidtags-update-from-0.7 to update the filename format." + + if echo "88d7506a4769d9402548cd9f0d242913cd46616f4fa755c52013094af33f5c1b /etc/dnf/plugins/swidtags.conf" | sha256sum -c > /dev/null 2>&1 ; then + sed -i 's/^# rpm2swidtag_command = /rpm2swidtag_command = /' /etc/dnf/plugins/swidtags.conf + echo + echo "The rpm2swidtag_command in /etc/dnf/plugins/swidtags.conf enabled" + echo "to keep the pre-0.8 behaviour." + fi +fi + +%%changelog +%%autochangelog diff --git a/setup.cfg b/setup.cfg index a41e293..acf4794 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,25 +1,3 @@ -[metadata] -name = rpm2swidtag -version = 0.8.20 -author = Jan Pazdziora -author_email = jpazdziora@redhat.com -license = ASL 2.0 -description = Tools for producing SWID tags from rpm package headers and inspecting the SWID tags -classifiers = - Development Status :: 4 - Beta - Environment :: Console - Environment :: Plugins - Intended Audience :: System Administrators - Intended Audience :: Developers - Intended Audience :: Information Technology - License :: OSI Approved :: Apache Software License - Operating System :: POSIX - Operating System :: POSIX :: Linux - Programming Language :: Python :: 3 - Topic :: Security - Topic :: Software Development :: Build Tools - Topic :: System :: Systems Administration - [options] package_dir = = lib