Skip to content

Commit

Permalink
Merge pull request #313 from danigm/psp-macros
Browse files Browse the repository at this point in the history
Add new head category for PSP macros
  • Loading branch information
kstreitova committed Sep 19, 2023
2 parents 281db12 + 914c432 commit 956baee
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec_cleaner/rpmpreamble.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions spec_cleaner/rpmpreambleelements.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class RpmPreambleElements(object):
'define',
'bconds',
'bcond_conditions',
'head',
'name',
'version',
'release',
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions spec_cleaner/rpmregexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions tests/in/psp-macro-all.spec
Original file line number Diff line number Diff line change
@@ -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

30 changes: 30 additions & 0 deletions tests/in/psp-macro.spec
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions tests/out/psp-macro-all.spec
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions tests/out/psp-macro.spec
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 956baee

Please sign in to comment.