Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 574626

Summary: eapply broken in BSD environment
Product: Portage Development Reporter: Yuta SATOH <nigoro.dev>
Component: CoreAssignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: normal CC: bsd+disabled, kumba, masanori.ogino, pilla, wizardedit
Priority: Normal Keywords: InVCS, PATCH
Version: unspecified   
Hardware: All   
OS: FreeBSD   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=670468
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 573774    
Attachments: sample patch for bin/phase-helpers.sh
tested ebuild-helpers/bsd/patch (Replacement from sed to patch)

Description Yuta SATOH 2016-02-13 11:38:11 UTC
alias patch=gpatch is set in Gentoo/FreeBSD profile.
(profiles/default/bsd/fbsd/profile.bashrc)

But, EAPI=6 patch method (_eapply_patch) ignores alias.

e.g.)
# emerge dev-vcs/git
>>> Emerging (1 of 1) dev-vcs/git-2.7.1::gentoo
 * git-2.7.1.tar.xz SHA256 SHA512 WHIRLPOOL size ;-) ...                [ ok ]
 * git-manpages-2.7.1.tar.xz SHA256 SHA512 WHIRLPOOL size ;-) ...       [ ok ]
>>> Unpacking source...
>>> Unpacking git-2.7.1.tar.xz to /var/tmp/portage/dev-vcs/git-2.7.1/work
>>> Unpacking git-manpages-2.7.1.tar.xz to /var/tmp/portage/dev-vcs/git-2.7.1/work/git-2.7.1
>>> Source unpacked in /var/tmp/portage/dev-vcs/git-2.7.1/work
>>> Preparing source in /var/tmp/portage/dev-vcs/git-2.7.1/work/git-2.7.1 ...
 * Applying git-2.2.2-optional-cvs.patch ...
patch: invalid option -- g
usage: patch [-bCcEeflNnRstuv] [-B backup-prefix] [-D symbol] [-d directory]
             [-F max-fuzz] [-i patchfile] [-o out-file] [-p strip-count]
             [-r rej-name] [-V t | nil | never] [-x number] [-z backup-ext]
             [--posix] [origfile [patchfile]]
       patch <patchfile                                                                                                                                       [ !! ]
 * ERROR: dev-vcs/git-2.7.1::gentoo failed (prepare phase):
 *   patch -p1  failed with /usr/portage/dev-vcs/git/files/git-2.2.2-optional-cvs.patch
 *
 * Call stack:
 *               ebuild.sh, line  133:  Called src_prepare
 *             environment, line 4045:  Called default
 *      phase-functions.sh, line  805:  Called default_src_prepare
 *      phase-functions.sh, line  870:  Called __eapi6_src_prepare
 *             environment, line  272:  Called eapply '/usr/portage/dev-vcs/git/files/git-2.2.2-optional-cvs.patch' '/usr/portage/dev-vcs/git/files/git-1.8.5-mw-vendor.patch' '/usr/portage/dev-vcs/git/files/git-2.2.0-svn-fe-linking.patch' '/usr/portage/dev-vcs/git/files/git-2.5.1-freebsd-10.x-no-iconv.patch'
 *             environment, line  834:  Called _eapply_patch '/usr/portage/dev-vcs/git/files/git-2.2.2-optional-cvs.patch'
 *             environment, line  772:  Called __helpers_die 'patch -p1  failed with /usr/portage/dev-vcs/git/files/git-2.2.2-optional-cvs.patch'
 *   isolated-functions.sh, line  117:  Called die
 * The specific snippet of code:
 *              die "$@"
 *
 * If you need support, post the output of `emerge --info '=dev-vcs/git-2.7.1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-vcs/git-2.7.1::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-vcs/git-2.7.1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-vcs/git-2.7.1/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-vcs/git-2.7.1/work/git-2.7.1'
 * S: '/var/tmp/portage/dev-vcs/git-2.7.1/work/git-2.7.1'


Reproducible: Always
Comment 1 Yuta SATOH 2016-02-13 11:39:24 UTC
Created attachment 425394 [details, diff]
sample patch for bin/phase-helpers.sh
Comment 2 Arfrever Frehtes Taifersar Arahesis 2016-04-11 15:27:04 UTC
Apparently addition of new aliases does not affect previously defined functions (at least in bash 4.3)...

I think that something like the following would be more readable:
local patch_executable
type -P gpatch > /dev/null && patch_executable=gpatch || patch_executable=patch
...
${patch_executable} -p1 -f -s -g0 ...
Comment 3 Arfrever Frehtes Taifersar Arahesis 2016-04-11 15:29:07 UTC
*** Bug 579578 has been marked as a duplicate of this bug. ***
Comment 4 Arfrever Frehtes Taifersar Arahesis 2016-06-13 16:57:47 UTC
*** Bug 585844 has been marked as a duplicate of this bug. ***
Comment 5 Mauricio L. Pilla (RETIRED) gentoo-dev 2016-06-14 18:28:51 UTC
*** Bug 585956 has been marked as a duplicate of this bug. ***
Comment 6 Zac Medico gentoo-dev 2016-06-17 18:26:36 UTC
We can use a bin/ebuild-helpers/bsd/patch script, similar to bin/ebuild-helpers/bsd/sed.
Comment 7 Yuta SATOH 2016-06-18 08:05:06 UTC
Created attachment 437930 [details, diff]
tested ebuild-helpers/bsd/patch (Replacement from sed to patch)

(In reply to Zac Medico from comment #6)
> We can use a bin/ebuild-helpers/bsd/patch script, similar to
> bin/ebuild-helpers/bsd/sed.
I tried your idea. And, I was confirm that the patch is applied.
Please add a helper script.
Comment 8 Zac Medico gentoo-dev 2016-06-19 05:02:27 UTC
(In reply to Yuta SATOH from comment #7)
> Created attachment 437930 [details, diff] [details, diff]
> tested ebuild-helpers/bsd/patch (Replacement from sed to patch)

Looks good, except I think we should remove the EPATCH variable support. The ESED variable probably isn't used by anyone, so I'd prefer not to support another variable that's not really needed.
Comment 9 Zac Medico gentoo-dev 2016-06-19 05:18:40 UTC
Hmm, I wonder if the patch wrapper will break some bsd build systems due to them expecting a bsd version of the patch command in $PATH. If so, it will be safer not to use a wrapper.

@bsd team: Do you think a patch wrapper that forces gpatch will break things?
Comment 11 Zac Medico gentoo-dev 2017-08-11 20:09:24 UTC
Fixed in 2.3.0.