Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doPatch: send patch name to %__patch #1350

Conversation

TomasTomecek
Copy link

when people override %__patch, they are able to process the patch name
now with this change

we need this change for creating repositories with expanded sources for CentOS Stream.

when people override %__patch, they are able to process the patch name
now with this change

Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
@dmnks
Copy link
Contributor

dmnks commented Aug 27, 2020

Thinking about your use case, you can achieve the same (i.e. get the filename of the patch being passed) just by running
readlink -f /dev/stdin
in your script pointed to by %__patch. No need to patch RPM after all :)

} else {
patchcmd = rpmExpand("%{__patch} ", args, " < ", fn, NULL);
patchcmd = rpmExpand("RPM_PATCH_NAME=", sp->path, " %{__patch} ", args, " < ", fn, NULL);
Copy link
Contributor

@dmnks dmnks Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fn is a pointer to the same string pointed to by sp->path, and is also what's passed to stdin of the %__patch binary in the end, which means you can easily get that value by running readlink -f /dev/stdin in your binary. Handy, isn't it? :)

TomasTomecek added a commit to TomasTomecek/dist-git-to-source-git that referenced this pull request Aug 28, 2020
We need to explicitly support the %setup + %patch combo because these
two macros can't be replaced via the traditional macro system in
/usr/lib/rpm/ since rpm parses them via C code in:

rpm-software-management/rpm#1350

This patch tries to detect the usage of %setup - if any of the
%auto{setup,patch} are used, we're good since those use the
%__scm_{setup/apply} which we override to make sure git repos are
created. Otherwise d2s replaces %setup with '%autosetup -N' (-N to let
%patch do the job). With that change we'll be sure that git repo is
created during %prep. We then replace %__patch with packitpatch to apply
the patches.

The last missing piece was patch metadata - rpm does not pass the patch
name to %__patch. Luckily, Michal Domonkos is so fabulous - we can
`readlink -f /dev/stdin` which points to the actual patch (rpm does `cat
$patch | %__patch`).

🍻 🥂 🎉 🥳

Fixes packit#37

Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
@TomasTomecek
Copy link
Author

Works awesome, thank you Michal, you rock!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants