Skip to content

Commit

Permalink
Stop using bdist_rpm.
Browse files Browse the repository at this point in the history
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 pypa/setuptools#1988 for details.
        ********************************************************************************

!!
  • Loading branch information
adelton committed Feb 17, 2024
1 parent ae18b39 commit 2534062
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 32 deletions.
39 changes: 29 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

[project]
name = "rpm2swidtag"
version = "0.8.20"
authors = [{name = "Jan Pazdziora", email = "[email protected]"}]
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",
]

76 changes: 76 additions & 0 deletions rpm2swidtag.spec.in
Original file line number Diff line number Diff line change
@@ -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
22 changes: 0 additions & 22 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
[metadata]
name = rpm2swidtag
version = 0.8.20
author = Jan Pazdziora
author_email = [email protected]
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
Expand Down

0 comments on commit 2534062

Please sign in to comment.