Skip to content

Commit

Permalink
treat %setup -T as a separate use case
Browse files Browse the repository at this point in the history
%setup -T means that rpm should not unpack source0 - if we turn %setup
into %autosetup thus getting a git repo after running it, we'll get an
empty git repo - bad. These cases usually unpack/construct the source
tree in %prep in a custom way. It would result into first patch
containing the whole source tree - we don't want that.

With this change, we'll create the git repo before applying first patch
which should match the initial source tree.

I hope it's clear we are getting into depths of odd packaging

Related packit#85

Signed-off-by: Tomas Tomecek <[email protected]>
  • Loading branch information
TomasTomecek committed Oct 8, 2020
1 parent 5845d70 commit 7d6a64d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dist2src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ def _enforce_autosetup(self):
`%autosetup -a -a` doesn't work https://bugzilla.redhat.com/show_bug.cgi?id=1881840
b) %setup + pushd/cd - we cannot recreate those patches correctly since
they are not applied from root #92
c) no bullshit, just plain %setup and %patch -- in any case, we turn
c) %setup -T - do not unpack SOURCE0: in this case we don't want %autosetup b/c
it would be empty, we need to rely on %patch
d) no bullshit, just plain %setup and %patch -- in any case, we turn
%setup into %autosetup -N to be sure the .git repo is created correctly
unless `-a -a` is used
"""
Expand All @@ -294,6 +296,8 @@ def _enforce_autosetup(self):
return

a_a_regex = re.compile(r"-a")
# -T means to not unpack, it can actually be set e.g. like "-cT"
cap_t_regex = re.compile(r"-[a-zA-Z]*T")
for i, line in enumerate(prep_lines):
if line.startswith(("%autosetup", "%autopatch")):
logger.info("This package uses %autosetup or %autopatch.")
Expand All @@ -305,6 +309,11 @@ def _enforce_autosetup(self):
"`%setup -aN -aM` detected, we cannot turn it to %autosetup"
)
continue
if cap_t_regex.findall(line):
logger.info(
"`%setup -T` detected - no %autosetup, we need to rely on %patch"
)
continue
# %setup -> %autosetup -N
prep_lines[i] = line.replace("%setup", "%autosetup -N")
# %autosetup does not accept -q, remove it
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"unbound",
"c8",
), # again, another level of directories and patches applied in a subdir
# ("hyperv-daemons", "c8"), # no archive, source code is %SOURCEXXX, does not update
]

# these packages only have a single commit in the respective dist-git branch
Expand Down

0 comments on commit 7d6a64d

Please sign in to comment.