Skip to content

Commit

Permalink
Merge 4628608 into 2ff2cb6
Browse files Browse the repository at this point in the history
  • Loading branch information
danigm committed Feb 27, 2024
2 parents 2ff2cb6 + 4628608 commit 9c4228c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
9 changes: 4 additions & 5 deletions spec_cleaner/rpmprep.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _prepare_patch(self, line: str) -> str:
"""
Convert patchlines to something pretty.
E.g. it converts "%patch -P 50 -p10" to "%patch50 -p10" and so on.
E.g. it converts "%patch50 -p10" to "%patch -P 50 -p10" and so on.
Args:
line: A string representing a line to process.
Expand All @@ -69,16 +69,15 @@ def _prepare_patch(self, line: str) -> str:
# -p0 is default
if line.startswith('%patch'):
line = line.replace('-p0', '')
# %patch0 is desired
# %patch without -P was %patch0 before, convert to %patch0 for the reges
if (line.startswith('%patch ') or line == '%patch') and '-P' not in line:
line = line.replace('%patch', '%patch0')

# convert the %patch -P 50 -p10 to %patch50 -p10
# this apply only if there is ONE -P on the line, not multiple ones
# convert the %patch50 -p10 to %patch -P 50 -p10
match = self.reg.re_patch_prep.match(line)
if match:
line = self.strip_useless_spaces(
'%%patch%s %s %s' % (match.group(2), match.group(1), match.group(3))
'%%patch -P %s %s' % (match.group(1), match.group(2))
)

return line
2 changes: 1 addition & 1 deletion spec_cleaner/rpmregexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class Regexp(object):
re_rm_double = re.compile(r'(\.|{)a')

# rpmprep
re_patch_prep = re.compile(r'^%patch\s*([^P]*)-P\s*(\d*)\s*([^P]*)$')
re_patch_prep = re.compile(r'^%patch(\d+)\s*(.*)$')
re_setup = re.compile(r'\s*-n\s+"?%{name}-%{version}"?($|\s)')
re_dephell_setup = re.compile(r'\s*dephell[s]?.*convert')

Expand Down
4 changes: 2 additions & 2 deletions tests/out/mingw32-clutter.spec
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ files for development.
%prep
%setup -q -n clutter-%{version}

%patch0 -p1 -b .windows
%patch1 -p1 -b .ldl
%patch -P 0 -p1 -b .windows
%patch -P 1 -p1 -b .ldl

%build
libtoolize --force --copy --install
Expand Down
20 changes: 10 additions & 10 deletions tests/out/patches.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ Patch12: i
Patch99: f

%prep
%patch3 -p1
%patch2
%patch99 -p1
%patch0 -p1
%patch1
%patch0 -p1
%patch10
%patch11 -p1
%patch12
%patch11 -p3
%patch -P 3 -p1
%patch -P 2
%patch -P 99 -p1
%patch -P 0 -p1
%patch -P 1
%patch -P 0 -p1
%patch -P 10
%patch -p1 -P 11
%patch -P12
%patch -P11 -p3
%patch -P20 -P30

%changelog
4 changes: 2 additions & 2 deletions tests/out/rpmpreamble.spec
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ Headers, pkg-config files, so link and other development files for %{name}

%prep
%setup -q
%patch1
%patch2
%patch -P 1
%patch -P 2

%build
%configure \
Expand Down
4 changes: 2 additions & 2 deletions tests/out/sourcespatches.spec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Patch10: test2
%setup -q -a1
%setup -q -b2
%setup -q -n %{name}-%{version}-src
%patch10 -p4
%patch0 -p1
%patch -P 10 -p4
%patch -P 0 -p1

%changelog

0 comments on commit 9c4228c

Please sign in to comment.