/etc/portage/patches

User patches Article description::provide a way for users to apply patches to package source code if the ebuild provides this feature. Ebuilds cannot be patched by this. This is useful for applying upstream patches to unresolved bugs and for the rare cases of site-specific patches.

EAPI 5 and older

 * The ebuild must call the  function explicitly.
 * The ebuild must inherit an eclass and rely on its default implementation of the  function.

EAPI 6 and greater
User patching is supported as a requirement of EAPI 6 and greater. Failure to support user patching results in an error.

Adding user patches
First choose the location for the patches. Granularity can be determined by package name and the version(s) for which the patch is intended. Use the following locations and optionally append  to any of them:



Examples:



Example
An example shows how to easily apply an upstream patch for of.

The affected version of that package is 1.2.5 and upstream provides the patch for it but has not yet released a new version.

For applying the patch from upstream, the appropriate directory needs to be created:

Next, an arbitrarily named file with suffix or  has to be dropped here with the content provided from upstream:

{{FileBox|filename={{path|/etc/portage/patches/x11-misc/pcmanfm-1.2.5/CVE-2017-8934.patch}}|1= * Removed options to Cut, Remove and Rename from context menu on mounted diff --git a/src/single-inst.c b/src/single-inst.c index 62c37b3..aaf84ab 100644 (file) --- a/src/single-inst.c +++ b/src/single-inst.c @@ -2,7 +2,7 @@ *     single-inst.c: simple IPC mechanism for single instance app * *      Copyright 2010 Hong Jen Yee (PCMan)  - *     Copyright 2012 Andriy Grytsenko (LStranger)  + *     Copyright 2012-2017 Andriy Grytsenko (LStranger)  * *      This program is free software; you can redistribute it and/or modify *     it under the terms of the GNU General Public License as published by @@ -404,11 +404,16 @@ static void get_socket_name(SingleInstData* data, char* buf, int len) }    else dpynum = 0; +#if GLIB_CHECK_VERSION(2, 28, 0) +   g_snprintf(buf, len, "%s/%s-socket-%s-%d", g_get_user_runtime_dir, +               data->prog_name, host ? host : "", dpynum); +#else g_snprintf(buf, len, "%s/.%s-socket-%s-%d-%s",                g_get_tmp_dir,                 data->prog_name,                 host ? host : "",                 dpynum,                 g_get_user_name); +#endif } }}
 * 1) index 8c2049a..876f7f3 100644 (file)
 * 2) --- a/NEWS
 * 3) +++ b/NEWS
 * 4) @@ -1,3 +1,7 @@
 * 5) +* Fixed potential access violation, use runtime user dir instead of tmp dir
 * 6) +    for single instance socket.
 * 7)  Changes on 1.2.5 since 1.2.4:
 * 1)  Changes on 1.2.5 since 1.2.4:
 * 1)  Changes on 1.2.5 since 1.2.4:

For testing, step into the package's ebuild directory and run the :

With the message "User patches applied." all is good and the package needs to be re-emerged as normally.

Once the patch gets merged to the ebuild repository, do not forget to remove it from the directory. Otherwise next time compiling the ebuild might fail.

Using a git directory as a source of patches
Instead of creating the directory, a symlink can be created to a git directory on the system.

Now, in the git directory, perform the usual work. After finishing remove all patches from the previous run and use git format-patch to create a patchset from the branch based on another known branch.

This solution relies on the fact that only files ending with are processed in the patch directory.

Enabling /etc/portage/patches for all ebuilds
If an ebuild has EAPI=5 or older and does not call, but user patches are still needed to be applied, it is possible to use /etc/portage/bashrc and hooks provided by Portage. For details see the article.

Enabling epatch_user for a single package
An example is shown in /etc/portage/package.env

External resources

 * eutils.eclass: Disable epatch_user in EAPI 6. - EAPI 6 has eapply_user which should be used instead.
 * The Ultimate Guide to EAPI 6
 * Patching with epatch - Patching within ebuilds, from devmanual.gentoo.org
 * How to write clean patches when not using git-format-patch.