diff --git a/spec-cleaner-psp-macros.patch b/spec-cleaner-psp-macros.patch new file mode 100644 index 0000000..fc5133e --- /dev/null +++ b/spec-cleaner-psp-macros.patch @@ -0,0 +1,226 @@ +From 914c432eb26bae6af766f2da6e81587251ebf1c0 Mon Sep 17 00:00:00 2001 +From: Daniel Garcia Moreno +Date: Tue, 19 Sep 2023 08:03:51 +0200 +Subject: [PATCH] Add new head category for PSP macros + +This patch adds a new category "head", similar to the "tail" category, +to match the modern python macros for SUSE SLE +(sle15_python_module_pythons and sle15allpythons), these macros changed +the "pythons" definition, so they should go before any usage of the +python-rpm-macros. + +Fix https://github.com/rpm-software-management/spec-cleaner/issues/308 +--- + spec_cleaner/rpmpreamble.py | 4 ++++ + spec_cleaner/rpmpreambleelements.py | 3 +++ + spec_cleaner/rpmregexp.py | 1 + + tests/in/psp-macro-all.spec | 31 +++++++++++++++++++++++++++++ + tests/in/psp-macro.spec | 30 ++++++++++++++++++++++++++++ + tests/out/psp-macro-all.spec | 30 ++++++++++++++++++++++++++++ + tests/out/psp-macro.spec | 30 ++++++++++++++++++++++++++++ + 7 files changed, 129 insertions(+) + create mode 100644 tests/in/psp-macro-all.spec + create mode 100644 tests/in/psp-macro.spec + create mode 100644 tests/out/psp-macro-all.spec + create mode 100644 tests/out/psp-macro.spec + +diff --git a/spec_cleaner/rpmpreamble.py b/spec_cleaner/rpmpreamble.py +index 0273b0c..363a9e8 100644 +--- a/spec_cleaner/rpmpreamble.py ++++ b/spec_cleaner/rpmpreamble.py +@@ -115,6 +115,7 @@ def __init__(self, options): + 'excludearch': self.reg.re_excludearch, + 'exclusivearch': self.reg.re_exclusivearch, + 'tail': self.reg.re_tail_macros, ++ 'head': self.reg.re_head_macros, + } + + # deprecated definitions that we no longer want to see +@@ -693,6 +694,9 @@ def add(self, line): + else: + self._add_line_value_to('exclusivearch', value) + ++ elif self.reg.re_head_macros.match(line): ++ self._add_line_value_to('head', line) ++ + # loop for all other matching categories which + # do not require special attention + else: +diff --git a/spec_cleaner/rpmpreambleelements.py b/spec_cleaner/rpmpreambleelements.py +index 8270ec8..9024264 100644 +--- a/spec_cleaner/rpmpreambleelements.py ++++ b/spec_cleaner/rpmpreambleelements.py +@@ -54,6 +54,7 @@ class RpmPreambleElements(object): + 'define', + 'bconds', + 'bcond_conditions', ++ 'head', + 'name', + 'version', + 'release', +@@ -308,6 +309,8 @@ def compile_category_prefix(self, category, key=None): + + if category == 'tail': + return '' ++ if category == 'head': ++ return '' + elif key: + pass + elif category in self.category_to_key: +diff --git a/spec_cleaner/rpmregexp.py b/spec_cleaner/rpmregexp.py +index 832ac2a..5649651 100644 +--- a/spec_cleaner/rpmregexp.py ++++ b/spec_cleaner/rpmregexp.py +@@ -90,6 +90,7 @@ class Regexp(object): + re_patternmacro = re.compile(r'pattern(-\S+)?\(\)', re.IGNORECASE) + re_patternobsolete = re.compile(r'patterns-openSUSE-\S+', re.IGNORECASE) + re_tail_macros = re.compile(r'^%{?python_subpackages}?') ++ re_head_macros = re.compile(r'^%{?\??(sle15_python_module_pythons|sle15allpythons)}?') + re_preamble_prefix = re.compile(r'^Prefix:\s*(.*)', re.IGNORECASE) + # grab all macros with rpm call that query for version, this still might + # be bit too greedy but it is good enough now +diff --git a/tests/in/psp-macro-all.spec b/tests/in/psp-macro-all.spec +new file mode 100644 +index 0000000..4f03c68 +--- /dev/null ++++ b/tests/in/psp-macro-all.spec +@@ -0,0 +1,31 @@ ++# ++# spec file ++# ++# Copyright (c) 2023 SUSE LLC ++# ++# All modifications and additions to the file contributed by third parties ++# remain the property of their copyright owners, unless otherwise agreed ++# upon. The license for this file, and modifications and additions to the ++# file, is the same license as for the pristine package itself (unless the ++# license for the pristine package is not an Open Source License, in which ++# case the license is the MIT License). An "Open Source License" is a ++# license that conforms to the Open Source Definition (Version 1.9) ++# published by the Open Source Initiative. ++ ++# Please submit bugfixes or comments via https://bugs.opensuse.org/ ++# ++ ++ ++%{?sle15allpythons} ++Name: python-munch ++Version: 3.0.0 ++Release: 0 ++BuildRequires: python-rpm-macros ++Requires: python-six ++BuildArch: noarch ++# SECTION test requirements ++BuildRequires: %{python_module pytest} ++BuildRequires: %{python_module six} ++ ++%changelog ++ +diff --git a/tests/in/psp-macro.spec b/tests/in/psp-macro.spec +new file mode 100644 +index 0000000..7056059 +--- /dev/null ++++ b/tests/in/psp-macro.spec +@@ -0,0 +1,30 @@ ++# ++# spec file ++# ++# Copyright (c) 2023 SUSE LLC ++# ++# All modifications and additions to the file contributed by third parties ++# remain the property of their copyright owners, unless otherwise agreed ++# upon. The license for this file, and modifications and additions to the ++# file, is the same license as for the pristine package itself (unless the ++# license for the pristine package is not an Open Source License, in which ++# case the license is the MIT License). An "Open Source License" is a ++# license that conforms to the Open Source Definition (Version 1.9) ++# published by the Open Source Initiative. ++ ++# Please submit bugfixes or comments via https://bugs.opensuse.org/ ++# ++ ++ ++%{?sle15_python_module_pythons} ++Name: python-munch ++Version: 3.0.0 ++Release: 0 ++BuildRequires: python-rpm-macros ++Requires: python-six ++BuildArch: noarch ++# SECTION test requirements ++BuildRequires: %{python_module pytest} ++BuildRequires: %{python_module six} ++ ++%changelog +diff --git a/tests/out/psp-macro-all.spec b/tests/out/psp-macro-all.spec +new file mode 100644 +index 0000000..97dd863 +--- /dev/null ++++ b/tests/out/psp-macro-all.spec +@@ -0,0 +1,30 @@ ++# ++# spec file ++# ++# Copyright (c) 2023 SUSE LLC ++# ++# All modifications and additions to the file contributed by third parties ++# remain the property of their copyright owners, unless otherwise agreed ++# upon. The license for this file, and modifications and additions to the ++# file, is the same license as for the pristine package itself (unless the ++# license for the pristine package is not an Open Source License, in which ++# case the license is the MIT License). An "Open Source License" is a ++# license that conforms to the Open Source Definition (Version 1.9) ++# published by the Open Source Initiative. ++ ++# Please submit bugfixes or comments via https://bugs.opensuse.org/ ++# ++ ++ ++%{?sle15allpythons} ++Name: python-munch ++Version: 3.0.0 ++Release: 0 ++BuildRequires: python-rpm-macros ++Requires: python-six ++BuildArch: noarch ++# SECTION test requirements ++BuildRequires: %{python_module pytest} ++BuildRequires: %{python_module six} ++ ++%changelog +diff --git a/tests/out/psp-macro.spec b/tests/out/psp-macro.spec +new file mode 100644 +index 0000000..7056059 +--- /dev/null ++++ b/tests/out/psp-macro.spec +@@ -0,0 +1,30 @@ ++# ++# spec file ++# ++# Copyright (c) 2023 SUSE LLC ++# ++# All modifications and additions to the file contributed by third parties ++# remain the property of their copyright owners, unless otherwise agreed ++# upon. The license for this file, and modifications and additions to the ++# file, is the same license as for the pristine package itself (unless the ++# license for the pristine package is not an Open Source License, in which ++# case the license is the MIT License). An "Open Source License" is a ++# license that conforms to the Open Source Definition (Version 1.9) ++# published by the Open Source Initiative. ++ ++# Please submit bugfixes or comments via https://bugs.opensuse.org/ ++# ++ ++ ++%{?sle15_python_module_pythons} ++Name: python-munch ++Version: 3.0.0 ++Release: 0 ++BuildRequires: python-rpm-macros ++Requires: python-six ++BuildArch: noarch ++# SECTION test requirements ++BuildRequires: %{python_module pytest} ++BuildRequires: %{python_module six} ++ ++%changelog diff --git a/spec-cleaner.changes b/spec-cleaner.changes index a8cf415..81aa807 100644 --- a/spec-cleaner.changes +++ b/spec-cleaner.changes @@ -1,7 +1,13 @@ +------------------------------------------------------------------- +Tue Oct 24 13:45:01 UTC 2023 - Dirk Müller + +- add spec-cleaner-psp-macros.patch to avoid spec-cleaner + rewriting the location of the psp macro + ------------------------------------------------------------------- Thu Jun 17 09:43:14 UTC 2021 - Atilla ÖNTAŞ -- Fix: Use Mageia specific macro for Mageia builds in spec file +- Fix: Use Mageia specific macro for Mageia builds in spec file ------------------------------------------------------------------- Tue Nov 17 06:02:08 UTC 2020 - John Vandenberg @@ -108,7 +114,7 @@ Wed Jul 17 08:17:52 UTC 2019 - Kristyna Streitova * Add docstrings to the functions and classes. * Use type hints for the most important functions * Update README and licences - * Various small fixes + * Various small fixes - add a temporary patch spec-cleaner-1.1.4_test_https.patch that fixes a test that fails if there is no internet connection @@ -125,7 +131,7 @@ Thu Mar 7 12:36:28 UTC 2019 - Tomáš Chvátal ------------------------------------------------------------------- Thu Dec 13 11:34:07 UTC 2018 - Tomáš Chvátal -- Version update to 1.1.2 bsc#1099674: +- Version update to 1.1.2 bsc#1099674: * Fixed qmake macro recommendation * More licenses recognised * Do not curlify sysuser_create diff --git a/spec-cleaner.spec b/spec-cleaner.spec index b7fa684..824a848 100644 --- a/spec-cleaner.spec +++ b/spec-cleaner.spec @@ -1,7 +1,7 @@ # # spec file for package spec-cleaner # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2023 SUSE LLC # Copyright (c) 2012 Vincent Untz # # All modifications and additions to the file contributed by third parties @@ -24,6 +24,8 @@ Summary: .spec file cleaner License: BSD-3-Clause URL: https://github.com/rpm-software-management/spec-cleaner Source0: https://github.com/rpm-software-management/spec-cleaner/archive/%{name}-%{version}.tar.gz +# PATCH-FIX-UPSTREAM: https://github.com/rpm-software-management/spec-cleaner/commit/914c432eb26bae6af766f2da6e81587251ebf1c0 +Patch1: spec-cleaner-psp-macros.patch BuildRequires: python-rpm-macros BuildRequires: python3-pytest BuildRequires: python3-setuptools @@ -46,7 +48,7 @@ Alternative provider of format_spec_file functionality in order to allow user to use spec-cleaner rather than to stick to perl based format_spec_file. %prep -%setup -q -n %{name}-%{name}-%{version} +%autosetup -p1 -n %{name}-%{name}-%{version} rm pytest.ini %build