forked from swidtags/rpm2swidtag
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Desperate attempt to figure out how rpm should be built in 2024
to get rid of $ 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. ******************************************************************************** !! Given pypa/setuptools#1988 deprecates bdist_rpm but does not provide any solid guidance about replacements, we just use a .spec file template in the end. But the necessary dependencies do not seem to be present / work on CentOS Stream 8 and 9, so we have to stop testing on those. We wanted to use pyproject.toml for everything. But tool.setuptools.data-files does not respect absolute path (unlike setup.py's data_files) so that has to be done with installs in the .spec; and py-modules fails with configuration error: `tool.setuptools.py-modules[0]` must be python-module-name GIVEN VALUE: "dnf-plugins.swidtags" OFFENDING RULE: 'format' DEFINITION: { "type": "string", "format": "python-module-name" } so we have to put those in setup.cfg. https://gregoryszorc.com/blog/2023/10/30/my-user-experience-porting-off-setup.py/
- Loading branch information
Showing
11 changed files
with
177 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,40 @@ | ||
|
||
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) | ||
mkdir -p $(DIST)/$(NAME)-$(VERSION) | ||
cp -rp -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 | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
[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", | ||
] | ||
|
||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools] | ||
package-dir = {"" = "lib"} | ||
# Workaround configuration error: `tool.setuptools.py-modules[0]` must be python-module-name | ||
# by keeping this in setup.cfg file: | ||
# py-modules = ["dnf-plugins.swidtags"] | ||
packages = ["rpm2swidtag", "swidq"] | ||
script-files = [ | ||
"bin/rpm2swidtag", | ||
"bin/dnf-plugin-swidtags-update-from-0.7", | ||
"bin/swidq", | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
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-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 | ||
install -D -t %%{buildroot}%%{_sysconfdir}/%%{name} \ | ||
rpm2swidtag.conf \ | ||
swidtag-template.xml \ | ||
swidtag.xslt \ | ||
rpm2swidtag.xslt \ | ||
rpm2swidtag-tagid.xslt | ||
install -D -t %%{buildroot}%%{_sysconfdir}/%%{name}/rpm2swidtag.conf.d \ | ||
rpm2swidtag.conf.d/fedora-37.conf \ | ||
rpm2swidtag.conf.d/fedora-38.conf \ | ||
rpm2swidtag.conf.d/fedora-39.conf \ | ||
rpm2swidtag.conf.d/fedora-40.conf \ | ||
rpm2swidtag.conf.d/fedora-rawhide.conf | ||
install -D -t %%{buildroot}%%{_sysconfdir}/swid swidq.conf | ||
install -d %%{buildroot}%%{_sysconfdir}/swid/swidtags.d | ||
install -D -t %%{buildroot}%%{_datarootdir}/swidq/stylesheets \ | ||
swidq-info.xslt \ | ||
swidq-dump.xslt \ | ||
swidq-files.xslt \ | ||
swidq-xml.xslt | ||
install -D -t %%{buildroot}%%{_sysconfdir}/dnf/plugins dnf/plugins/swidtags.conf | ||
|
||
%%check | ||
%%pyproject_check_import | ||
make test-pylint test | ||
|
||
%%files -f %%{pyproject_files} | ||
|
||
%%{_sysconfdir}/%%{name} | ||
%%{_sysconfdir}/swid/swidq.conf | ||
%%{_sysconfdir}/swid/swidtags.d | ||
%%{_datarootdir}/swidq | ||
%%{_sysconfdir}/dnf/plugins/swidtags.conf | ||
|
||
%%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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
[bdist_rpm] | ||
requires = python3-rpm python3-lxml python3-zstandard dnf-plugins-core xmlsec1-openssl | ||
build_requires = python3 make python3-setuptools python3-rpm python3-lxml python3-zstandard openssl xmlsec1-openssl createrepo_c fakechroot fakeroot dnf dnf-plugins-core gzip gnupg2 python3-pylint | ||
release = 1%%{dist} | ||
obsoletes = dnf-plugin-swidtags swid-tools | ||
|
||
[options] | ||
py_modules = dnf-plugins.swidtags | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
FROM registry.fedoraproject.org/fedora | ||
COPY . /src/ | ||
WORKDIR /src | ||
RUN if test -f /etc/centos-release ; then dnf install -y epel-release ; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters