Skip to content

Commit

Permalink
Merge pull request #52 from packit/nforro-prep
Browse files Browse the repository at this point in the history
Implement modification of %prep macros

Fixes #44.

Reviewed-by: František Nečas <None>
Reviewed-by: Nikola Forró <None>
  • Loading branch information
softwarefactory-project-zuul[bot] authored May 13, 2022
2 parents 626ad70 + ce00d21 commit 2faf042
Show file tree
Hide file tree
Showing 19 changed files with 1,307 additions and 324 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,16 @@ from specfile.prep import AutosetupMacro
with specfile.prep() as prep:
# name of the first macro
print(prep.macros[0].name)
# options of the last macro
print(prep.macros[-1].options)
# checking if %autosetup is being used
print('%autosetup' in prep.macros)
print(AutosetupMacro in prep.macros)
print('%autosetup' in prep)
print(AutosetupMacro in prep)
# changing macro options
prep.autosetup.options.n = '%{srcname}-%{version}'
# adding a new %patch macro
prep.add_patch_macro(28, p=1, b='.test')
# removing an existing %patch macro
# removing an existing %patch macro by name
del prep.patch0
# this works for both '%patch0' and '%patch -P0'
prep.remove_patch_macro(0)
```

Expand Down
4 changes: 4 additions & 0 deletions specfile/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ def __str__(self) -> str:

class MacroRemovalException(SpecfileException):
"""Exception related to failed removal of RPM macros."""


class MacroOptionsException(SpecfileException):
"""Exception related to processing macro options."""
Loading

0 comments on commit 2faf042

Please sign in to comment.